use of androidx.recyclerview.widget.ItemTouchHelper in project Signal-Android by WhisperSystems.
the class ConversationItemSwipeCallback method attachToRecyclerView.
void attachToRecyclerView(@NonNull RecyclerView recyclerView) {
recyclerView.addOnItemTouchListener(itemTouchListener);
new ItemTouchHelper(this).attachToRecyclerView(recyclerView);
}
use of androidx.recyclerview.widget.ItemTouchHelper in project AntennaPod by AntennaPod.
the class FavoriteEpisodesFragment method onCreateView.
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = super.onCreateView(inflater, container, savedInstanceState);
emptyView.setIcon(R.drawable.ic_star);
emptyView.setTitle(R.string.no_fav_episodes_head_label);
emptyView.setMessage(R.string.no_fav_episodes_label);
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int swipeDir) {
EpisodeItemViewHolder holder = (EpisodeItemViewHolder) viewHolder;
Log.d(TAG, String.format("remove(%s)", holder.getFeedItem().getId()));
if (disposable != null) {
disposable.dispose();
}
FeedItem item = holder.getFeedItem();
if (item != null) {
DBWriter.removeFavoriteItem(item);
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.removed_item, Snackbar.LENGTH_LONG).setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item));
}
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
return root;
}
use of androidx.recyclerview.widget.ItemTouchHelper in project MyJapanese by 54wall.
the class FavLessonFragment method setData.
@Override
public void setData(List<LessonFav> data) {
Log.e(TAG, "setData!!!!!!");
lessonFavList = data;
staggeredGridAdapter = new StaggeredGridAdapter(getActivity(), data);
mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
mRecyclerView.setAdapter(staggeredGridAdapter);
staggeredGridAdapter.setOnItemClickLitener(new OnItemClickLitener() {
@Override
public void onItemClick(View view, int position) {
staggeredGridAdapter.notifyItemRemoved(position);
((MainActivity) getActivity()).switchFavWord(staggeredGridAdapter.getItemLessonId(position), false);
}
@Override
public void onItemLongClick(View view, final int position) {
}
});
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(mRecyclerView);
}
use of androidx.recyclerview.widget.ItemTouchHelper in project FlexibleAdapter by davideas.
the class FlexibleAdapter method initializeItemTouchHelper.
/*---------------*/
/* TOUCH METHODS */
/*---------------*/
private void initializeItemTouchHelper() {
if (mItemTouchHelper == null) {
if (mRecyclerView == null) {
throw new IllegalStateException("RecyclerView cannot be null. Enabling LongPressDrag or Swipe must be done after the Adapter has been attached to the RecyclerView.");
}
if (mItemTouchHelperCallback == null) {
mItemTouchHelperCallback = new ItemTouchHelperCallback(this);
log.i("Initialized default ItemTouchHelperCallback");
}
mItemTouchHelper = new ItemTouchHelper(mItemTouchHelperCallback);
mItemTouchHelper.attachToRecyclerView(mRecyclerView);
}
}
use of androidx.recyclerview.widget.ItemTouchHelper in project collect by opendatakit.
the class RankingWidgetDialog method setUpRecyclerView.
private RecyclerView setUpRecyclerView() {
rankingListAdapter = new RankingListAdapter(viewModel.getItems(), viewModel.getFormIndex());
RecyclerView recyclerView = new RecyclerView(getContext());
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(rankingListAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Callback callback = new RankingItemTouchHelperCallback(rankingListAdapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(recyclerView);
return recyclerView;
}
Aggregations