Java Code Examples for android.support.v7.widget.helper.ItemTouchHelper#LEFT
The following examples show how to use
android.support.v7.widget.helper.ItemTouchHelper#LEFT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShopCartItemTouchHelperCallback.java From FastWaiMai with MIT License | 6 votes |
/** * Callback回调监听时先调用的,用来判断当前是什么动作,比如判断方向 * 作用:哪个方向的拖动 * * @param recyclerView * @param viewHolder * @return */ @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { //方向:up,down,left,right //常量 // ItemTouchHelper.UP 0x0001 // ItemTouchHelper.DOWN 0x0010 // ItemTouchHelper.LEFT // ItemTouchHelper.RIGHT //我要监听的拖拽方向是哪个方向 int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; //我要监听的swipe侧滑方向是哪个方向 int swipeFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int flags = makeMovementFlags(dragFlags, swipeFlags); return flags; }
Example 2
Source File: ItemDragHelperCallback.java From fingerpoetry-android with Apache License 2.0 | 6 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags; RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager instanceof GridLayoutManager || manager instanceof StaggeredGridLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; } // 如果想支持滑动(删除)操作, swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END int swipeFlags = 0; // 热门和推荐不能移除 if(viewHolder.getAdapterPosition() == 1 ){ return 0; } return makeMovementFlags(dragFlags, swipeFlags); }
Example 3
Source File: LanguagesEditorFragment.java From OpenHub with GNU General Public License v3.0 | 6 votes |
@Override protected void initFragment(Bundle savedInstanceState) { super.initFragment(savedInstanceState); setHasOptionsMenu(true); setCanLoadMore(false); if(LanguagesEditorActivity.LanguageEditorMode.Sort.equals(mPresenter.getMode())){ ItemTouchHelperCallback callback = new ItemTouchHelperCallback( ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT, this); itemTouchHelper = new ItemTouchHelper(callback); itemTouchHelper.attachToRecyclerView(recyclerView); if(PrefUtils.isLanguagesEditorTipAble()){ showOperationTip(R.string.languages_editor_tip); PrefUtils.set(PrefUtils.LANGUAGES_EDITOR_TIP_ABLE, false); } } addVerticalDivider(); initSearchEditText(); }
Example 4
Source File: WalletFragment.java From alpha-wallet-android with MIT License | 5 votes |
SwipeCallback(TokensAdapter adapter) { super(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT); mAdapter = adapter; if (getActivity() != null) { icon = ContextCompat.getDrawable(getActivity(), R.drawable.ic_hide_token); if (icon != null) { icon.setTint(ContextCompat.getColor(getActivity(), R.color.white)); } background = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.cancel_red)); } }
Example 5
Source File: ItemTouchHelperCallback.java From PowerfulRecyclerView with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); }
Example 6
Source File: GiveawayListFragment.java From SteamGifts with MIT License | 5 votes |
public GiveawaySwipeHelper() { super(0, ItemTouchHelper.LEFT); xMark = ContextCompat.getDrawable(getActivity(), R.drawable.ic_eye_off); xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); xMarkMargin = (int) getResources().getDimension(R.dimen.ic_clear_margin); }
Example 7
Source File: ItemDragHelperCallback.java From MicroReader with MIT License | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags; RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager instanceof GridLayoutManager || manager instanceof StaggeredGridLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; } // 如果想支持滑动(删除)操作, swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END int swipeFlags = 0; return makeMovementFlags(dragFlags, swipeFlags); }
Example 8
Source File: DragItemTouchHelperCallBack.java From DragLayout with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { if (viewHolder.getItemViewType() == BaseDragAdapter.KEEP) { return makeMovementFlags(0, 0); } int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; return makeMovementFlags(dragFlags, 0); }
Example 9
Source File: ListDragMenuActivity.java From LRecyclerView with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = 0, swipeFlags = 0; if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; //设置侧滑方向为从左到右和从右到左都可以 swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; } return makeMovementFlags(dragFlags, swipeFlags); }
Example 10
Source File: MyItemTouchHelperCallback.java From MaterialDesignDemo with MIT License | 5 votes |
/** * 获取动作标识 * 动作标识分:dragFlags和swipeFlags * dragFlags:列表滚动方向的动作标识(如竖直列表就是上和下,水平列表就是左和右) * wipeFlags:与列表滚动方向垂直的动作标识(如竖直列表就是左和右,水平列表就是上和下) */ @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; int swipeFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int flags = makeMovementFlags(dragFlags, swipeFlags); return flags; }
Example 11
Source File: GiveawayListFragment.java From SteamGifts with MIT License | 5 votes |
@Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { if (direction == ItemTouchHelper.LEFT) { int position = viewHolder.getAdapterPosition(); Giveaway giveaway = (Giveaway) adapter.getItem(position); if (giveaway != null && giveaway.getInternalGameId() > 0) { EndlessAdapter.RemovedElement removedGiveaway = adapter.removeSwipedGiveaway(position); lastRemovedGame = new LastRemovedGame(removedGiveaway, giveaway.getInternalGameId()); requestHideGame(giveaway.getInternalGameId(), giveaway.getTitle()); } } }
Example 12
Source File: MainSwipeDecorator.java From Flubber with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { if (viewHolder.getAdapterPosition() > 0) { final int dragFlags = ItemTouchHelper.LEFT; final int swipeFlags = ItemTouchHelper.LEFT; return ItemTouchHelper.Callback.makeMovementFlags(dragFlags, swipeFlags); } return ItemTouchHelper.Callback.makeMovementFlags(0, 0); }
Example 13
Source File: QueueActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder) { final int swipeFlags = ItemTouchHelper.LEFT; int dragFlags = 0; if (mAdapter.getItemCount() > 1) { dragFlags |= ItemTouchHelper.UP | ItemTouchHelper.DOWN; } return makeMovementFlags(dragFlags, swipeFlags); }
Example 14
Source File: BindDragCallBack.java From LazyRecyclerAdapter with MIT License | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { final int dragFlags; final int swipeFlags; if (recyclerView.getLayoutManager() instanceof GridLayoutManager || recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; swipeFlags = 0; } else { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; swipeFlags = mSwipeFlags; } return makeMovementFlags(dragFlags, swipeFlags); }
Example 15
Source File: ItemDragHelperCallback.java From Toutiao with Apache License 2.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags; RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager instanceof GridLayoutManager || manager instanceof StaggeredGridLayoutManager) { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; } // 如果想支持滑动(删除)操作, swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END int swipeFlags = 0; return makeMovementFlags(dragFlags, swipeFlags); }
Example 16
Source File: ItemDragHelperCallback.java From ZZShow with Apache License 2.0 | 5 votes |
public int setDragFlags(RecyclerView recyclerView) { int dragFlags; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if(layoutManager instanceof GridLayoutManager || layoutManager instanceof StaggeredGridLayoutManager){ dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else { dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; } return dragFlags; }
Example 17
Source File: ItemDragCallback.java From ChannelManageDemo_Java with MIT License | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { //固定位置及tab下面的channel不能拖动 if (viewHolder.getLayoutPosition() < mAdapter.getFixSize() + 1 || viewHolder.getLayoutPosition() > mAdapter.getSelectedSize()) { return 0; } int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; int swipeFlags = 0; return makeMovementFlags(dragFlags, swipeFlags); }
Example 18
Source File: Reminders.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@Override public void onItemDismiss(int position) { // snooze + save in undo + save details for pushbuttons final Reminder remind = reminders.get(position); final Cloner cloner = new Cloner(); //cloner.setDumpClonedClasses(true); //cloner.dontClone( // android.graphics.DashPathEffect.class); last_undo = cloner.deepClone(remind); if (SimpleItemTouchHelperCallback.last_swipe_direction == ItemTouchHelper.LEFT) { // swipe left snoozeReminder(remind, remind.last_snoozed_for > 0 ? remind.last_snoozed_for : default_snooze); last_swiped = remind; last_undo_pos = position; reminders.remove(position); notifyItemRemoved(position); cancelAlert(); showSnoozeFloater(); } else { // swipe right if (remind.repeating || !remind.isDue()) { remind.schedule_next(); setFloaterText(remind.getTitle() + " " + xdrip.getAppContext().getString(R.string.next_in) + " " + JoH.niceTimeTill(remind.next_due)); } else if (!remind.repeating) { setFloaterText(remind.getTitle() + " " + xdrip.getAppContext().getString(R.string.completed)); remind.enabled = false; remind.save(); } last_swiped = remind; last_undo_pos = position; reminders.remove(position); notifyItemRemoved(position); cancelAlert(); showSnoozeFloater(); } JoH.runOnUiThreadDelayed(new Runnable() { @Override public void run() { reinject(remind); } }, 500); }
Example 19
Source File: NoteTouchCallback.java From reductor with Apache License 2.0 | 4 votes |
public NoteTouchCallback(Action1<Integer> onDismissed) { super(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT); this.onDismissed = onDismissed; }
Example 20
Source File: BookshelfFragment.java From MaterialHome with Apache License 2.0 | 4 votes |
@Override protected void initEvents() { mToolbar.setTitle("Bookshelf"); spanCount = getResources().getInteger(R.integer.gallery_span_count); mBookshelfPresenter = new BookshelfPresenterImpl(this); mBookshelfs = new ArrayList<>(); mSwipeRefreshLayout.setColorSchemeResources(R.color.recycler_color1, R.color.recycler_color2, R.color.recycler_color3, R.color.recycler_color4); //设置布局管理器 mLayoutManager = new GridLayoutManager(getActivity(), spanCount); mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return mbookshelfAdapter.getItemColumnSpan(position); } }); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); //设置adapter mbookshelfAdapter = new BookShelfAdapter(getActivity(), mBookshelfs, spanCount); mbookshelfAdapter.setSortable(isSortable); mRecyclerView.setAdapter(mbookshelfAdapter); //设置Item增加、移除动画 mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.addOnScrollListener(new RecyclerViewScrollDetector()); final int space = DensityUtils.dp2px(getActivity(), 4); mRecyclerView.addItemDecoration(new StaggeredGridDecoration(space, space, space, space, spanCount)); mSwipeRefreshLayout.setOnRefreshListener(this); // mFab.setImageDrawable(AppCompatResources.getDrawable(getActivity(), R.drawable.ic_action_add_white)); mFab.setOnClickListener(v -> { final BookShelfEditorHolder bookShelfHolder = new BookShelfEditorHolder(getActivity(), "", ""); final int inputSpace = DensityUtils.dp2px(getActivity(), 16); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setCancelable(false) .setView(bookShelfHolder.getContentView(), inputSpace, inputSpace, inputSpace, inputSpace) .setTitle(UIUtils.getContext().getString(R.string.add_bookshelf)) .setNegativeButton(R.string.cancel, (dialog, which) -> { dialog.dismiss(); KeyBoardUtils.closeKeyBord(bookShelfHolder.et_bookshelf_name, getActivity()); }) .setPositiveButton(R.string.ok, (dialog, which) -> { if (!bookShelfHolder.check()) { Snackbar.make(BaseActivity.activity.getToolbar(), R.string.bookshelf_name_is_empty, Snackbar.LENGTH_SHORT).show(); } else { mBookshelfPresenter.addBookshelf(bookShelfHolder.getName(), bookShelfHolder.getRemark(), TimeUtils.getCurrentTime()); } KeyBoardUtils.closeKeyBord(bookShelfHolder.et_bookshelf_name, getActivity()); }).create().show(); }); touchHelper = new ItemTouchHelper(new SimpleItemTouchHelperCallback(ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT | ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT)); }