mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 21:57:19 +00:00
Refactoring
This commit is contained in:
parent
617c2cc18e
commit
0900aee1d3
6 changed files with 10 additions and 7 deletions
|
@ -327,7 +327,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
this.dp12 = Math.round(12 * context.getResources().getDisplayMetrics().density);
|
||||
this.dp12 = Helper.dp2pixels(12, context);
|
||||
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
|
|
@ -1718,7 +1718,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.confirm = prefs.getBoolean("confirm", false);
|
||||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
this.dp24 = Math.round(24 * context.getResources().getDisplayMetrics().density);
|
||||
this.dp24 = Helper.dp2pixels(24, context);
|
||||
this.colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
|
||||
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
|
||||
|
|
|
@ -1834,8 +1834,7 @@ public class FragmentCompose extends FragmentEx {
|
|||
}
|
||||
}
|
||||
|
||||
float scale = getContext().getResources().getDisplayMetrics().density;
|
||||
int px = Math.round(12 * scale);
|
||||
int px = Helper.dp2pixels(12, getContext());
|
||||
Drawable d = getContext().getResources().getDrawable(R.drawable.baseline_broken_image_24, getContext().getTheme());
|
||||
d.setBounds(0, 0, px, px);
|
||||
return d;
|
||||
|
|
|
@ -497,7 +497,7 @@ public class FragmentMessages extends FragmentEx {
|
|||
boolean inbox = (EntityFolder.ARCHIVE.equals(message.folderType) || EntityFolder.TRASH.equals(message.folderType));
|
||||
|
||||
View itemView = viewHolder.itemView;
|
||||
int margin = Math.round(12 * (getContext().getResources().getDisplayMetrics().density));
|
||||
int margin = Helper.dp2pixels(12, getContext());
|
||||
|
||||
if (dX > margin) {
|
||||
// Right swipe
|
||||
|
|
|
@ -176,6 +176,11 @@ public class Helper {
|
|||
return intent;
|
||||
}
|
||||
|
||||
static int dp2pixels(int dp, Context context) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
return Math.round(dp * scale);
|
||||
}
|
||||
|
||||
static int resolveColor(Context context, int attr) {
|
||||
int[] attrs = new int[]{attr};
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
|
||||
|
|
|
@ -109,8 +109,7 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
static Drawable decodeImage(String source, Context context, long id, boolean show) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
int px = Math.round(48 * scale);
|
||||
int px = Helper.dp2pixels(48, context);
|
||||
|
||||
if (TextUtils.isEmpty(source)) {
|
||||
Drawable d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24, context.getTheme());
|
||||
|
|
Loading…
Reference in a new issue