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

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

Merge "Reduce cost of FooterView#showHistory"

parents 72d07fb8 d9b18355
Loading
Loading
Loading
Loading
+25 −7
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ public class FooterView extends StackScrollerDecorView {
    private FooterViewButton mClearAllButton;
    private FooterViewButton mManageButton;
    private boolean mShowHistory;
    // String cache, for performance reasons.
    // Reading them from a Resources object can be quite slow sometimes.
    private String mManageNotificationText;
    private String mManageNotificationHistoryText;

    public FooterView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -68,6 +72,8 @@ public class FooterView extends StackScrollerDecorView {
        super.onFinishInflate();
        mClearAllButton = (FooterViewButton) findSecondaryView();
        mManageButton = findViewById(R.id.manage_text);
        updateResources();
        updateText();
    }

    public void setManageButtonClickListener(OnClickListener listener) {
@@ -86,15 +92,20 @@ public class FooterView extends StackScrollerDecorView {
    }

    public void showHistory(boolean showHistory) {
        if (mShowHistory == showHistory) {
            return;
        }
        mShowHistory = showHistory;
        updateText();
    }

    private void updateText() {
        if (mShowHistory) {
            mManageButton.setText(R.string.manage_notifications_history_text);
            mManageButton.setContentDescription(
                    mContext.getString(R.string.manage_notifications_history_text));
            mManageButton.setText(mManageNotificationHistoryText);
            mManageButton.setContentDescription(mManageNotificationHistoryText);
        } else {
            mManageButton.setText(R.string.manage_notifications_text);
            mManageButton.setContentDescription(
                    mContext.getString(R.string.manage_notifications_text));
            mManageButton.setText(mManageNotificationText);
            mManageButton.setContentDescription(mManageNotificationText);
        }
    }

@@ -109,7 +120,8 @@ public class FooterView extends StackScrollerDecorView {
        mClearAllButton.setText(R.string.clear_all_notifications_text);
        mClearAllButton.setContentDescription(
                mContext.getString(R.string.accessibility_clear_all));
        showHistory(mShowHistory);
        updateResources();
        updateText();
    }

    /**
@@ -124,6 +136,12 @@ public class FooterView extends StackScrollerDecorView {
        mManageButton.setTextColor(textColor);
    }

    private void updateResources() {
        mManageNotificationText = getContext().getString(R.string.manage_notifications_text);
        mManageNotificationHistoryText = getContext()
                .getString(R.string.manage_notifications_history_text);
    }

    @Override
    public ExpandableViewState createExpandableViewState() {
        return new FooterViewState();