I want to display a Loading view i.e., an indeterminate Progress bar until I load my recycler view with data fetched from Firebase. I need to know the event which would be triggered as soon as the Recycler View is loaded with the data.
I extended this class and used as an adapter
My extended class is
public class TrendingRecycler extends FirebaseRecyclerAdapter
<TrendingRecycler.ViewHolder, DataStuff> {
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView Data;
public ViewHolder(View view) {
super(view);
Data= (TextView) view.findViewById(R.id.text_card_trending);
}
}
public TrendingRecycler(Query query, Class<DataStuff> itemClass) {
super(query, itemClass);
}
@Override public TrendingRecycler.ViewHolder
onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.trending_card_view, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(TrendingRecycler.ViewHolder holder,
int position) {
final DataStuff item = getItem(position);
holder.Data.setText(item.Data);
final Context context =holder.itemView.getContext();
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyApplication.getAppContext(),
item.Tags.toString(), Toast.LENGTH_LONG).show();
TempShowStore.setDataStuff(item);
context.startActivity(
new Intent(context, ShowComplete.class)
);
}
});
}
@Override
protected void itemAdded(DataStuff item, String key, int position) {
Log.d("ADDED",String.valueOf(position));
}
@Override
protected void itemChanged(DataStuff oldItem, DataStuff newItem, String key, int position) {
Log.d("CHANGED",String.valueOf(position));
}
@Override
protected void itemRemoved(DataStuff item, String key, int position) {
Log.d("REMOVED",String.valueOf(position));
}
@Override
protected void itemMoved(DataStuff item, String key, int oldPosition, int newPosition) {
Log.d("MOVED",String.valueOf(oldPosition) + " to " +String.valueOf(newPosition));
}
}
You have to try overriding onDataChanged() in your adapter:
mProgressDialog.show();
mFirebaseAdapter = new FirebaseRecyclerAdapter(...) {
@Override
protected void populateViewHolder(...) {...}
@Override
protected void onDataChanged() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
};