我如何处理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);
我想显示一个进度对话框,检查它是否已加载并且是否填充了视图,然后关闭进度对话框。
任何见解?
M progress dialog.show();
在适配器初始化之前然后
尝试覆盖适配器中的onDataChanged()
:
mFirebaseAdapter = new FirebaseRecyclerAdapter(...) {
@Override
protected void onDataChanged() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
};