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

Commit c17c3876 authored by Kirill Grouchnikov's avatar Kirill Grouchnikov Committed by Android (Google) Code Review
Browse files

Merge "@TestApi method to get display value for current selection"

parents c6491789 1d1e7db6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47203,6 +47203,7 @@ package android.widget {
    ctor public NumberPicker(android.content.Context, android.util.AttributeSet);
    ctor public NumberPicker(android.content.Context, android.util.AttributeSet, int);
    ctor public NumberPicker(android.content.Context, android.util.AttributeSet, int, int);
    method public java.lang.CharSequence getDisplayedValueForCurrentSelection();
    method public java.lang.String[] getDisplayedValues();
    method public int getMaxValue();
    method public int getMinValue();
+17 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.widget;

import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.TestApi;
import android.annotation.Widget;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -1507,6 +1508,22 @@ public class NumberPicker extends LinearLayout {
        tryComputeMaxWidth();
    }

    /**
     * Retrieves the displayed value for the current selection in this picker.
     *
     * @hide
     */
    @TestApi
    public CharSequence getDisplayedValueForCurrentSelection() {
        // The cache field itself is initialized at declaration time, and since it's final, it
        // can't be null here. The cache is updated in ensureCachedScrollSelectorValue which is
        // called, directly or indirectly, on every call to setDisplayedValues, setFormatter,
        // setMinValue, setMaxValue and setValue, as well as user-driven interaction with the
        // picker. As such, the contents of the cache are always synced to the latest state of
        // the widget.
        return mSelectorIndexToStringCache.get(getValue());
    }

    @Override
    protected float getTopFadingEdgeStrength() {
        return TOP_AND_BOTTOM_FADING_EDGE_STRENGTH;