第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 Firestore 增加價值

從 Firestore 增加價值

達令說 2024-01-28 16:26:03
我的條目看起來像這樣:在輸入數(shù)據(jù)之前,必須使用條碼掃描儀填寫條碼。當 Firestore 中存在條形碼時,我希望增加產(chǎn)品數(shù)量。當條形碼在Firestore中不可用時,Intent到另一個類。代碼 :@Overridepublic void handleResult(Result result) {    final String scanResult = result.getText();    ToneGenerator toneNotification = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);    toneNotification.startTone(ToneGenerator.TONE_PROP_BEEP, 150);    collectionReference.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {        @Override        public void onComplete(@NonNull Task<QuerySnapshot> task) {            if (task.isSuccessful()) {                for (QueryDocumentSnapshot queryDocumentSnapshot : task.getResult()) {                    // if barcode is existing, then product quantity to increment                    if (queryDocumentSnapshot.getString("barCode") != null) {                        collectionReference.document(queryDocumentSnapshot.getId()).update("productQuantity", FieldValue.increment(1));                        Intent moveView = new Intent(ScannersActivity.this, ViewData.class);                        moveView.putExtra("documentID", documentID);                        startActivity(moveView);                        finish();                    } else { // If barcode is not available in firestore, then intent to another class                        Intent moveCode = new Intent(ScannersActivity.this, AddItems.class);                        moveCode.putExtra("sendDocumentID", documentID);                        moveCode.putExtra("ScanResult", scanResult);                        startActivity(moveCode);                        finish();                    }                }            }        }    });}
查看完整描述

2 回答

?
大話西游666

TA貢獻1817條經(jīng)驗 獲得超14個贊

productQuantity要根據(jù)財產(chǎn)的存在增加財產(chǎn)的價值barCode,請嘗試以下代碼行:


collectionReference.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {

    @Override

    public void onComplete(@NonNull Task<QuerySnapshot> task) {

        if (task.isSuccessful()) {

            for (QueryDocumentSnapshot document : task.getResult()) {

                if (document.getString("barCode") != null) {

                    collectionReference.document(document.getId()).update(

                        "productQuantity", FieldValue.increment(1)

                    );

                }

            }

        }

    }

});


查看完整回答
反對 回復(fù) 2024-01-28
?
ITMISS

TA貢獻1871條經(jīng)驗 獲得超8個贊

這將確定條形碼是否存在。您可以填寫交易TODO注釋來更新數(shù)量值。


public void handleResult(Result result) {

? String scanResult = result.getText();

? // ...


? collectionReference

? ? .whereEqualTo("barCode", scanResult)

? ? .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {

? ? ? @Override

? ? ? public void onComplete(@NonNull Task<QuerySnapshot> task) {

? ? ? ? if (task.isSuccessful() && task.getResult().size() > 0) {

? ? ? ? ? // TODO barcode exists; increase qty

? ? ? ? }

? ? ? ? else {

? ? ? ? ? // barcode not found, new Intent

? ? ? ? }

? ? ? }

? ? });

}


查看完整回答
反對 回復(fù) 2024-01-28
  • 2 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號