diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-10-25 11:20:29 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-10-25 11:20:29 +0200 |
commit | dcc7c9d25d5540f0caa6e10b2bb69a249e340455 (patch) | |
tree | 87b6f93fdfa40d0e6f771687d1e625fa60b51bb2 /app/src | |
parent | 17feaa72adfee3e0ceb66a8fb20a262f702e0cc0 (diff) | |
download | AntennaPod-dcc7c9d25d5540f0caa6e10b2bb69a249e340455.zip |
Removed use of indeterminate progress bar
No longer supported in version 21 of the support library
Diffstat (limited to 'app/src')
9 files changed, 70 insertions, 41 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index f9001adad..8a8fa2438 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -269,14 +269,17 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override protected void postStatusMsg(int resId) { - setSupportProgressBarIndeterminateVisibility(resId == R.string.player_preparing_msg + if (resId == R.string.player_preparing_msg || resId == R.string.player_seeking_msg - || resId == R.string.player_buffering_msg); + || resId == R.string.player_buffering_msg) { + // TODO Show progress bar here + } } @Override protected void clearStatusMsg() { - setSupportProgressBarIndeterminateVisibility(false); + // TODO Hide progress bar here + } /** diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 7029fd32c..9b7c11843 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -75,7 +75,6 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity public void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); - supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); StorageUtils.checkStorageAvailability(this); setContentView(R.layout.main); setVolumeControlStream(AudioManager.STREAM_MUSIC); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index f16b287f6..561188291 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -167,9 +167,6 @@ public abstract class MediaplayerActivity extends ActionBarActivity chooseTheme(); super.onCreate(savedInstanceState); - // subclasses might use this feature - supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - if (BuildConfig.DEBUG) Log.d(TAG, "Creating Activity"); StorageUtils.checkStorageAvailability(this); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java index f0e73a372..4a5c3f718 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java @@ -349,10 +349,6 @@ public class ItemDescriptionFragment extends Fragment { @Override protected void onCancelled() { super.onCancelled(); - if (getActivity() != null) { - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(false); - } webViewLoader = null; } @@ -364,10 +360,6 @@ public class ItemDescriptionFragment extends Fragment { // /webvDescription.loadData(url, "text/html", "utf-8"); webvDescription.loadDataWithBaseURL(null, data, "text/html", "utf-8", "about:blank"); - if (getActivity() != null) { - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(false); - } if (BuildConfig.DEBUG) Log.d(TAG, "Webview loaded"); webViewLoader = null; @@ -376,10 +368,6 @@ public class ItemDescriptionFragment extends Fragment { @Override protected void onPreExecute() { super.onPreExecute(); - if (getActivity() != null) { - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(false); - } } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 9eaeb56dd..ab294ecfe 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -37,7 +37,6 @@ import de.danoeh.antennapod.core.asynctask.FeedRemover; import de.danoeh.antennapod.core.asynctask.PicassoProvider; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; -import de.danoeh.antennapod.dialog.FeedItemDialog; import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; @@ -48,6 +47,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.QueueAccess; +import de.danoeh.antennapod.dialog.FeedItemDialog; import de.danoeh.antennapod.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.NavDrawerActivity; @@ -82,6 +82,7 @@ public class ItemlistFragment extends ListFragment { private FeedItemDialog feedItemDialog; private FeedItemDialog.FeedItemDialogSavedInstance feedItemDialogSavedInstance; + private boolean isUpdatingFeed; /** * Creates new ItemlistFragment which shows the Feeditems of a specific @@ -160,6 +161,17 @@ public class ItemlistFragment extends ListFragment { feedItemDialog = null; } + private final MenuItemUtils.UpdateRefreshMenuItemChecker updateRefreshMenuItemChecker = new MenuItemUtils.UpdateRefreshMenuItemChecker() { + @Override + public boolean isRefreshing() { + if (feed != null && DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFile(feed)) { + return true; + } else { + return false; + } + } + }; + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); @@ -185,6 +197,7 @@ public class ItemlistFragment extends ListFragment { return false; } }); + isUpdatingFeed = MenuItemUtils.updateRefreshMenuItem(menu, R.id.refresh_item, updateRefreshMenuItemChecker); } } @@ -277,15 +290,7 @@ public class ItemlistFragment extends ListFragment { }; private void updateProgressBarVisibility() { - if (feed != null) { - if (DownloadService.isRunning - && DownloadRequester.getInstance().isDownloadingFile(feed)) { - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(true); - } else { - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(false); - } + if (isUpdatingFeed != updateRefreshMenuItemChecker.isRefreshing()) { getActivity().supportInvalidateOptionsMenu(); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index d126f2980..d423c335a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -7,6 +7,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; +import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.view.*; @@ -75,6 +76,8 @@ public class NewEpisodesFragment extends Fragment { private FeedItemDialog feedItemDialog; private FeedItemDialog.FeedItemDialogSavedInstance feedItemDialogSavedInstance; + private boolean isUpdatingFeeds; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -136,6 +139,14 @@ public class NewEpisodesFragment extends Fragment { feedItemDialog = null; } + + private final MenuItemUtils.UpdateRefreshMenuItemChecker updateRefreshMenuItemChecker = new MenuItemUtils.UpdateRefreshMenuItemChecker() { + @Override + public boolean isRefreshing() { + return DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFeeds(); + } + }; + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); @@ -158,6 +169,7 @@ public class NewEpisodesFragment extends Fragment { return false; } }); + isUpdatingFeeds = MenuItemUtils.updateRefreshMenuItem(menu, R.id.refresh_item, updateRefreshMenuItemChecker); } } @@ -252,7 +264,6 @@ public class NewEpisodesFragment extends Fragment { } listAdapter.notifyDataSetChanged(); getActivity().supportInvalidateOptionsMenu(); - updateProgressBarVisibility(); updateShowOnlyEpisodesListViewState(); } @@ -319,21 +330,14 @@ public class NewEpisodesFragment extends Fragment { }; - private void updateProgressBarVisibility() { - if (!viewsCreated) { - return; - } - ((ActionBarActivity) getActivity()) - .setSupportProgressBarIndeterminateVisibility(DownloadService.isRunning - && DownloadRequester.getInstance().isDownloadingFeeds()); - } - private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() { @Override public void update(EventDistributor eventDistributor, Integer arg) { if ((arg & EVENTS) != 0) { startItemLoader(); - updateProgressBarVisibility(); + if (isUpdatingFeeds != updateRefreshMenuItemChecker.isRefreshing()) { + getActivity().supportInvalidateOptionsMenu(); + } } } }; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java index c4a96ac3f..a1e666df0 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java @@ -28,4 +28,29 @@ 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(); + } } diff --git a/app/src/main/res/layout/refresh_action_view.xml b/app/src/main/res/layout/refresh_action_view.xml new file mode 100644 index 000000000..66148a553 --- /dev/null +++ b/app/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 diff --git a/app/src/main/res/menu/new_episodes.xml b/app/src/main/res/menu/new_episodes.xml index 4cf3b5fec..d74e70b3b 100644 --- a/app/src/main/res/menu/new_episodes.xml +++ b/app/src/main/res/menu/new_episodes.xml @@ -7,7 +7,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="ifRoom|collapseActionView" + custom:showAsAction="ifRoom" android:icon="?attr/navigation_refresh"/> <item |