Allow to add a manga to the library with a long click

This commit is contained in:
inorichi 2016-01-17 16:11:30 +01:00
parent b2e579173b
commit 173e86320b
2 changed files with 18 additions and 1 deletions

View File

@ -18,6 +18,8 @@ import android.widget.AdapterView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Spinner; import android.widget.Spinner;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -257,6 +259,17 @@ public class CatalogueFragment extends BaseRxFragment<CataloguePresenter>
@Override @Override
public void onListItemLongClick(int position) { 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();
} }
} }

View File

@ -170,4 +170,8 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
return sourceManager.getSources(); return sourceManager.getSources();
} }
public void addMangaToLibrary(Manga manga) {
manga.favorite = true;
db.insertManga(manga).executeAsBlocking();
}
} }