Search in sources :

Example 1 with Balloon

use of com.skydoves.balloon.Balloon 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)

Aggregations

Button (android.widget.Button)1 TextView (android.widget.TextView)1 Balloon (com.skydoves.balloon.Balloon)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 CancelDownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton)1 DeleteActionButton (de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton)1 DownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.DownloadActionButton)1 ItemActionButton (de.danoeh.antennapod.adapter.actionbutton.ItemActionButton)1 MarkAsPlayedActionButton (de.danoeh.antennapod.adapter.actionbutton.MarkAsPlayedActionButton)1 PauseActionButton (de.danoeh.antennapod.adapter.actionbutton.PauseActionButton)1 PlayActionButton (de.danoeh.antennapod.adapter.actionbutton.PlayActionButton)1 PlayLocalActionButton (de.danoeh.antennapod.adapter.actionbutton.PlayLocalActionButton)1 StreamActionButton (de.danoeh.antennapod.adapter.actionbutton.StreamActionButton)1 VisitWebsiteActionButton (de.danoeh.antennapod.adapter.actionbutton.VisitWebsiteActionButton)1 UnreadItemsUpdateEvent (de.danoeh.antennapod.event.UnreadItemsUpdateEvent)1