From 048660d24ff6a0cef47a87251ef088c227bf4d58 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 7 Aug 2018 06:51:49 +0000 Subject: [PATCH] Refactored adapters to use bindTo method --- .../eu/faircode/email/AdapterAccount.java | 15 +++--- .../eu/faircode/email/AdapterAttachment.java | 46 ++++++++++--------- .../java/eu/faircode/email/AdapterFolder.java | 40 ++++++++-------- .../eu/faircode/email/AdapterIdentity.java | 15 +++--- 4 files changed, 65 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterAccount.java b/app/src/main/java/eu/faircode/email/AdapterAccount.java index e1bd1138..9eb09f58 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAccount.java +++ b/app/src/main/java/eu/faircode/email/AdapterAccount.java @@ -73,6 +73,14 @@ public class AdapterAccount extends RecyclerView.Adapter 0 ? Typeface.BOLD : Typeface.NORMAL); + tvName.setTextColor(Helper.resolveColor(context, folder.unseen > 0 ? R.attr.colorUnread : android.R.attr.textColorSecondary)); + + tvAfter.setText(Integer.toString(folder.after)); + tvAfter.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE); + + ivSync.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE); + + tvAccount.setText(folder.accountName); + tvAccount.setVisibility(EntityFolder.TYPE_OUTBOX.equals(folder.type) ? View.GONE : View.VISIBLE); + + int resid = context.getResources().getIdentifier( + "title_folder_" + folder.type.toLowerCase(), + "string", + context.getPackageName()); + tvType.setText(resid > 0 ? context.getString(resid) : folder.type); + } + @Override public void onClick(View view) { int pos = getAdapterPosition(); @@ -225,25 +246,8 @@ public class AdapterFolder extends RecyclerView.Adapter 0 ? Typeface.BOLD : Typeface.NORMAL); - holder.tvName.setTextColor(Helper.resolveColor(context, folder.unseen > 0 ? R.attr.colorUnread : android.R.attr.textColorSecondary)); - - holder.tvAfter.setText(Integer.toString(folder.after)); - holder.tvAfter.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE); - - holder.ivSync.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE); - - holder.tvAccount.setText(folder.accountName); - holder.tvAccount.setVisibility(EntityFolder.TYPE_OUTBOX.equals(folder.type) ? View.GONE : View.VISIBLE); - - int resid = context.getResources().getIdentifier( - "title_folder_" + folder.type.toLowerCase(), - "string", - context.getPackageName()); - holder.tvType.setText(resid > 0 ? context.getString(resid) : folder.type); holder.wire(); } diff --git a/app/src/main/java/eu/faircode/email/AdapterIdentity.java b/app/src/main/java/eu/faircode/email/AdapterIdentity.java index 6f645a41..8c84305e 100644 --- a/app/src/main/java/eu/faircode/email/AdapterIdentity.java +++ b/app/src/main/java/eu/faircode/email/AdapterIdentity.java @@ -73,6 +73,14 @@ public class AdapterIdentity extends RecyclerView.Adapter