我该如何处理Firebase线程,例如,我想用recyclerview填充视图持有者,所以我尝试调用一个伪方法,例如:
private void load() {
adapter = new FirebaseRecyclerAdapter<ModelClass, ViewHolder>(
ModelClass.class,
R.layout.desgin_row_gridview,
ViewHolder.class,
mRef
加载populateViewholder
方法时
像这样的东西:
@Override
protected void populateViewHolder(ViewHolder viewHolder, ModelClass
model, int position) {
viewHolder.mTitleView.setText(model.getTitle());
Picasso.get().load(model.getImage())
.into(viewHolder.mImageIv);
我想显示一个进度对话框,检查其是否已加载并且是否填充了Viewholder,然后关闭进度对话框。
有什么见解?
答案 0 :(得分:2)
mProgressDialog.show();
在适配器初始化之前然后
尝试在适配器中覆盖onDataChanged()
:
mFirebaseAdapter = new FirebaseRecyclerAdapter(...) {
@Override
protected void onDataChanged() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
};