예제 #1
0
  private void np_initiate() {
    // TODO Auto-generated method stub
    np_T1 = (NumberPicker) findViewById(R.id.np_T1);
    String[] nums = new String[11];
    for (int i = 0; i < nums.length; i++) nums[i] = Integer.toString(i);

    np_T1.setMinValue(0);
    np_T1.setMaxValue(10);
    np_T1.setWrapSelectorWheel(false);
    np_T1.setDisplayedValues(nums);
    np_T1.setValue(0);

    np_T2 = (NumberPicker) findViewById(R.id.np_T2);

    np_T2.setMinValue(0);
    np_T2.setMaxValue(10);
    np_T2.setWrapSelectorWheel(false);
    np_T2.setDisplayedValues(nums);
    np_T2.setValue(0);

    np_T3 = (NumberPicker) findViewById(R.id.np_T3);

    np_T3.setMinValue(0);
    np_T3.setMaxValue(10);
    np_T3.setWrapSelectorWheel(false);
    np_T3.setDisplayedValues(nums);
    np_T3.setValue(0);
  }
예제 #2
0
  /*년도 최대값을 올해로 설정하게, 캘린더로 현재 연도 가져오기.*/
  public void birthDialog() {
    final Dialog d = new Dialog(BabyAddActivity.this);
    d.setTitle("생년월일");
    d.setContentView(R.layout.dialog_baby_add_birth);
    //                아마도 가로세로 크기 지정???????????????????????????????????
    //        d.getWindow().setLayout(디멘으로 값지정);

    final NumberPicker npY, npM, npD;

    npY = (NumberPicker) d.findViewById(R.id.numberPickerY);
    npY.setMaxValue(2015);
    npY.setMinValue(1900);
    npY.setValue(2000);
    npY.setWrapSelectorWheel(false);

    npM = (NumberPicker) d.findViewById(R.id.numberPickerM);
    npM.setMaxValue(12);
    npM.setMinValue(1);
    npM.setWrapSelectorWheel(false);

    npD = (NumberPicker) d.findViewById(R.id.numberPickerD);
    npD.setMaxValue(31);
    npD.setMinValue(1);
    npD.setWrapSelectorWheel(false);

    Button btn_ok;
    btn_ok = (Button) d.findViewById(R.id.btn_birth_ok);
    btn_ok.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // 한자리수 월 일 앞에 0 붙이기
            StringBuilder sb = new StringBuilder();
            String Y, M, D;
            Y = npY.getValue() + "";
            M = npM.getValue() + "";
            D = npD.getValue() + "";
            if (String.valueOf(npM.getValue()).length() == 1) {
              M = "0" + npM.getValue();
            }
            if (String.valueOf(npD.getValue()).length() == 1) {
              D = "0" + npD.getValue();
            }
            sb.append(Y);
            sb.append(M);
            sb.append(D);
            babyBirth_num = sb.toString(); // 서버로 보내는 값
            babyBirth.setText(
                String.valueOf(npY.getValue())
                    + " / "
                    + String.valueOf(npM.getValue())
                    + " / "
                    + String.valueOf(npD.getValue()));
            d.dismiss();
          }
        });

    d.show();
  }
 public void numberPickerSetup(NumberPicker currentNumberPicker, int setValue) {
   currentNumberPicker.setMaxValue(listOfNumbers.length - 1);
   currentNumberPicker.setMinValue(0);
   currentNumberPicker.setWrapSelectorWheel(false);
   currentNumberPicker.setValue(setValue + 1);
   currentNumberPicker.setDisplayedValues(listOfNumbers);
 }
  private void show(final String stdUser) {
    final Dialog d = new Dialog(ViewEnrolledStdUpdateScoreActivity.this);
    d.setTitle("NumberPicker");
    d.setContentView(R.layout.layout_number_picker);
    Button b1 = (Button) d.findViewById(R.id.button1);
    Button b2 = (Button) d.findViewById(R.id.button2);
    final NumberPicker np = (NumberPicker) d.findViewById(R.id.numberPicker1);
    np.setMaxValue(100); // max value 100
    np.setMinValue(0); // min value 0
    np.setWrapSelectorWheel(false);

    b1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            updateScore(stdUser, np.getValue());
            d.dismiss();
          }
        });

    b2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            d.dismiss(); // dismiss the dialog
          }
        });

    d.show();
  }
예제 #5
0
 @Override
 protected void onBindDialogView(View view) {
   super.onBindDialogView(view);
   picker.setMinValue(MIN_VALUE);
   picker.setMaxValue(MAX_VALUE);
   picker.setWrapSelectorWheel(WRAP_SELECTOR_WHEEL);
   picker.setValue(getValue());
 }
  private void loadUserHeight() {
    if (null != user.getHeight()) {
      String height[] = user.getHeight().split("-");
      heightFeet = Integer.parseInt(height[0]);
      heightInch = Integer.parseInt(height[1]);
    } else {
      heightFeet = Globals.DEFAULT_HEIGHT_FEET;
      heightInch = Globals.DEFAULT_HEIGHT_INCH;
    }

    pickerHeightFeet.setMinValue(Globals.MIN_HEIGHT_FEET);
    pickerHeightFeet.setMaxValue(Globals.MAX_HEIGHT_FEET);
    pickerHeightFeet.setValue(heightFeet);
    pickerHeightFeet.setWrapSelectorWheel(false);

    pickerHeightFeet.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });

    pickerHeightInch.setMinValue(Globals.MIN_HEIGHT_INCH);
    pickerHeightInch.setMaxValue(Globals.MAX_HEIGHT_INCH);
    pickerHeightInch.setValue(heightInch);
    pickerHeightInch.setWrapSelectorWheel(false);

    pickerHeightInch.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });
  }
 @Override
 protected void showDialog(Bundle state) {
   super.showDialog(state);
   User user = ((CompassApplication) getContext().getApplicationContext()).getUser();
   mValue = user.getDailyNotifications();
   Dialog dialog = getDialog();
   NumberPicker picker = (NumberPicker) dialog.findViewById(R.id.number_picker_picker);
   picker.setOnValueChangedListener(this);
   picker.setMinValue(0);
   picker.setMaxValue(20);
   picker.setValue(mValue);
   picker.setWrapSelectorWheel(false);
 }
예제 #8
0
  public void addListenerOnNumberPickerCapacity() {

    txtNumberViewCapacity = (TextView) findViewById(R.id.numberView);
    NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
    numberPicker.setMaxValue(MAX_VALUE);
    numberPicker.setMinValue(MIN_VALUE);
    numberPicker.setWrapSelectorWheel(true);
    numberPicker.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {
          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            txtNumberViewCapacity.setText("Capacidade: " + newVal);
            capacity = newVal;
          }
        });
  }
예제 #9
0
  static void SetSnoozePickerValues(NumberPicker picker, boolean above, int default_snooze) {
    String[] values = new String[snoozeValues.length];
    for (int i = 0; i < values.length; i++) {
      values[i] = getNameFromTime(snoozeValues[i]);
    }

    picker.setMaxValue(values.length - 1);
    picker.setMinValue(0);
    picker.setDisplayedValues(values);
    picker.setWrapSelectorWheel(false);
    if (default_snooze != 0) {
      picker.setValue(getSnoozeLocatoin(default_snooze));
    } else {
      picker.setValue(getSnoozeLocatoin(getDefaultSnooze(above)));
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    type = SET_SELECTION;
    prev = getArguments().getInt(Constants.TOTAL_PLAYERS_KEY, 8);
    next = Integer.MAX_VALUE;

    final Dialog dialog = new Dialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT);
    dialog.setTitle("Select Number of Total Players");
    dialog.setContentView(R.layout.dialog_number_picker);
    Button negative = (Button) dialog.findViewById(R.id.game_setup_dialog_negativebutton);
    Button positive = (Button) dialog.findViewById(R.id.game_setup_dialog_positivebutton);

    NumberPicker picker = (NumberPicker) dialog.findViewById(R.id.game_setup_dialog_numberpicker);

    picker.setMaxValue(10);
    picker.setMinValue(5);
    picker.setValue(prev);

    picker.setWrapSelectorWheel(false);
    picker.setOnValueChangedListener(this);
    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    negative.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            dialog.dismiss();
          }
        });

    positive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (prev > next) type = CLEAR_SELECTION;

            if (next == Integer.MAX_VALUE) next = prev;

            getPlotListener().onEventStart(type, next);

            dialog.dismiss();
          }
        });

    return dialog;
  }
예제 #11
0
  public DateTimePicker(Context context) {
    super(context);
    /*
     *獲取系統時間
     */
    mDate = Calendar.getInstance();
    mHour = mDate.get(Calendar.HOUR_OF_DAY);
    mMinute = mDate.get(Calendar.MINUTE);
    /** 加载布局 */
    inflate(context, R.layout.datadialog, this);
    /** 初始化控件 */
    mDateSpinner = (NumberPicker) this.findViewById(R.id.np_date);
    mDateSpinner.setMinValue(0);
    mDateSpinner.setMaxValue(6);
    updateDateControl();
    mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
    mHourSpinner = (NumberPicker) this.findViewById(R.id.np_hour);
    mHourSpinner.setMaxValue(23);
    mHourSpinner.setMinValue(0);
    mHourSpinner.setValue(mHour);
    mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
    mHourSpinner.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

    mMinuteSpinner = (NumberPicker) this.findViewById(R.id.np_minute);
    mMinuteSpinner.setMaxValue(59);
    mMinuteSpinner.setMinValue(0);
    mMinuteSpinner.setValue(mMinute);
    mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
    mMinuteSpinner.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
    mMinuteSpinner.setWrapSelectorWheel(true);

    FixScroller mScroller =
        new FixScroller(mDateSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mDateSpinner, mScroller);

    FixScroller mScroller1 =
        new FixScroller(mHourSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mHourSpinner, mScroller1);

    FixScroller mScroller2 =
        new FixScroller(mMinuteSpinner.getContext(), new DecelerateInterpolator());
    BaseUtil.setViewPagerScroller(mMinuteSpinner, mScroller2);
  }
  @Override
  protected void onPrepareDialogBuilder(final Builder builder) {
    super.onPrepareDialogBuilder(builder);

    mNumberPicker = new NumberPicker(this.getContext());
    mNumberPicker.setMinValue(mMinValue);
    mNumberPicker.setMaxValue(mMaxValue);
    mNumberPicker.setValue(mSelectedValue);
    mNumberPicker.setWrapSelectorWheel(mWrapSelectorWheel);
    mNumberPicker.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    final LinearLayout linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(mNumberPicker);

    builder.setView(linearLayout);
  }
  private void loadUserWeight() {
    weightLbs = user.getWeightLbs();
    if (weightLbs <= 0) {
      weightLbs = Globals.DEFAULT_WEIGHT_LBS;
    }

    pickerWeight.setMinValue(Globals.MIN_WEIGHT_LBS);
    pickerWeight.setMaxValue(Globals.MAX_WEIGHT_LBS);
    pickerWeight.setValue(weightLbs);
    pickerWeight.setWrapSelectorWheel(false);

    pickerWeight.setOnValueChangedListener(
        new NumberPicker.OnValueChangeListener() {

          @Override
          public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            isDataChanged = true;
            Log.v(
                Globals.TAG,
                "picker : " + picker + ", oldVal : " + oldVal + ", newVal : " + newVal);
          }
        });
  }
예제 #14
0
  private void updateSpinners() {
    boolean isLeapYear = false;
    int gregorianYear = mCurrentDate.get(Calendar.YEAR);
    int gregorianMonth = mCurrentDate.get(Calendar.MONTH) + 1;
    int gregorianDay = mCurrentDate.get(Calendar.DAY_OF_MONTH);
    int lunarDate[] =
        LunarUtil.calculateLunarByGregorian(gregorianYear, gregorianMonth, gregorianDay);
    int leapMonth = LunarUtil.leapMonth(lunarDate[0]);
    int monthIndexDisplay = lunarDate[1];
    String lunarDateString = LunarUtil.getLunarDateString(mCurrentDate);

    if (leapMonth == 0) {
      monthIndexDisplay--;
    } else if (monthIndexDisplay < leapMonth && leapMonth != 0) {
      monthIndexDisplay--;
    } else if ((monthIndexDisplay == leapMonth) && (!lunarDateString.contains("闰"))) {
      monthIndexDisplay--;
    }

    if (leapMonth != 0) {
      mNumberOfMonths = 13;
      isLeapYear = true;
    } else {
      mNumberOfMonths = 12;
    }

    int monthCountDays = LunarUtil.daysOfALunarMonth(lunarDate[0], lunarDate[1]);
    if ((leapMonth != 0) && (monthIndexDisplay == leapMonth) && (!lunarDateString.contains("闰"))) {
      monthCountDays = LunarUtil.daysOfLeapMonthInLunarYear(lunarDate[0]);
    }

    // set the spinner ranges respecting the min and max dates
    if (mCurrentDate.equals(mMinDate)) {
      mDaySpinner.setDisplayedValues(null);
      mDaySpinner.setMinValue(lunarDate[2]);
      mDaySpinner.setMaxValue(monthCountDays);
      mDaySpinner.setWrapSelectorWheel(false);
      mMonthSpinner.setDisplayedValues(null);
      mMonthSpinner.setMinValue(monthIndexDisplay);
      mMonthSpinner.setMaxValue(mNumberOfMonths - 1);
      mMonthSpinner.setWrapSelectorWheel(false);
    } else if (mCurrentDate.equals(mMaxDate)) {
      mDaySpinner.setDisplayedValues(null);
      mDaySpinner.setMinValue(1);
      mDaySpinner.setMaxValue(lunarDate[2]);
      mDaySpinner.setWrapSelectorWheel(false);
      mMonthSpinner.setDisplayedValues(null);
      mMonthSpinner.setMinValue(0);
      mMonthSpinner.setMaxValue(monthIndexDisplay);
      mMonthSpinner.setWrapSelectorWheel(false);
    } else {
      mDaySpinner.setDisplayedValues(null);
      mDaySpinner.setMinValue(1);
      mDaySpinner.setMaxValue(monthCountDays);
      mDaySpinner.setWrapSelectorWheel(true);
      mMonthSpinner.setDisplayedValues(null);
      mMonthSpinner.setMinValue(0);
      mMonthSpinner.setMaxValue(mNumberOfMonths - 1);
      mMonthSpinner.setWrapSelectorWheel(true);
    }

    String[] displayedMonths = new String[mNumberOfMonths];
    if (isLeapYear) {
      int i = 0;
      for (; i < leapMonth; i++) {
        displayedMonths[i] = mShortMonths[i];
      }
      displayedMonths[leapMonth] = "闰" + chineseNumber[leapMonth - 1];
      i++;
      for (; i < 13; i++) {
        displayedMonths[i] = mShortMonths[i - 1];
      }
    } else {
      displayedMonths =
          Arrays.copyOfRange(
              mShortMonths, mMonthSpinner.getMinValue(), mMonthSpinner.getMaxValue() + 1);
    }
    mMonthSpinner.setDisplayedValues(displayedMonths);

    int max = mDaySpinner.getMaxValue();
    int min = mDaySpinner.getMinValue();
    String[] displayedDays = new String[max - min + 1];
    LunarUtil lunar = new LunarUtil();

    for (int i = min; i <= max; i++) {
      displayedDays[i - min] = LunarUtil.chneseStringOfALunarDay(i);
    }
    mDaySpinner.setDisplayedValues(displayedDays);

    // year spinner range does not change based on the current date
    int minGregorianYear = mMinDate.get(Calendar.YEAR);
    int minGregorianMonth = mMinDate.get(Calendar.MONTH) + 1;
    int minGregorianDay = mMinDate.get(Calendar.DAY_OF_MONTH);
    int minLunarDate[] =
        LunarUtil.calculateLunarByGregorian(minGregorianYear, minGregorianMonth, minGregorianDay);

    int maxGregorianYear = mMaxDate.get(Calendar.YEAR);
    int maxGregorianMonth = mMaxDate.get(Calendar.MONTH) + 1;
    int maxGregorianDay = mMaxDate.get(Calendar.DAY_OF_MONTH);
    int maxLunarDate[] =
        LunarUtil.calculateLunarByGregorian(maxGregorianYear, maxGregorianMonth, maxGregorianMonth);

    mYearSpinner.setMinValue(minLunarDate[0]);
    mYearSpinner.setMaxValue(maxLunarDate[0]);
    mYearSpinner.setWrapSelectorWheel(false);

    mYearSpinner.setValue(lunarDate[0]);
    mMonthSpinner.setValue(monthIndexDisplay);
    mDaySpinner.setValue(lunarDate[2]);
  }
예제 #15
0
  @SuppressLint("NewApi")
  @Override
  protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
    // super.onPrepareDialogBuilder(builder);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      dialog = ((Activity) ctx).getLayoutInflater().inflate(R.layout.num_picker_pref_v10, null);
      final Button plus = (Button) dialog.findViewById(R.id.dialog_num_pick_plus);
      final Button minus = (Button) dialog.findViewById(R.id.dialog_num_pick_minus);
      tx = (TextView) dialog.findViewById(R.id.dialog_num_pick_val);
      updateV10Value();
      plus.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              if (VALUE < MAX_VAL) {
                ++VALUE;
                updateV10Value();
                updateSummary();
              }
            }
          });
      minus.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              if (VALUE > MIN_VAL) {
                --VALUE;
                updateV10Value();
                updateSummary();
              }
            }
          });
    } else {
      dialog = ((Activity) ctx).getLayoutInflater().inflate(R.layout.num_picker_pref, null);
      picker = (NumberPicker) dialog.findViewById(R.id.numberPicker);
      picker.setMaxValue(MAX_VAL);
      picker.setMinValue(MIN_VAL);
      picker.setValue(VALUE);
      picker.setWrapSelectorWheel(false);
      picker.setOnValueChangedListener(
          new OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
              VALUE = newVal;
              updateSummary();
            }
          });
    }
    updateSummary();
    builder.setPositiveButton(
        android.R.string.ok,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            callChangeListener(VALUE);
          }
        });
    builder.setNegativeButton(
        android.R.string.cancel,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // Nothing
          }
        });
    builder.setView(dialog);
  }
예제 #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bus_alarm);

    //	Creating the database for the application
    DatabaseHandler db = new DatabaseHandler(getApplicationContext());
    db.createDatabase();

    // Setting Alarm properties
    alarm = new AlarmManagerBroadcastReceiver();

    // set date picker as current date
    final Calendar calender = Calendar.getInstance();
    year = calender.get(Calendar.YEAR);
    month = calender.get(Calendar.MONTH);
    day = calender.get(Calendar.DAY_OF_MONTH);

    Format formatter = new SimpleDateFormat("MMM,dd yyyy");
    txtDate = (TextView) findViewById(R.id.txtDate);
    txtDate.setText("Date Selected: " + formatter.format((calender.getTime())));

    selectedDate = formatter.format(calender.getTime()).toString();
    schedulecal = new GregorianCalendar(year, month, day);

    btnSetAlarm = (Button) findViewById(R.id.btnSubmit);
    btnSetAlarm.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onetimeTimer();
          }
        });

    // Setting the Range of Number Picker Values
    setMinutes = (NumberPicker) findViewById(R.id.setMinutes);
    setMinutes.setMinValue(1);
    setMinutes.setMaxValue(60);
    setMinutes.setWrapSelectorWheel(false);
    addListenerOnNumberPicker();

    btnDatePicker = (Button) findViewById(R.id.btnDatePicker);
    btnDatePicker.setHorizontalFadingEdgeEnabled(true);
    addDatePickerListenerOnButton();

    spinnerRoute = (Spinner) findViewById(R.id.spinner_route);
    spinnerStreet = (Spinner) findViewById(R.id.spinner_street);
    spinnerTime = (Spinner) findViewById(R.id.spinner_time);

    loadSpinnerRoute();

    // Loading Route Spinner data
    spinnerRoute.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            route = spinnerRoute.getSelectedItem().toString();
            Log.d("OnItemSelected ", "selected route is " + route);
            loadSpinnerStreet(route);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

          }
        });

    // Loading Street Spinner data
    spinnerStreet.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            street = spinnerStreet.getSelectedItem().toString();
            Log.d("OnItemSelected ", "selected street is " + street);
            loadSpinnerTime(street, route);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

          }
        });

    // Loading Bus Timing spinner data
    spinnerTime.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            time = spinnerTime.getSelectedItem().toString();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
          }
        });
  }
예제 #17
0
  private void createDelayWithADistraction() {
    final Dialog d = new Dialog(MainActivity.this);
    d.setTitle(getResources().getString(R.string.delay_question));
    d.setContentView(R.layout.dialog_delay);
    Button setDelayButton = (Button) d.findViewById(R.id.button1);
    Button cancelDelayButton = (Button) d.findViewById(R.id.button2);
    final NumberPicker np = (NumberPicker) d.findViewById(R.id.numberPicker1);
    np.setMaxValue(45); // max value 45
    np.setMinValue(10); // min value 10
    np.setValue(prefs.getInt("delaySeconds", 20));
    np.setWrapSelectorWheel(false);
    np.setOnValueChangedListener(this);
    setDelayButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            d.dismiss();
            buttonStartTime.setVisibility(View.GONE);
            textViewShowTime.setVisibility(View.VISIBLE);
            showMinutes(false);
            mProgressBar
                .getBackground()
                .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
            mProgressBar
                .getProgressDrawable()
                .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
            mProgressBar.setMax(prefs.getInt("delaySeconds", 20));
            int delayInMilliseconds = (prefs.getInt("delaySeconds", 20)) * 1000;
            delayCountDown =
                new CountDownTimer(delayInMilliseconds, 500) {
                  @Override
                  public void onTick(long millisUntilFinished) {
                    long seconds = millisUntilFinished / 1000;
                    mProgressBar.setProgress((int) (millisUntilFinished / 1000));
                    textViewShowTime.setText(
                        String.format("%02d", seconds / 60)
                            + ":"
                            + String.format("%02d", seconds % 60));
                  }

                  @Override
                  public void onFinish() {
                    setTimer();
                    buttonStartTime.setVisibility(View.GONE);
                    textViewShowTime.setVisibility(View.VISIBLE);
                    startTimer();
                    // set volt buttons disabled
                    setButtonDisabled(false);
                    int volt = textViewToInt(volts);
                    increaseThread = increaseVoltToMax(volt);
                  }
                }.start();
          }
        });
    cancelDelayButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            d.dismiss(); // dismiss the dialog
            // Lets not start the timer here as the user might want to change the voltage.
          }
        });
    d.show();
  }
        @Override
        public void onClick(View view) {
          mInitialOrientation = -1;

          mNumberPicker = new NumberPicker(mContext);
          String[] names = new String[mResolutionsName.size()];
          mResolutionsName.toArray(names);
          if (names.length > 0) {
            mNumberPicker.setDisplayedValues(names);

            mNumberPicker.setMinValue(0);
            mNumberPicker.setMaxValue(names.length - 1);
          } else {
            mNumberPicker.setMinValue(0);
            mNumberPicker.setMaxValue(0);
          }
          mNumberPicker.setWrapSelectorWheel(false);
          mNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
          mNumberPicker.setFormatter(
              new NumberPicker.Formatter() {
                @Override
                public String format(int i) {
                  return mResolutionsName.get(i);
                }
              });

          if (CameraActivity.getCameraMode() == CameraActivity.CAMERA_MODE_VIDEO) {
            // TODO set correct menu selection also for video
            String actualSz = getActualProfileResolution();
            if (mVideoResolutions != null) {
              for (int i = 0; i < mVideoResolutions.size(); i++) {
                if (mVideoResolutions.get(i).equals(actualSz)) {
                  mNumberPicker.setValue(i);
                  break;
                }
              }
            }
          } else {
            Camera.Size actualSz = mCamManager.getParameters().getPictureSize();
            if (mResolutions != null) {
              for (int i = 0; i < mResolutions.size(); i++) {
                if (mResolutions.get(i).equals(actualSz)) {
                  mNumberPicker.setValue(i);
                  break;
                }
              }
            }
          }

          AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
          builder.setView(mNumberPicker);
          builder.setTitle(null);
          builder.setCancelable(false);
          builder.setPositiveButton(
              mContext.getString(R.string.ok),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                  mInitialOrientation = -1;

                  if (CameraActivity.getCameraMode() == CameraActivity.CAMERA_MODE_PHOTO
                      || CameraActivity.getCameraMode() == CameraActivity.CAMERA_MODE_PICSPHERE) {
                    // Set picture size
                    Camera.Size size = mResolutions.get(mNumberPicker.getValue());
                    // TODO: only one method
                    mCamManager.setPictureSize("" + size.width + "x" + size.height);

                    if (CameraActivity.getCameraMode() == CameraActivity.CAMERA_MODE_PHOTO) {
                      SettingsStorage.storeCameraSetting(
                          mContext,
                          mCamManager.getCurrentFacing(),
                          "picture-size",
                          "" + size.width + "x" + size.height);
                    } else {
                      SettingsStorage.storeCameraSetting(
                          mContext,
                          mCamManager.getCurrentFacing(),
                          "picsphere-picture-size",
                          "" + size.width + "x" + size.height);
                    }
                  } else if (CameraActivity.getCameraMode() == CameraActivity.CAMERA_MODE_VIDEO) {
                    // Set video size
                    String size = mVideoResolutions.get(mNumberPicker.getValue());
                    applyVideoResolution(size);

                    String[] splat = size.split("x");
                    int width = Integer.parseInt(splat[0]);
                    int height = Integer.parseInt(splat[1]);

                    SettingsStorage.storeCameraSetting(
                        mContext,
                        mCamManager.getCurrentFacing(),
                        "video-size",
                        "" + width + "x" + height);
                  }
                }
              });

          mResolutionDialog = builder.create();
          mResolutionDialog.show();
          ((ViewGroup) mNumberPicker.getParent().getParent().getParent())
              .animate()
              .rotation(mOrientation)
              .setDuration(300)
              .start();
        }