Search in sources :

Example 1 with GoldManagerAdapter

use of com.codeest.geeknews.ui.gold.adapter.GoldManagerAdapter in project GeekNews by codeestX.

the class GoldManagerActivity method initEventAndData.

@Override
protected void initEventAndData() {
    setToolBar(toolBar, "首页特别展示");
    mList = ((GoldManagerBean) getIntent().getParcelableExtra(Constants.IT_GOLD_MANAGER)).getManagerList();
    mAdapter = new GoldManagerAdapter(mContext, mList);
    rvGoldManagerList.setLayoutManager(new LinearLayoutManager(mContext));
    rvGoldManagerList.setAdapter(mAdapter);
    mCallback = new DefaultItemTouchHelpCallback(new DefaultItemTouchHelpCallback.OnItemTouchCallbackListener() {

        @Override
        public void onSwiped(int adapterPosition) {
        }

        @Override
        public boolean onMove(int srcPosition, int targetPosition) {
            if (mList != null) {
                Collections.swap(mList, srcPosition, targetPosition);
                mAdapter.notifyItemMoved(srcPosition, targetPosition);
                return true;
            }
            return false;
        }
    });
    mCallback.setDragEnable(true);
    mCallback.setSwipeEnable(false);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mCallback);
    itemTouchHelper.attachToRecyclerView(rvGoldManagerList);
}
Also used : DefaultItemTouchHelpCallback(com.codeest.geeknews.widget.DefaultItemTouchHelpCallback) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) GoldManagerAdapter(com.codeest.geeknews.ui.gold.adapter.GoldManagerAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 GoldManagerAdapter (com.codeest.geeknews.ui.gold.adapter.GoldManagerAdapter)1 DefaultItemTouchHelpCallback (com.codeest.geeknews.widget.DefaultItemTouchHelpCallback)1