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 911a6ed370..7059d63bb9 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 c2cb4bd82d..0db1795f3f 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(); + } }