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));
}
Aggregations