use of android.support.design.widget.Snackbar in project gene-rate by Pixplicity.
the class Rate method showRatingSnackbar.
private void showRatingSnackbar() {
// Wie is hier nou de snackbar?
final Snackbar snackbar = Snackbar.make(mParentView, mMessage, mSnackBarSwipeToDismiss ? Snackbar.LENGTH_INDEFINITE : Snackbar.LENGTH_LONG);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
// Hide default text
TextView textView = layout.findViewById(android.support.design.R.id.snackbar_text);
textView.setVisibility(View.INVISIBLE);
// Inflate our custom view
final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
@SuppressLint("InflateParams") View snackView = inflater.inflate(R.layout.in_snackbar, null);
// Configure the view
TextView tvMessage = snackView.findViewById(R.id.text);
tvMessage.setText(mMessage);
final CheckBox cbNever = snackView.findViewById(R.id.cb_never);
cbNever.setText(mTextNever);
cbNever.setChecked(DEFAULT_CHECKED);
final Button btFeedback = snackView.findViewById(R.id.bt_negative);
btFeedback.setPaintFlags(btFeedback.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
final Button btRate = snackView.findViewById(R.id.bt_positive);
snackView.findViewById(R.id.tv_swipe).setVisibility(mSnackBarSwipeToDismiss ? View.VISIBLE : View.GONE);
// Remember to not ask again if user swiped it
snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, @DismissEvent int event) {
super.onDismissed(transientBottomBar, event);
if (event == Snackbar.Callback.DISMISS_EVENT_SWIPE && cbNever.isChecked()) {
saveAsked();
}
mFeedbackAction.onRequestDismissed(cbNever.isChecked());
}
});
// Rate listener
btRate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
openPlayStore();
saveAsked();
mFeedbackAction.onRateTapped();
}
});
// Feedback listener
if (mFeedbackAction != null) {
btFeedback.setText(mTextNegative);
btFeedback.setVisibility(View.VISIBLE);
btFeedback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cbNever.isChecked()) {
saveAsked();
}
snackbar.dismiss();
mFeedbackAction.onFeedbackTapped();
}
});
}
// Checkbox listener
cbNever.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton button, boolean checked) {
mPrefs.edit().putBoolean(KEY_BOOL_ASKED, checked).apply();
}
});
// Add the view to the Snackbar's layout
layout.addView(snackView, 0);
// Show the Snackbar
snackbar.show();
}
use of android.support.design.widget.Snackbar in project zype-android by zype.
the class UiUtils method showWarningSnackbar.
public static void showWarningSnackbar(View view, String text) {
if (view == null) {
return;
}
Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
View snackView = snackbar.getView();
snackView.setBackgroundColor(view.getContext().getResources().getColor(R.color.snackbar_warning));
snackbar.show();
}
use of android.support.design.widget.Snackbar in project zype-android by zype.
the class UiUtils method showErrorSnackbar.
public static void showErrorSnackbar(@Nullable final View view, @NonNull final String text) {
if (view == null) {
return;
}
Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
View snackView = snackbar.getView();
snackView.setBackgroundColor(view.getContext().getResources().getColor(R.color.snackbar_error));
snackbar.show();
}
use of android.support.design.widget.Snackbar in project TinyKeePass by sorz.
the class EntryFragment method copyEntry.
private void copyEntry(Entry entry, boolean copyUsername, boolean copyPassword) {
if (copyUsername && notEmpty(entry.getUsername())) {
clipboardManager.setPrimaryClip(ClipData.newPlainText(getString(R.string.username), entry.getUsername()));
String message = getString(R.string.username_copied, entry.getUsername());
if (getView() == null) {
Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
} else {
Snackbar snackbar = Snackbar.make(getView(), message, Snackbar.LENGTH_LONG);
if (copyPassword)
snackbar.setAction(R.string.copy_password, v -> copyPassword(entry));
snackbar.show();
}
}
if (copyPassword && notEmpty(entry.getPassword())) {
if (copyUsername && notEmpty(entry.getUsername())) {
// username already copied, waiting for user's action before copy password.
Intent intent = new Intent(getContext(), PasswordCopingService.class);
intent.setAction(PasswordCopingService.ACTION_NEW_NOTIFICATION);
intent.putExtra(PasswordCopingService.EXTRA_PASSWORD, entry.getPassword());
if (entry.getUsername() != null)
intent.putExtra(PasswordCopingService.EXTRA_USERNAME, entry.getUsername());
if (entry.getTitle() != null)
intent.putExtra(PasswordCopingService.EXTRA_ENTRY_TITLE, entry.getTitle());
getContext().startService(intent);
} else {
// username not copied, copy password immediately.
copyPassword(entry);
}
}
}
use of android.support.design.widget.Snackbar in project bugzy by cpunq.
the class CaseDetailsFragment method getSyncSnackbar.
public Snackbar getSyncSnackbar() {
Snackbar bar = Snackbar.make(getView(), "Syncing case details..", Snackbar.LENGTH_INDEFINITE);
ViewGroup contentLay = (ViewGroup) bar.getView().findViewById(android.support.design.R.id.snackbar_text).getParent();
ProgressBar item = new ProgressBar(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(inDp(24), inDp(24));
params.gravity = Gravity.CENTER_VERTICAL;
item.setLayoutParams(params);
contentLay.addView(item, 0);
return bar;
}
Aggregations