Java Code Examples for android.widget.NumberPicker#setDescendantFocusability()

The following examples show how to use android.widget.NumberPicker#setDescendantFocusability() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumericDayPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void doContentSection() {
    int maxDaysToShow = 7;

    String[] days = new String[maxDaysToShow];

    //1-7 day(s) picker
    for (int dayNumber = 1; dayNumber < maxDaysToShow+1 ; dayNumber++) {
        int arrayNumber = dayNumber-1;
        if(dayNumber>1) days[arrayNumber] = (dayNumber)+" Days";
        else days[arrayNumber] = (dayNumber)+" Day";
    }
    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);
}
 
Example 2
Source File: LocationPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override @SuppressWarnings({"unchecked"})
public void doContentSection() {
    if (getArguments() != null) {
        Serializable object = getArguments().getSerializable(LOCATIONS);
        if (object != null) {
            locations = (ArrayList<String>) object;
        }
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setVisibility(View.GONE);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);

    String[] displayedValues = new String[locations.size()];
    for (int i = 0; i < locations.size(); i++) {
        displayedValues[i] = locations.get(i);
    }

    picker.setMaxValue(displayedValues.length - 1);
    picker.setDisplayedValues(displayedValues);
    picker.setVisibility(View.VISIBLE);
}
 
Example 3
Source File: TimezonePickerPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override public void doContentSection() {
    timezones = getTimezones();
    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setVisibility(View.GONE);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);

    String[] displayedValues = new String[timezones.size()];
    for (int i = 0; i < timezones.size(); i++) {
        displayedValues[i] = timezones.get(i).getName();
    }

    picker.setMaxValue(displayedValues.length - 1);
    picker.setDisplayedValues(displayedValues);
    picker.setValue(getIndexOfCurrentZoneOrDefault(0));
    picker.setVisibility(View.VISIBLE);

    Bundle args = getArguments();
    if (args == null) {
        forceNotification = false;
    } else {
        forceNotification = args.getBoolean(FORCE_NOTIFICATION, false);
    }
}
 
Example 4
Source File: WeeklyIntervalPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    int maxDaysToShow = 7;

    String[] days = new String[maxDaysToShow];

    for (int i = 0; i < maxDaysToShow; i++) {
        if (i > 1) {
            days[i] = headerDateFormat.format(current.getTime());
        }
        else {
            days[i] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);
}
 
Example 5
Source File: FormatPickerDialog.java    From Android-Webcam with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    setCancelable(false);

    numberPicker = (NumberPicker) getDialog().findViewById(R.id.number_picker);
    numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    numberPicker.setDisplayedValues(values);
    numberPicker.setMinValue(getMinimumValue());
    numberPicker.setMaxValue(getMaximumValue());
    numberPicker.setValue(getInitialValue());
    numberPicker.setWrapSelectorWheel(false);
    numberPicker.setOnValueChangedListener(new OnValueChangeListener() {
        @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            currentIndex = newVal;
        }
    });
}
 
Example 6
Source File: OddDaysPopup.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    String[] days = new String[7];
    int j=0;
    int i=0;
    do {
        if ( (current.get(Calendar.DAY_OF_MONTH) & 1) == 0 ) {
            i++;
        } else {
            if (i > 1) {
                days[j] = headerDateFormat.format(current.getTime());
            }
            else {
                days[j] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
            }
            j++;
            i++;
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    } while(i<14);

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(6);
    picker.setDisplayedValues(days);
}
 
Example 7
Source File: EvenDaysPopup.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    String[] days = new String[7];
    int j=0;
    int i=0;
    do {
        if ( (current.get(Calendar.DAY_OF_MONTH) & 1) == 0 ) {
            if (i > 1) {
                days[j] = headerDateFormat.format(current.getTime());
            }
            else {
                days[j] = i == 0 ? getString(R.string.today) : getString(R.string.tomorrow);
            }
            j++;
            i++;
        } else {
            i++;
        }
        current.add(Calendar.DAY_OF_MONTH, 1);
    } while(i<14);

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(6);
    picker.setDisplayedValues(days);
}
 
Example 8
Source File: DayPickerPopup.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void doContentSection() {
    Calendar current = Calendar.getInstance();
    int DEFAULT_MAX_DAYS_TO_SHOW = 14;
    int maxDaysToShow = getNonNullArguments().getInt(MAX_DAYS, DEFAULT_MAX_DAYS_TO_SHOW);
    int dayAddOrSubtract = getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? -1 : 1;
    String yesterdayTomorrowText = getString(getNonNullArguments().getBoolean(DAYS_GOING_BACKWARDS, true) ? R.string.yesterday : R.string.tomorrow);

    String[] days = new String[maxDaysToShow];

    for (int i = 0; i < maxDaysToShow; i++) {
        if (i > 1) {
            days[i] = headerDateFormat.format(current.getTime());
        }
        else {
            days[i] = i == 0 ? getString(R.string.today) : yesterdayTomorrowText;
        }
        current.add(Calendar.DAY_OF_MONTH, dayAddOrSubtract);
    }

    picker = (NumberPicker) contentView.findViewById(R.id.floating_day_number_picker);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    picker.setMinValue(0);
    picker.setMaxValue(maxDaysToShow - 1);
    picker.setDisplayedValues(days);

    View divider = contentView.findViewById(R.id.picker_title_divider);
    if (divider != null) {
        divider.setVisibility(View.VISIBLE);
    }
}
 
Example 9
Source File: DynamicGridSizeFragment.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
private void showNumberPicker() {
    mDialog = new Dialog(getActivity());
    mDialog.setTitle(getResources().getString(
            R.string.preferences_interface_homescreen_custom));
    mDialog.setContentView(R.layout.custom_grid_size_dialog);

    NumberPicker nPRows = (NumberPicker) mDialog.findViewById(R.id.custom_rows);
    NumberPicker nPColumns = (NumberPicker) mDialog.findViewById(R.id.custom_columns);

    InvariantDeviceProfile grid = getInvariantDeviceProfile();
    int rows = grid.numRowsBase;
    int columns = grid.numColumnsBase;

    nPRows.setMinValue(Math.max(MIN_DYNAMIC_GRID_ROWS, rows - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPRows.setMaxValue(rows + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPRows.setValue(mCustomGridRows);
    nPRows.setWrapSelectorWheel(false);
    nPRows.setOnValueChangedListener(this);
    nPRows.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS,
            columns - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPColumns.setMaxValue(columns + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPColumns.setValue(mCustomGridColumns);
    nPColumns.setWrapSelectorWheel(false);
    nPColumns.setOnValueChangedListener(this);
    nPColumns.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    Button button = (Button) mDialog.findViewById(R.id.dialog_confirm_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mDialog != null) {
                mDialog.dismiss();
            }
        }
    });

    mDialog.setOnDismissListener(this);
    mDialog.show();
}
 
Example 10
Source File: NumberPickerPreference.java    From CrimeTalk-Reader with Apache License 2.0 2 votes vote down vote up
@Override
@SuppressLint("InflateParams")
protected View onCreateDialogView() {

    final LayoutInflater layoutInflater = (LayoutInflater)
            getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View view = layoutInflater.inflate(R.layout.preference_numberpicker, null);

    mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

    mNumberPicker.setMaxValue(25);
    mNumberPicker.setMinValue(5);
    mNumberPicker.setValue(getPersistedInt(10));
    mNumberPicker.setWrapSelectorWheel(false);
    mNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    // There's a bug in the text color, correct it manually
    if (mNumberPicker.getChildCount() >= 1) {

        final View childView = mNumberPicker.getChildAt(1);

        if (childView != null && childView instanceof TextView) {

            if (PreferenceUtils.getDarkTheme(getContext())) {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.white));

            } else {

                ((TextView) childView).setTextColor(getContext().getResources().getColor(R.color.black));

            }

        }

    }

    return view;

}