Метод
@Override
protected void onStart() {
super.onStart();
///получить uid///
ZayavkaRef.addValueEventListener(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Get map of users in datasnapshot
// Result will be holded Here
for (DataSnapshot dsp : dataSnapshot.getChildren()) {
Log.d("Irk", dsp.getValue(OtvetShop.class).getUidClient());
if (mAuth.getCurrentUser().getUid().equals(dsp.getValue(OtvetShop.class).getUidClient())) {
isHaveAnswer += 1;
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w("Arthur", databaseError.toException());
}
});
/// Log.d("Arthur", mAuth.getCurrentUser().getUid());
/// Log.d("joker", String.valueOf(isHaveAnswer));
if (isHaveAnswer >0) {
FirebaseRecyclerOptions<OtvetShop> options = new FirebaseRecyclerOptions.Builder<OtvetShop>()
.setQuery(ZayavkaRef, OtvetShop.class).build();
FirebaseRecyclerAdapter<OtvetShop, OtvetShopHolder> adapter = new FirebaseRecyclerAdapter<OtvetShop, OtvetShopHolder>(options) {
@Override
protected void onBindViewHolder(@androidx.annotation.NonNull OtvetShopHolder holder, int position, @androidx.annotation.NonNull OtvetShop model) {
Log.d("Arthur", model.getUidClient() + "model");
Log.d("Arthur", holder.text_tovar_name.getText().toString());
if (mAuth.getCurrentUser().getUid().equals(model.getUidClient())) {
holder.text_tovar_name.setText(model.getTovarname());
holder.text_tovar_price.setText(model.getTovarprice());
holder.text_shop_adress.setText(model.getMagazadress());
Picasso.get().load(model.getImage()).into(holder.image_tovar_shop);
}
}
@Override
public OtvetShopHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_customer_shop, parent, false);
OtvetShopHolder holder = new OtvetShopHolder(view);
return holder;
}
};
recyclerView.setAdapter(adapter);
adapter.startListening();
}else {
pusto.setVisibility(View.VISIBLE);
text_text.setVisibility(View.VISIBLE);
}
}
}
Инициализая
ZayavkaRef= FirebaseDatabase.getInstance().getReference().child("zayavli");
mAuth=FirebaseAuth.getInstance();
int isHaveAnswer = 0;
Else срабатывает. А если убрать if появляется все что есть в бд а мне надо чтобы появлялось только то где прописано uid пользователя который принимает.