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

Commit b53ecd84 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Cleaning up listener when task completes""

parents 98eb33dd 25978ac5
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -3473,10 +3473,18 @@ public class RemoteViews implements Parcelable, Filter {
        return applyAsync(context, parent, executor, listener, null);
    }

    private CancellationSignal startTaskOnExecutor(AsyncApplyTask task, Executor executor) {
        CancellationSignal cancelSignal = new CancellationSignal();
        cancelSignal.setOnCancelListener(task);

        task.executeOnExecutor(executor == null ? AsyncTask.THREAD_POOL_EXECUTOR : executor);
        return cancelSignal;
    }

    /** @hide */
    public CancellationSignal applyAsync(Context context, ViewGroup parent,
            Executor executor, OnViewAppliedListener listener, OnClickHandler handler) {
        return getAsyncApplyTask(context, parent, listener, handler).startTaskOnExecutor(executor);
        return startTaskOnExecutor(getAsyncApplyTask(context, parent, listener, handler), executor);
    }

    private AsyncApplyTask getAsyncApplyTask(Context context, ViewGroup parent,
@@ -3487,7 +3495,6 @@ public class RemoteViews implements Parcelable, Filter {

    private class AsyncApplyTask extends AsyncTask<Void, Void, ViewTree>
            implements CancellationSignal.OnCancelListener {
        final CancellationSignal mCancelSignal = new CancellationSignal();
        final RemoteViews mRV;
        final ViewGroup mParent;
        final Context mContext;
@@ -3538,7 +3545,6 @@ public class RemoteViews implements Parcelable, Filter {

        @Override
        protected void onPostExecute(ViewTree viewTree) {
            mCancelSignal.setOnCancelListener(null);
            if (mError == null) {
                if (mListener != null) {
                    mListener.onViewInflated(viewTree.mRoot);
@@ -3575,13 +3581,6 @@ public class RemoteViews implements Parcelable, Filter {
        @Override
        public void onCancel() {
            cancel(true);
            mCancelSignal.setOnCancelListener(null);
        }

        private CancellationSignal startTaskOnExecutor(Executor executor) {
            mCancelSignal.setOnCancelListener(this);
            executeOnExecutor(executor == null ? AsyncTask.THREAD_POOL_EXECUTOR : executor);
            return mCancelSignal;
        }
    }

@@ -3647,8 +3646,8 @@ public class RemoteViews implements Parcelable, Filter {
            }
        }

        return new AsyncApplyTask(rvToApply, (ViewGroup) v.getParent(),
                context, listener, handler, v).startTaskOnExecutor(executor);
        return startTaskOnExecutor(new AsyncApplyTask(rvToApply, (ViewGroup) v.getParent(),
                context, listener, handler, v), executor);
    }

    private void performApply(View v, ViewGroup parent, OnClickHandler handler) {