Browse Source

fix: prevent flickering on message view

main
Distopico Vegan 6 years ago
parent
commit
d6294c63c4
4 changed files with 39 additions and 7 deletions
  1. +0
    -1
      .gitlab-ci.yml
  2. +6
    -5
      app/src/main/java/org/dystopia/email/AdapterMessage.java
  3. +27
    -0
      app/src/main/java/org/dystopia/email/EntityMessage.java
  4. +6
    -1
      app/src/main/java/org/dystopia/email/TupleMessageEx.java

+ 0
- 1
.gitlab-ci.yml View File

@ -18,7 +18,6 @@ cache:
- .gradle/
before_script:
- apt-get update -qq && apt-get install -y -qq pandoc wget
# Get sdk version from project
- export ANDROID_COMPILE_SDK=`egrep '^[[:blank:]]+compileSdkVersion' app/build.gradle | awk '{print $2}'`
# Explict output for logging purpose only


+ 6
- 5
app/src/main/java/org/dystopia/email/AdapterMessage.java View File

@ -424,7 +424,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
tvError.setVisibility(message.error == null ? View.GONE : View.VISIBLE);
}
int typeface = (message.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL);
int typeface = (message.unseen <= 0 || show_expanded ? Typeface.NORMAL : Typeface.BOLD);
tvFrom.setTypeface(null, typeface);
tvTime.setTypeface(null, typeface);
tvSubject.setTypeface(null, typeface);
@ -448,8 +448,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
pbHeaders.setVisibility(View.GONE);
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
bnvActions.setVisibility(View.GONE);
vSeparatorBody.setVisibility(View.GONE);
bnvActions.setVisibility(show_expanded ? View.INVISIBLE : View.GONE);
vSeparatorBody.setVisibility(!show_expanded ? View.INVISIBLE : View.GONE);
btnImages.setVisibility(View.GONE);
pbBody.setVisibility(View.GONE);
grpAttachments.setVisibility(
@ -1623,14 +1623,15 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK =
new DiffUtil.ItemCallback<TupleMessageEx>() {
@Override
public boolean areItemsTheSame(@NonNull TupleMessageEx prev, @NonNull TupleMessageEx next) {
public boolean areItemsTheSame(
@NonNull TupleMessageEx prev, @NonNull TupleMessageEx next) {
return prev.id.equals(next.id);
}
@Override
public boolean areContentsTheSame(
@NonNull TupleMessageEx prev, @NonNull TupleMessageEx next) {
return prev.equals(next);
return prev.shallowEquals(next);
}
};


+ 27
- 0
app/src/main/java/org/dystopia/email/EntityMessage.java View File

@ -83,6 +83,7 @@ import javax.mail.Address;
@Index(value = {"ui_found"}),
@Index(value = {"ui_ignored"})
})
public class EntityMessage implements Serializable {
static final String TABLE_NAME = "message";
@ -230,6 +231,32 @@ public class EntityMessage implements Serializable {
return false;
}
public boolean shallowEquals(Object obj) {
if (obj instanceof EntityMessage) {
EntityMessage other = (EntityMessage) obj;
return ((this.msgid == null ? other.msgid == null : this.msgid.equals(other.msgid))
&& (this.thread == null ? other.thread == null : this.thread.equals(other.thread))
&& (this.avatar == null ? other.avatar == null : this.avatar.equals(other.avatar))
&& equal(this.from, other.from)
&& equal(this.to, other.to)
&& equal(this.cc, other.cc)
&& equal(this.bcc, other.bcc)
&& equal(this.reply, other.reply)
&& (this.headers == null ? other.headers == null : this.headers.equals(other.headers))
&& (this.subject == null ? other.subject == null : this.subject.equals(other.subject))
&& (this.size == null ? other.size == null : this.size.equals(other.size))
&& this.content == other.content
&& this.received.equals(other.received)
&& this.ui_seen.equals(other.ui_seen)
&& this.ui_flagged.equals(other.ui_flagged)
&& this.ui_hide.equals(other.ui_hide)
&& this.ui_found.equals(other.ui_found)
&& this.ui_ignored.equals(other.ui_ignored)
&& (this.error == null ? other.error == null : this.error.equals(other.error)));
}
return false;
}
private static boolean equal(Address[] a1, Address[] a2) {
if (a1 == null && a2 == null) {
return true;


+ 6
- 1
app/src/main/java/org/dystopia/email/TupleMessageEx.java View File

@ -31,6 +31,11 @@ public class TupleMessageEx extends EntityMessage {
public int unflagged;
public int attachments;
@Override
public boolean shallowEquals(Object obj) {
return super.shallowEquals(obj);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof TupleMessageEx) {
@ -52,6 +57,6 @@ public class TupleMessageEx extends EntityMessage {
&& this.unflagged == other.unflagged
&& this.attachments == other.attachments);
}
return super.equals(obj);
return false;
}
}

Loading…
Cancel
Save