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

Commit fe03b40d authored by Winson Chung's avatar Winson Chung
Browse files

Adding additional null checks to prevent crash after task stack view callback...

Adding additional null checks to prevent crash after task stack view callback is reset. (Bug 18376798)

Change-Id: I46a324b3b6acba6b6519506ff2431d285e3b57f9
parent 99253d00
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -554,7 +554,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal

    /** Resets the focused task. */
    void resetFocusedTask() {
        if (mFocusedTaskIndex > -1) {
        if ((mStack != null) && (0 <= mFocusedTaskIndex) &&
                (mFocusedTaskIndex < mStack.getTaskCount())) {
            Task t = mStack.getTasks().get(mFocusedTaskIndex);
            TaskView tv = getChildViewForTask(t);
            tv.unsetFocusedTask();
+22 −8
Original line number Diff line number Diff line
@@ -469,8 +469,10 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
        startDeleteTaskAnimation(new Runnable() {
            @Override
            public void run() {
                if (mCb != null) {
                    mCb.onTaskViewDismissed(tv);
                }
            }
        });
    }

@@ -486,9 +488,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
    void setClipViewInStack(boolean clip) {
        if (clip != mClipViewInStack) {
            mClipViewInStack = clip;
            if (mCb != null) {
                mCb.onTaskViewClipStateChanged(this);
            }
        }
    }

    /** Sets the current task progress. */
    public void setTaskProgress(float p) {
@@ -570,7 +574,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
        // Update the thumbnail alpha with the focus
        mThumbnailView.onFocusChanged(true);
        // Call the callback
        if (mCb != null) {
            mCb.onTaskViewFocusChanged(this, true);
        }
        // Workaround, we don't always want it focusable in touch mode, but we want the first task
        // to be focused after the enter-recents animation, which can be triggered from either touch
        // or keyboard
@@ -593,7 +599,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
        // Update the thumbnail alpha with the focus
        mThumbnailView.onFocusChanged(false);
        // Call the callback
        if (mCb != null) {
            mCb.onTaskViewFocusChanged(this, false);
        }
        invalidate();
    }

@@ -694,7 +702,9 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
                @Override
                public void run() {
                    if (Constants.DebugFlags.App.EnableTaskFiltering && v == mHeaderView.mApplicationIcon) {
                        if (mCb != null) {
                            mCb.onTaskViewAppIconClicked(tv);
                        }
                    } else if (v == mHeaderView.mDismissButton) {
                        dismissTask();
                    }
@@ -705,18 +715,22 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
                // Reset the translation of the action button before we animate it out
                mActionButtonView.setTranslationZ(0f);
            }
            if (mCb != null) {
                mCb.onTaskViewClicked(tv, tv.getTask(), (v == mActionButtonView));
            }
        }
    }

    /**** View.OnLongClickListener Implementation ****/

    @Override
    public boolean onLongClick(View v) {
        if (v == mHeaderView.mApplicationIcon) {
            if (mCb != null) {
                mCb.onTaskViewAppInfoClicked(this);
                return true;
            }
        }
        return false;
    }
}