当项目在Firestore中不可用时过滤搜索列表

时间:2019-11-08 13:22:39

标签: java android google-cloud-firestore

我被添加了搜索栏,当我想输入数据在Firestore中不可用时,则TextView noDocumentAvailable可见;当我想输入数据在Firestore中可用时,则TextView消失。

代码:

private void searchDocument(String search) {
    collectionReference.orderBy("documentName").startAt(search).endAt(search + '\uf8ff').get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
            if (task.isSuccessful()) {
                documentsList.clear();

                if (task.getResult().size() < 0) { // not working for me
                    noDocumentAvailable.setVisibility(View.VISIBLE);
                } else {
                    for (DocumentSnapshot documentSnapshot : task.getResult()) {
                        Documents documents = documentSnapshot.toObject(Documents.class);
                        documentsList.add(documents);
                        documentListAdapter.notifyDataSetChanged();
                    }
                }
            }
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Toast.makeText(StartCounting.this, "Error : " + e.getMessage(), Toast.LENGTH_LONG).show();
        }
    });
}

1 个答案:

答案 0 :(得分:1)

更改此行

[renderEncoder setVertexBytes:&quadVertices
                       length:sizeof(quadVertices)
                       atIndex:AAPLVertexInputIndexVertices];

if (task.getResult().size() < 0) {

if (task.getResult().size() < 1) {

列表的大小不能小于零