mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Day headers can change
This commit is contained in:
parent
e38a5346b2
commit
ff15246ce2
2 changed files with 31 additions and 21 deletions
|
@ -403,27 +403,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean day;
|
TupleMessageEx prev = null;
|
||||||
TupleMessageEx prev = (position == 0 ? null : differ.getItem(position - 1));
|
if (position > 0)
|
||||||
if (prev == null)
|
prev = differ.getItem(position - 1);
|
||||||
day = true;
|
message.day = getDay(prev, message);
|
||||||
else {
|
if (message.day)
|
||||||
Calendar cal0 = Calendar.getInstance();
|
|
||||||
Calendar cal1 = Calendar.getInstance();
|
|
||||||
cal0.setTimeInMillis(prev.received);
|
|
||||||
cal1.setTimeInMillis(message.received);
|
|
||||||
int day0 = cal0.get(Calendar.DAY_OF_YEAR);
|
|
||||||
int day1 = cal1.get(Calendar.DAY_OF_YEAR);
|
|
||||||
day = (day0 != day1);
|
|
||||||
}
|
|
||||||
if (day)
|
|
||||||
tvDay.setText(
|
tvDay.setText(
|
||||||
DateUtils.getRelativeTimeSpanString(
|
DateUtils.getRelativeTimeSpanString(
|
||||||
message.received,
|
message.received,
|
||||||
new Date().getTime(),
|
new Date().getTime(),
|
||||||
DAY_IN_MILLIS, 0));
|
DAY_IN_MILLIS, 0));
|
||||||
grpDay.setVisibility(day ? View.VISIBLE : View.GONE);
|
grpDay.setVisibility(message.day ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
|
||||||
itemView.setAlpha(message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType)
|
itemView.setAlpha(message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType)
|
||||||
? Helper.LOW_LIGHT : 1.0f);
|
? Helper.LOW_LIGHT : 1.0f);
|
||||||
|
@ -2083,9 +2073,29 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
}
|
}
|
||||||
|
|
||||||
void submitList(PagedList<TupleMessageEx> pagedList) {
|
void submitList(PagedList<TupleMessageEx> pagedList) {
|
||||||
|
TupleMessageEx prev = null;
|
||||||
|
for (TupleMessageEx message : pagedList) {
|
||||||
|
if (message != null)
|
||||||
|
message.day = getDay(prev, message);
|
||||||
|
prev = message;
|
||||||
|
}
|
||||||
|
|
||||||
differ.submitList(pagedList);
|
differ.submitList(pagedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean getDay(TupleMessageEx prev, TupleMessageEx cur) {
|
||||||
|
if (prev == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Calendar cal0 = Calendar.getInstance();
|
||||||
|
Calendar cal1 = Calendar.getInstance();
|
||||||
|
cal0.setTimeInMillis(prev.received);
|
||||||
|
cal1.setTimeInMillis(cur.received);
|
||||||
|
int day0 = cal0.get(Calendar.DAY_OF_YEAR);
|
||||||
|
int day1 = cal1.get(Calendar.DAY_OF_YEAR);
|
||||||
|
return (day0 != day1);
|
||||||
|
}
|
||||||
|
|
||||||
PagedList<TupleMessageEx> getCurrentList() {
|
PagedList<TupleMessageEx> getCurrentList() {
|
||||||
return differ.getCurrentList();
|
return differ.getCurrentList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
|
@ -33,8 +32,6 @@ import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.mail.Address;
|
import javax.mail.Address;
|
||||||
|
@ -42,6 +39,7 @@ import javax.mail.Address;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
import androidx.room.ForeignKey;
|
import androidx.room.ForeignKey;
|
||||||
|
import androidx.room.Ignore;
|
||||||
import androidx.room.Index;
|
import androidx.room.Index;
|
||||||
import androidx.room.PrimaryKey;
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
@ -143,7 +141,8 @@ public class EntityMessage implements Serializable {
|
||||||
public String error; // volatile
|
public String error; // volatile
|
||||||
public Long last_attempt; // send
|
public Long last_attempt; // send
|
||||||
|
|
||||||
private static final Map<String, Uri> emailLookupUri = new HashMap<>();
|
@Ignore
|
||||||
|
public boolean day = false;
|
||||||
|
|
||||||
static String generateMessageId() {
|
static String generateMessageId() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -260,7 +259,8 @@ public class EntityMessage implements Serializable {
|
||||||
this.ui_browsed.equals(other.ui_browsed) &&
|
this.ui_browsed.equals(other.ui_browsed) &&
|
||||||
(this.ui_snoozed == null ? other.ui_snoozed == null : this.ui_snoozed.equals(other.ui_snoozed)) &&
|
(this.ui_snoozed == null ? other.ui_snoozed == null : this.ui_snoozed.equals(other.ui_snoozed)) &&
|
||||||
(this.warning == null ? other.warning == null : this.warning.equals(other.warning)) &&
|
(this.warning == null ? other.warning == null : this.warning.equals(other.warning)) &&
|
||||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
(this.error == null ? other.error == null : this.error.equals(other.error)) &&
|
||||||
|
this.day == other.day);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue