From 173e86320bd248b4cce44a8d5ae85ac4fc9bb85a Mon Sep 17 00:00:00 2001 From: inorichi Date: Sun, 17 Jan 2016 16:11:30 +0100 Subject: [PATCH] Allow to add a manga to the library with a long click --- .../tachiyomi/ui/catalogue/CatalogueFragment.java | 15 ++++++++++++++- .../ui/catalogue/CataloguePresenter.java | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.java index 911a6ed37..7059d63bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.java @@ -18,6 +18,8 @@ import android.widget.AdapterView; import android.widget.ProgressBar; import android.widget.Spinner; +import com.afollestad.materialdialogs.MaterialDialog; + import java.util.List; import java.util.concurrent.TimeUnit; @@ -257,6 +259,17 @@ public class CatalogueFragment extends BaseRxFragment @Override public void onListItemLongClick(int position) { - // Do nothing + final Manga selectedManga = adapter.getItem(position); + + new MaterialDialog.Builder(getActivity()) + .items(getString(R.string.add_to_library)) + .itemsCallback((dialog, itemView, which, text) -> { + switch (which) { + case 0: + getPresenter().addMangaToLibrary(selectedManga); + break; + } + }) + .show(); } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.java index c2cb4bd82..0db1795f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CataloguePresenter.java @@ -170,4 +170,8 @@ public class CataloguePresenter extends BasePresenter { return sourceManager.getSources(); } + public void addMangaToLibrary(Manga manga) { + manga.favorite = true; + db.insertManga(manga).executeAsBlocking(); + } }