Added message placeholder

pull/162/head
M66B 5 years ago
parent 76581cbfe6
commit 79b20ce1b6

@ -282,7 +282,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvPreview;
private TextView tvError;
private ImageButton ibHelp;
private ContentLoadingProgressBar pbLoading;
private View vsBody;
@ -400,7 +399,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivThread = itemView.findViewById(R.id.ivThread);
tvError = itemView.findViewById(R.id.tvError);
ibHelp = itemView.findViewById(R.id.ibHelp);
pbLoading = itemView.findViewById(R.id.pbLoading);
if (tvSubject != null) {
tvSubject.setTextColor(colorRead);
@ -663,15 +661,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvPreview.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
ibHelp.setVisibility(View.GONE);
pbLoading.setVisibility(View.VISIBLE);
clearExpanded(null);
}
@SuppressLint("WrongConstant")
private void bindTo(final TupleMessageEx message) {
pbLoading.setVisibility(View.GONE);
boolean inbox = EntityFolder.INBOX.equals(message.folderType);
boolean outbox = EntityFolder.OUTBOX.equals(message.folderType);
boolean outgoing = isOutgoing(message);
@ -3758,8 +3753,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public int getItemViewType(int position) {
TupleMessageEx message = differ.getItem(position);
if (filter_duplicates && message != null && message.duplicate)
if (message == null || context == null)
return R.layout.item_message_placeholder;
if (filter_duplicates && message.duplicate)
return R.layout.item_message_duplicate;
return (compact ? R.layout.item_message_compact : R.layout.item_message_normal);
}
@ -4051,7 +4050,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
TupleMessageEx message = differ.getItem(position);
if (filter_duplicates && message != null && message.duplicate) {
if (message == null || context == null)
return;
if (filter_duplicates && message.duplicate) {
holder.tvFolder.setText(context.getString(R.string.title_duplicate_in, message.getFolderName(context)));
holder.tvFolder.setTypeface(message.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
holder.tvFolder.setTextColor(message.unseen > 0 ? colorUnread : colorRead);
@ -4060,13 +4062,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
holder.unwire();
if (message == null || context == null)
holder.clear();
else {
holder.bindTo(message);
holder.wire();
}
holder.bindTo(message);
holder.wire();
}
@Override

@ -332,15 +332,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvError" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbLoading"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/paddingBottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -325,15 +325,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvError" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbLoading"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/paddingBottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="@string/title_loading"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -871,6 +871,7 @@
<string name="title_minutes">Minutes</string>
<string name="title_dismiss">Dismiss</string>
<string name="title_snooze_now">Snooze</string>
<string name="title_loading">Loading &#8230;</string>
<string name="title_icalendar_accept">Accept</string>
<string name="title_icalendar_decline">Decline</string>

Loading…
Cancel
Save