summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2015-01-15 12:22:27 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2015-01-15 12:22:27 +0100
commit066cab8da5a3189b77d74732a16ebfe74299725d (patch)
tree48a2aa9ca6f30f2a3331f16cb0eb27e6b7bc63f8 /core
parent18bc827ed2d38ad996106c954d43339b2d3136d2 (diff)
downloadAntennaPod-066cab8da5a3189b77d74732a16ebfe74299725d.zip
Moved updateRefreshMenuItem into core package
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java38
-rw-r--r--core/src/main/res/layout/refresh_action_view.xml8
2 files changed, 46 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java b/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java
new file mode 100644
index 000000000..b8d17bcce
--- /dev/null
+++ b/core/src/main/java/de/danoeh/antennapod/core/menuhandler/MenuItemUtils.java
@@ -0,0 +1,38 @@
+package de.danoeh.antennapod.core.menuhandler;
+
+import android.support.v4.view.MenuItemCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import de.danoeh.antennapod.core.R;
+
+/**
+ * Utilities for menu items
+ */
+public class MenuItemUtils {
+
+ /**
+ * Changes the appearance of a MenuItem depending on whether the given UpdateRefreshMenuItemChecker
+ * is refreshing or not. If it returns true, the menu item will be replaced by an indeterminate progress
+ * bar, otherwise nothing will happen.
+ *
+ * @param menu The menu that the MenuItem belongs to
+ * @param resId The id of the MenuItem
+ * @param checker Is used for checking whether to show the progress indicator or not.
+ * @return The returned value of the UpdateRefreshMenuItemChecker's isRefreshing() method.
+ */
+ public static boolean updateRefreshMenuItem(Menu menu, int resId, UpdateRefreshMenuItemChecker checker) {
+ // expand actionview if feeds are being downloaded, collapse otherwise
+ if (checker.isRefreshing()) {
+ MenuItem refreshItem = menu.findItem(resId);
+ MenuItemCompat.setActionView(refreshItem, R.layout.refresh_action_view);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static interface UpdateRefreshMenuItemChecker {
+ public boolean isRefreshing();
+ }
+}
diff --git a/core/src/main/res/layout/refresh_action_view.xml b/core/src/main/res/layout/refresh_action_view.xml
new file mode 100644
index 000000000..66148a553
--- /dev/null
+++ b/core/src/main/res/layout/refresh_action_view.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end"
+ android:indeterminateOnly="true">
+
+</ProgressBar> \ No newline at end of file