user9970916
user9970916

Reputation:

How can I put a progress dialog while firebase is loading?

How can I handle a Firebase thread, as an example, I want to populate a view holder with a recyclerview, I tried calling a dummy method like:

 private void load() {

     adapter = new FirebaseRecyclerAdapter<ModelClass, ViewHolder>(
            ModelClass.class,
            R.layout.desgin_row_gridview,
            ViewHolder.class,
            mRef 

While populateViewholder method gets loaded something like this:

@Override
protected void populateViewHolder(ViewHolder viewHolder, ModelClass 
model, int position) {
           viewHolder.mTitleView.setText(model.getTitle());
            Picasso.get().load(model.getImage())
                    .into(viewHolder.mImageIv);

I want to show a progress dialog, check if its loaded and the viewholder is populated and then dismiss the progress dialog.

any insights?

Upvotes: 1

Views: 220

Answers (1)

Nouman Ch
Nouman Ch

Reputation: 4121

mProgressDialog.show();

before adapter initialization and then

try overriding onDataChanged() in your adapter:

mFirebaseAdapter = new FirebaseRecyclerAdapter(...) {

  @Override
  protected void onDataChanged() {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
    }
  }

};

Upvotes: 3

Related Questions