Search in sources :

Example 1 with CancellableTask

use of com.android.quickstep.util.CancellableTask in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 2 with CancellableTask

use of com.android.quickstep.util.CancellableTask in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && cachedThumbnail.thumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 3 with CancellableTask

use of com.android.quickstep.util.CancellableTask in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && cachedThumbnail.thumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 4 with CancellableTask

use of com.android.quickstep.util.CancellableTask in project android_packages_apps_404Launcher by P-404.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && cachedThumbnail.thumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 5 with CancellableTask

use of com.android.quickstep.util.CancellableTask in project android_packages_apps_Launcher3 by AOSPA.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && cachedThumbnail.thumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Aggregations

CancellableTask (com.android.quickstep.util.CancellableTask)5 ThumbnailData (com.android.systemui.shared.recents.model.ThumbnailData)5