微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.support.v7.widget.helper.ItemTouchHelper的实例源码

项目:WeatherPlus    文件CityListFragment.java   
@Override
public void onActivityCreated(Bundle state) {
    Log.d(TAG,"onActivityCreated");
    super.onActivityCreated(state);

    if (state != null) {
        isRefreshing = state.getBoolean(KEY_IS_REFRESHING);
        isAddQueueHandling = state.getBoolean(KEY_IS_ADD_QUEUE_HANDLING);

        currNameIndex = state.getInt(KEY_CURR_NAME_INDEX);

        cityWeatherList = state.getParcelableArrayList(KEY_CITY_WEATHER_LIST);

        cityAddQueue = state.getParcelableArrayList(KEY_CITY_ADD_QUEUE);

        updateRecyclerView();
    } else {
        loadCitiesFromdisk();
    }

    itemTouchCallBack = new itemtouchhelperAdapter(itemtouchhelper.UP | itemtouchhelper.DOWN,itemtouchhelper.LEFT | itemtouchhelper.RIGHT,this,cityWeatherList,true);

    new itemtouchhelper(itemTouchCallBack).attachToRecyclerView(recyclerView);
}
项目:letv    文件ChannelFragmentAdapter.java   
public ChannelFragmentAdapter(Context context,itemtouchhelper helper,ChannelListBean channelListBean,RecyclerView view) {
    this.mInflater = LayoutInflater.from(context);
    this.mContext = context;
    this.mitemtouchhelper = helper;
    this.mRecyclerView = view;
    this.mChannelListBean = channelListBean;
    if (channelListBean != null && !BaseTypeUtils.isListempty(channelListBean.listChannel)) {
        for (int i = 0; i < channelListBean.listChannel.size(); i++) {
            if (channelListBean.listChannel.get(i) != null) {
                this.mMyChannelItems.add(channelListBean.listChannel.get(i));
                if (((Channel) channelListBean.listChannel.get(i)).top == 0) {
                    this.mTopSize++;
                }
                if (((Channel) channelListBean.listChannel.get(i)).lock == 1) {
                    this.mlockSize++;
                }
            }
        }
        this.mImageDownloader = ImageDownloader.getInstance();
    }
}
项目:RLibrary    文件DefaultitemtouchhelperCallback.java   
@Override
public void onChildDraw(Canvas c,RecyclerView recyclerView,RecyclerView.ViewHolder viewHolder,float dX,float dY,int actionState,boolean isCurrentlyActive) {
    //判断当前是否是swipe方式:侧滑。
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        //1.ItemView--ViewHolder; 2.侧滑条目的透明度程度关联谁?dX(delta增量,范围:当前条目-width~width)。
        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        float alpha = 1;
        if (layoutManager instanceof linearlayoutmanager) {
            int orientation = ((linearlayoutmanager) layoutManager).getorientation();
            if (orientation == linearlayoutmanager.HORIZONTAL) {
                alpha = 1 - Math.abs(dY) / viewHolder.itemView.getHeight();
            } else if (orientation == linearlayoutmanager.VERTICAL) {
                alpha = 1 - Math.abs(dX) / viewHolder.itemView.getWidth();
            }
        }
        viewHolder.itemView.setAlpha(alpha);//1~0
    }
    super.onChildDraw(c,recyclerView,viewHolder,dX,dY,actionState,isCurrentlyActive);
}
项目:JD-Test    文件ItemDragAndSwipeCallback.java   
@Override
public void onChildDrawOver(Canvas c,boolean isCurrentlyActive) {
    super.onChildDrawOver(c,isCurrentlyActive);

    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE
            && !isViewCreateByAdapter(viewHolder)) {
        View itemView = viewHolder.itemView;

        c.save();
        if (dX > 0) {
            c.clipRect(itemView.getLeft(),itemView.getTop(),itemView.getLeft() + dX,itemView.getBottom());
            c.translate(itemView.getLeft(),itemView.getTop());
        } else {
            c.clipRect(itemView.getRight() + dX,itemView.getRight(),itemView.getBottom());
            c.translate(itemView.getRight() + dX,itemView.getTop());
        }

        mAdapter.onItemSwiping(c,isCurrentlyActive);
        c.restore();

    }
}
项目:GitHub    文件ItemDragAndSwipeCallback.java   
@Override
public void onChildDrawOver(Canvas c,isCurrentlyActive);
        c.restore();

    }
}
项目:letv    文件FirstPageCustomAdapter.java   
public FirstPageCustomAdapter(Context context,List<HomeBlock> list,TextView view,RecyclerView recyclerView) {
    this.mInflater = LayoutInflater.from(context);
    if (!BaseTypeUtils.isListempty(list)) {
        for (HomeBlock block : list) {
            if (block != null) {
                if (TextUtils.equals(block.isLock,"1")) {
                    this.mList.add(this.mlockSize,block);
                    this.mlockSize++;
                } else {
                    this.mList.add(block);
                }
            }
        }
        this.mitemtouchhelper = helper;
        this.mContext = context;
        if (this.mlockSize == 0) {
            this.mHeadSize = 1;
        } else {
            this.mHeadSize = 2;
        }
        this.mSaveView = view;
        this.mRecyclerView = recyclerView;
    }
}
项目:MyCalendar    文件LocationListActivity.java   
private void initView() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setdisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext,R.color.color_Actionbar)));
    }
    mCoordinatorLayout = findViewById(R.id.coordinator);

    RecyclerView recyclerView = findViewById(R.id.recycle_view);
    recyclerView.setLayoutManager(new linearlayoutmanager(this));
    mAdapter = new LocationAdapter(this,new ArrayList<Location>());
    @SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter,recyclerView);
    recyclerView.setAdapter(animatorAdapter);

    itemtouchhelper.Callback callback = new itemtouchhelperCallBackNoMove(mAdapter);
    itemtouchhelper touchHelper = new itemtouchhelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);

    mView_FABMenu = findViewById(R.id.fab_menu_1);
    FloatingActionButton addLocation = findViewById(R.id.fab_action_1);
    addLocation.setVisibility(View.VISIBLE);
    addLocation.setLabelText(mContext.getResources().getString(R.string.add_location));
    addLocation.setonClickListener(this);
}
项目:GitHub    文件MyitemtouchhelperCallback.java   
@Override
    public int getMovementFlags(RecyclerView recyclerView,RecyclerView.ViewHolder holder) {
        //方向:up,down,left,right
        //常量:
        int up = itemtouchhelper.UP;//1  0x0001
        int down = itemtouchhelper.DOWN;//2 0x0010
//      itemtouchhelper.LEFT
//      itemtouchhelper.RIGHT
        //我要监听的拖拽方向是哪两个方向。
        int dragFlags = itemtouchhelper.UP | itemtouchhelper.DOWN|itemtouchhelper.LEFT | itemtouchhelper.RIGHT;
        //我要监听的swipe侧滑方向是哪个方向
//      int swipeFlags = 0;
        int swipeFlags = itemtouchhelper.LEFT | itemtouchhelper.RIGHT;


        int flags = makeMovementFlags(dragFlags,swipeFlags);
        return flags;
    }
项目:Hands-On-Android-UI-Development    文件OverviewActivity.java   
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_overview);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    final RecyclerView claimItems = findViewById(R.id.claim_items);
    claimItems.setAdapter(new ClaimItemAdapter(
            this,ClaimApplication.getClaimDatabase().claimItemDao().selectAll()
    ));

    new itemtouchhelper(new SwipetoDeleteCallback())
            .attachToRecyclerView(claimItems);
}
项目:GitHub    文件MyitemtouchhelperCallback.java   
@Override
public void onChildDraw(Canvas c,boolean isCurrentlyActive) {
    //dX:水平方向移动的增量(负:往左;正:往右)范围:0~View.getWidth  0~1
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        //透明度动画
        float alpha = 1 - Math.abs(dX) / viewHolder.itemView.getWidth();
        viewHolder.itemView.setAlpha(alpha);//1~0
        viewHolder.itemView.setScaleX(alpha);//1~0
        viewHolder.itemView.setScaleY(alpha);//1~0
    }


    super.onChildDraw(c,isCurrentlyActive);
}
项目:OpenHub    文件TraceFragment.java   
@Override
    protected void initFragment(Bundle savedInstanceState) {
        super.initFragment(savedInstanceState);
        setLoadMoreEnable(true);
        itemtouchhelperCallback callback = new itemtouchhelperCallback(0,this);
        itemtouchhelper = new itemtouchhelper(callback);
        itemtouchhelper.attachToRecyclerView(recyclerView);
        StickyRecyclerHeadersdecoration headersDecor = new StickyRecyclerHeadersdecoration(adapter);
        recyclerView.addItemdecoration(headersDecor);

        StickyRecyclerHeadersTouchListener touchListener =
                new StickyRecyclerHeadersTouchListener(recyclerView,headersDecor);
        touchListener.setonHeaderClickListener((header,position,headerId) -> {
            //wrong position returned
//            recyclerView.smoothScrollToPosition(mPresenter.getFirstItemByDate((Long) header.getTag()));
        });
        recyclerView.addOnItemTouchListener(touchListener);

    }
项目:DynamicTab    文件MainActivity.java   
private void initView() {
    mRecyclerSrc = (RecyclerView) findViewById(R.id.teach_src);
    mRecyclerDst = (RecyclerView) findViewById(R.id.teach_dst);
    GridLayoutManager layoutManagerSrc = new GridLayoutManager(this,4);
    GridLayoutManager layoutManagerDst = new GridLayoutManager(this,4);
    mRecyclerSrc.setLayoutManager(layoutManagerSrc);
    mRecyclerDst.setLayoutManager(layoutManagerDst);
    TeachAdapter srcAdapter = new TeachAdapter(this,getDataSrc());
    mRecyclerSrc.setAdapter(srcAdapter);
    srcAdapter.setListener(this);
    TeachAdapter detAdapter = new TeachAdapter(this,getDataDst());
    mRecyclerDst.setAdapter(detAdapter);
    detAdapter.setListener(this);

    itemtouchhelper itemtouchhelper = new itemtouchhelper(new ItemTouchCallback(srcAdapter));
    itemtouchhelper.attachToRecyclerView(mRecyclerSrc);
}
项目:GitHub    文件itemtouchhelperCallback.java   
/**
 * {@inheritDoc}
 */
@Override
public int getMovementFlags(RecyclerView recyclerView,RecyclerView.ViewHolder viewHolder) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    int dragFlags;
    int swipeFlags;
    //Set movement flags based on the Layout Manager and Orientation
    if (layoutManager instanceof GridLayoutManager || layoutManager instanceof StaggeredGridLayoutManager) {
        dragFlags = itemtouchhelper.UP | itemtouchhelper.DOWN | itemtouchhelper.LEFT | itemtouchhelper.RIGHT;
        swipeFlags = 0;
    } else if (Utils.getorientation(layoutManager) == linearlayoutmanager.VERTICAL) {
        dragFlags = itemtouchhelper.UP | itemtouchhelper.DOWN;
        swipeFlags = mSwipeFlags > 0 ? mSwipeFlags : itemtouchhelper.LEFT | itemtouchhelper.RIGHT;
    } else {
        dragFlags = itemtouchhelper.LEFT | itemtouchhelper.RIGHT;
        swipeFlags = mSwipeFlags > 0 ? mSwipeFlags : itemtouchhelper.UP | itemtouchhelper.DOWN;
    }
    //disallow item swiping or dragging
    if (viewHolder instanceof ViewHolderCallback) {
        ViewHolderCallback viewHolderCallback = (ViewHolderCallback) viewHolder;
        if (!viewHolderCallback.isDraggable()) dragFlags = 0;
        if (!viewHolderCallback.isSwipeable()) swipeFlags = 0;
    }
    return makeMovementFlags(dragFlags,swipeFlags);
}
项目:GitHub    文件FlexibleViewHolder.java   
/**
 * {@inheritDoc}
 *
 * @see #toggleActivation()
 * @since 5.0.0-b1
 */
@Override
@CallSuper
public void onClick(View view) {
    int position = getFlexibleAdapterPosition();
    if (!mAdapter.isEnabled(position)) return;
    // Experimented that,if LongClick is not consumed,onClick is fired. We skip the
    // call to the listener in this case,which is allowed only in ACTION_STATE_IDLE.
    if (mAdapter.mItemClickListener != null && mActionState == itemtouchhelper.ACTION_STATE_IDLE) {
        if (FlexibleAdapter.DEBUG)
            Log.v(TAG,"onClick on position " + position + " mode=" + mAdapter.getMode());
        // Get the permission to activate the View from user
        if (mAdapter.mItemClickListener.onItemClick(position)) {
            // Now toggle the activation
            toggleActivation();
        }
    }
}
项目:JSSample    文件SRecyclerView.java   
/**
 * 设置移动方向 模式
 *
 * @param recyclerView
 * @param viewHolder
 * @return
 */
@Override
public int getMovementFlags(RecyclerView recyclerView,RecyclerView.ViewHolder viewHolder) {
    int dragflag = 0;
    int swipeflag = 0;
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
        if (canswitch)
            dragflag = itemtouchhelper.UP |
                    itemtouchhelper.DOWN |
                    itemtouchhelper.LEFT |
                    itemtouchhelper.RIGHT;
        if (canswipe)
            swipeflag = itemtouchhelper.END;
    } else {
        if (canswitch)
            dragflag = itemtouchhelper.UP |
                    itemtouchhelper.DOWN;
        if (canswipe)
            swipeflag = itemtouchhelper.END;
    }
    return makeMovementFlags(dragflag,swipeflag);
}
项目:UiLib    文件DefaultitemtouchhelperCallback.java   
@Override
public void onChildDraw(Canvas c,int
        actionState,isCurrentlyActive);
}
项目:GoogleVR    文件ItemDragAndSwipeCallback.java   
@Override
public void onChildDrawOver(Canvas c,isCurrentlyActive);

    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        View itemView = viewHolder.itemView;

        c.save();
        if (dX > 0) {
            c.clipRect(itemView.getLeft(),isCurrentlyActive);
        c.restore();

    }
}
项目:Android-Code-Demos    文件Linearactivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_linear);

    List<String> list = new ArrayList<>();
    for (int i = 1; i <= 20; i++) {
        list.add("Hello,I am " + i);
    }
    Adapter adapter = new Adapter(this,this);
    adapter.addAll(list);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.linear_recycler_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new linearlayoutmanager(this));

    itemtouchhelper.Callback callback = new itemtouchhelperCallBack(adapter);
    mitemtouchhelper = new itemtouchhelper(callback);
    mitemtouchhelper.attachToRecyclerView(recyclerView);
}
项目:ImitateZHRB    文件SimpleitemtouchhelperCallback.java   
@Override
public void onChildDraw(Canvas c,boolean isCurrentlyActive) {
    super.onChildDraw(c,isCurrentlyActive);

    // Fade out the view as it is swiped out of the parent's bounds
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        View itemView = viewHolder.itemView;
        final float alpha = ALPHA_FULL - Math.abs(dX) / (float) itemView.getWidth();
        itemView.setAlpha(alpha);
    }
}
项目:AvatarTinderView    文件SimpleitemtouchhelperCallback.java   
@Override
public void onChildDraw(Canvas c,boolean isCurrentlyActive) {
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        // Fade out the view as it is swiped out of the parent's bounds
        final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
        viewHolder.itemView.setAlpha(alpha);
        viewHolder.itemView.setTranslationX(dX);
    } else {
        super.onChildDraw(c,isCurrentlyActive);
    }
}
项目:ucar-weex-core    文件DragSupportCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
    if (actionState != itemtouchhelper.ACTION_STATE_IDLE && viewHolder instanceof ListBaseViewHolder) {
        ListBaseViewHolder vh = (ListBaseViewHolder) viewHolder;
        if (vh.getComponent() != null) {
            mDragHelper.onDragStart(vh.getComponent(),vh.getAdapterPosition());
        }
    }

    super.onSelectedChanged(viewHolder,actionState);
}
项目:Android-Open-Shopping-List    文件itemtouchhelperCallback.java   
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder,int direction) {
    Shoppinglistadapter.ViewHolder vh = (Shoppinglistadapter.ViewHolder) viewHolder;

    vh.isSwiped = true;

    if (direction == itemtouchhelper.START) {
        listener.onSwipeLeft(vh);
    } else if (direction == itemtouchhelper.END) {
        listener.onSwipeRight(vh);
    }
}
项目:MyCalendar    文件WeekLessonDetailActivity.java   
private void initView() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setdisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext,R.color.color_Actionbar)));
    }

    mView_Coordinator = findViewById(R.id.coordinator);
    mView_SubjectName = findViewById(R.id.week_lesson_detail_subject_name);
    mView_SubjectArrow = findViewById(R.id.arrow);
    mView_Weekday = findViewById(R.id.week_lesson_detail_weekday);
    mView_Repeat = findViewById(R.id.week_lesson_detail_repeat);
    mView_Day = findViewById(R.id.week_lesson_detail_day);
    mView_FABMenu = findViewById(R.id.fab_menu_1);
    FloatingActionButton addDayLesson = findViewById(R.id.fab_action_1);
    FloatingActionButton editWeekLesson = findViewById(R.id.fab_action_2);
    addDayLesson.setVisibility(View.VISIBLE);
    editWeekLesson.setVisibility(View.VISIBLE);
    addDayLesson.setLabelText(mResources.getString(R.string.add_day_lesson));
    editWeekLesson.setLabelText(mResources.getString(R.string.edit_week_lesson));
    editWeekLesson.setimageResource(R.drawable.ic_edit_white_24dp);

    RecyclerView mView_RecyclerView = findViewById(R.id.recycle_view);
    mView_RecyclerView.setnestedScrollingEnabled(false);
    mView_RecyclerView.setLayoutManager(new linearlayoutmanager(this));
    mAdapter = new DayLessonAdapter(mContext,new ArrayList<DayLesson>(),mColorText,mColorBackground);
    @SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter,mView_RecyclerView);
    mView_RecyclerView.setAdapter(animatorAdapter);

    itemtouchhelper.Callback callback = new itemtouchhelperCallBackNoMove(mAdapter);
    itemtouchhelper touchHelper = new itemtouchhelper(callback);
    touchHelper.attachToRecyclerView(mView_RecyclerView);

    registerForContextMenu(mView_SubjectArrow);
    mView_SubjectArrow.setonClickListener(this);
    mView_SubjectName.setonClickListener(this);
    addDayLesson.setonClickListener(this);
    editWeekLesson.setonClickListener(this);
    setUpInfo();
}
项目:OddLauncher    文件RecyclerItemSwiper.java   
public RecyclerItemSwiper(int dragDirs,int swipeDirs,Context context,AppAdapter adapter,List<AppInfo> list,DatabaseHelper db,String tag,RecyclerView recyclerView) {
    super(dragDirs,swipeDirs);
    this.context = context;
    this.adapter = adapter;
    this.list = list;
    this.db = db;
    this.tag = tag;
    itemtouchhelper = new itemtouchhelper(RecyclerItemSwiper.this);
    itemtouchhelper.attachToRecyclerView(recyclerView);
}
项目:EasyTodo    文件SimpleitemtouchhelperCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
    // We only want the active item to change
    if (actionState != itemtouchhelper.ACTION_STATE_IDLE) {
        if (viewHolder instanceof itemtouchhelperViewHolder) {
            // Let the view holder kNow that this item is being moved or dragged
            itemtouchhelperViewHolder itemViewHolder = (itemtouchhelperViewHolder) viewHolder;
            itemViewHolder.onItemSelected();
        }
    }

    super.onSelectedChanged(viewHolder,actionState);
}
项目:decoy    文件ItemDragAndSwipeCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
    if (actionState == itemtouchhelper.ACTION_STATE_DRAG
            && !isViewCreateByAdapter(viewHolder)) {
        mAdapter.onItemDragStart(viewHolder);
        viewHolder.itemView.setTag(R.id.BaseQuickAdapter_dragging_support,true);
    } else if (actionState == itemtouchhelper.ACTION_STATE_SWIPE
            && !isViewCreateByAdapter(viewHolder)) {
        mAdapter.onItemSwipestart(viewHolder);
        viewHolder.itemView.setTag(R.id.BaseQuickAdapter_swiping_support,true);
    }
    super.onSelectedChanged(viewHolder,actionState);
}
项目:MaterialDesignDemo    文件MyitemtouchhelperCallback.java   
/**
 * 当item被拖拽或侧滑时触发
 *
 * @param viewHolder
 * @param actionState 当前item的状态
 */
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
    super.onSelectedChanged(viewHolder,actionState);
    //不管是拖拽或是侧滑,背景色都要变化
    if (actionState != itemtouchhelper.ACTION_STATE_IDLE)
        viewHolder.itemView.setBackgroundColor(viewHolder.itemView.getContext().getResources().getColor(android.R.color.darker_gray));
}
项目:GitHub    文件SimpleitemtouchhelperCallback.java   
@Override
public int getMovementFlags(RecyclerView recyclerView,RecyclerView.ViewHolder viewHolder) {
    // Set movement flags based on the layout manager
    int dragFlags;
    int swipeFlags;
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager ||
            recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
        if (mDragFlags != 0) {
            dragFlags = mDragFlags;
        } else {
            dragFlags = itemtouchhelper.UP | itemtouchhelper.DOWN | itemtouchhelper.LEFT | itemtouchhelper.RIGHT;
        }
        if (mSwipeFlags != 0) {
            swipeFlags = mSwipeFlags;
        } else {
            swipeFlags = itemtouchhelper.START;
        }
    } else {
        if (mDragFlags != 0) {
            dragFlags = mDragFlags;
        } else {
            dragFlags = itemtouchhelper.UP | itemtouchhelper.DOWN;
        }
        if (mSwipeFlags != 0) {
            swipeFlags = mSwipeFlags;
        } else {
            swipeFlags = itemtouchhelper.START | itemtouchhelper.END;
        }
    }
    return makeMovementFlags(dragFlags,swipeFlags);
}
项目:OSchina_resources_android    文件TweetPicturesPreviewerItemTouchCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,actionState);
}
项目:GitHub    文件SimpleitemtouchhelperCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,actionState);
}
项目:GitHub    文件RecyclerViewHelper.java   
/**
 * 启动拖拽和滑动
 * @param view 视图
 * @param adapter 适配器
 */
public static void startDragAndSwipe(RecyclerView view,BaseQuickAdapter adapter) {
    SimpleitemtouchhelperCallback callback = new SimpleitemtouchhelperCallback(adapter);
    final itemtouchhelper itemtouchhelper = new itemtouchhelper(callback);
    itemtouchhelper.attachToRecyclerView(view);
    adapter.setDragStartListener(new OnStartDragListener() {
        @Override
        public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
            itemtouchhelper.startDrag(viewHolder);
        }
    });
    adapter.setDragCallback(callback);
    adapter.setDragColor(Color.LTGRAY);
}
项目:text_converter    文件StylistFragment.java   
@Override
public void onViewCreated(@NonNull View view,@Nullable Bundle savedInstanceState) {
    super.onViewCreated(view,savedInstanceState);
    mGenerator = new StylistGenerator(getContext());

    mInput = view.findViewById(R.id.edit_input);


    mAdapter = new StyleAdapter(getActivity(),R.layout.list_item_style);
    mAdapter.setonSwapStyleListener(new OnSwapStyleListener() {
        @Override
        public void onSwap(int fromPosition,int toPosition) {
            mGenerator.swapPosition(fromPosition,toPosition);
        }
    });

    mListResult = view.findViewById(R.id.recycler_view);
    mListResult.setLayoutManager(new linearlayoutmanager(getContext()));
    mListResult.setHasFixedSize(true);
    mListResult.setAdapter(mAdapter);
    mListResult.addItemdecoration(new DividerItemdecoration(getContext(),DividerItemdecoration.VERTICAL));

    itemtouchhelperCallback callback = new itemtouchhelperCallback(mAdapter);
    itemtouchhelper helper = new itemtouchhelper(callback);
    helper.attachToRecyclerView(mListResult);

    mInput.addTextChangedListener(this);

    restore();
}
项目:GitHub    文件SimpleItemTouchCallback.java   
/**
 * 状态改变时回调
 */
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,actionState);
    Log.i("Callback",actionState + "");
    if(actionState != itemtouchhelper.ACTION_STATE_IDLE){
        normalAdapter.VH holder = (normalAdapter.VH)viewHolder;
        holder.itemView.setBackgroundColor(0xffbcbcbc);
    }
}
项目:Fairy    文件MyItemTouchCallback.java   
@Override
public void onChildDraw(Canvas c,boolean isCurrentlyActive) {
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        //滑动时改变 Item 的透明度,以实现滑动过程中实现渐变效果
        final float alpha = 1 - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
        viewHolder.itemView.setAlpha(alpha);
        viewHolder.itemView.setTranslationX(dX);
    } else {
        super.onChildDraw(c,isCurrentlyActive);
    }
}
项目:RetroMusicPlayer    文件SwipeAndDragHelper.java   
@Override
public void onChildDraw(Canvas c,boolean isCurrentlyActive) {
    if (actionState == itemtouchhelper.ACTION_STATE_SWIPE) {
        float alpha = 1 - (Math.abs(dX) / recyclerView.getWidth());
        viewHolder.itemView.setAlpha(alpha);
    }
    super.onChildDraw(c,isCurrentlyActive);
}
项目:Rey-MusicPlayer    文件SimpleitemtouchhelperCallback.java   
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder,int actionState) {
    // We only want the active item to change
    if (actionState != itemtouchhelper.ACTION_STATE_IDLE) {
        if (viewHolder instanceof itemtouchhelperViewHolder) {
            itemtouchhelperViewHolder itemViewHolder = (itemtouchhelperViewHolder) viewHolder;
            itemViewHolder.onItemSelected();
        }
    }
    super.onSelectedChanged(viewHolder,actionState);
}
项目:MusicX-music-player    文件TabRemoveFragment.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.playlist_picker,new LinearLayout(getActivity()),false);
    rv = (RecyclerView) view.findViewById(R.id.rv);
    btn = (Button) view.findViewById(R.id.create_playlist);
    btn.setVisibility(View.GONE);
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity());
    CustomLayoutManager customlayoutmanager = new CustomLayoutManager(getActivity());
    customlayoutmanager.setorientation(linearlayoutmanager.VERTICAL);
    customlayoutmanager.setSmoothScrollbarEnabled(true);
    rv.setLayoutManager(customlayoutmanager);
    tabAdapter = new RemoveTabAdapter(getActivity(),this);
    itemtouchhelper.Callback callback = new SimpleitemtouchhelperCallback(tabAdapter);
    mitemtouchhelper = new itemtouchhelper(callback);
    mitemtouchhelper.attachToRecyclerView(rv);
    List<String> data = new ArrayList<String>();
    data.add("1. Recent");
    data.add("2. Folder");
    data.add("3. Song");
    data.add("4. Album");
    data.add("5. Artist");
    data.add("6.Playlist");
    tabAdapter.addDataList(data);
    rv.setAdapter(tabAdapter);
    builder.title("Tab Remove")
            .autodismiss(true)
            .positiveText(R.string.okay)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog,@NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .customView(view,false);
    return builder.show();
}
项目:OpenHub    文件BookmarksFragment.java   
@Override
protected void initFragment(Bundle savedInstanceState) {
    super.initFragment(savedInstanceState);
    setLoadMoreEnable(true);
    itemtouchhelperCallback callback = new itemtouchhelperCallback(0,this);
    itemtouchhelper = new itemtouchhelper(callback);
    itemtouchhelper.attachToRecyclerView(recyclerView);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。