use of com.seven.seven.user.adapter.CollectAdapter in project seven_develop by seven123456.
the class CollectListActivity method initRecycler.
private void initRecycler() {
collectAdapter = new CollectAdapter(R.layout.recycler_item_collect, collectInfoList);
recyclerView.setAdapter(collectAdapter);
collectAdapter.setOnLoadMoreListener(this, recyclerView);
collectAdapter.disableLoadMoreIfNotFullPage();
ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(collectAdapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemDragAndSwipeCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
itemDragAndSwipeCallback.setSwipeMoveFlags(ItemTouchHelper.START | ItemTouchHelper.END);
collectAdapter.enableSwipeItem();
collectAdapter.setOnItemSwipeListener(new OnItemSwipeListener() {
@Override
public void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos) {
Log.d("onItemSwipeStart", "执行了");
}
@Override
public void clearView(RecyclerView.ViewHolder viewHolder, int pos) {
Log.d("clearView", "执行了");
}
@Override
public void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos) {
Log.d("onItemSwiped", "执行了");
collectInfo = collectAdapter.getItem(pos);
position = pos;
if (collectInfo != null) {
collectPresenter.deleteCollect(collectInfo.getId());
}
}
@Override
public void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive) {
canvas.drawColor(ContextCompat.getColor(CollectListActivity.this, R.color.red));
Log.d("onItemSwipeMoving", "执行了");
}
});
collectAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
CollectInfo collectInfo = (CollectInfo) adapter.getItem(position);
HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
homeToWebViewInfo.collect = collectInfo.isCollect();
homeToWebViewInfo.h5Url = collectInfo.getLink();
homeToWebViewInfo.id = collectInfo.getId();
homeToWebViewInfo.imgUrl = collectInfo.getEnvelopePic();
homeToWebViewInfo.title = collectInfo.getTitle();
Intent intent = new Intent(mActivity, HomeNewsDetailActivity.class);
intent.putExtra("newsInfo", homeToWebViewInfo);
startActivity(intent);
}
});
}
Aggregations