Search in sources :

Example 66 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project collect by opendatakit.

the class SnackbarUtils method showSnackbar.

/**
 * Displays snackbar with {@param message}
 * and multi-line message enabled.
 *
 * @param view    The view to find a parent from.
 * @param message The text to show.  Can be formatted text.
 */
private static void showSnackbar(@NonNull View view, @NonNull String message, int duration) {
    if (message.isEmpty()) {
        return;
    }
    Snackbar snackbar = Snackbar.make(view, message.trim(), duration);
    TextView textView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
    textView.setSingleLine(false);
    snackbar.show();
}
Also used : TextView(android.widget.TextView) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 67 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project AndroidUtilCode by Blankj.

the class SnackbarUtils method addView.

/**
 * Add view to the snackbar.
 * <p>Call it after {@link #show()}</p>
 *
 * @param child  The child view.
 * @param params The params.
 */
public static void addView(@NonNull final View child, @NonNull final ViewGroup.LayoutParams params) {
    final View view = getView();
    if (view != null) {
        view.setPadding(0, 0, 0, 0);
        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view;
        layout.addView(child, params);
    }
}
Also used : View(android.view.View) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 68 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project SeriesGuide by UweTrottmann.

the class BaseMessageActivity method onEventEpisodeTask.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventEpisodeTask(ServiceCompletedEvent event) {
    if (event.confirmationText != null) {
        // show a confirmation/error text
        Snackbar snackbarCompleted = Snackbar.make(getSnackbarParentView(), event.confirmationText, event.isSuccessful ? Snackbar.LENGTH_SHORT : Snackbar.LENGTH_LONG);
        // replaces any previous snackbar, including the indefinite progress one
        snackbarCompleted.show();
    } else {
        handleServiceActiveEvent(null);
    }
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 69 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project SeriesGuide by UweTrottmann.

the class BaseTopActivity method onShowCloudAccountWarning.

protected void onShowCloudAccountWarning() {
    if (snackbar != null && snackbar.isShown()) {
        Timber.d("NOT showing Cloud account warning: existing snackbar.");
        return;
    }
    Snackbar newSnackbar = Snackbar.make(getSnackbarParentView(), R.string.hexagon_signed_out, Snackbar.LENGTH_INDEFINITE);
    newSnackbar.addCallback(new Snackbar.Callback() {

        @Override
        public void onDismissed(Snackbar snackbar, int event) {
            if (event == Snackbar.Callback.DISMISS_EVENT_SWIPE) {
                // user has dismissed warning, so disable Cloud
                HexagonTools hexagonTools = SgApp.getServicesComponent(BaseTopActivity.this).hexagonTools();
                hexagonTools.removeAccountAndSetDisabled();
            }
        }
    }).setAction(R.string.hexagon_signin, v -> {
        // forward to cloud setup which can help fix the account issue
        startActivity(new Intent(BaseTopActivity.this, CloudSetupActivity.class));
    }).show();
    snackbar = newSnackbar;
}
Also used : Utils(com.battlelancer.seriesguide.util.Utils) SgApp(com.battlelancer.seriesguide.SgApp) CloudSetupActivity(com.battlelancer.seriesguide.backend.CloudSetupActivity) Intent(android.content.Intent) StatsActivity(com.battlelancer.seriesguide.ui.stats.StatsActivity) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) ActionBar(androidx.appcompat.app.ActionBar) BuildConfig(com.battlelancer.seriesguide.BuildConfig) ContentResolver(android.content.ContentResolver) AccountUtils(com.battlelancer.seriesguide.sync.AccountUtils) SyncStatusObserver(android.content.SyncStatusObserver) Menu(android.view.Menu) BackupSettings(com.battlelancer.seriesguide.dataliberation.BackupSettings) View(android.view.View) HexagonTools(com.battlelancer.seriesguide.backend.HexagonTools) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) HexagonSettings(com.battlelancer.seriesguide.backend.settings.HexagonSettings) SupportTheDev(com.battlelancer.seriesguide.util.SupportTheDev) Account(android.accounts.Account) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) Timber(timber.log.Timber) IdRes(androidx.annotation.IdRes) TextView(android.widget.TextView) MoreOptionsActivity(com.battlelancer.seriesguide.ui.preferences.MoreOptionsActivity) R(com.battlelancer.seriesguide.R) Snackbar(com.google.android.material.snackbar.Snackbar) DataLiberationActivity(com.battlelancer.seriesguide.dataliberation.DataLiberationActivity) HexagonTools(com.battlelancer.seriesguide.backend.HexagonTools) Intent(android.content.Intent) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 70 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project SeriesGuide by UweTrottmann.

the class BaseTopActivity method askForSupport.

private void askForSupport() {
    if (snackbar != null && snackbar.isShown()) {
        Timber.d("NOT asking for support: existing snackbar.");
        return;
    }
    Snackbar newSnackbar = SupportTheDev.buildSnackbar(this, getSnackbarParentView());
    newSnackbar.show();
    snackbar = newSnackbar;
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Aggregations

Snackbar (com.google.android.material.snackbar.Snackbar)110 View (android.view.View)61 Intent (android.content.Intent)46 TextView (android.widget.TextView)41 AlertDialog (androidx.appcompat.app.AlertDialog)29 Context (android.content.Context)28 ImageView (android.widget.ImageView)28 LayoutInflater (android.view.LayoutInflater)24 ArrayList (java.util.ArrayList)23 RecyclerView (androidx.recyclerview.widget.RecyclerView)22 Bundle (android.os.Bundle)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 DialogInterface (android.content.DialogInterface)19 List (java.util.List)19 CreateCardView (me.ccrama.redditslide.Views.CreateCardView)18 Submission (net.dean.jraw.models.Submission)18 SubredditView (me.ccrama.redditslide.Activities.SubredditView)17 ApiException (net.dean.jraw.ApiException)17 Activity (android.app.Activity)16 OnSingleClickListener (me.ccrama.redditslide.util.OnSingleClickListener)16