Java Code Examples for android.support.v7.widget.helper.ItemTouchHelper#START

The following examples show how to use android.support.v7.widget.helper.ItemTouchHelper#START . 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: MainActivity.java    From CircularDeletionSwipe with Apache License 2.0 6 votes vote down vote up
@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.semi_black));
setSupportActionBar(toolbar);

recycler = (RecyclerView)findViewById(R.id.recyclerView);
recycler.setLayoutManager(new LinearLayoutManager(this));
recycler.setItemAnimator(new DefaultItemAnimator());
recycler.setAdapter(new AdapterRecyclerView(this, getItemList()));

ItemTouchHelper.Callback callback = new DeletionSwipeHelper(0, ItemTouchHelper.START, this, this);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(recycler);
  }
 
Example 2
Source File: CustomItemTouchHelper.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@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 3
Source File: SwipeToDismissItemCallback.java    From SimpleRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
  if (simpleRecyclerView == null) {
    simpleRecyclerView = (SimpleRecyclerView) recyclerView;
  }

  // obtain current item
  swipeItemPosition = viewHolder.getAdapterPosition();
  if (swipeItemPosition != NO_POSITION) {
    swipeItem = simpleRecyclerView.getCell(swipeItemPosition).getItem();
  }

  // reset
  isItemSettled = false;
  isItemSwiped = false;

  int swipeFlags = 0;

  if (options.canSwipeLeft()) {
    swipeFlags = swipeFlags | ItemTouchHelper.START;
  }
  if (options.canSwipeRight()) {
    swipeFlags = swipeFlags | ItemTouchHelper.END;
  }
  if (options.canSwipeUp()) {
    swipeFlags = swipeFlags | ItemTouchHelper.UP;
  }
  if (options.canSwipeDown()) {
    swipeFlags = swipeFlags | ItemTouchHelper.DOWN;
  }

  return makeMovementFlags(0, swipeFlags);
}
 
Example 4
Source File: ItemDragHelperCallback.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags;
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager || layoutManager instanceof StaggeredGridLayoutManager) {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.START | ItemTouchHelper.END;
    } else {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    }
    int swipeFlags = 0;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 5
Source File: ListDragMenuActivity.java    From LRecyclerView with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: SimpleItemTouchHelperCallback.java    From PracticalRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    if (!(recyclerView.getAdapter() instanceof AbstractAdapter)) {
        return 0;
    }

    mAdapter = (AbstractAdapter) recyclerView.getAdapter();
    int currentPosition = viewHolder.getAdapterPosition();
    if (!mAdapter.canDrag(currentPosition)) {
        return 0;
    }

    int dragFlags;
    int swipeFlags;
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
        swipeFlags = 0;
    } else if (layoutManager instanceof LinearLayoutManager) {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
        swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    } else {
        dragFlags = 0;
        swipeFlags = 0;
    }

    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 7
Source File: SimpleItemTouchHelperCallback.java    From LazyRecyclerAdapter with MIT License 5 votes vote down vote up
@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 8
Source File: TodayAdapter.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onItemRemoved(int position, int direction) {
    Assignment mJustDeletedToDoItem = getData().remove(position).assignment;
    notifyItemRemoved(position);
    if (onItemRemovedListener != null) {
        if (direction == ItemTouchHelper.END) {
            onItemRemovedListener.onItemRemovedRight(mJustDeletedToDoItem, position);
        } else if (direction == ItemTouchHelper.START) {
            onItemRemovedListener.onItemRemovedLeft(mJustDeletedToDoItem, position);
        }
    }
}
 
Example 9
Source File: SimpleItemTouchHelperCallback.java    From privacy-friendly-weather with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @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: ItemTouchHelperCallback.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 5 votes vote down vote up
@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 11
Source File: MyItemTouchCallback.java    From TimePicker with Apache License 2.0 4 votes vote down vote up
@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 12
Source File: ItemTouchHelperCallback.java    From recyclerviewItemDecorations with MIT License 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = 0;
    int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 13
Source File: FilterTouchHelperCallback.java    From android-proguards with Apache License 2.0 4 votes vote down vote up
public FilterTouchHelperCallback(ItemTouchHelperAdapter adapter) {
    super(0, ItemTouchHelper.START);
    this.adapter = adapter;
}
 
Example 14
Source File: SimpleItemTouchHelperCallback.java    From PowerfulRecyclerView with Apache License 2.0 4 votes vote down vote up
@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 15
Source File: SimpleItemTouchHelperCallback.java    From Stock-Hawk with Apache License 2.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    final int dragFlags = 0;
    final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 16
Source File: SelectableViewAdapterActivity.java    From FancyAdapters with MIT License 4 votes vote down vote up
public CustomAdapter(List<String> items, RecyclerView recyclerView) {
    super(items, recyclerView, ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.START | ItemTouchHelper.END);
}
 
Example 17
Source File: SuperSelectableAdapterActivity.java    From FancyAdapters with MIT License 4 votes vote down vote up
public CustomAdapter(List<String> items, RecyclerView recyclerView) {
    super(items, recyclerView, ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.START | ItemTouchHelper.END);
}
 
Example 18
Source File: HandleAdapterActivity.java    From FancyAdapters with MIT License 4 votes vote down vote up
public CustomAdapter(List<String> items, RecyclerView recyclerView) {
    super(items, recyclerView, ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.START | ItemTouchHelper.END);
}
 
Example 19
Source File: SimpleItemTouchHelperCallback.java    From ankihelper with GNU General Public License v3.0 4 votes vote down vote up
@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 20
Source File: TabListTouchHelperCallback.java    From photosearcher with Apache License 2.0 4 votes vote down vote up
@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);
}