Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00c3659e authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Do not remove handlers for loaders.

In rare situations we might trigger a force-load if the handler	is
stopped.

Change-Id: I103744654805dcbe0744b09b5be9da1f505817d3
Fixes: 29581798
parent dd962fd1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class PrintServiceRecommendationsLoader extends Loader<List<Recommendatio
    private final @NonNull PrintManager mPrintManager;

    /** Handler to sequentialize the delivery of the results to the main thread */
    private final Handler mHandler;
    private final @NonNull Handler mHandler;

    /** Listens for updates to the data from the platform */
    private PrintManager.PrintServiceRecommendationsChangeListener mListener;
@@ -90,10 +90,8 @@ public class PrintServiceRecommendationsLoader extends Loader<List<Recommendatio
            mListener = null;
        }

        if (mHandler != null) {
        mHandler.removeMessages(0);
    }
    }

    @Override
    protected void onReset() {
+3 −8
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public class PrintServicesLoader extends Loader<List<PrintServiceInfo>> {
    private final @NonNull PrintManager mPrintManager;

    /** Handler to sequentialize the delivery of the results to the main thread */
    private Handler mHandler;
    private final @NonNull Handler mHandler;

    /** Listens for updates to the data from the platform */
    private PrintManager.PrintServicesChangeListener mListener;
@@ -54,6 +54,7 @@ public class PrintServicesLoader extends Loader<List<PrintServiceInfo>> {
    public PrintServicesLoader(@NonNull PrintManager printManager, @NonNull Context context,
            int selectionFlags) {
        super(Preconditions.checkNotNull(context));
        mHandler = new MyHandler();
        mPrintManager = Preconditions.checkNotNull(printManager);
        mSelectionFlags = Preconditions.checkFlagsArgument(selectionFlags,
                PrintManager.ALL_SERVICES);
@@ -75,7 +76,6 @@ public class PrintServicesLoader extends Loader<List<PrintServiceInfo>> {

    @Override
    protected void onStartLoading() {
        mHandler = new MyHandler();
        mListener = new PrintManager.PrintServicesChangeListener() {
            @Override public void onPrintServicesChanged() {
                queueNewResult();
@@ -95,10 +95,7 @@ public class PrintServicesLoader extends Loader<List<PrintServiceInfo>> {
            mListener = null;
        }

        if (mHandler != null) {
        mHandler.removeMessages(0);
            mHandler = null;
        }
    }

    @Override
@@ -119,8 +116,6 @@ public class PrintServicesLoader extends Loader<List<PrintServiceInfo>> {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            if (isStarted()) {
                deliverResult((List<PrintServiceInfo>) msg.obj);
            }