use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.
the class ItemFragment method showOnDemandConfigBalloon.
private void showOnDemandConfigBalloon(boolean offerStreaming) {
boolean isLocaleRtl = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
Balloon balloon = new Balloon.Builder(getContext()).setArrowOrientation(ArrowOrientation.TOP).setArrowOrientationRules(ArrowOrientationRules.ALIGN_FIXED).setArrowPosition(0.25f + ((isLocaleRtl ^ offerStreaming) ? 0f : 0.5f)).setWidthRatio(1.0f).setMarginLeft(8).setMarginRight(8).setBackgroundColor(ThemeUtils.getColorFromAttr(getContext(), R.attr.colorSecondary)).setBalloonAnimation(BalloonAnimation.OVERSHOOT).setLayout(R.layout.popup_bubble_view).setDismissWhenTouchOutside(true).setLifecycleOwner(this).build();
Button positiveButton = balloon.getContentView().findViewById(R.id.balloon_button_positive);
Button negativeButton = balloon.getContentView().findViewById(R.id.balloon_button_negative);
TextView message = balloon.getContentView().findViewById(R.id.balloon_message);
message.setText(offerStreaming ? R.string.on_demand_config_stream_text : R.string.on_demand_config_download_text);
positiveButton.setOnClickListener(v1 -> {
UserPreferences.setStreamOverDownload(offerStreaming);
// Update all visible lists to reflect new streaming action button
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.on_demand_config_setting_changed, Snackbar.LENGTH_SHORT);
balloon.dismiss();
});
negativeButton.setOnClickListener(v1 -> {
// Type does not matter. Both are silenced.
UsageStatistics.askAgainLater(UsageStatistics.ACTION_STREAM);
balloon.dismiss();
});
balloon.showAlignBottom(butAction1, 0, (int) (-12 * getResources().getDisplayMetrics().density));
}
use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.
the class DBWriter method markFeedRead.
/**
* Sets the 'read'-attribute of all FeedItems of a specific Feed to PLAYED.
*
* @param feedId ID of the Feed.
*/
public static Future<?> markFeedRead(final long feedId) {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setFeedItems(FeedItem.PLAYED, feedId);
adapter.close();
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
});
}
use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.
the class DBWriter method removeAllNewFlags.
/**
* Sets the 'read'-attribute of all NEW FeedItems to UNPLAYED.
*/
public static Future<?> removeAllNewFlags() {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setFeedItems(FeedItem.NEW, FeedItem.UNPLAYED);
adapter.close();
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
});
}
use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.
the class DBWriter method markItemPlayed.
/*
* Sets the 'read'-attribute of all specified FeedItems
*
* @param played New value of the 'read'-attribute, one of FeedItem.PLAYED, FeedItem.NEW,
* FeedItem.UNPLAYED
* @param broadcastUpdate true if this operation should trigger a UnreadItemsUpdate broadcast.
* This option is usually set to true
* @param itemIds IDs of the FeedItems.
*/
public static Future<?> markItemPlayed(final int played, final boolean broadcastUpdate, final long... itemIds) {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setFeedItemRead(played, itemIds);
adapter.close();
if (broadcastUpdate) {
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
}
});
}
use of de.danoeh.antennapod.event.UnreadItemsUpdateEvent in project AntennaPod by AntennaPod.
the class FeedSortDialog method showDialog.
public static void showDialog(Context context) {
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(context.getString(R.string.pref_nav_drawer_feed_order_title));
dialog.setNegativeButton(android.R.string.cancel, (d, listener) -> d.dismiss());
int selected = UserPreferences.getFeedOrder();
List<String> entryValues = Arrays.asList(context.getResources().getStringArray(R.array.nav_drawer_feed_order_values));
final int selectedIndex = entryValues.indexOf("" + selected);
String[] items = context.getResources().getStringArray(R.array.nav_drawer_feed_order_options);
dialog.setSingleChoiceItems(items, selectedIndex, (d, which) -> {
if (selectedIndex != which) {
UserPreferences.setFeedOrder(entryValues.get(which));
// Update subscriptions
EventBus.getDefault().post(new UnreadItemsUpdateEvent());
}
d.dismiss();
});
dialog.show();
}
Aggregations