Search in sources :

Example 1 with UnreadItemsUpdateEvent

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));
}
Also used : DeleteActionButton(de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton) CancelDownloadActionButton(de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton) DownloadActionButton(de.danoeh.antennapod.adapter.actionbutton.DownloadActionButton) Button(android.widget.Button) PlayActionButton(de.danoeh.antennapod.adapter.actionbutton.PlayActionButton) PlayLocalActionButton(de.danoeh.antennapod.adapter.actionbutton.PlayLocalActionButton) VisitWebsiteActionButton(de.danoeh.antennapod.adapter.actionbutton.VisitWebsiteActionButton) PauseActionButton(de.danoeh.antennapod.adapter.actionbutton.PauseActionButton) ItemActionButton(de.danoeh.antennapod.adapter.actionbutton.ItemActionButton) MarkAsPlayedActionButton(de.danoeh.antennapod.adapter.actionbutton.MarkAsPlayedActionButton) StreamActionButton(de.danoeh.antennapod.adapter.actionbutton.StreamActionButton) UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) Balloon(com.skydoves.balloon.Balloon) TextView(android.widget.TextView) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 2 with UnreadItemsUpdateEvent

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());
    });
}
Also used : UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent)

Example 3 with 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());
    });
}
Also used : UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent)

Example 4 with 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());
        }
    });
}
Also used : UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent)

Example 5 with 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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent)

Aggregations

UnreadItemsUpdateEvent (de.danoeh.antennapod.event.UnreadItemsUpdateEvent)12 AlertDialog (androidx.appcompat.app.AlertDialog)2 PreferenceActivity (de.danoeh.antennapod.activity.PreferenceActivity)2 Activity (android.app.Activity)1 Context (android.content.Context)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 ActivityCompat (androidx.core.app.ActivityCompat)1 ListPreference (androidx.preference.ListPreference)1 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)1 Snackbar (com.google.android.material.snackbar.Snackbar)1 Balloon (com.skydoves.balloon.Balloon)1 R (de.danoeh.antennapod.R)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 CancelDownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton)1