Recyclerview 为什么不能局部刷新
1 CameraViewHolder中有一些回调,用来更新状态
但是好像没有生效 回调函数也执行了,但是状态没有更新
代码如下
class CameraViewHolder extends RecyclerView.ViewHolder implements Item {
@BindView(R.id.title_ll)
LinearLayout cameraHeadGroup;
@BindView(R.id.camera_title_tv)
TextView cameraTitleTv;
@BindView(R.id.camera_empty_iv)
ImageView cameraEmptyIv;
@BindView(R.id.camera_live)
TextureVideoView playView;
@BindView(R.id.camera_label_iv)
ImageView cameraLabelIv;
@BindView(R.id.camera_status_iv)
ImageView cameraStatusIv;
@BindView(R.id.live_progress)
ProgressBar mProgressBar;
@BindView(R.id.btn_refresh)
ImageButton btnRefresh;
private Device realDevice;
private int videoState = START_IDLE;
private static final int START_IDLE = 0;
private static final int START_ACTIVED = 1;
private static final int START_DEACTIVED = 2;
private CameraListAdapter mCameraListAdapter;
CameraViewHolder(View view,CameraListAdapter cameraListAdapter){
super(view);
mCameraListAdapter = cameraListAdapter;
ButterKnife.bind(this,view);
}
public void onBind(final int position , Device item){
realDevice = item;
cameraTitleTv.setText(item.getTitle());
btnRefresh.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
TextureVideoView.PlayerCallback callback = new TextureVideoView.PlayerCallback() {
@Override
public void cameraPlayFailed(View view, String error) {
mProgressBar.setVisibility(View.GONE);
btnRefresh.setVisibility(View.VISIBLE);
KLog.d("播放失败");
cameraEmptyIv.setVisibility(View.GONE);
mCameraListAdapter.notifyItemChanged(position,null);
}
@Override
public void cameraPlayGotData(View view) {
KLog.d("播放成功");
mProgressBar.setVisibility(View.GONE);
btnRefresh.setVisibility(View.GONE);
cameraStatusIv.setBackgroundResource(R.drawable.mon_green);
cameraEmptyIv.setVisibility(View.GONE);
mCameraListAdapter.notifyItemChanged(position,null);
}
@Override
public void cameraStop() {
cameraEmptyIv.setVisibility(View.VISIBLE);
cameraStatusIv.setBackgroundResource(R.drawable.mon_red);
mCameraListAdapter.notifyItemChanged(position,null);
}
};
playView.setPlayerCallback(callback);
playView.setRealDevice(item);
}
private void reset(){
}
@OnClick(R.id.btn_refresh)
void refresh(){
mProgressBar.setVisibility(View.VISIBLE);
btnRefresh.setVisibility(View.GONE);
playView.start();
}
@Override
public void setActive(View newActiveView, int newActiveViewPosition) {
videoState = START_ACTIVED;
KLog.d("active:" + newActiveViewPosition);
}
@Override
public void deactivate(View currentView, int position) {
KLog.d("deactivate :" + position);
videoState = START_DEACTIVED;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次刷新都会执行你的
onBind()
方法,