use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.
the class QueueFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (!super.onOptionsItemSelected(item)) {
switch(item.getItemId()) {
case R.id.queue_lock:
boolean newLockState = !UserPreferences.isQueueLocked();
UserPreferences.setQueueLocked(newLockState);
getActivity().supportInvalidateOptionsMenu();
recyclerAdapter.setLocked(newLockState);
if (newLockState) {
Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_locked, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_unlocked, Snackbar.LENGTH_SHORT).show();
}
return true;
case R.id.refresh_item:
List<Feed> feeds = ((MainActivity) getActivity()).getFeeds();
if (feeds != null) {
DBTasks.refreshAllFeeds(getActivity(), feeds);
}
return true;
case R.id.clear_queue:
// make sure the user really wants to clear the queue
ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(), R.string.clear_queue_label, R.string.clear_queue_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.clearQueue();
}
};
conDialog.createNewDialog().show();
return true;
case R.id.queue_sort_episode_title_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_ASC, true);
return true;
case R.id.queue_sort_episode_title_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_DESC, true);
return true;
case R.id.queue_sort_date_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_ASC, true);
return true;
case R.id.queue_sort_date_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_DESC, true);
return true;
case R.id.queue_sort_duration_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_ASC, true);
return true;
case R.id.queue_sort_duration_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_DESC, true);
return true;
case R.id.queue_sort_feed_title_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_ASC, true);
return true;
case R.id.queue_sort_feed_title_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_DESC, true);
return true;
default:
return false;
}
} else {
return true;
}
}
use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.
the class AllEpisodesFragment method onFragmentLoaded.
private void onFragmentLoaded() {
if (listAdapter == null) {
MainActivity mainActivity = (MainActivity) getActivity();
listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess, new DefaultActionButtonCallback(mainActivity), showOnlyNewEpisodes());
listAdapter.setHasStableIds(true);
recyclerView.setAdapter(listAdapter);
}
listAdapter.notifyDataSetChanged();
restoreScrollPosition();
getActivity().supportInvalidateOptionsMenu();
updateShowOnlyEpisodesListViewState();
}
use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.
the class CompletedDownloadsFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.episode_actions:
EpisodesApplyActionFragment fragment = EpisodesApplyActionFragment.newInstance(items, EpisodesApplyActionFragment.ACTION_REMOVE);
((MainActivity) getActivity()).loadChildFragment(fragment);
return true;
default:
return false;
}
}
use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.
the class TagListFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.gpodder_podcasts, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
MenuItemUtils.adjustTextColor(getActivity(), sv);
sv.setQueryHint(getString(R.string.gpodnet_search_hint));
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
Activity activity = getActivity();
if (activity != null) {
sv.clearFocus();
((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s));
}
return true;
}
@Override
public boolean onQueryTextChange(String s) {
return false;
}
});
}
use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.
the class SubscriptionFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
subscriptionAdapter = new SubscriptionsAdapter((MainActivity) getActivity(), itemAccess);
subscriptionGridLayout.setAdapter(subscriptionAdapter);
loadSubscriptions();
subscriptionGridLayout.setOnItemClickListener(subscriptionAdapter);
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.subscriptions_label);
}
EventDistributor.getInstance().register(contentUpdate);
}
Aggregations