Moved updateRefreshMenuItem into core package
This commit is contained in:
parent
18bc827ed2
commit
066cab8da5
|
@ -10,7 +10,7 @@ import de.danoeh.antennapod.core.R;
|
|||
/**
|
||||
* Utilities for menu items
|
||||
*/
|
||||
public class MenuItemUtils {
|
||||
public class MenuItemUtils extends de.danoeh.antennapod.core.menuhandler.MenuItemUtils {
|
||||
|
||||
public static MenuItem addSearchItem(Menu menu, SearchView searchView) {
|
||||
MenuItem item = menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label);
|
||||
|
@ -28,29 +28,4 @@ public class MenuItemUtils {
|
|||
public static boolean isActivityDrawerOpen(NavDrawerActivity activity) {
|
||||
return activity != null && activity.isDrawerOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, de.danoeh.antennapod.R.layout.refresh_action_view);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static interface UpdateRefreshMenuItemChecker {
|
||||
public boolean isRefreshing();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue