Fixed search spinner

pull/145/head
M66B 6 years ago
parent c14108839f
commit c2a078a340

@ -65,7 +65,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
private int index; private int index;
private boolean searching = false; private boolean searching = false;
private int loaded = 0; private int loaded = 0;
private boolean destroyed = false;
interface IBoundaryCallbackMessages { interface IBoundaryCallbackMessages {
void onLoading(); void onLoading();
@ -87,7 +86,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
@Override @Override
public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) { public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) {
if (event == Lifecycle.Event.ON_DESTROY) { if (event == Lifecycle.Event.ON_DESTROY) {
destroyed = true;
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -140,7 +138,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!destroyed)
intf.onLoading(); intf.onLoading();
} }
}); });
@ -232,7 +229,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!destroyed)
intf.onError(context, ex); intf.onError(context, ex);
} }
}); });
@ -241,7 +237,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!destroyed)
intf.onLoaded(); intf.onLoaded();
} }
}); });

@ -52,6 +52,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.paging.LivePagedListBuilder; import androidx.paging.LivePagedListBuilder;
@ -682,6 +683,7 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
public void onError(Context context, Throwable ex) { public void onError(Context context, Throwable ex) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(Helper.formatThrowable(ex)) .setMessage(Helper.formatThrowable(ex))
.setPositiveButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.cancel, null)
@ -727,6 +729,7 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
public void onError(Context context, Throwable ex) { public void onError(Context context, Throwable ex) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(Helper.formatThrowable(ex)) .setMessage(Helper.formatThrowable(ex))
.setPositiveButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.cancel, null)

Loading…
Cancel
Save