mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
cleanup chapter action menu
This commit is contained in:
parent
50d71d1395
commit
f84731c2df
2 changed files with 43 additions and 25 deletions
|
@ -2,16 +2,11 @@ package eu.kanade.tachiyomi.ui.manga.chapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.kanade.tachiyomi.R;
|
||||
|
@ -21,6 +16,11 @@ import eu.kanade.tachiyomi.data.download.model.Download;
|
|||
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder;
|
||||
import rx.Observable;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Date;
|
||||
|
||||
public class ChaptersHolder extends FlexibleViewHolder {
|
||||
|
||||
@Bind(R.id.chapter_title) TextView title;
|
||||
|
@ -110,19 +110,36 @@ public class ChaptersHolder extends FlexibleViewHolder {
|
|||
// Inflate our menu resource into the PopupMenu's Menu
|
||||
popup.getMenuInflater().inflate(R.menu.chapter_single, popup.getMenu());
|
||||
|
||||
// Hide download and show delete if the chapter is downloaded and
|
||||
if(item.isDownloaded()) {
|
||||
Menu menu = popup.getMenu();
|
||||
menu.findItem(R.id.action_download).setVisible(false);
|
||||
menu.findItem(R.id.action_delete).setVisible(true);
|
||||
}
|
||||
|
||||
// Hide mark as unread when the chapter is unread
|
||||
if(!item.read && item.last_page_read == 0) {
|
||||
popup.getMenu().findItem(R.id.action_mark_as_unread).setVisible(false);
|
||||
}
|
||||
|
||||
// Hide mark as read when the chapter is read
|
||||
if(item.read) {
|
||||
popup.getMenu().findItem(R.id.action_mark_as_read).setVisible(false);
|
||||
}
|
||||
|
||||
// Set a listener so we are notified if a menu item is clicked
|
||||
popup.setOnMenuItemClickListener(menuItem -> {
|
||||
Observable<Chapter> chapter = Observable.just(item);
|
||||
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_mark_as_read:
|
||||
return adapter.getFragment().onMarkAsRead(chapter);
|
||||
case R.id.action_mark_as_unread:
|
||||
return adapter.getFragment().onMarkAsUnread(chapter);
|
||||
case R.id.action_download:
|
||||
return adapter.getFragment().onDownload(chapter);
|
||||
case R.id.action_delete:
|
||||
return adapter.getFragment().onDelete(chapter);
|
||||
case R.id.action_mark_as_read:
|
||||
return adapter.getFragment().onMarkAsRead(chapter);
|
||||
case R.id.action_mark_as_unread:
|
||||
return adapter.getFragment().onMarkAsUnread(chapter);
|
||||
case R.id.action_mark_previous_as_read:
|
||||
return adapter.getFragment().onMarkPreviousAsRead(item);
|
||||
}
|
||||
|
|
|
@ -4,27 +4,28 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:id="@+id/action_download"
|
||||
android:title="@string/action_download"
|
||||
android:icon="@drawable/ic_file_download"
|
||||
app:showAsAction="ifRoom"/>
|
||||
android:title="@string/action_download"
|
||||
android:icon="@drawable/ic_file_download"
|
||||
android:visible="true"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/action_delete"
|
||||
android:title="@string/action_delete"
|
||||
android:icon="@drawable/ic_action_delete"
|
||||
app:showAsAction="ifRoom"/>
|
||||
android:title="@string/action_delete"
|
||||
android:icon="@drawable/ic_action_delete"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/action_mark_as_read"
|
||||
android:title="@string/action_mark_as_read"
|
||||
android:icon="@drawable/ic_action_done_all"
|
||||
app:showAsAction="ifRoom"/>
|
||||
android:title="@string/action_mark_as_read"
|
||||
android:icon="@drawable/ic_action_done_all"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/action_mark_as_unread"
|
||||
android:title="@string/action_mark_as_unread"
|
||||
android:icon="@drawable/ic_action_undone_all"
|
||||
app:showAsAction="ifRoom"/>
|
||||
android:title="@string/action_mark_as_unread"
|
||||
android:icon="@drawable/ic_action_undone_all"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_mark_previous_as_read"
|
||||
android:title="@string/action_mark_previous_as_read"/>
|
||||
<item android:id="@+id/action_mark_previous_as_read"
|
||||
android:title="@string/action_mark_previous_as_read"/>
|
||||
|
||||
</menu>
|
Loading…
Reference in a new issue