mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Fixed adapter snackbar parent view
This commit is contained in:
parent
c4a46648a2
commit
e8e3542a2b
7 changed files with 27 additions and 30 deletions
|
@ -66,6 +66,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private LifecycleOwner owner;
|
||||
private View parentView;
|
||||
private boolean show_hidden;
|
||||
|
||||
private long account;
|
||||
|
@ -497,10 +498,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (ex instanceof IllegalStateException) {
|
||||
Snackbar snackbar = Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
ex.getMessage(),
|
||||
Snackbar.LENGTH_LONG);
|
||||
Snackbar snackbar = Snackbar.make(parentView, ex.getMessage(), Snackbar.LENGTH_LONG);
|
||||
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -511,10 +509,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
});
|
||||
snackbar.show();
|
||||
} else if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
ex.getMessage(),
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
Snackbar.make(parentView, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Helper.unexpectedError(context, owner, ex);
|
||||
}
|
||||
|
@ -715,10 +710,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean show_hidden, IFolderSelectedListener listener) {
|
||||
AdapterFolder(Context context, LifecycleOwner owner, View parentView,
|
||||
long account, boolean show_hidden, IFolderSelectedListener listener) {
|
||||
this.context = context;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.owner = owner;
|
||||
this.parentView = parentView;
|
||||
this.show_hidden = show_hidden;
|
||||
this.account = account;
|
||||
this.listener = listener;
|
||||
|
|
|
@ -52,6 +52,7 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private LifecycleOwner owner;
|
||||
private View parentView;
|
||||
|
||||
private List<EntityAttachment> items = new ArrayList<>();
|
||||
|
||||
|
@ -131,7 +132,7 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
// Check if viewer available
|
||||
if (ris.size() == 0) {
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
parentView,
|
||||
context.getString(R.string.title_no_viewer, attachment.type),
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
|
@ -177,10 +178,11 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
|||
}
|
||||
}
|
||||
|
||||
AdapterImage(Context context, LifecycleOwner owner) {
|
||||
AdapterImage(Context context, LifecycleOwner owner, View parentView) {
|
||||
this.context = context;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.owner = owner;
|
||||
this.parentView = parentView;
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private LifecycleOwner owner;
|
||||
private View parentView;
|
||||
private ViewType viewType;
|
||||
private boolean compact;
|
||||
private int zoom;
|
||||
|
@ -405,7 +406,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
StaggeredGridLayoutManager sglm =
|
||||
new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
|
||||
rvImage.setLayoutManager(sglm);
|
||||
adapterImage = new AdapterImage(context, owner);
|
||||
adapterImage = new AdapterImage(context, owner, parentView);
|
||||
rvImage.setAdapter(adapterImage);
|
||||
|
||||
grpAddresses = vsBody.findViewById(R.id.grpAddresses);
|
||||
|
@ -1411,7 +1412,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
|
||||
DateFormat day = new SimpleDateFormat("E");
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
parentView,
|
||||
day.format(message.ui_snoozed) + " " + df.format(message.ui_snoozed),
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -1621,10 +1622,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (edit.resolveActivity(pm) == null)
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
R.string.title_no_contacts,
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
Snackbar.make(parentView, R.string.title_no_contacts, Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
context.startActivity(edit);
|
||||
}
|
||||
|
@ -2664,10 +2662,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (share.resolveActivity(pm) == null)
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
R.string.title_no_viewer,
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
Snackbar.make(parentView, R.string.title_no_viewer, Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
context.startActivity(share);
|
||||
}
|
||||
|
@ -2967,7 +2962,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
LinearLayoutManager llm = new LinearLayoutManager(context);
|
||||
rvFolder.setLayoutManager(llm);
|
||||
|
||||
final AdapterFolder adapter = new AdapterFolder(context, owner, data.message.account, false,
|
||||
final AdapterFolder adapter = new AdapterFolder(context, owner, parentView, data.message.account, false,
|
||||
new AdapterFolder.IFolderSelectedListener() {
|
||||
@Override
|
||||
public void onFolderSelected(TupleFolderEx folder) {
|
||||
|
@ -3214,7 +3209,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
|
||||
if (answers == null || answers.size() == 0) {
|
||||
Snackbar snackbar = Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
parentView,
|
||||
context.getString(R.string.title_no_answers),
|
||||
Snackbar.LENGTH_LONG);
|
||||
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
||||
|
@ -3276,7 +3271,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
AdapterMessage(Context context, LifecycleOwner owner,
|
||||
AdapterMessage(Context context, LifecycleOwner owner, View parentView,
|
||||
ViewType viewType, boolean compact, int zoom, String sort, boolean filter_duplicates, final IProperties properties) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
|
@ -3285,6 +3280,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.context = context;
|
||||
this.owner = owner;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.parentView = parentView;
|
||||
this.viewType = viewType;
|
||||
this.compact = compact;
|
||||
this.zoom = zoom;
|
||||
|
|
|
@ -54,6 +54,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
private Context context;
|
||||
private LifecycleOwner owner;
|
||||
private LayoutInflater inflater;
|
||||
private View parentView;
|
||||
|
||||
private List<TupleRuleEx> items = new ArrayList<>();
|
||||
|
||||
|
@ -259,7 +260,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
@Override
|
||||
protected void onExecuted(Bundle args, Integer applied) {
|
||||
Snackbar.make(
|
||||
(View) itemView.getParent(),
|
||||
parentView,
|
||||
context.getString(R.string.title_rule_applied, applied),
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -278,10 +279,11 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|||
}
|
||||
}
|
||||
|
||||
AdapterRule(Context context, LifecycleOwner owner) {
|
||||
AdapterRule(Context context, LifecycleOwner owner, View parentView) {
|
||||
this.context = context;
|
||||
this.owner = owner;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.parentView = parentView;
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
|
||||
rvFolder.addItemDecoration(itemDecorator);
|
||||
|
||||
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, show_hidden, null);
|
||||
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), view, account, show_hidden, null);
|
||||
rvFolder.setAdapter(adapter);
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -501,7 +501,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
boolean filter_duplicates = prefs.getBoolean("filter_duplicates", false);
|
||||
|
||||
adapter = new AdapterMessage(
|
||||
getContext(), getViewLifecycleOwner(),
|
||||
getContext(), getViewLifecycleOwner(), view,
|
||||
viewType, compact, zoom, sort, filter_duplicates, iProperties);
|
||||
rvMessage.setAdapter(adapter);
|
||||
|
||||
|
@ -1926,7 +1926,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
LinearLayoutManager llm = new LinearLayoutManager(getContext());
|
||||
rvFolder.setLayoutManager(llm);
|
||||
|
||||
final AdapterFolder adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, false,
|
||||
final AdapterFolder adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), view, account, false,
|
||||
new AdapterFolder.IFolderSelectedListener() {
|
||||
@Override
|
||||
public void onFolderSelected(TupleFolderEx folder) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class FragmentRules extends FragmentBase {
|
|||
LinearLayoutManager llm = new LinearLayoutManager(getContext());
|
||||
rvRule.setLayoutManager(llm);
|
||||
|
||||
adapter = new AdapterRule(getContext(), getViewLifecycleOwner());
|
||||
adapter = new AdapterRule(getContext(), getViewLifecycleOwner(), view);
|
||||
rvRule.setAdapter(adapter);
|
||||
|
||||
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation());
|
||||
|
|
Loading…
Reference in a new issue