Search in sources :

Example 1 with Implemented

use of com.hippo.annotation.Implemented in project EhViewer by seven332.

the class FavoritesScene method onItemClick.

@Override
@Implemented(AdapterView.OnItemClickListener.class)
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // Skip if in search mode
    if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
        return;
    }
    if (mUrlBuilder == null || mHelper == null) {
        return;
    }
    // Local favorite position is 0, All favorite position is 1, so position - 2 is OK
    int newFavCat = position - 2;
    // Check is the same
    if (mUrlBuilder.getFavCat() == newFavCat) {
        return;
    }
    // Ensure outOfCustomChoiceMode to avoid error
    if (mRecyclerView != null) {
        mRecyclerView.isInCustomChoice();
    }
    exitSearchMode(true);
    mUrlBuilder.setKeyword(null);
    mUrlBuilder.setFavCat(newFavCat);
    updateSearchBar();
    mHelper.refresh();
    closeDrawer(Gravity.RIGHT);
}
Also used : SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Implemented(com.hippo.annotation.Implemented)

Example 2 with Implemented

use of com.hippo.annotation.Implemented in project EhViewer by seven332.

the class FavoritesScene method onClickSecondaryFab.

@Override
@Implemented(FabLayout.OnClickFabListener.class)
public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) {
    Context context = getContext2();
    if (null == context || null == mRecyclerView || null == mHelper) {
        return;
    }
    if (!mRecyclerView.isInCustomChoice()) {
        switch(position) {
            case // Go to
            0:
                if (mHelper.canGoTo()) {
                    showGoToDialog();
                }
                break;
            case // Refresh
            1:
                mHelper.refresh();
                break;
        }
        view.setExpanded(false);
        return;
    }
    mModifyGiList.clear();
    SparseBooleanArray stateArray = mRecyclerView.getCheckedItemPositions();
    for (int i = 0, n = stateArray.size(); i < n; i++) {
        if (stateArray.valueAt(i)) {
            GalleryInfo gi = mHelper.getDataAtEx(stateArray.keyAt(i));
            if (gi != null) {
                mModifyGiList.add(gi);
            }
        }
    }
    switch(position) {
        case 2:
            {
                // Download
                Activity activity = getActivity2();
                if (activity != null) {
                    CommonOperations.startDownload(getActivity2(), mModifyGiList, false);
                }
                mModifyGiList.clear();
                if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
                    mRecyclerView.outOfCustomChoiceMode();
                }
                break;
            }
        case 3:
            {
                // Delete
                DeleteDialogHelper helper = new DeleteDialogHelper();
                new AlertDialog.Builder(context).setTitle(R.string.delete_favorites_dialog_title).setMessage(getString(R.string.delete_favorites_dialog_message, mModifyGiList.size())).setPositiveButton(android.R.string.ok, helper).setOnCancelListener(helper).show();
                break;
            }
        case 4:
            {
                // Move
                MoveDialogHelper helper = new MoveDialogHelper();
                // First is local favorite, the other 10 is cloud favorite
                String[] array = new String[11];
                array[0] = getString(R.string.local_favorites);
                System.arraycopy(Settings.getFavCat(), 0, array, 1, 10);
                new AlertDialog.Builder(context).setTitle(R.string.move_favorites_dialog_title).setItems(array, helper).setOnCancelListener(helper).show();
                break;
            }
    }
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder) SpannableStringBuilder(android.text.SpannableStringBuilder) FavListUrlBuilder(com.hippo.ehviewer.client.data.FavListUrlBuilder) SparseBooleanArray(android.util.SparseBooleanArray) GalleryInfo(com.hippo.ehviewer.client.data.GalleryInfo) MainActivity(com.hippo.ehviewer.ui.MainActivity) Activity(android.app.Activity) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Implemented(com.hippo.annotation.Implemented)

Example 3 with Implemented

use of com.hippo.annotation.Implemented in project EhViewer by seven332.

the class FavoritesScene method onItemClick.

@Override
@Implemented(EasyRecyclerView.OnItemClickListener.class)
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
    if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
        // Skip if in search mode
        if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
            return true;
        }
        if (mUrlBuilder == null || mHelper == null) {
            return true;
        }
        // Local favorite position is 0, All favorite position is 1, so position - 2 is OK
        int newFavCat = position - 2;
        // Check is the same
        if (mUrlBuilder.getFavCat() == newFavCat) {
            return true;
        }
        // Ensure outOfCustomChoiceMode to avoid error
        if (mRecyclerView != null) {
            mRecyclerView.isInCustomChoice();
        }
        exitSearchMode(true);
        mUrlBuilder.setKeyword(null);
        mUrlBuilder.setFavCat(newFavCat);
        updateSearchBar();
        mHelper.refresh();
        closeDrawer(Gravity.RIGHT);
    } else {
        if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
            mRecyclerView.toggleItemChecked(position);
        } else if (mHelper != null) {
            GalleryInfo gi = mHelper.getDataAtEx(position);
            if (gi == null) {
                return true;
            }
            Bundle args = new Bundle();
            args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
            args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
            Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
            View thumb;
            if (null != (thumb = view.findViewById(R.id.thumb))) {
                announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
            }
            startScene(announcer);
        }
    }
    return true;
}
Also used : Announcer(com.hippo.scene.Announcer) Bundle(android.os.Bundle) GalleryInfo(com.hippo.ehviewer.client.data.GalleryInfo) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Implemented(com.hippo.annotation.Implemented)

Aggregations

SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 Implemented (com.hippo.annotation.Implemented)3 GalleryInfo (com.hippo.ehviewer.client.data.GalleryInfo)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 SparseBooleanArray (android.util.SparseBooleanArray)1 View (android.view.View)1 TextView (android.widget.TextView)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)1 EditTextDialogBuilder (com.hippo.app.EditTextDialogBuilder)1 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)1 FavListUrlBuilder (com.hippo.ehviewer.client.data.FavListUrlBuilder)1 MainActivity (com.hippo.ehviewer.ui.MainActivity)1 Announcer (com.hippo.scene.Announcer)1