Re-implemented menus
This commit is contained in:
parent
3a3116fe96
commit
15c333ed39
|
@ -5,39 +5,37 @@
|
|||
<item
|
||||
android:id="@+id/refresh_item"
|
||||
android:icon="?attr/navigation_refresh"
|
||||
android:menuCategory="container"
|
||||
custom:showAsAction="ifRoom|collapseActionView"
|
||||
android:title="@string/refresh_label">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/mark_all_read_item"
|
||||
android:menuCategory="container"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/mark_all_read_label">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/show_info_item"
|
||||
android:menuCategory="container"
|
||||
android:icon="?attr/action_about"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/show_info_label">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/support_item"
|
||||
android:menuCategory="container"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/support_label"
|
||||
android:visible="false">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/remove_item"
|
||||
android:menuCategory="container"
|
||||
android:icon="?attr/content_discard"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/remove_feed_label"
|
||||
android:visible="true">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/visit_website_item"
|
||||
android:icon="?attr/location_web_site"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/visit_website_label"
|
||||
android:visible="true">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/support_item"
|
||||
custom:showAsAction="collapseActionView"
|
||||
android:title="@string/support_label"
|
||||
android:visible="false">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -5,6 +5,7 @@
|
|||
<item
|
||||
android:id="@+id/show_preferences"
|
||||
android:title="@string/settings_label"
|
||||
android:menuCategory="system"
|
||||
android:icon="?attr/action_settings"
|
||||
custom:showAsAction="collapseActionView"/>
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/refresh_item"
|
||||
android:title="@string/refresh_label"
|
||||
android:menuCategory="container"
|
||||
custom:showAsAction="ifRoom|collapseActionView"
|
||||
android:icon="?attr/navigation_refresh"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/mark_all_read_item"
|
||||
android:title="@string/mark_all_read_label"
|
||||
android:menuCategory="container"
|
||||
custom:showAsAction="ifRoom|collapseActionView"
|
||||
android:icon="?attr/navigation_accept"/>
|
||||
|
||||
</menu>
|
|
@ -76,8 +76,9 @@
|
|||
|
||||
<!-- Actions on feeds -->
|
||||
<string name="mark_all_read_label">Mark all as read</string>
|
||||
<string name="mark_all_read_msg">Marked all episodes as read</string>
|
||||
<string name="show_info_label">Show information</string>
|
||||
<string name="remove_feed_label">Remove Feed</string>
|
||||
<string name="remove_feed_label">Remove podcast</string>
|
||||
<string name="share_link_label">Share website link</string>
|
||||
<string name="share_source_label">Share feed link</string>
|
||||
<string name="feed_delete_confirmation_msg">Please confirm that you want to delete this feed and ALL episodes of this feed that you have downloaded.</string>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.app.SearchableInfo;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -14,11 +12,9 @@ import android.support.v4.app.ActionBarDrawerToggle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
@ -45,6 +41,12 @@ public class MainActivity extends ActionBarActivity {
|
|||
| EventDistributor.FEED_LIST_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE;
|
||||
|
||||
public static final int POS_NEW = 0,
|
||||
POS_QUEUE = 1,
|
||||
POS_DOWNLOADS = 2,
|
||||
POS_HISTORY = 3,
|
||||
POS_ADD = 4;
|
||||
|
||||
private ExternalPlayerFragment externalPlayerFragment;
|
||||
private DrawerLayout drawerLayout;
|
||||
|
||||
|
@ -61,6 +63,7 @@ public class MainActivity extends ActionBarActivity {
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
setContentView(R.layout.main);
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
@ -99,7 +102,7 @@ public class MainActivity extends ActionBarActivity {
|
|||
if (mainFragment != null) {
|
||||
transaction.replace(R.id.main_view, mainFragment);
|
||||
} else {
|
||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, NavListAdapter.POS_NEW, null);
|
||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, POS_NEW, null);
|
||||
}
|
||||
|
||||
externalPlayerFragment = new ExternalPlayerFragment();
|
||||
|
@ -121,6 +124,10 @@ public class MainActivity extends ActionBarActivity {
|
|||
return getSupportActionBar();
|
||||
}
|
||||
|
||||
public List<Feed> getFeeds() {
|
||||
return feeds;
|
||||
}
|
||||
|
||||
private void loadFragment(int viewType, int relPos, Bundle args) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
// clear back stack
|
||||
|
@ -132,19 +139,19 @@ public class MainActivity extends ActionBarActivity {
|
|||
Fragment fragment = null;
|
||||
if (viewType == NavListAdapter.VIEW_TYPE_NAV) {
|
||||
switch (relPos) {
|
||||
case NavListAdapter.POS_NEW:
|
||||
case POS_NEW:
|
||||
fragment = new NewEpisodesFragment();
|
||||
break;
|
||||
case NavListAdapter.POS_QUEUE:
|
||||
case POS_QUEUE:
|
||||
fragment = new QueueFragment();
|
||||
break;
|
||||
case NavListAdapter.POS_DOWNLOADS:
|
||||
case POS_DOWNLOADS:
|
||||
fragment = new DownloadsFragment();
|
||||
break;
|
||||
case NavListAdapter.POS_HISTORY:
|
||||
case POS_HISTORY:
|
||||
fragment = new PlaybackHistoryFragment();
|
||||
break;
|
||||
case NavListAdapter.POS_ADD:
|
||||
case POS_ADD:
|
||||
fragment = new AddFeedFragment();
|
||||
break;
|
||||
|
||||
|
@ -161,11 +168,16 @@ public class MainActivity extends ActionBarActivity {
|
|||
if (args != null) {
|
||||
fragment.setArguments(args);
|
||||
}
|
||||
fT.replace(R.id.main_view, fragment, "main");fragmentManager.popBackStack();
|
||||
fT.replace(R.id.main_view, fragment, "main");
|
||||
fragmentManager.popBackStack();
|
||||
}
|
||||
fT.commit();
|
||||
}
|
||||
|
||||
public void loadNavFragment(int position, Bundle args) {
|
||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, position, args);
|
||||
}
|
||||
|
||||
public void loadFeedFragment(long feedID) {
|
||||
if (feeds != null) {
|
||||
for (int i = 0; i < feeds.size(); i++) {
|
||||
|
@ -244,8 +256,8 @@ public class MainActivity extends ActionBarActivity {
|
|||
if (extra != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AddFeedFragment.ARG_FEED_URL, extra);
|
||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, NavListAdapter.POS_ADD, args);
|
||||
selectedNavListIndex = NavListAdapter.POS_ADD;
|
||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, POS_ADD, args);
|
||||
selectedNavListIndex = POS_ADD;
|
||||
navAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -360,12 +372,6 @@ public class MainActivity extends ActionBarActivity {
|
|||
static final int VIEW_TYPE_SECTION_DIVIDER = 1;
|
||||
static final int VIEW_TYPE_SUBSCRIPTION = 2;
|
||||
|
||||
static final int POS_NEW = 0,
|
||||
POS_QUEUE = 1,
|
||||
POS_DOWNLOADS = 2,
|
||||
POS_HISTORY = 3,
|
||||
POS_ADD = 4;
|
||||
|
||||
static final int[] NAV_TITLES = {R.string.new_episodes_label, R.string.queue_label, R.string.downloads_label, R.string.playback_history_label, R.string.add_feed_label};
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
@ -12,21 +11,20 @@ import android.support.v7.app.ActionBarActivity;
|
|||
import android.support.v7.widget.SearchView;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.*;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.ItemviewActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.adapter.DefaultActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.InternalFeedItemlistAdapter;
|
||||
import de.danoeh.antennapod.asynctask.DownloadObserver;
|
||||
import de.danoeh.antennapod.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.asynctask.ImageLoader;
|
||||
import de.danoeh.antennapod.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.dialog.FeedItemDialog;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
|
@ -35,12 +33,14 @@ import de.danoeh.antennapod.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.service.download.Downloader;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.util.QueueAccess;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||
import de.danoeh.antennapod.util.menuhandler.MenuItemUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* Displays a list of FeedItems.
|
||||
|
@ -146,6 +146,8 @@ public class ItemlistFragment extends ListFragment {
|
|||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
FeedMenuHandler.onCreateOptionsMenu(inflater, menu);
|
||||
|
||||
final SearchView sv = new SearchView(getActivity());
|
||||
MenuItemUtils.addSearchItem(menu, sv);
|
||||
sv.setQueryHint(getString(R.string.search_hint));
|
||||
|
@ -166,10 +168,61 @@ public class ItemlistFragment extends ListFragment {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
FeedMenuHandler.onPrepareOptionsMenu(menu, feed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (!super.onOptionsItemSelected(item)) {
|
||||
try {
|
||||
if (!FeedMenuHandler.onOptionsItemClicked(getActivity(), item, feed)) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.remove_item:
|
||||
final FeedRemover remover = new FeedRemover(
|
||||
getActivity(), feed) {
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
((MainActivity)getActivity()).loadNavFragment(MainActivity.POS_NEW, null);
|
||||
}
|
||||
};
|
||||
ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(),
|
||||
R.string.remove_feed_label,
|
||||
R.string.feed_delete_confirmation_msg) {
|
||||
|
||||
@Override
|
||||
public void onConfirmButtonPressed(
|
||||
DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
remover.executeAsync();
|
||||
}
|
||||
};
|
||||
conDialog.createNewDialog().show();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
((ActionBarActivity)getActivity()).getSupportActionBar().setTitle("");
|
||||
((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("");
|
||||
|
||||
viewsCreated = true;
|
||||
if (itemsLoaded) {
|
||||
|
@ -232,8 +285,7 @@ public class ItemlistFragment extends ListFragment {
|
|||
feedItemDialog.setQueue(queue);
|
||||
feedItemDialog.updateMenuAppearance();
|
||||
}
|
||||
|
||||
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() {
|
||||
|
|
|
@ -6,11 +6,13 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.*;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
|
@ -19,10 +21,15 @@ import de.danoeh.antennapod.adapter.NewEpisodesListAdapter;
|
|||
import de.danoeh.antennapod.asynctask.DownloadObserver;
|
||||
import de.danoeh.antennapod.dialog.FeedItemDialog;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.service.download.Downloader;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DBTasks;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.util.QueueAccess;
|
||||
import de.danoeh.antennapod.util.menuhandler.MenuItemUtils;
|
||||
|
||||
|
@ -121,6 +128,8 @@ public class NewEpisodesFragment extends Fragment {
|
|||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.new_episodes, menu);
|
||||
|
||||
final SearchView sv = new SearchView(getActivity());
|
||||
MenuItemUtils.addSearchItem(menu, sv);
|
||||
sv.setQueryHint(getString(R.string.search_hint));
|
||||
|
@ -139,6 +148,35 @@ public class NewEpisodesFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
menu.findItem(R.id.mark_all_read_item).setVisible(unreadItems != null && !unreadItems.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (!super.onOptionsItemSelected(item)) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.refresh_item:
|
||||
List<Feed> feeds = ((MainActivity) getActivity()).getFeeds();
|
||||
if (feeds != null) {
|
||||
DBTasks.refreshAllFeeds(getActivity(), feeds);
|
||||
}
|
||||
return true;
|
||||
case R.id.mark_all_read_item:
|
||||
DBWriter.markAllItemsRead(getActivity());
|
||||
Toast.makeText(getActivity(), R.string.mark_all_read_msg, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
@ -190,6 +228,8 @@ public class NewEpisodesFragment extends Fragment {
|
|||
feedItemDialog.updateMenuAppearance();
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
updateProgressBarVisibility();
|
||||
}
|
||||
|
||||
private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() {
|
||||
|
@ -260,11 +300,25 @@ public class NewEpisodesFragment extends Fragment {
|
|||
|
||||
};
|
||||
|
||||
private void updateProgressBarVisibility() {
|
||||
if (DownloadService.isRunning
|
||||
&& DownloadRequester.getInstance().isDownloadingFeeds()) {
|
||||
((ActionBarActivity) getActivity())
|
||||
.setSupportProgressBarIndeterminateVisibility(true);
|
||||
} else {
|
||||
((ActionBarActivity) getActivity())
|
||||
.setSupportProgressBarIndeterminateVisibility(false);
|
||||
}
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((arg & EVENTS) != 0) {
|
||||
startItemLoader();
|
||||
updateProgressBarVisibility();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,12 +2,18 @@ package de.danoeh.antennapod.fragment;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.ActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.DefaultActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.InternalFeedItemlistAdapter;
|
||||
|
@ -18,6 +24,7 @@ import de.danoeh.antennapod.feed.FeedItem;
|
|||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.service.download.Downloader;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
import de.danoeh.antennapod.util.QueueAccess;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -44,6 +51,7 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
startItemLoader();
|
||||
}
|
||||
|
@ -106,12 +114,44 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);
|
||||
MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
TypedArray drawables = getActivity().obtainStyledAttributes(new int[] {R.attr.content_discard});
|
||||
clearHistory.setIcon(drawables.getDrawable(0));
|
||||
drawables.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
menu.findItem(R.id.clear_history_item).setVisible(playbackHistory != null && !playbackHistory.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (!super.onOptionsItemSelected(item)) {
|
||||
switch(item.getItemId()) {
|
||||
case R.id.clear_history_item:
|
||||
DBWriter.clearPlaybackHistory(getActivity());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((arg & EventDistributor.PLAYBACK_HISTORY_UPDATE) != 0) {
|
||||
startItemLoader();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -130,6 +170,7 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
feedItemDialog.setQueue(queue);
|
||||
feedItemDialog.updateMenuAppearance();
|
||||
}
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private DownloadObserver.Callback downloadObserverCallback = new DownloadObserver.Callback() {
|
||||
|
|
Loading…
Reference in New Issue