diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-01-21 22:47:19 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-01-21 22:47:19 +0100 |
commit | 825ccd28c1572c2f49b1bd2c83c78cd76d0e6629 (patch) | |
tree | bff9ae5daf5b0adf3ad3f0399327dad2c20c2c73 | |
parent | ccd75800c92051e4f7366ab65f9cc17f32f96f23 (diff) | |
download | AntennaPod-825ccd28c1572c2f49b1bd2c83c78cd76d0e6629.zip |
Improved performance of FeedItemMenuHandler's prepare method
-rw-r--r-- | res/menu/feeditem.xml | 30 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java | 56 |
2 files changed, 43 insertions, 43 deletions
diff --git a/res/menu/feeditem.xml b/res/menu/feeditem.xml index 1944dceb9..a76f2c658 100644 --- a/res/menu/feeditem.xml +++ b/res/menu/feeditem.xml @@ -5,29 +5,25 @@ android:id="@+id/download_item" android:icon="?attr/av_download" android:showAsAction="ifRoom" - android:title="@string/download_label" - android:visible="false"> + android:title="@string/download_label"> </item> <item android:id="@+id/stream_item" android:icon="?attr/action_stream" android:showAsAction="ifRoom" - android:title="@string/stream_label" - android:visible="false"> + android:title="@string/stream_label"> </item> <item android:id="@+id/play_item" android:icon="?attr/av_play" android:showAsAction="ifRoom" - android:title="@string/play_label" - android:visible="false"> + android:title="@string/play_label"> </item> <item android:id="@+id/remove_item" android:icon="?attr/content_discard" android:showAsAction="collapseActionView" - android:title="@string/remove_label" - android:visible="false"> + android:title="@string/remove_label"> </item> <item android:id="@+id/cancel_download_item" @@ -38,26 +34,22 @@ <item android:id="@+id/mark_read_item" android:showAsAction="collapseActionView" - android:title="@string/mark_read_label" - android:visible="false"> + android:title="@string/mark_read_label"> </item> <item android:id="@+id/mark_unread_item" android:showAsAction="collapseActionView" - android:title="@string/mark_unread_label" - android:visible="false"> + android:title="@string/mark_unread_label"> </item> <item android:id="@+id/add_to_queue_item" android:showAsAction="collapseActionView" - android:title="@string/add_to_queue_label" - android:visible="false"> + android:title="@string/add_to_queue_label"> </item> <item android:id="@+id/remove_from_queue_item" android:showAsAction="collapseActionView" - android:title="@string/remove_from_queue_label" - android:visible="false"> + android:title="@string/remove_from_queue_label"> </item> <item android:id="@+id/share_link_item" @@ -68,14 +60,12 @@ android:id="@+id/visit_website_item" android:icon="?attr/location_web_site" android:showAsAction="ifRoom|collapseActionView" - android:title="@string/visit_website_label" - android:visible="false"> + android:title="@string/visit_website_label"> </item> <item android:id="@+id/support_item" android:showAsAction="collapseActionView" - android:title="@string/support_label" - android:visible="false"> + android:title="@string/support_label"> </item> </menu>
\ No newline at end of file diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java index a1145f372..c3d3af495 100644 --- a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java +++ b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.util.menuhandler; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Debug; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -47,36 +48,45 @@ public class FeedItemMenuHandler { && (!downloading); FeedItem.State state = selectedItem.getState(); - mi.setItemVisibility(R.id.play_item, downloaded); - mi.setItemVisibility(R.id.remove_item, downloaded); - mi.setItemVisibility(R.id.download_item, notLoadedAndNotLoading); - mi.setItemVisibility(R.id.stream_item, notLoadedAndNotLoading - | downloading); - mi.setItemVisibility(R.id.cancel_download_item, downloading); + if (!downloaded) { + mi.setItemVisibility(R.id.play_item, false); + mi.setItemVisibility(R.id.remove_item, false); + } + if (!notLoadedAndNotLoading) { + mi.setItemVisibility(R.id.download_item, false); + } + if (!(notLoadedAndNotLoading | downloading)) { + mi.setItemVisibility(R.id.stream_item, false); + } + if (!downloading) { + mi.setItemVisibility(R.id.cancel_download_item, false); + } boolean isInQueue = manager.isInQueue(selectedItem); + if (!isInQueue) { + mi.setItemVisibility(R.id.remove_from_queue_item, false); + } + if (!(!isInQueue && selectedItem.getMedia() != null)) { + mi.setItemVisibility(R.id.add_to_queue_item, false); + } + if (selectedItem.getLink() == null) { + mi.setItemVisibility(R.id.share_link_item, false); + } - mi.setItemVisibility(R.id.remove_from_queue_item, isInQueue); - mi.setItemVisibility(R.id.add_to_queue_item, - !isInQueue && selectedItem.getMedia() != null); - - mi.setItemVisibility(R.id.share_link_item, - selectedItem.getLink() != null); - - mi.setItemVisibility(R.id.mark_unread_item, - state == FeedItem.State.IN_PROGRESS - || state == FeedItem.State.READ); - mi.setItemVisibility(R.id.mark_read_item, state == FeedItem.State.NEW - || state == FeedItem.State.IN_PROGRESS); - - if (selectedItem.getLink() != null) { - mi.setItemVisibility(R.id.visit_website_item, true); + if (!(state == FeedItem.State.IN_PROGRESS || state == FeedItem.State.READ)) { + mi.setItemVisibility(R.id.mark_unread_item, false); + } + if (!(state == FeedItem.State.NEW || state == FeedItem.State.IN_PROGRESS)) { + mi.setItemVisibility(R.id.mark_read_item, false); } - if (selectedItem.getPaymentLink() != null) { - mi.setItemVisibility(R.id.support_item, true); + if (selectedItem.getLink() == null) { + mi.setItemVisibility(R.id.visit_website_item, false); } + if (selectedItem.getPaymentLink() == null) { + mi.setItemVisibility(R.id.support_item, false); + } return true; } |