Attach snackbar to parent view

This commit is contained in:
M66B 2019-06-24 09:49:45 +02:00
parent da0f528798
commit 8c0e81d6df
5 changed files with 31 additions and 9 deletions

View File

@ -217,7 +217,10 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
// Check if viewer available // Check if viewer available
if (ris.size() == 0) if (ris.size() == 0)
Snackbar.make(view, context.getString(R.string.title_no_viewer, attachment.type), Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
context.getString(R.string.title_no_viewer, attachment.type),
Snackbar.LENGTH_LONG).show();
else else
context.startActivity(intent); context.startActivity(intent);
} }

View File

@ -485,7 +485,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalStateException) { if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG); Snackbar snackbar = Snackbar.make(
(View) itemView.getParent(),
ex.getMessage(),
Snackbar.LENGTH_LONG);
snackbar.setAction(R.string.title_fix, new View.OnClickListener() { snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -496,7 +499,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}); });
snackbar.show(); snackbar.show();
} else if (ex instanceof IllegalArgumentException) } else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
ex.getMessage(),
Snackbar.LENGTH_LONG).show();
else else
Helper.unexpectedError(context, owner, ex); Helper.unexpectedError(context, owner, ex);
} }

View File

@ -130,7 +130,10 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
// Check if viewer available // Check if viewer available
if (ris.size() == 0) { if (ris.size() == 0) {
Snackbar.make(view, context.getString(R.string.title_no_viewer, attachment.type), Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
context.getString(R.string.title_no_viewer, attachment.type),
Snackbar.LENGTH_LONG).show();
return; return;
} }

View File

@ -1411,7 +1411,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message.ui_snoozed != null) { if (message.ui_snoozed != null) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT); DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
DateFormat day = new SimpleDateFormat("E"); DateFormat day = new SimpleDateFormat("E");
Snackbar.make(view, Snackbar.make(
(View) itemView.getParent(),
day.format(message.ui_snoozed) + " " + df.format(message.ui_snoozed), day.format(message.ui_snoozed) + " " + df.format(message.ui_snoozed),
Snackbar.LENGTH_LONG).show(); Snackbar.LENGTH_LONG).show();
} }
@ -1621,7 +1622,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
if (edit.resolveActivity(pm) == null) if (edit.resolveActivity(pm) == null)
Snackbar.make(view, R.string.title_no_contacts, Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
R.string.title_no_contacts,
Snackbar.LENGTH_LONG).show();
else else
context.startActivity(edit); context.startActivity(edit);
} }
@ -2661,7 +2665,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
if (share.resolveActivity(pm) == null) if (share.resolveActivity(pm) == null)
Snackbar.make(view, R.string.title_no_viewer, Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
R.string.title_no_viewer,
Snackbar.LENGTH_LONG).show();
else else
context.startActivity(share); context.startActivity(share);
} }
@ -3208,7 +3215,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onExecuted(Bundle args, List<EntityAnswer> answers) { protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
if (answers == null || answers.size() == 0) { if (answers == null || answers.size() == 0) {
Snackbar snackbar = Snackbar.make( Snackbar snackbar = Snackbar.make(
view, (View) itemView.getParent(),
context.getString(R.string.title_no_answers), context.getString(R.string.title_no_answers),
Snackbar.LENGTH_LONG); Snackbar.LENGTH_LONG);
snackbar.setAction(R.string.title_fix, new View.OnClickListener() { snackbar.setAction(R.string.title_fix, new View.OnClickListener() {

View File

@ -258,7 +258,10 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
@Override @Override
protected void onExecuted(Bundle args, Integer applied) { protected void onExecuted(Bundle args, Integer applied) {
Snackbar.make(view, context.getString(R.string.title_rule_applied, applied), Snackbar.LENGTH_LONG).show(); Snackbar.make(
(View) itemView.getParent(),
context.getString(R.string.title_rule_applied, applied),
Snackbar.LENGTH_LONG).show();
} }
@Override @Override