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