I'm using FirebaseRecyclerAdapter
to populate a RecyclerView
in a Fragment
.
Here's my code
mDatabase = FirebaseDatabase.getInstance().getReference();
myAdapter = new FirebaseRecyclerAdapter<Product, ProductViewHolder>(Product.class,
R.layout.product_item,ProductViewHolder.class,
mDatabase.child("clothes")) {
@Override
protected void populateViewHolder(ProductViewHolder viewHolder, Product model, int position) {
mProgressBar.setVisibility(ProgressBar.INVISIBLE);
viewHolder.name.setText(model.name);
viewHolder.price.setText(model.price);
Glide.with(getActivity()).load(model.imageUri).into(viewHolder.thumbnail);
Log.d("NAME", model.name);
}
};
recyclerView.setAdapter(myAdapter);
The problem is, the ProgressBar
keeps moving in the first launch, it never hides and the RecyclerView
never shows itself but If I exit the app and launch again, the RecyclerView
is properly populated, even if the screen locks itself and I unlock it, the RecyclerView
is populated. I'm confused.