Search in sources :

Example 1 with CollectInfo

use of com.seven.seven.user.model.CollectInfo 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);
        }
    });
}
Also used : CollectAdapter(com.seven.seven.user.adapter.CollectAdapter) CollectInfo(com.seven.seven.user.model.CollectInfo) Canvas(android.graphics.Canvas) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) RecyclerView(android.support.v7.widget.RecyclerView) OnItemSwipeListener(com.chad.library.adapter.base.listener.OnItemSwipeListener) ItemDragAndSwipeCallback(com.chad.library.adapter.base.callback.ItemDragAndSwipeCallback) HomeNewsDetailActivity(com.seven.seven.home.HomeNewsDetailActivity)

Aggregations

Intent (android.content.Intent)1 Canvas (android.graphics.Canvas)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 ItemDragAndSwipeCallback (com.chad.library.adapter.base.callback.ItemDragAndSwipeCallback)1 OnItemSwipeListener (com.chad.library.adapter.base.listener.OnItemSwipeListener)1 HomeNewsDetailActivity (com.seven.seven.home.HomeNewsDetailActivity)1 HomeToWebViewInfo (com.seven.seven.home.model.HomeToWebViewInfo)1 CollectAdapter (com.seven.seven.user.adapter.CollectAdapter)1 CollectInfo (com.seven.seven.user.model.CollectInfo)1