Java Code Examples for android.support.v7.widget.helper.ItemTouchHelper#DOWN
The following examples show how to use
android.support.v7.widget.helper.ItemTouchHelper#DOWN .
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: 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 2
Source File: SheetSortController.java From Musicoco with Apache License 2.0 | 6 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // 滑动或者拖拽的方向,上下左右 RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); int dragFlags; if (manager instanceof GridLayoutManager || manager instanceof StaggeredGridLayoutManager) { //网格布局管理器允许上下左右拖动 dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT; } else { //其他布局管理器允许上下拖动 dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; } return makeMovementFlags(dragFlags, 0); }
Example 3
Source File: ItemActivity.java From Fairy with Apache License 2.0 | 6 votes |
private void initView() { RecyclerView recycleView = findViewById(R.id.recycle_main); adapter = new MyAdapter(this); itemTouchCallback = new MyItemTouchCallback(this, adapter, ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.END); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback); recycleView.setLayoutManager(new LinearLayoutManager(this)); recycleView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); recycleView.setAdapter(adapter); adapter.addAll(new ArrayList<>()); itemTouchHelper.attachToRecyclerView(recycleView); adapter.setOnClickListener(position -> { viewModel.setTempPosition(position); Intent intent = new Intent(ItemActivity.this, LogcatActivity.class); LogcatItem item = adapter.get(position); intent.putExtra(LogcatActivity.LOGCAT_ITEM, item); startActivityForResult(intent, ITEM_REQUEST_CODE); }); }
Example 4
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 5
Source File: SimpleItemTouchHelperCallback.java From LazyRecyclerAdapter with MIT License | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // Enable drag and swipe in both directions final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); }
Example 6
Source File: CustomNewsActivity.java From NewsMe with Apache License 2.0 | 5 votes |
private SimpleItemTouchHelperCallback simpleItemTouch(ItemTouchHelperAdapter adapter) { return new SimpleItemTouchHelperCallback(adapter) { @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; final int swipeFlags = 0; return makeMovementFlags(dragFlags, swipeFlags); } }; }
Example 7
Source File: CustomItemTouchHelper.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { if (viewHolder.getItemViewType() == IItemTouchHelperAdapter.ViewType.HEADER.id || viewHolder.getItemViewType() == IItemTouchHelperAdapter.ViewType.FOOTER.id){ return makeMovementFlags(0,0); } int upFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(upFlags, swipeFlags); }
Example 8
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 9
Source File: SimpleItemTouchHelperCallback.java From privacy-friendly-weather with GNU General Public License v3.0 | 5 votes |
/** * @see android.support.v7.widget.helper.ItemTouchHelper.Callback#getMovementFlags(RecyclerView, RecyclerView.ViewHolder) * Sets the swipe flags for start and end. */ @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); }
Example 10
Source File: MainActivity.java From Ucount with GNU General Public License v3.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // 如果不想上下拖动,可以将 dragFlags = 0 int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // 如果你想左右滑动,可以将 swipeFlags = 0 int swipeFlags = ItemTouchHelper.RIGHT; //最终的动作标识(flags)必须要用makeMovementFlags()方法生成 int flags = makeMovementFlags(dragFlags, swipeFlags); return flags; }
Example 11
Source File: SimpleItemTouchHelperCallback.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // Enable drag up and down and right swipe in right direction final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; final int swipeFlags = ItemTouchHelper.END; // final int swipeFlags = ItemTouchHelper.END | ItemTouchHelper.START; Enable swipe in both direction return makeMovementFlags(dragFlags, swipeFlags); }
Example 12
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 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: SuperSelectableAdapterActivity.java From FancyAdapters with MIT License | 4 votes |
public CustomAdapter(List<String> items, RecyclerView recyclerView) { super(items, recyclerView, ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.START | ItemTouchHelper.END); }
Example 15
Source File: MyItemTouchHelperCallback.java From FaceT with Mozilla Public License 2.0 | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // movements drag return makeFlag( ItemTouchHelper.ACTION_STATE_DRAG , dragFlags); // as parameter, action drag and flags drag }
Example 16
Source File: ChecklistDragCallback.java From Travel-Mate with MIT License | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // swipeFlags 0 should disable swiping for all directions return makeMovementFlags(dragFlags, 0); }
Example 17
Source File: ItemTouchHelperCallback.java From SimpleNews with Apache License 2.0 | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); }
Example 18
Source File: MyItemTouchCallback.java From TimePicker with Apache License 2.0 | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; return makeMovementFlags(dragFlags, swipeFlags); }
Example 19
Source File: DownloadFileItemHelperCallback.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
public DownloadFileItemHelperCallback(SubsonicFragment fragment, boolean mainList) { super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT); this.fragment = fragment; this.mainList = mainList; }
Example 20
Source File: ItemMoveCallback.java From YTPlayer with GNU General Public License v3.0 | 4 votes |
@Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; return makeMovementFlags(dragFlags, 0); }