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; } }
精彩评论