use of com.xxx.ency.view.like.adapter.LikeAdapter in project Ency by xiarunhao123.
the class LikeFragment method initialize.
@Override
protected void initialize() {
daoManager = EncyApplication.getAppComponent().getGreenDaoManager();
likeAdapter = new LikeAdapter();
likeAdapter.setNewData(daoManager.queryAll());
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(likeAdapter);
likeAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
LikeBean bean = (LikeBean) adapter.getData().get(position);
if (bean.getType() == Constants.TYPE_VIDEO) {
JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
JZVideoPlayerStandard.startFullscreen(mContext, JZVideoPlayerStandard.class, bean.getUrl(), bean.getTitle());
} else {
WebActivity.open(new WebActivity.Builder().setGuid(bean.getUrl()).setImgUrl(bean.getImageUrl()).setType(bean.getType()).setUrl(bean.getUrl()).setTitle(bean.getTitle()).setShowLikeIcon(true).setContext(mContext));
}
}
});
likeAdapter.setOnItemLongClickListener(new BaseQuickAdapter.OnItemLongClickListener() {
@SuppressLint("ResourceAsColor")
@Override
public boolean onItemLongClick(BaseQuickAdapter adapter, View view, final int position) {
final LikeBean bean = (LikeBean) adapter.getData().get(position);
new MaterialDialog.Builder(mContext).content("确认要删除该收藏吗?").negativeText("取消").negativeColorRes(R.color.colorNegative).positiveText("确定").positiveColorRes(R.color.colorPositive).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
daoManager.delete(bean);
likeAdapter.remove(position);
}
}).show();
return true;
}
});
likeAdapter.setEmptyView(R.layout.view_empty, recyclerView);
}
Aggregations