Refactoring

pull/147/head
M66B 6 years ago
parent 69b5448859
commit 6157eece5e

@ -105,7 +105,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
} }
private void bindTo(EntityAttachment attachment) { private void bindTo(EntityAttachment attachment) {
itemView.setAlpha(attachment.isInline() ? 0.6f : 1.0f); itemView.setAlpha(attachment.isInline() ? Helper.LOW_LIGHT : 1.0f);
ivDelete.setVisibility(readonly ? View.GONE : attachment.isInline() ? View.INVISIBLE : View.VISIBLE); ivDelete.setVisibility(readonly ? View.GONE : attachment.isInline() ? View.INVISIBLE : View.VISIBLE);
tvName.setText(attachment.name); tvName.setText(attachment.name);

@ -145,8 +145,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
enum ViewType {UNIFIED, FOLDER, THREAD, SEARCH} enum ViewType {UNIFIED, FOLDER, THREAD, SEARCH}
private static final float LOW_LIGHT = 0.6f;
private static DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG); private static DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG);
public class ViewHolder extends RecyclerView.ViewHolder implements public class ViewHolder extends RecyclerView.ViewHolder implements
@ -394,24 +392,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbLoading.setVisibility(View.GONE); pbLoading.setVisibility(View.GONE);
itemView.setAlpha(message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType) ? LOW_LIGHT : 1.0f); itemView.setAlpha(message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType)
? Helper.LOW_LIGHT : 1.0f);
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
ivFlagged.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivFlagged.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivAvatar.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivAvatar.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvFrom.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvFrom.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvSize.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvSize.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvTime.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvTime.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivDraft.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivDraft.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivSnoozed.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivSnoozed.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivAnswered.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivAnswered.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivAttachments.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivAttachments.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvSubject.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvSubject.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvFolder.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvFolder.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvCount.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvCount.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
ivThread.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); ivThread.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvPreview.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvPreview.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
tvError.setAlpha(message.duplicate ? LOW_LIGHT : 1.0f); tvError.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
} }
if (!outgoing && (avatars || identicons)) { if (!outgoing && (avatars || identicons)) {
@ -599,7 +598,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSizeEx.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true)); tvSizeEx.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
if (!message.duplicate) if (!message.duplicate)
tvSizeEx.setAlpha(message.content ? 1.0f : LOW_LIGHT); tvSizeEx.setAlpha(message.content ? 1.0f : Helper.LOW_LIGHT);
tvSizeEx.setVisibility(message.size == null ? View.GONE : View.VISIBLE); tvSizeEx.setVisibility(message.size == null ? View.GONE : View.VISIBLE);
tvSubjectEx.setText(message.subject); tvSubjectEx.setText(message.subject);

@ -95,6 +95,8 @@ public class Helper {
static final int AUTH_TYPE_PASSWORD = 1; static final int AUTH_TYPE_PASSWORD = 1;
static final int AUTH_TYPE_GMAIL = 2; static final int AUTH_TYPE_GMAIL = 2;
static final float LOW_LIGHT = 0.6f;
static ThreadFactory backgroundThreadFactory = new ThreadFactory() { static ThreadFactory backgroundThreadFactory = new ThreadFactory() {
@Override @Override
public Thread newThread(@NonNull Runnable runnable) { public Thread newThread(@NonNull Runnable runnable) {

Loading…
Cancel
Save