Search in sources :

Example 16 with ItemTouchHelper

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);
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper)

Example 17 with ItemTouchHelper

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;
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) NonNull(androidx.annotation.NonNull) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 18 with ItemTouchHelper

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);
}
Also used : OnItemClickLitener(pri.weiqiang.liyujapanese.ui.adapter.stagger.OnItemClickLitener) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) StaggeredGridAdapter(pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) FavLessonFragmentView(pri.weiqiang.liyujapanese.mvp.view.dic.FavLessonFragmentView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 19 with ItemTouchHelper

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);
    }
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) ItemTouchHelperCallback(eu.davidea.flexibleadapter.helpers.ItemTouchHelperCallback)

Example 20 with ItemTouchHelper

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;
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) RankingListAdapter(org.odk.collect.android.adapters.RankingListAdapter) LayoutParams(android.widget.LinearLayout.LayoutParams) RankingItemTouchHelperCallback(org.odk.collect.android.utilities.RankingItemTouchHelperCallback) Callback(androidx.recyclerview.widget.ItemTouchHelper.Callback) RankingItemTouchHelperCallback(org.odk.collect.android.utilities.RankingItemTouchHelperCallback) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)24 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 View (android.view.View)10 Intent (android.content.Intent)3 Canvas (android.graphics.Canvas)3 NonNull (androidx.annotation.NonNull)3 Context (android.content.Context)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 TextView (android.widget.TextView)2 Nullable (androidx.annotation.Nullable)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 Toolbar (androidx.appcompat.widget.Toolbar)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)2 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)2 BindView (butterknife.BindView)2 SwipeDismissalDelegate (com.android.settings.homepage.contextualcards.slices.SwipeDismissalDelegate)2 EpisodeItemViewHolder (de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder)2 ArrayList (java.util.ArrayList)2