Search in sources :

Example 6 with NumberPicker

use of android.widget.NumberPicker in project wire-android by wireapp.

the class EphemeralLayout method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ContextThemeWrapper cw = new ContextThemeWrapper(getContext(), com.waz.zclient.ui.R.style.NumberPickerText);
    numberPicker = new NumberPicker(cw);
    numberPicker.setMinValue(0);
    final EphemeralExpiration[] ephemeralExpirationsValues = getAvailableEphemeralExpirations();
    numberPicker.setMaxValue(ephemeralExpirationsValues.length - 1);
    String[] values = new String[ephemeralExpirationsValues.length];
    for (int i = 0; i < values.length; i++) {
        values[i] = getDisplayName(ephemeralExpirationsValues[i]);
    }
    numberPicker.setDisplayedValues(values);
    numberPicker.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (callback != null) {
                callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], true);
            }
        }
    });
    numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {

        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            if (callback != null) {
                callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], false);
            }
        }
    });
    try {
        //NoSuchFieldException
        Field f = numberPicker.getClass().getDeclaredField("mSelectionDivider");
        f.setAccessible(true);
        f.set(numberPicker, getResources().getDrawable(com.waz.zclient.ui.R.drawable.number_picker_divider));
    } catch (Throwable t) {
        Timber.e(t, "Something went wrong");
    }
    addView(numberPicker);
}
Also used : NumberPicker(android.widget.NumberPicker) EphemeralExpiration(com.waz.api.EphemeralExpiration) View(android.view.View) Field(java.lang.reflect.Field) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper)

Example 7 with NumberPicker

use of android.widget.NumberPicker in project Talon-for-Twitter by klinker24.

the class ConfigurePagerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.menu_select_number_of_pages:
            final NumberPicker picker = new NumberPicker(context);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            picker.setLayoutParams(params);
            picker.setMaxValue(TimelinePagerAdapter.MAX_EXTRA_PAGES);
            picker.setMinValue(0);
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle(R.string.menu_number_of_pages);
            builder.setView(picker);
            builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    sharedPrefs.edit().putInt("number_of_extra_pages", picker.getValue()).commit();
                    dialog.dismiss();
                    recreate();
                }
            });
            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.create().show();
            return true;
        default:
            return true;
    }
}
Also used : AlertDialog(android.app.AlertDialog) NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) FrameLayout(android.widget.FrameLayout)

Example 8 with NumberPicker

use of android.widget.NumberPicker in project material-calendarview by prolificinteractive.

the class DynamicSettersActivity method onTileWidthHeightClicked.

@OnClick(R.id.button_set_width_height)
void onTileWidthHeightClicked() {
    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    final NumberPicker pickerWidth = new NumberPicker(this);
    pickerWidth.setMinValue(24);
    pickerWidth.setMaxValue(64);
    pickerWidth.setWrapSelectorWheel(false);
    pickerWidth.setValue(currentTileWidth);
    final NumberPicker pickerHeight = new NumberPicker(this);
    pickerHeight.setMinValue(24);
    pickerHeight.setMaxValue(64);
    pickerHeight.setWrapSelectorWheel(false);
    pickerHeight.setValue(currentTileHeight);
    layout.addView(pickerWidth);
    layout.addView(pickerHeight);
    new AlertDialog.Builder(this).setView(layout).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
            currentTileWidth = pickerWidth.getValue();
            currentTileHeight = pickerHeight.getValue();
            widget.setTileSize(-1);
            widget.setTileWidthDp(currentTileWidth);
            widget.setTileHeightDp(currentTileHeight);
        }
    }).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) NonNull(android.support.annotation.NonNull) LinearLayout(android.widget.LinearLayout) OnClick(butterknife.OnClick)

Example 9 with NumberPicker

use of android.widget.NumberPicker in project material-calendarview by prolificinteractive.

the class DynamicSettersActivity method onTileSizeClicked.

@OnClick(R.id.button_set_tile_size)
void onTileSizeClicked() {
    final NumberPicker view = new NumberPicker(this);
    view.setMinValue(24);
    view.setMaxValue(64);
    view.setWrapSelectorWheel(false);
    view.setValue(currentTileSize);
    new AlertDialog.Builder(this).setView(view).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
            currentTileSize = view.getValue();
            widget.setTileSizeDp(currentTileSize);
        }
    }).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) NonNull(android.support.annotation.NonNull) OnClick(butterknife.OnClick)

Aggregations

NumberPicker (android.widget.NumberPicker)9 DialogInterface (android.content.DialogInterface)5 NonNull (android.support.annotation.NonNull)4 AlertDialog (android.support.v7.app.AlertDialog)4 OnClick (butterknife.OnClick)4 View (android.view.View)3 TextView (android.widget.TextView)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 ComponentName (android.content.ComponentName)1 ContentProviderOperation (android.content.ContentProviderOperation)1 Context (android.content.Context)1 Intent (android.content.Intent)1 OperationApplicationException (android.content.OperationApplicationException)1 Bitmap (android.graphics.Bitmap)1 Color (android.graphics.Color)1 Drawable (android.graphics.drawable.Drawable)1 RemoteException (android.os.RemoteException)1