Search in sources :

Example 1 with SimpleDragCallback

use of com.mikepenz.fastadapter.drag.SimpleDragCallback in project Hentoid by avluis.

the class DrawerEditActivity method onCreate.

@SuppressLint("NonConstantResourceId")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer_edit);
    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(v -> onBackPressed());
    toolbar.setOnMenuItemClickListener(clickedMenuItem -> {
        switch(clickedMenuItem.getItemId()) {
            case R.id.action_check_all:
                onCheckAll();
                break;
            case R.id.action_uncheck_all:
                onUncheckAll();
                break;
            default:
        }
        return true;
    });
    // Activate drag & drop
    SimpleDragCallback dragCallback = new SimpleDragCallback(this);
    dragCallback.setNotifyAllDrops(true);
    ItemTouchHelper touchHelper = new ItemTouchHelper(dragCallback);
    // Recycler
    List<SiteItem> items = new ArrayList<>();
    List<Site> activeSites = Preferences.getActiveSites();
    // First add active sites
    for (Site s : activeSites) if (s.isVisible())
        items.add(new SiteItem(s, true, touchHelper));
    // Then add the others
    for (Site s : Site.values()) // We don't want to show these
    if (s.isVisible() && !activeSites.contains(s))
        items.add(new SiteItem(s, false, touchHelper));
    itemAdapter.add(items);
    recyclerView = findViewById(R.id.drawer_edit_list);
    recyclerView.setAdapter(fastAdapter);
    recyclerView.setHasFixedSize(true);
    touchHelper.attachToRecyclerView(recyclerView);
    // OK button
    View okBtn = findViewById(R.id.drawer_edit_ok_btn);
    okBtn.setOnClickListener(v -> onValidateClick());
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) Site(me.devsaki.hentoid.enums.Site) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) ArrayList(java.util.ArrayList) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SiteItem(me.devsaki.hentoid.viewholders.SiteItem) Toolbar(androidx.appcompat.widget.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 2 with SimpleDragCallback

use of com.mikepenz.fastadapter.drag.SimpleDragCallback in project Hentoid by avluis.

the class ViewerGalleryFragment method updateListAdapter.

private void updateListAdapter(boolean isChapterEditMode) {
    if (isChapterEditMode) {
        if (!fastAdapter2.hasObservers())
            fastAdapter2.setHasStableIds(true);
        itemAdapter2.clear();
        ExpandableExtension<INestedItem<SubExpandableItem.ViewHolder>> expandableExtension = fastAdapter2.getOrCreateExtension(ExpandableExtension.class);
        GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager();
        if (glm != null) {
            int spanCount = Preferences.getViewerGalleryColumns();
            glm.setSpanCount(spanCount);
            // Use the correct size to display chapter separators, if any
            GridLayoutManager.SpanSizeLookup spanSizeLookup = new GridLayoutManager.SpanSizeLookup() {

                @Override
                public int getSpanSize(int position) {
                    if (fastAdapter2.getItemViewType(position) == R.id.expandable_item) {
                        return spanCount;
                    }
                    return 1;
                }
            };
            glm.setSpanSizeLookup(spanSizeLookup);
        }
        // Activate drag & drop
        SimpleDragCallback dragCallback = new SimpleDragCallback(this);
        dragCallback.setNotifyAllDrops(true);
        touchHelper = new ItemTouchHelper(dragCallback);
        touchHelper.attachToRecyclerView(recyclerView);
        recyclerView.setAdapter(fastAdapter2);
        fastAdapter2.addEventHook(new SubExpandableItem.DragHandlerTouchEvent(position -> {
            RecyclerView.ViewHolder vh = recyclerView.findViewHolderForAdapterPosition(position);
            if (vh != null)
                touchHelper.startDrag(vh);
            return null;
        }));
        // Item click listener
        fastAdapter2.setOnClickListener((v, a, i, p) -> onNestedItemClick(i));
        // Select on swipe
        if (mDragSelectTouchListener != null) {
            recyclerView.removeOnItemTouchListener(mDragSelectTouchListener);
            mDragSelectTouchListener = null;
        }
    } else {
        if (!fastAdapter.hasObservers())
            fastAdapter.setHasStableIds(true);
        itemAdapter.clear();
        // Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`
        selectExtension = fastAdapter.getOrCreateExtension(SelectExtension.class);
        if (selectExtension != null) {
            selectExtension.setSelectable(true);
            selectExtension.setMultiSelect(true);
            selectExtension.setSelectOnLongClick(true);
            selectExtension.setSelectWithItemUpdate(true);
            selectExtension.setSelectionListener((i, b) -> this.onSelectionChanged());
            FastAdapterPreClickSelectHelper<ImageFileItem> helper = new FastAdapterPreClickSelectHelper<>(selectExtension);
            fastAdapter.setOnPreClickListener(helper::onPreClickListener);
            fastAdapter.setOnPreLongClickListener((v, a, i, p) -> {
                // Warning : specific code for drag selection
                mDragSelectTouchListener.startDragSelection(p);
                return helper.onPreLongClickListener(v, a, i, p);
            });
        }
        // Item click listener
        fastAdapter.setOnClickListener((v, a, i, p) -> onItemClick(i));
        GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager();
        if (glm != null) {
            int spanCount = Preferences.getViewerGalleryColumns();
            glm.setSpanCount(spanCount);
            // Use the correct size to display chapter separators, if any
            GridLayoutManager.SpanSizeLookup spanSizeLookup = new GridLayoutManager.SpanSizeLookup() {

                @Override
                public int getSpanSize(int position) {
                    if (fastAdapter.getItemViewType(position) == R.id.expandable_item) {
                        return spanCount;
                    }
                    return 1;
                }
            };
            glm.setSpanSizeLookup(spanSizeLookup);
        }
        if (touchHelper != null)
            touchHelper.attachToRecyclerView(null);
        recyclerView.setAdapter(fastAdapter);
        // Select on swipe
        DragSelectTouchListener.OnDragSelectListener onDragSelectionListener = (start, end, isSelected) -> selectExtension.select(IntStream.rangeClosed(start, end).boxed().toList());
        mDragSelectTouchListener = new DragSelectTouchListener().withSelectListener(onDragSelectionListener);
        if (mDragSelectTouchListener2 != null) {
            recyclerView.removeOnItemTouchListener(mDragSelectTouchListener2);
            mDragSelectTouchListener2 = null;
        }
        recyclerView.addOnItemTouchListener(mDragSelectTouchListener);
    }
}
Also used : Content(me.devsaki.hentoid.database.domains.Content) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) FastAdapterDiffUtil(com.mikepenz.fastadapter.diff.FastAdapterDiffUtil) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Chapter(me.devsaki.hentoid.database.domains.Chapter) Optional(com.annimon.stream.Optional) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) Handler(android.os.Handler) Looper(android.os.Looper) ImageFile(me.devsaki.hentoid.database.domains.ImageFile) Fragment(androidx.fragment.app.Fragment) ImageViewerActivity(me.devsaki.hentoid.activities.ImageViewerActivity) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ItemTouchCallback(com.mikepenz.fastadapter.drag.ItemTouchCallback) PowerSpinnerView(com.skydoves.powerspinner.PowerSpinnerView) ExpandableExtension(com.mikepenz.fastadapter.expandable.ExpandableExtension) DragSelectTouchListener(me.devsaki.hentoid.widget.DragSelectTouchListener) Set(java.util.Set) ToastHelper(me.devsaki.hentoid.util.ToastHelper) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ViewModelFactory(me.devsaki.hentoid.viewmodels.ViewModelFactory) Nullable(org.jetbrains.annotations.Nullable) ViewCompat.requireViewById(androidx.core.view.ViewCompat.requireViewById) List(java.util.List) ImageItemBundle(me.devsaki.hentoid.activities.bundles.ImageItemBundle) ContentNotProcessedException(me.devsaki.hentoid.util.exception.ContentNotProcessedException) ImageFileItem(me.devsaki.hentoid.viewholders.ImageFileItem) SubExpandableItem(me.devsaki.hentoid.viewholders.SubExpandableItem) FastAdapter(com.mikepenz.fastadapter.FastAdapter) Toolbar(androidx.appcompat.widget.Toolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Snackbar(com.google.android.material.snackbar.Snackbar) IntStream(com.annimon.stream.IntStream) Context(android.content.Context) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Preferences(me.devsaki.hentoid.util.Preferences) Stream(com.annimon.stream.Stream) DiffCallback(com.mikepenz.fastadapter.diff.DiffCallback) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) BaseTransientBottomBar(com.google.android.material.snackbar.BaseTransientBottomBar) IntDef(androidx.annotation.IntDef) MenuItem(android.view.MenuItem) Retention(java.lang.annotation.Retention) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) FastAdapterPreClickSelectHelper(me.devsaki.hentoid.widget.FastAdapterPreClickSelectHelper) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) WeakReference(java.lang.ref.WeakReference) ImageViewerViewModel(me.devsaki.hentoid.viewmodels.ImageViewerViewModel) FragmentManager(androidx.fragment.app.FragmentManager) ViewerKeyListener(me.devsaki.hentoid.widget.ViewerKeyListener) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) INestedItem(me.devsaki.hentoid.viewholders.INestedItem) DragDropUtil(com.mikepenz.fastadapter.utils.DragDropUtil) FastScrollerBuilder(me.zhanghai.android.fastscroll.FastScrollerBuilder) R(me.devsaki.hentoid.R) ProgressDialogFragment(me.devsaki.hentoid.fragments.ProgressDialogFragment) RetentionPolicy(java.lang.annotation.RetentionPolicy) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) SubExpandableItem(me.devsaki.hentoid.viewholders.SubExpandableItem) SuppressLint(android.annotation.SuppressLint) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ImageFileItem(me.devsaki.hentoid.viewholders.ImageFileItem) FastAdapterPreClickSelectHelper(me.devsaki.hentoid.widget.FastAdapterPreClickSelectHelper) INestedItem(me.devsaki.hentoid.viewholders.INestedItem) DragSelectTouchListener(me.devsaki.hentoid.widget.DragSelectTouchListener)

Example 3 with SimpleDragCallback

use of com.mikepenz.fastadapter.drag.SimpleDragCallback in project Hentoid by avluis.

the class MergeDialogFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(rootView, savedInstanceState);
    List<Content> contentList = loadContentList();
    if (contentList.isEmpty())
        return;
    boolean isExternal = contentList.get(0).getStatus().equals(StatusContent.EXTERNAL);
    itemAdapter.set(Stream.of(contentList).map(s -> new TextItem<>(s.getTitle(), s, true, false, false, touchHelper)).toList());
    // Activate drag & drop
    SimpleDragCallback dragCallback = new SimpleDragCallback(this);
    dragCallback.setNotifyAllDrops(true);
    touchHelper = new ItemTouchHelper(dragCallback);
    touchHelper.attachToRecyclerView(binding.list);
    fastAdapter.addEventHook(new TextItem.DragHandlerTouchEvent<>(position -> {
        RecyclerView.ViewHolder vh = binding.list.findViewHolderForAdapterPosition(position);
        if (vh != null)
            touchHelper.startDrag(vh);
    }));
    binding.list.setAdapter(fastAdapter);
    initialTitle = contentList.get(0).getTitle();
    newTitleTxt = binding.titleNew.getEditText();
    if (newTitleTxt != null)
        newTitleTxt.setText(initialTitle);
    if (isExternal) {
        binding.mergeDeleteSwitch.setEnabled(Preferences.isDeleteExternalLibrary());
        binding.mergeDeleteSwitch.setChecked(Preferences.isDeleteExternalLibrary() && deleteDefault);
    } else {
        binding.mergeDeleteSwitch.setEnabled(true);
        binding.mergeDeleteSwitch.setChecked(deleteDefault);
    }
    binding.actionButton.setOnClickListener(v -> onActionClick());
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) Content(me.devsaki.hentoid.database.domains.Content) Bundle(android.os.Bundle) Preferences(me.devsaki.hentoid.util.Preferences) TextItem(me.devsaki.hentoid.viewholders.TextItem) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) IDraggableViewHolder(me.devsaki.hentoid.viewholders.IDraggableViewHolder) StatusContent(me.devsaki.hentoid.enums.StatusContent) DialogLibraryMergeBinding(me.devsaki.hentoid.databinding.DialogLibraryMergeBinding) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) Helper(me.devsaki.hentoid.util.Helper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ItemTouchCallback(com.mikepenz.fastadapter.drag.ItemTouchCallback) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) ViewGroup(android.view.ViewGroup) DragDropUtil(com.mikepenz.fastadapter.utils.DragDropUtil) ObjectBoxDAO(me.devsaki.hentoid.database.ObjectBoxDAO) List(java.util.List) Nullable(androidx.annotation.Nullable) FastAdapter(com.mikepenz.fastadapter.FastAdapter) CollectionDAO(me.devsaki.hentoid.database.CollectionDAO) NotNull(org.jetbrains.annotations.NotNull) EditText(android.widget.EditText) DialogFragment(androidx.fragment.app.DialogFragment) TextItem(me.devsaki.hentoid.viewholders.TextItem) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) IDraggableViewHolder(me.devsaki.hentoid.viewholders.IDraggableViewHolder) Content(me.devsaki.hentoid.database.domains.Content) StatusContent(me.devsaki.hentoid.enums.StatusContent)

Example 4 with SimpleDragCallback

use of com.mikepenz.fastadapter.drag.SimpleDragCallback in project Hentoid by avluis.

the class BookmarksDialogFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(rootView, savedInstanceState);
    MaterialButton homepage = requireViewById(rootView, R.id.bookmark_homepage_btn);
    homepage.setIcon(ContextCompat.getDrawable(requireContext(), site.getIco()));
    homepage.setOnClickListener(v -> parent.loadUrl(site.getUrl()));
    List<SiteBookmark> bookmarks = reloadBookmarks();
    // Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`
    selectExtension = fastAdapter.getOrCreateExtension(SelectExtension.class);
    if (selectExtension != null) {
        selectExtension.setSelectable(true);
        selectExtension.setMultiSelect(true);
        selectExtension.setSelectOnLongClick(true);
        selectExtension.setSelectWithItemUpdate(true);
        selectExtension.setSelectionListener((i, b) -> this.onSelectionChanged());
        FastAdapterPreClickSelectHelper<TextItem<SiteBookmark>> helper = new FastAdapterPreClickSelectHelper<>(selectExtension);
        fastAdapter.setOnPreClickListener(helper::onPreClickListener);
        fastAdapter.setOnPreLongClickListener(helper::onPreLongClickListener);
    }
    recyclerView = requireViewById(rootView, R.id.bookmarks_list);
    // Activate drag & drop
    SimpleDragCallback dragCallback = new SimpleDragCallback(this);
    dragCallback.setNotifyAllDrops(true);
    touchHelper = new ItemTouchHelper(dragCallback);
    touchHelper.attachToRecyclerView(recyclerView);
    recyclerView.setAdapter(fastAdapter);
    fastAdapter.setOnClickListener((v, a, i, p) -> onItemClick(i));
    fastAdapter.addEventHook(new TextItem.DragHandlerTouchEvent<>(position -> {
        RecyclerView.ViewHolder vh = recyclerView.findViewHolderForAdapterPosition(position);
        if (vh != null)
            touchHelper.startDrag(vh);
    }));
    selectionToolbar = requireViewById(rootView, R.id.toolbar);
    selectionToolbar.setOnMenuItemClickListener(this::selectionToolbarOnItemClicked);
    editMenu = selectionToolbar.getMenu().findItem(R.id.action_edit);
    copyMenu = selectionToolbar.getMenu().findItem(R.id.action_copy);
    homeMenu = selectionToolbar.getMenu().findItem(R.id.action_home);
    bookmarkCurrentBtn = requireViewById(rootView, R.id.bookmark_current_btn);
    Optional<SiteBookmark> currentBookmark = Stream.of(bookmarks).filter(b -> SiteBookmark.urlsAreSame(b.getUrl(), url)).findFirst();
    if (currentBookmark.isPresent())
        bookmarkId = currentBookmark.get().id;
    updateBookmarkButton();
}
Also used : InputDialog(me.devsaki.hentoid.ui.InputDialog) Context(android.content.Context) Bundle(android.os.Bundle) TextItem(me.devsaki.hentoid.viewholders.TextItem) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) Completable(io.reactivex.Completable) IDraggableViewHolder(me.devsaki.hentoid.viewholders.IDraggableViewHolder) MenuItem(android.view.MenuItem) FragmentActivity(androidx.fragment.app.FragmentActivity) SuppressLint(android.annotation.SuppressLint) Optional(com.annimon.stream.Optional) Site(me.devsaki.hentoid.enums.Site) FastAdapterPreClickSelectHelper(me.devsaki.hentoid.widget.FastAdapterPreClickSelectHelper) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) MaterialButton(com.google.android.material.button.MaterialButton) Helper(me.devsaki.hentoid.util.Helper) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) Handler(android.os.Handler) Looper(android.os.Looper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) ItemTouchCallback(com.mikepenz.fastadapter.drag.ItemTouchCallback) LayoutInflater(android.view.LayoutInflater) Set(java.util.Set) ToastHelper(me.devsaki.hentoid.util.ToastHelper) SiteBookmark(me.devsaki.hentoid.database.domains.SiteBookmark) ViewGroup(android.view.ViewGroup) DragDropUtil(com.mikepenz.fastadapter.utils.DragDropUtil) ObjectBoxDAO(me.devsaki.hentoid.database.ObjectBoxDAO) R(me.devsaki.hentoid.R) ViewCompat.requireViewById(androidx.core.view.ViewCompat.requireViewById) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) Nullable(androidx.annotation.Nullable) FastAdapter(com.mikepenz.fastadapter.FastAdapter) Toolbar(androidx.appcompat.widget.Toolbar) CollectionDAO(me.devsaki.hentoid.database.CollectionDAO) NotNull(org.jetbrains.annotations.NotNull) DialogFragment(androidx.fragment.app.DialogFragment) TextItem(me.devsaki.hentoid.viewholders.TextItem) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) MaterialButton(com.google.android.material.button.MaterialButton) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) SiteBookmark(me.devsaki.hentoid.database.domains.SiteBookmark) IDraggableViewHolder(me.devsaki.hentoid.viewholders.IDraggableViewHolder) FastAdapterPreClickSelectHelper(me.devsaki.hentoid.widget.FastAdapterPreClickSelectHelper)

Example 5 with SimpleDragCallback

use of com.mikepenz.fastadapter.drag.SimpleDragCallback in project Hentoid by avluis.

the class LibraryGroupsFragment method setPagingMethod.

/**
 * Initialize the paging method of the screen
 */
private void setPagingMethod() /*boolean isEditMode*/
{
    viewModel.setPagingMethod(true);
    itemAdapter = new ItemAdapter<>();
    fastAdapter = FastAdapter.with(itemAdapter);
    if (!fastAdapter.hasObservers())
        fastAdapter.setHasStableIds(true);
    // Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`
    selectExtension = fastAdapter.getOrCreateExtension(SelectExtension.class);
    if (selectExtension != null) {
        selectExtension.setSelectable(true);
        selectExtension.setMultiSelect(true);
        selectExtension.setSelectOnLongClick(true);
        selectExtension.setSelectWithItemUpdate(true);
        selectExtension.setSelectionListener((i, b) -> this.onSelectionChanged());
        FastAdapterPreClickSelectHelper<GroupDisplayItem> helper = new FastAdapterPreClickSelectHelper<>(selectExtension);
        fastAdapter.setOnPreClickListener(helper::onPreClickListener);
        fastAdapter.setOnPreLongClickListener(helper::onPreLongClickListener);
    }
    // Drag, drop & swiping
    if (activity.get().isEditMode()) {
        SimpleDragCallback dragSwipeCallback = new SimpleSwipeDragCallback(this, this, ContextCompat.getDrawable(requireContext(), R.drawable.ic_action_delete_forever)).withSensitivity(10f).withSurfaceThreshold(0.75f);
        dragSwipeCallback.setNotifyAllDrops(true);
        // Despite its name, that's actually to disable drag on long tap
        dragSwipeCallback.setIsDragEnabled(false);
        touchHelper = new ItemTouchHelper(dragSwipeCallback);
        touchHelper.attachToRecyclerView(recyclerView);
    }
    // Item click listener
    fastAdapter.setOnClickListener((v, a, i, p) -> onItemClick(i));
    // Favourite button click listener
    fastAdapter.addEventHook(new ClickEventHook<GroupDisplayItem>() {

        @Override
        public void onClick(@NotNull View view, int i, @NotNull FastAdapter<GroupDisplayItem> fastAdapter, @NotNull GroupDisplayItem item) {
            if (item.getGroup() != null)
                onGroupFavouriteClick(item.getGroup());
        }

        @org.jetbrains.annotations.Nullable
        @Override
        public View onBind(RecyclerView.@NotNull ViewHolder viewHolder) {
            if (viewHolder instanceof GroupDisplayItem.GroupViewHolder) {
                return ((GroupDisplayItem.GroupViewHolder) viewHolder).getFavouriteButton();
            }
            return super.onBind(viewHolder);
        }
    });
    fastAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
    recyclerView.setAdapter(fastAdapter);
    recyclerView.setHasFixedSize(true);
}
Also used : SimpleSwipeDragCallback(com.mikepenz.fastadapter.swipe_drag.SimpleSwipeDragCallback) SimpleDragCallback(com.mikepenz.fastadapter.drag.SimpleDragCallback) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) NotNull(org.jetbrains.annotations.NotNull) SuppressLint(android.annotation.SuppressLint) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) GroupDisplayItem(me.devsaki.hentoid.viewholders.GroupDisplayItem) RecyclerView(androidx.recyclerview.widget.RecyclerView) FastAdapterPreClickSelectHelper(me.devsaki.hentoid.widget.FastAdapterPreClickSelectHelper)

Aggregations

View (android.view.View)5 ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 SimpleDragCallback (com.mikepenz.fastadapter.drag.SimpleDragCallback)5 SuppressLint (android.annotation.SuppressLint)4 Bundle (android.os.Bundle)3 LayoutInflater (android.view.LayoutInflater)3 ViewGroup (android.view.ViewGroup)3 NonNull (androidx.annotation.NonNull)3 Toolbar (androidx.appcompat.widget.Toolbar)3 Stream (com.annimon.stream.Stream)3 FastAdapter (com.mikepenz.fastadapter.FastAdapter)3 ItemAdapter (com.mikepenz.fastadapter.adapters.ItemAdapter)3 ItemTouchCallback (com.mikepenz.fastadapter.drag.ItemTouchCallback)3 DragDropUtil (com.mikepenz.fastadapter.utils.DragDropUtil)3 List (java.util.List)3 Context (android.content.Context)2 Handler (android.os.Handler)2 Looper (android.os.Looper)2 MenuItem (android.view.MenuItem)2