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,8 +138,7 @@ 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,8 +229,7 @@ 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);
} }
}); });
} finally { } finally {
@ -241,8 +237,7 @@ 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,11 +683,12 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
public void onError(Context context, Throwable ex) { public void onError(Context context, Throwable ex) {
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
.setMessage(Helper.formatThrowable(ex)) new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setPositiveButton(android.R.string.cancel, null) .setMessage(Helper.formatThrowable(ex))
.create() .setPositiveButton(android.R.string.cancel, null)
.show(); .create()
.show();
} }
}); });
@ -727,11 +729,12 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
public void onError(Context context, Throwable ex) { public void onError(Context context, Throwable ex) {
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
.setMessage(Helper.formatThrowable(ex)) new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setPositiveButton(android.R.string.cancel, null) .setMessage(Helper.formatThrowable(ex))
.create() .setPositiveButton(android.R.string.cancel, null)
.show(); .create()
.show();
} }
}); });

Loading…
Cancel
Save