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

Commit c56db333 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Initialize ViewState member variable in constructor and make it final.

Bug: 119762423
Test: atest SystemUITests
Change-Id: I5f8c305f7aa68ba7ef4dcd5bf44e10613b54b38b
parent 6ad12e57
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -58,10 +57,11 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
    private ViewGroup mTransientContainer;
    private boolean mInShelf;
    private boolean mTransformingInShelf;
    @Nullable private ExpandableViewState mViewState;
    private final ExpandableViewState mViewState;

    public ExpandableView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mViewState = createExpandableViewState();
    }

    @Override
@@ -522,11 +522,6 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {

    /** Sets {@link ExpandableViewState} to default state. */
    public ExpandableViewState resetViewState() {
        // TODO(http://b/119762423): Move the null check to getViewState().
        if (mViewState == null) {
            mViewState = createExpandableViewState();
        }

        // initialize with the default values of the view
        mViewState.height = getIntrinsicHeight();
        mViewState.gone = getVisibility() == View.GONE;
@@ -559,9 +554,7 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {

    /** Applies internal {@link ExpandableViewState} to this view. */
    public void applyViewState() {
        if (mViewState == null) {
            Log.wtf(TAG, "No child state was found when applying this state to the hostView");
        } else if (!mViewState.gone) {
        if (!mViewState.gone) {
            mViewState.applyToView(this);
        }
    }