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

Commit 51290d7d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use safer casting asAppHeader() to prevent ClassCastException." into main

parents ef74fc97 59c72b32
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -111,14 +111,14 @@ import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;

import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.MainCoroutineDispatcher;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;

import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.MainCoroutineDispatcher;

/**
 * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
 * {@link DesktopModeWindowDecorViewModel}.
@@ -731,13 +731,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        } else {
            // App header is visible since `mWindowDecorViewHolder` is of type
            // [AppHeaderViewHolder].
            ((AppHeaderViewHolder) mWindowDecorViewHolder).runOnAppChipGlobalLayout(
            final AppHeaderViewHolder appHeader = asAppHeader(mWindowDecorViewHolder);
            if (appHeader != null) {
                appHeader.runOnAppChipGlobalLayout(
                        () -> {
                            notifyAppHeaderStateChanged();
                            return Unit.INSTANCE;
                        });
            }
        }
    }

    private boolean isCapturedLinkAvailable() {
        return mCapturedLink != null && !mCapturedLink.mUsed;
@@ -766,11 +769,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    }

    private void notifyAppHeaderStateChanged() {
        if (isAppHandle(mWindowDecorViewHolder) || mWindowDecorViewHolder == null) {
        final AppHeaderViewHolder appHeader = asAppHeader(mWindowDecorViewHolder);
        if (appHeader == null) {
            return;
        }
        final Rect appChipPositionInWindow =
                ((AppHeaderViewHolder) mWindowDecorViewHolder).getAppChipLocationInWindow();
        final Rect appChipPositionInWindow = appHeader.getAppChipLocationInWindow();
        final Rect taskBounds = mTaskInfo.configuration.windowConfiguration.getBounds();
        final Rect appChipGlobalPosition = new Rect(
                taskBounds.left + appChipPositionInWindow.left,