Browse Source

Fixed crash

main
M66B 6 years ago
parent
commit
a85b5434ab
2 changed files with 7 additions and 28 deletions
  1. +0
    -25
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +7
    -3
      app/src/main/java/eu/faircode/email/FragmentMessages.java

+ 0
- 25
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -885,29 +885,4 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}.load(this, args);
}
}
void setMessages(PagedList<TupleMessageEx> messages) {
this.messages = messages;
}
public String[] getPrevNext(String thread) {
boolean found = false;
TupleMessageEx prev = null;
TupleMessageEx next = null;
for (int i = 0; i < messages.size(); i++) {
TupleMessageEx item = messages.get(i);
if (item == null)
continue;
if (found) {
next = item;
messages.loadAround(i);
break;
}
if (thread.equals(item.thread))
found = true;
else
prev = item;
}
return new String[]{prev == null ? null : prev.thread, next == null ? null : next.thread};
}
}

+ 7
- 3
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -57,6 +57,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;
@ -585,7 +586,8 @@ public class FragmentMessages extends FragmentEx {
// Compose FAB
if (viewType == AdapterMessage.ViewType.THREAD) {
String[] pn = ((ActivityView) getActivity()).getPrevNext(thread);
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
String[] pn = model.getPrevNext(thread);
fabPrev.setTag(pn[0]);
fabNext.setTag(pn[1]);
@ -854,8 +856,10 @@ public class FragmentMessages extends FragmentEx {
return;
}
if (viewType != AdapterMessage.ViewType.THREAD)
((ActivityView) getActivity()).setMessages(messages);
if (viewType != AdapterMessage.ViewType.THREAD) {
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
model.setMessages(messages);
}
if (viewType == AdapterMessage.ViewType.THREAD && autoExpand) {
autoExpand = false;


Loading…
Cancel
Save