List of usage examples for android.widget NumberPicker setWrapSelectorWheel
public void setWrapSelectorWheel(boolean wrapSelectorWheel)
From source file:com.untie.daywal.activity.MainActivity.java
private void showDayPicker() { Calendar calender = Calendar.getInstance(); pickedYear = calender.get(Calendar.YEAR); pickedMonth = calender.get(Calendar.MONTH) + 1; final Dialog dayPickerDialog = new Dialog(this); dayPickerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dayPickerDialog.setContentView(R.layout.dialog); Button okBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_ok); Button cancelBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_cancel); dialog_year_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_year_title); dialog_month_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_month_title); final NumberPicker yearPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.yearPicker); final NumberPicker monthPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.monthPicker); dialog_year_title.setText(String.valueOf(pickedYear) + ""); dialog_month_title.setText(String.valueOf(pickedMonth) + ""); yearPicker.setMinValue(pickedYear - 100); yearPicker.setMaxValue(pickedYear + 40); yearPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); // setDividerColor(yearPicker, android.R.color.white ); yearPicker.setWrapSelectorWheel(false); yearPicker.setValue(pickedYear);/*from w w w. j a va2 s. c om*/ yearPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { dialog_year_title.setText(String.valueOf(newVal) + ""); } }); monthPicker.setMinValue(1); monthPicker.setMaxValue(12); monthPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); // setDividerColor(monthPicker, android.R.color.white); //monthPicker.setWrapSelectorWheel(false); monthPicker.setValue(pickedMonth); monthPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { dialog_month_title.setText(String.valueOf(newVal) + ""); } }); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO : ?? yearPicker.getValue() monthPicker.getValue() //Toast.makeText(MainActivity.this, String.valueOf(yearPicker.getValue())+"/"+monthPicker.getValue(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, MainActivity.class); intent.putExtra("year", yearPicker.getValue()); intent.putExtra("month", monthPicker.getValue()); intent.putExtra("order", 1); dayPickerDialog.dismiss(); startActivity(intent); overridePendingTransition(0, 0); } }); cancelBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dayPickerDialog.dismiss(); } }); dayPickerDialog.show(); }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawQuickSilenceWidget() { LinearLayout quicksilenceBox = (LinearLayout) rootView .findViewById(R.id.advanced_settings_quicksilence_box); quicksilenceBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2 s.c o m*/ public void onClick(View v) { LayoutInflater inflater = LayoutInflater.from(v.getContext()); View dialogView = inflater.inflate(R.layout.dialog_quicksilent, null); final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, R.style.Dialog)); builder.setTitle(R.string.notification_quicksilence_title); builder.setView(dialogView); final NumberPicker hourP = (NumberPicker) dialogView.findViewById(R.id.hourPicker); final NumberPicker minP = (NumberPicker) dialogView.findViewById(R.id.minutePicker); String[] hours = new String[25]; String[] minutes = new String[59]; for (int i = 0; i < hours.length; i++) { hours[i] = Integer.toString(i); } int i = 0; while (i < minutes.length) { minutes[i] = Integer.toString(++i); } hourP.setMinValue(1); hourP.setMaxValue(hours.length - 1); hourP.setWrapSelectorWheel(false); hourP.setDisplayedValues(hours); hourP.setValue(prefs.getQuickSilenceHours() + 1); minP.setMinValue(1); minP.setMaxValue(minutes.length - 1); minP.setWrapSelectorWheel(false); minP.setDisplayedValues(minutes); minP.setValue(prefs.getQuicksilenceMinutes()); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { prefs.setQuickSilenceHours(hourP.getValue() - 1); prefs.setQuicksilenceMinutes(minP.getValue()); drawQuickSilenceWidget(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //do nothing } }); AlertDialog dialog = builder.show(); } }); //the quick silence button TextView quickTV = (TextView) rootView.findViewById(R.id.quickSilenceDescription); String quicksilenceText = getResources() .getString(R.string.advanced_settings_section_interval_quicksilence_duration); String hrs = ""; if (prefs.getQuickSilenceHours() > 0) { hrs = String.valueOf(prefs.getQuickSilenceHours()) + " " + getString(R.string.hours_lower) + " "; } quickTV.setText(String.format(quicksilenceText, hrs, prefs.getQuicksilenceMinutes())); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
public void TimeLapseDialog() { if (isRecording) return;/*from ww w . ja va2 s . c o m*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); interval = Integer.valueOf(prefs.getString("timelapseInterval", "0")); measurementVal = Integer.valueOf(prefs.getString("timelapseMeasurementVal", "0")); // show time lapse settings timeLapseDialog = new TimeLapseDialog(ApplicationScreen.instance); timeLapseDialog.setContentView(R.layout.plugin_capture_video_timelapse_dialog); final NumberPicker np = (NumberPicker) timeLapseDialog.findViewById(R.id.numberPicker1); np.setMaxValue(16); np.setMinValue(0); np.setValue(interval); np.setDisplayedValues(stringInterval); np.setWrapSelectorWheel(false); np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); final NumberPicker np2 = (NumberPicker) timeLapseDialog.findViewById(R.id.numberPicker2); np2.setMaxValue(2); np2.setMinValue(0); np2.setValue(measurementVal); np2.setWrapSelectorWheel(false); np2.setDisplayedValues(stringMeasurement); np2.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); final Switch sw = (Switch) timeLapseDialog.findViewById(R.id.timelapse_switcher); // disable/enable controls in dialog sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!sw.isChecked()) { swChecked = false; } else { swChecked = true; } } }); np2.setOnScrollListener(new NumberPicker.OnScrollListener() { @Override public void onScrollStateChange(NumberPicker numberPicker, int scrollState) { sw.setChecked(true); } }); np.setOnScrollListener(new NumberPicker.OnScrollListener() { @Override public void onScrollStateChange(NumberPicker numberPicker, int scrollState) { sw.setChecked(true); } }); // disable control in dialog by default if (!swChecked) { sw.setChecked(false); } else { sw.setChecked(true); } timeLapseDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (swChecked) { measurementVal = np2.getValue(); interval = np.getValue(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(ApplicationScreen.getMainContext()); Editor editor = prefs.edit(); editor.putString("timelapseMeasurementVal", String.valueOf(measurementVal)); editor.putString("timelapseInterval", String.valueOf(interval)); editor.commit(); timeLapseButton.setImageDrawable(ApplicationScreen.getAppResources() .getDrawable(R.drawable.plugin_capture_video_timelapse_active)); ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START); } else { timeLapseButton.setImageDrawable(ApplicationScreen.getAppResources() .getDrawable(R.drawable.plugin_capture_video_timelapse_inactive)); ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START); } } }); timeLapseDialog.show(); }
From source file:com.b44t.ui.PasscodeActivity.java
@Override public View createView(Context context) { actionBar// w w w . j a v a 2 s . co m .setBackButtonImage(screen == SCREEN0_SETTINGS ? R.drawable.ic_ab_back : R.drawable.ic_close_white); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } else if (id == pin_item) { currentPasswordType = 0; updateDropDownTextView(); } else if (id == password_item) { currentPasswordType = 1; updateDropDownTextView(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; if (screen != SCREEN0_SETTINGS) { ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); titleTextView = new TextView(context); titleTextView.setTextColor(0xff757575); if (screen == SCREEN1_ENTER_CODE1) { if (UserConfig.passcodeHash.length() != 0) { titleTextView .setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode)); } else { titleTextView.setText( LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode)); } } else { titleTextView .setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode)); } titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); if (screen == SCREEN1_ENTER_CODE1) { passcodeSetStep = 0; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } else { passcodeSetStep = 1; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); } passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); frameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(90); layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (passcodeSetStep == 0) { processNext(); return true; } else if (passcodeSetStep == 1) { processDone(); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4) { if (screen == SCREEN2_ENTER_CODE2 && UserConfig.passcodeType == 0) { processDone(); } else if (screen == SCREEN1_ENTER_CODE1 && currentPasswordType == 0) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); if (screen == SCREEN1_ENTER_CODE1) { dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; dropDownContainer.setLayoutParams(layoutParams); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dropDownContainer.toggleSubMenu(); } }); dropDown = new TextView(context); dropDown.setGravity(Gravity.LEFT); dropDown.setSingleLine(true); dropDown.setLines(1); dropDown.setMaxLines(1); dropDown.setEllipsize(TextUtils.TruncateAt.END); dropDown.setTextColor(0xffffffff); dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); dropDown.setLayoutParams(layoutParams); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); } updateDropDownTextView(); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); frameLayout.setBackgroundColor(0xfff0f0f0); listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == changePasscodeRow) { presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1)); } else if (i == passcodeOnOffRow) { TextCheckCell cell = (TextCheckCell) view; if (UserConfig.passcodeHash.length() != 0) { UserConfig.passcodeHash = ""; UserConfig.appLocked = false; UserConfig.saveConfig(false); int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) child; textCell.setTextColor(0xffc6c6c6); break; } } cell.setChecked(UserConfig.passcodeHash.length() != 0); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.didSetPasscode); } else { presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1)); } } else if (i == autoLockRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(0); numberPicker.setMaxValue(4); if (UserConfig.autoLockIn == 0) { numberPicker.setValue(0); } else if (UserConfig.autoLockIn == 60) { numberPicker.setValue(1); } else if (UserConfig.autoLockIn == 60 * 5) { numberPicker.setValue(2); } else if (UserConfig.autoLockIn == 60 * 60) { numberPicker.setValue(3); } else if (UserConfig.autoLockIn == 60 * 60 * 5) { numberPicker.setValue(4); } numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { if (value == 0) { return LocaleController.getString("Disabled", R.string.Disabled); } else if (value == 1) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Minutes, 1, 1); } else if (value == 2) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Minutes, 5, 5); } else if (value == 3) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Hours, 1, 1); } else if (value == 4) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Hours, 5, 5); } return ""; } }); numberPicker.setWrapSelectorWheel(false); builder.setView(numberPicker); builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which = numberPicker.getValue(); if (which == 0) { UserConfig.autoLockIn = 0; } else if (which == 1) { UserConfig.autoLockIn = 60; } else if (which == 2) { UserConfig.autoLockIn = 60 * 5; } else if (which == 3) { UserConfig.autoLockIn = 60 * 60; } else if (which == 4) { UserConfig.autoLockIn = 60 * 60 * 5; } listView.invalidateViews(); UserConfig.saveConfig(false); } }); showDialog(builder.create()); } else if (i == fingerprintRow) { UserConfig.useFingerprint = !UserConfig.useFingerprint; UserConfig.saveConfig(false); ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); } return fragmentView; }