mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 22:41:48 +01:00
cleanup chapter action menu
This commit is contained in:
parent
50d71d1395
commit
f84731c2df
@ -2,16 +2,11 @@ package eu.kanade.tachiyomi.ui.manga.chapter;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
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.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.kanade.tachiyomi.R;
|
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 eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class ChaptersHolder extends FlexibleViewHolder {
|
public class ChaptersHolder extends FlexibleViewHolder {
|
||||||
|
|
||||||
@Bind(R.id.chapter_title) TextView title;
|
@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
|
// Inflate our menu resource into the PopupMenu's Menu
|
||||||
popup.getMenuInflater().inflate(R.menu.chapter_single, popup.getMenu());
|
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
|
// Set a listener so we are notified if a menu item is clicked
|
||||||
popup.setOnMenuItemClickListener(menuItem -> {
|
popup.setOnMenuItemClickListener(menuItem -> {
|
||||||
Observable<Chapter> chapter = Observable.just(item);
|
Observable<Chapter> chapter = Observable.just(item);
|
||||||
|
|
||||||
switch (menuItem.getItemId()) {
|
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:
|
case R.id.action_download:
|
||||||
return adapter.getFragment().onDownload(chapter);
|
return adapter.getFragment().onDownload(chapter);
|
||||||
case R.id.action_delete:
|
case R.id.action_delete:
|
||||||
return adapter.getFragment().onDelete(chapter);
|
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:
|
case R.id.action_mark_previous_as_read:
|
||||||
return adapter.getFragment().onMarkPreviousAsRead(item);
|
return adapter.getFragment().onMarkPreviousAsRead(item);
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,28 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item android:id="@+id/action_download"
|
<item android:id="@+id/action_download"
|
||||||
android:title="@string/action_download"
|
android:title="@string/action_download"
|
||||||
android:icon="@drawable/ic_file_download"
|
android:icon="@drawable/ic_file_download"
|
||||||
app:showAsAction="ifRoom"/>
|
android:visible="true"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item android:id="@+id/action_delete"
|
<item android:id="@+id/action_delete"
|
||||||
android:title="@string/action_delete"
|
android:title="@string/action_delete"
|
||||||
android:icon="@drawable/ic_action_delete"
|
android:icon="@drawable/ic_action_delete"
|
||||||
app:showAsAction="ifRoom"/>
|
android:visible="false"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item android:id="@+id/action_mark_as_read"
|
<item android:id="@+id/action_mark_as_read"
|
||||||
android:title="@string/action_mark_as_read"
|
android:title="@string/action_mark_as_read"
|
||||||
android:icon="@drawable/ic_action_done_all"
|
android:icon="@drawable/ic_action_done_all"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item android:id="@+id/action_mark_as_unread"
|
<item android:id="@+id/action_mark_as_unread"
|
||||||
android:title="@string/action_mark_as_unread"
|
android:title="@string/action_mark_as_unread"
|
||||||
android:icon="@drawable/ic_action_undone_all"
|
android:icon="@drawable/ic_action_undone_all"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item
|
<item android:id="@+id/action_mark_previous_as_read"
|
||||||
android:id="@+id/action_mark_previous_as_read"
|
android:title="@string/action_mark_previous_as_read"/>
|
||||||
android:title="@string/action_mark_previous_as_read"/>
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in New Issue
Block a user