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

Commit 1d1e7db6 authored by Kirill Grouchnikov's avatar Kirill Grouchnikov
Browse files

@TestApi method to get display value for current selection

Bug: 28189574
Change-Id: Ic6b7554a95004c68a097f2d78cfe7d33c29afb46
parent 9a7fa83b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47234,6 +47234,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;