List of usage examples for android.widget SeekBar setOnSeekBarChangeListener
public void setOnSeekBarChangeListener(OnSeekBarChangeListener l)
From source file:org.noise_planet.noisecapture.CommentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comment); View mainView = findViewById(R.id.mainLayout); if (mainView != null) { mainView.setOnTouchListener(new MainOnTouchListener(this)); }//www . ja v a 2 s . c om // Read record activity parameter // Use last record of no parameter provided this.measurementManager = new MeasurementManager(this); Intent intent = getIntent(); // Read the last stored record List<Storage.Record> recordList = measurementManager.getRecords(); if (intent != null && intent.hasExtra(COMMENT_RECORD_ID)) { record = measurementManager.getRecord(intent.getIntExtra(COMMENT_RECORD_ID, -1)); } else { if (!recordList.isEmpty()) { record = recordList.get(0); } else { // Message for starting a record Toast.makeText(getApplicationContext(), getString(R.string.no_results), Toast.LENGTH_LONG).show(); return; } } if (record != null) { View addPhoto = findViewById(R.id.btn_add_photo); addPhoto.setOnClickListener(new OnAddPhotoClickListener(this)); View resultsBtn = findViewById(R.id.resultsBtn); resultsBtn.setOnClickListener(new OnGoToResultPage(this)); View deleteBts = findViewById(R.id.deleteBtn); deleteBts.setOnClickListener(new OnDeleteMeasurement(this)); TextView noisePartyTag = (TextView) findViewById(R.id.edit_noiseparty_tag); noisePartyTag.setEnabled(record.getUploadId().isEmpty()); noisePartyTag.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // [^A-Za-z0-9_] StringBuilder stringBuilder = new StringBuilder(); for (int i = start; i < end; i++) { char c = source.charAt(i); if (Character.isLetterOrDigit(c) || c == '_') { stringBuilder.append(c); } } // keep original if unchanged or return swapped chars boolean modified = (stringBuilder.length() == end - start); return modified ? null : stringBuilder.toString(); } } }); if (record.getNoisePartyTag() == null) { // Read last stored NoiseParty id for (Storage.Record recordItem : recordList) { if (recordItem.getId() != record.getId()) { if (recordItem.getNoisePartyTag() != null) { noisePartyTag.setText(recordItem.getNoisePartyTag()); } break; } } } else { noisePartyTag.setText(record.getNoisePartyTag()); } } initDrawer(record != null ? record.getId() : null); SeekBar seekBar = (SeekBar) findViewById(R.id.pleasantness_slider); // Load stored user comment // Pleasantness and tags are read only if the record has been uploaded Map<String, Storage.TagInfo> tagToIndex = new HashMap<>(Storage.TAGS_INFO.length); for (Storage.TagInfo sysTag : Storage.TAGS_INFO) { tagToIndex.put(sysTag.name, sysTag); } View thumbnail = findViewById(R.id.image_thumbnail); thumbnail.setOnClickListener(new OnImageClickListener(this)); if (record != null) { // Load selected tags for (String sysTag : measurementManager.getTags(record.getId())) { Storage.TagInfo tagInfo = tagToIndex.get(sysTag); if (tagInfo != null) { checkedTags.add(tagInfo.id); } } // Load description if (record.getDescription() != null) { TextView description = (TextView) findViewById(R.id.edit_description); description.setText(record.getDescription()); } Integer pleasantness = record.getPleasantness(); if (pleasantness != null) { seekBar.setProgress((int) (Math.round((pleasantness / 100.0) * seekBar.getMax()))); seekBar.setThumb( seekBar.getResources().getDrawable(R.drawable.seekguess_scrubber_control_normal_holo)); userInputSeekBar.set(true); } else { seekBar.setThumb( seekBar.getResources().getDrawable(R.drawable.seekguess_scrubber_control_disabled_holo)); } photo_uri = record.getPhotoUri(); // User can only update not uploaded data seekBar.setEnabled(record.getUploadId().isEmpty()); } else { // Message for starting a record Toast.makeText(getApplicationContext(), getString(R.string.no_results), Toast.LENGTH_LONG).show(); } thumbnailImageLayoutDoneObserver = new OnThumbnailImageLayoutDoneObserver(this); thumbnail.getViewTreeObserver().addOnGlobalLayoutListener(thumbnailImageLayoutDoneObserver); seekBar.setOnSeekBarChangeListener(new OnSeekBarUserInput(userInputSeekBar)); // Fill tags grid Resources r = getResources(); String[] tags = r.getStringArray(R.array.tags); // Append tags items for (Storage.TagInfo tagInfo : Storage.TAGS_INFO) { ViewGroup tagContainer = (ViewGroup) findViewById(tagInfo.location); if (tagContainer != null && tagInfo.id < tags.length) { addTag(tags[tagInfo.id], tagInfo.id, tagContainer, tagInfo.color != -1 ? r.getColor(tagInfo.color) : -1); } } }
From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java
/** * ??//from w w w . j av a 2 s .co m * @param root */ private void initConfigFlight(final View root) { mMaxAltitudeFormat = getString(R.string.config_max_altitude); mMaxTiltFormat = getString(R.string.config_max_tilt); mMaxVerticalSpeedFormat = getString(R.string.config_max_vertical_speed); mMaxRotationSpeedFormat = getString(R.string.config_max_rotating_speed); // mMaxAltitudeLabel = (TextView) root.findViewById(R.id.max_altitude_textview); SeekBar seekbar = (SeekBar) root.findViewById(R.id.max_altitude_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxAltitude = mFlightController.getMaxAltitude(); try { seekbar.setProgress((int) ((mMaxAltitude.current() - mMaxAltitude.min()) / (mMaxAltitude.max() - mMaxAltitude.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxAltitude(mMaxAltitude.current()); // // bebop?5-3050km/hr???13.9m/s/300.46[m/s/] mMaxTiltLabel = (TextView) root.findViewById(R.id.max_tilt_textview); seekbar = (SeekBar) root.findViewById(R.id.max_tilt_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxTilt = mFlightController.getMaxTilt(); try { seekbar.setProgress( (int) ((mMaxTilt.current() - mMaxTilt.min()) / (mMaxTilt.max() - mMaxTilt.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxTilt(mMaxTilt.current()); // /?, Bebop2?6m/s mMaxVerticalSpeedLabel = (TextView) root.findViewById(R.id.max_vertical_speed_textview); seekbar = (SeekBar) root.findViewById(R.id.max_vertical_speed_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxVerticalSpeed = mFlightController.getMaxVerticalSpeed(); try { seekbar.setProgress((int) ((mMaxVerticalSpeed.current() - mMaxVerticalSpeed.min()) / (mMaxVerticalSpeed.max() - mMaxVerticalSpeed.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxVerticalSpeed(mMaxVerticalSpeed.current()); // mMaxRotationSpeedLabel = (TextView) root.findViewById(R.id.max_rotation_speed_textview); seekbar = (SeekBar) root.findViewById(R.id.max_rotation_speed_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxRotationSpeed = mFlightController.getMaxRotationSpeed(); try { seekbar.setProgress((int) ((mMaxRotationSpeed.current() - mMaxRotationSpeed.min()) / (mMaxRotationSpeed.max() - mMaxRotationSpeed.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxRotationSpeed(mMaxRotationSpeed.current()); }
From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java
/** * ???/* w w w . jav a2 s . c om*/ * @param root */ private void initConfigAutopilot(final View root) { mAutopilotScaleXFormat = getString(R.string.config_scale_x); mAutopilotScaleYFormat = getString(R.string.config_scale_y); mAutopilotScaleZFormat = getString(R.string.config_scale_z); mAutopilotScaleRFormat = getString(R.string.config_scale_r); mAutopilotMaxControlValueFormat = getString(R.string.config_control_max); // mAutopilotMaxControlValueLabel = (TextView) root.findViewById(R.id.max_control_value_textview); SeekBar seekbar = (SeekBar) root.findViewById(R.id.max_control_value_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxControlValue = mPref.getFloat(APP_CONFIG_KEY_MAX_CONTROL_VALUE, APP_CONFIG_DEFAULT_MAX_CONTROL_VALUE); try { seekbar.setProgress((int) (mMaxControlValue + APP_SCALE_OFFSET)); } catch (final Exception e) { seekbar.setProgress(APP_SCALE_OFFSET); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateAutopilotMaxControlValue(mMaxControlValue); // X mAutopilotScaleXLabel = (TextView) root.findViewById(R.id.scale_x_textview); seekbar = (SeekBar) root.findViewById(R.id.scale_seekbar_x); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mScaleX = mPref.getFloat(APP_CONFIG_KEY_SCALE_X, APP_CONFIG_DEFAULT_SCALE_X); try { seekbar.setProgress((int) (mScaleX * APP_SCALE_FACTOR + APP_SCALE_OFFSET)); } catch (final Exception e) { seekbar.setProgress(APP_SCALE_OFFSET); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateAutopilotScaleX(mScaleX); // Y mAutopilotScaleYLabel = (TextView) root.findViewById(R.id.scale_y_textview); seekbar = (SeekBar) root.findViewById(R.id.scale_seekbar_y); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mScaleY = mPref.getFloat(APP_CONFIG_KEY_SCALE_Y, APP_CONFIG_DEFAULT_SCALE_Y); try { seekbar.setProgress((int) (mScaleY * APP_SCALE_FACTOR + APP_SCALE_OFFSET)); } catch (final Exception e) { seekbar.setProgress(APP_SCALE_OFFSET); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateAutopilotScaleY(mScaleY); // Z mAutopilotScaleZLabel = (TextView) root.findViewById(R.id.scale_z_textview); seekbar = (SeekBar) root.findViewById(R.id.scale_seekbar_z); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mScaleZ = mPref.getFloat(APP_CONFIG_KEY_SCALE_Z, APP_CONFIG_DEFAULT_SCALE_Z); try { seekbar.setProgress((int) (mScaleZ * APP_SCALE_FACTOR + APP_SCALE_OFFSET)); } catch (final Exception e) { seekbar.setProgress(APP_SCALE_OFFSET); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateAutopilotScaleZ(mScaleZ); // R mAutopilotScaleRLabel = (TextView) root.findViewById(R.id.scale_r_textview); seekbar = (SeekBar) root.findViewById(R.id.scale_seekbar_r); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mScaleR = mPref.getFloat(APP_CONFIG_KEY_SCALE_R, APP_CONFIG_DEFAULT_SCALE_R); try { seekbar.setProgress((int) (mScaleR * APP_SCALE_FACTOR + APP_SCALE_OFFSET)); } catch (final Exception e) { seekbar.setProgress(APP_SCALE_OFFSET); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateAutopilotScaleR(mScaleR); }
From source file:com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/*from ww w . j a v a2 s .c om*/ ScrollView ll = (ScrollView) inflater.inflate(R.layout.sound_control, container, false); fa = (ActionBarActivity) super.getActivity(); fa.getSupportActionBar().setDisplayHomeAsUpEnabled(true); fa.getSupportActionBar().setHomeButtonEnabled(true); bootPrefs = fa.getSharedPreferences("BOOT_PREFS", 0); final Boolean isLinked = fa.getSharedPreferences("SOUND_CONTROL", 0).getBoolean("LINKED", true); assert ll != null; final SeekBar headphoneLeft = (SeekBar) ll.findViewById(R.id.headphone_seekbar_left); final SeekBar headphoneRight = (SeekBar) ll.findViewById(R.id.headphone_seekbar_right); final SeekBar headphonePALeft = (SeekBar) ll.findViewById(R.id.headphone_pa_seekbar_left); final SeekBar headphonePARight = (SeekBar) ll.findViewById(R.id.headphone_pa_seekbar_right); final SeekBar speakerLeft = (SeekBar) ll.findViewById(R.id.speaker_seekbar_left); final SeekBar speakerRight = (SeekBar) ll.findViewById(R.id.speaker_seekbar_right); final SeekBar micGain = (SeekBar) ll.findViewById(R.id.mic_seekbar); final SeekBar camMicGain = (SeekBar) ll.findViewById(R.id.cam_mic_seekbar); final TextView headUnitLeft = (TextView) ll.findViewById(R.id.headphone_unit_left); final TextView headUnitRight = (TextView) ll.findViewById(R.id.headphone_unit_right); final TextView headPAUnitLeft = (TextView) ll.findViewById(R.id.headphone_pa_unit_left); final TextView headPAUnitRight = (TextView) ll.findViewById(R.id.headphone_pa_unit_right); final TextView speakerUnitLeft = (TextView) ll.findViewById(R.id.speaker_unit_left); final TextView speakerUnitRight = (TextView) ll.findViewById(R.id.speaker_unit_right); final TextView micUnit = (TextView) ll.findViewById(R.id.mic_unit); final TextView camMicUnit = (TextView) ll.findViewById(R.id.cam_mic_unit); // Headphone L/R Gain if (Helpers.doesFileExist(FAUX_SC_HEADPHONE)) { headphoneLeft.setMax(40); headphoneRight.setMax(40); String[] headphoneGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE).split(" "); int headphoneGainLeft = Integer.valueOf(headphoneGains[0]); if (headphoneGainLeft > 100) headphoneGainLeft -= 256; int headphoneGainRight = Integer.valueOf(headphoneGains[1]); if (headphoneGainRight > 100) headphoneGainRight -= 256; headphoneLeft.setProgress(headphoneGainLeft + 30); headphoneRight.setProgress(headphoneGainRight + 30); headUnitLeft.setText(headphoneGainLeft + ""); headUnitRight.setText(headphoneGainRight + ""); headphoneLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { headUnitLeft.setText(i - 30 + ""); if (isLinked) { headUnitRight.setText(i - 30 + ""); headphoneRight.setProgress(i); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSCInt(seekBar.getProgress()); int toApplyRight = getSCInt(headphoneRight.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_HEADPHONE + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("HEADPHONE", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); headphoneRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { headUnitRight.setText(i - 30 + ""); if (isLinked) { headUnitLeft.setText(i - 30 + ""); headphoneLeft.setProgress(i); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSCInt(headphoneLeft.getProgress()); int toApplyRight = getSCInt(seekBar.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_HEADPHONE + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("HEADPHONE", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); } else { headphoneLeft.setMax(40); headphoneRight.setMax(40); headphoneLeft.setProgress(20); headphoneRight.setProgress(20); headphoneLeft.setEnabled(false); headphoneRight.setEnabled(false); headUnitLeft.setText("Unsupported"); headUnitRight.setText("Unsupported"); } // Headphone analog L/R gain if (Helpers.doesFileExist(FAUX_SC_HEADPHONE_POWERAMP)) { headphonePALeft.setMax(12); headphonePARight.setMax(12); String[] headphonePAGains = CPUHelper.readOneLineNotRoot(FAUX_SC_HEADPHONE_POWERAMP).split(" "); int headphonePAGainLeft = Integer.valueOf(headphonePAGains[0]); int headphonePAGainRight = Integer.valueOf(headphonePAGains[1]); headphonePALeft.setProgress(headphonePAGainLeft); headphonePARight.setProgress(headphonePAGainRight); headPAUnitLeft.setText(headphonePAGainLeft - 26 + ""); headPAUnitRight.setText(headphonePAGainRight - 26 + ""); headphonePALeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { headPAUnitLeft.setText(i - 6 + ""); if (isLinked) { headphonePARight.setProgress(i); headPAUnitRight.setText(i - 6 + ""); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSysfsValue(seekBar.getProgress()); int toApplyRight = getSysfsValue(headphonePARight.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_HEADPHONE_POWERAMP + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("HEADPHONE_PA", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); headphonePARight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { headPAUnitRight.setText(i - 6 + ""); if (isLinked) { headphonePALeft.setProgress(i); headPAUnitLeft.setText(i - 6 + ""); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSysfsValue(headphonePALeft.getProgress()); int toApplyRight = getSysfsValue(seekBar.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_HEADPHONE_POWERAMP + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("HEADPHONE_PA", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); } else { headphonePALeft.setMax(40); headphonePARight.setMax(40); headphonePALeft.setProgress(20); headphonePARight.setProgress(20); headphonePALeft.setEnabled(false); headphonePARight.setEnabled(false); headPAUnitLeft.setText("Unsupported"); headPAUnitRight.setText("Unsupported"); } // Speaker L/R Gain if (Helpers.doesFileExist(FAUX_SC_SPEAKER)) { speakerLeft.setMax(40); speakerRight.setMax(40); String[] speakerGains = CPUHelper.readOneLineNotRoot(FAUX_SC_SPEAKER).split(" "); int speakerGainLeft = Integer.valueOf(speakerGains[0]); if (speakerGainLeft > 100) speakerGainLeft -= 256; int speakerGainRight = Integer.valueOf(speakerGains[1]); if (speakerGainRight > 100) speakerGainRight -= 256; speakerLeft.setProgress(speakerGainLeft + 30); speakerRight.setProgress(speakerGainRight + 30); speakerUnitLeft.setText(speakerGainLeft + ""); speakerUnitRight.setText(speakerGainRight + ""); speakerLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { speakerUnitLeft.setText(i - 30 + ""); if (isLinked) { speakerUnitRight.setText(i - 30 + ""); speakerRight.setProgress(i); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSCInt(seekBar.getProgress()); int toApplyRight = getSCInt(speakerRight.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_SPEAKER + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("SPEAKER", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); speakerRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { speakerUnitRight.setText(i - 30 + ""); if (isLinked) { speakerUnitLeft.setText(i - 30 + ""); speakerLeft.setProgress(i); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int toApplyLeft = getSCInt(speakerLeft.getProgress()); int toApplyRight = getSCInt(seekBar.getProgress()); Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + FAUX_SC_SPEAKER + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("SPEAKER", toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)) .commit(); } }); } else { speakerLeft.setMax(40); speakerRight.setMax(40); speakerLeft.setProgress(20); speakerRight.setProgress(20); speakerLeft.setEnabled(false); speakerRight.setEnabled(false); speakerUnitLeft.setText("Unsupported"); speakerUnitRight.setText("Unsupported"); } // Microphone Gain if (Helpers.doesFileExist(FAUX_SC_MIC)) { int micValue = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_MIC)); if (micValue > 100) micValue -= 256; micGain.setMax(40); micGain.setProgress(micValue + 30); micUnit.setText(micValue + ""); micGain.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { micUnit.setText(i - 30 + ""); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int scProgress = seekBar.getProgress() - 30; if (scProgress < 0) scProgress += 256; Helpers.CMDProcessorWrapper .runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0) + " > " + FAUX_SC_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("SC_MIC", scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0)) .commit(); } }); } else { micGain.setMax(40); micGain.setProgress(20); micUnit.setText("Unsupported"); micGain.setEnabled(false); } // Camera Microphone Gain if (Helpers.doesFileExist(FAUX_SC_CAM_MIC)) { int camMicValue = Integer.valueOf(CPUHelper.readOneLine(FAUX_SC_CAM_MIC)); if (camMicValue > 100) camMicValue -= 256; camMicGain.setMax(40); camMicGain.setProgress(camMicValue + 30); camMicUnit.setText(camMicValue + ""); camMicGain.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { camMicUnit.setText(i - 30 + ""); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { int scProgress = seekBar.getProgress() - 30; if (scProgress < 0) scProgress += 256; Helpers.CMDProcessorWrapper .runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + "\n" + "busybox echo " + scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0) + " > " + FAUX_SC_CAM_MIC + "\n" + "busybox echo 1 > " + FAUX_SC_LOCKED); bootPrefs.edit() .putString("SC_MIC", scProgress + " " + Helpers.getSoundCountrolBitRepresentation(scProgress, 0)) .commit(); } }); } else { camMicGain.setMax(40); camMicGain.setProgress(20); camMicUnit.setText("Unsupported"); camMicGain.setEnabled(false); } return ll; }
From source file:nf.frex.android.FrexActivity.java
private void preparePropertiesDialog(final Dialog dialog) { final Registry<Fractal> fractals = Registries.fractals; int fractalTypeIndex = fractals.getIndex(view.getFractalId()); final Spinner fractalTypeSpinner = (Spinner) dialog.findViewById(R.id.fractal_type_spinner); final SeekBar iterationsSeekBar = (SeekBar) dialog.findViewById(R.id.num_iterations_seek_bar); final EditText iterationsEditText = (EditText) dialog.findViewById(R.id.num_iterations_edit_text); final CheckBox juliaModeCheckBox = (CheckBox) dialog.findViewById(R.id.julia_mode_fractal_check_box); final CheckBox decoratedFractal = (CheckBox) dialog.findViewById(R.id.decorated_fractal_check_box); final Button okButton = (Button) dialog.findViewById(R.id.ok_button); final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button); juliaModeCheckBox.setEnabled(true);//from w w w .j a va 2 s . c o m ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, fractals.getIds()); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fractalTypeSpinner.setAdapter(arrayAdapter); fractalTypeSpinner.setSelection(fractalTypeIndex, true); fractalTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) { Fractal fractal = fractals.getValue(position); iterationsEditText.setText(fractal.getDefaultIterMax() + ""); boolean sameFractal = view.getFractalId().equals(fractals.getId(position)); if (!sameFractal) { juliaModeCheckBox.setChecked(false); } juliaModeCheckBox.setEnabled(sameFractal); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); iterationsEditText.setText(view.getIterMax() + "", TextView.BufferType.NORMAL); final double iterationsMin = 1; final double iterationsMax = 3; final SeekBarConfigurer iterationsSeekBarConfigurer = SeekBarConfigurer.create(iterationsSeekBar, iterationsMin, iterationsMax, true, view.getIterMax()); iterationsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { int iterMax = iterationsSeekBarConfigurer.getValueInt(); iterationsEditText.setText(iterMax + "", TextView.BufferType.NORMAL); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); iterationsEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { try { int iterMax = Integer.parseInt(v.getText().toString()); iterationsSeekBarConfigurer.setValue(iterMax); return true; } catch (NumberFormatException e) { return false; } } }); decoratedFractal.setChecked(view.isDecoratedFractal()); juliaModeCheckBox.setChecked(view.isJuliaModeFractal()); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int iterMax; try { iterMax = Integer.parseInt(iterationsEditText.getText().toString()); } catch (NumberFormatException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); return; } dialog.dismiss(); String oldConfigName = view.getConfigName(); String newFractalId = fractals.getId(fractalTypeSpinner.getSelectedItemPosition()); Fractal fractal = fractals.getValue(fractalTypeSpinner.getSelectedItemPosition()); String oldFractalId = view.getFractalId(); boolean newJuliaModeFractal = juliaModeCheckBox.isChecked(); boolean oldJuliaModeFractal = view.isJuliaModeFractal(); view.setFractalId(newFractalId); view.setIterMax(iterMax); view.setDecoratedFractal(decoratedFractal.isChecked()); view.setJuliaModeFractal(newJuliaModeFractal); boolean fractalTypeChanged = !oldFractalId.equals(newFractalId); if (fractalTypeChanged) { if (oldConfigName.contains(oldFractalId.toLowerCase())) { view.setConfigName(newFractalId.toLowerCase()); } view.setRegion(fractal.getDefaultRegion()); view.setBailOut(fractal.getDefaultBailOut()); } boolean juliaModeChanged = oldJuliaModeFractal != newJuliaModeFractal; if (fractalTypeChanged || juliaModeChanged) { view.getRegionHistory().clear(); view.getRegionHistory().add(fractal.getDefaultRegion().clone()); } view.recomputeAll(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
From source file:mx.klozz.xperience.tweaker.fragments.CPUAdvanced.java
public void openDialog(String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = context.getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); final EditText settingText; LayoutInflater factory = LayoutInflater.from(context); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); int currentProgress = Integer.parseInt(Helpers.LeerUnaLinea(path)); seekbar.setMax(max - min);/* ww w . j a va 2 s . co m*/ if (currentProgress > max) currentProgress = max - min; else if (currentProgress < min) currentProgress = 0; else currentProgress = currentProgress - min; seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setText(Integer.toString(currentProgress + min)); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()) - min; seekbar.setProgress(val); return true; } return false; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val - min); } catch (NumberFormatException ex) { } } }); SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { final int mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress + min)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = min; if (!settingText.getText().toString().equals("")) val = Integer.parseInt(settingText.getText().toString()); if (val < min) val = min; seekbar.setProgress(val - min); int newProgress = seekbar.getProgress() + min; new CMDProcessor().su .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path); final String v = Helpers.LeerUnaLinea(path); mPreferences.edit().putString(key, v).commit(); pref.setSummary(v); } }).create().show(); }
From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java
private void initPreprocess(final View rootView) { mExposureFormat = getString(R.string.trace_use_exposure); mSaturationFormat = getString(R.string.trace_use_saturation); mBrightnessFormat = getString(R.string.trace_use_brightness); mBinarizeThresholdFormat = getString(R.string.trace_binarize_threshold); SeekBar sb; Button btn;/*from ww w. j ava2 s . c om*/ // mExposure = mPref.getFloat(KEY_EXPOSURE, DEFAULT_EXPOSURE); mExposureLabel = (TextView) rootView.findViewById(R.id.exposure_textview); sb = (SeekBar) rootView.findViewById(R.id.exposure_seekbar); sb.setMax(6000); sb.setProgress(exposureToProgress(mExposure)); // [-3,+ 3] => [0, 6000] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateExposure(mExposure); // mSaturation = mPref.getFloat(KEY_SATURATION, DEFAULT_SATURATION); mSaturationLabel = (TextView) rootView.findViewById(R.id.saturation_textview); sb = (SeekBar) rootView.findViewById(R.id.saturation_seekbar); sb.setMax(200); sb.setProgress((int) (mSaturation * 100.0f) + 100); // [-1.0f, +1.0f] => [0, 200] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateSaturation(mSaturation); // ? mBrightness = mPref.getFloat(KEY_BRIGHTNESS, DEFAULT_BRIGHTNESS); mBrightnessLabel = (TextView) rootView.findViewById(R.id.brightness_textview); sb = (SeekBar) rootView.findViewById(R.id.brightness_seekbar); sb.setMax(200); sb.setProgress((int) (mBrightness * 100.0f) + 100); // [-1.0f, +1.0f] => [0, 200] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateBrightness(mBrightness); // mBinarizeThreshold = mPref.getFloat(KEY_BINARIZE_THRESHOLD, DEFAULT_BINARIZE_THRESHOLD); mBinarizeThresholdLabel = (TextView) rootView.findViewById(R.id.binarize_threshold_textview); sb = (SeekBar) rootView.findViewById(R.id.binarize_threshold_seekbar); sb.setMax(100); sb.setProgress((int) (mBinarizeThreshold * 100.0f)); // [0.0f, +1.0f] => [0, 100] sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateBinarizeThreshold(mBinarizeThreshold); }
From source file:mx.klozz.xperience.tweaker.fragments.Advanced.java
public void openDialog(String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = context.getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); final EditText settingText; LayoutInflater factory = LayoutInflater.from(context); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); seekbar.setMax(max - min);/*w w w . j a v a 2s. co m*/ int currentProgress = min; if (key.equals("pref_viber")) { currentProgress = Integer.parseInt(Helpers.LeerUnaLinea(path)); } else { currentProgress = Integer.parseInt(vib.get_val(path)); } if (currentProgress > max) currentProgress = max - min; else if (currentProgress < min) currentProgress = 0; else currentProgress = currentProgress - min; seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setText(Integer.toString(currentProgress + min)); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()) - min; seekbar.setProgress(val); return true; } return false; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val - min); } catch (NumberFormatException ex) { } } }); OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { final int mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress + min)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = min; if (!settingText.getText().toString().equals("")) val = Integer.parseInt(settingText.getText().toString()); if (val < min) val = min; seekbar.setProgress(val - min); int newProgress = seekbar.getProgress() + min; new CMDProcessor().su .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path); String v; if (key.equals("pref_viber")) { v = vib.get_val(path); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(1000); } else { v = Helpers.LeerUnaLinea(path); } final SharedPreferences.Editor editor = mPreferences.edit(); editor.putInt(key, Integer.parseInt(v)).commit(); pref.setSummary(v); } }).create().show(); }
From source file:com.brewcrewfoo.performance.fragments.Advanced.java
public void openDialog(String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = context.getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); final EditText settingText; LayoutInflater factory = LayoutInflater.from(context); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); seekbar.setMax(max - min);//from www . j a va 2 s . c o m int currentProgress = min; if (key.equals("pref_viber")) { currentProgress = Integer.parseInt(vib.get_val(path)); } else { currentProgress = Integer.parseInt(Helpers.readOneLine(path)); } if (currentProgress > max) currentProgress = max - min; else if (currentProgress < min) currentProgress = 0; else currentProgress = currentProgress - min; seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setText(Integer.toString(currentProgress + min)); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()) - min; seekbar.setProgress(val); return true; } return false; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val - min); } catch (NumberFormatException ex) { } } }); OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { final int mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress + min)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = min; if (!settingText.getText().toString().equals("")) val = Integer.parseInt(settingText.getText().toString()); if (val < min) val = min; seekbar.setProgress(val - min); int newProgress = seekbar.getProgress() + min; new CMDProcessor().su .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path); String v; if (key.equals("pref_viber")) { v = vib.get_val(path); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(1000); } else { v = Helpers.readOneLine(path); } final SharedPreferences.Editor editor = mPreferences.edit(); editor.putInt(key, Integer.parseInt(v)).commit(); pref.setSummary(v); } }).create().show(); }
From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java
/** * ??//from w w w . j av a 2 s . c o m * @param root */ private void initConfigFlight(final View root) { if (DEBUG) Log.v(TAG, "initConfigFlight:"); mMaxAltitudeFormat = getString(R.string.config_max_altitude); mMaxTiltFormat = getString(R.string.config_max_tilt); mMaxVerticalSpeedFormat = getString(R.string.config_max_vertical_speed); mMaxRotationSpeedFormat = getString(R.string.config_max_rotating_speed); // mMaxAltitudeLabel = (TextView) root.findViewById(R.id.max_altitude_textview); SeekBar seekbar = (SeekBar) root.findViewById(R.id.max_altitude_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxAltitude = mFlightController.getMaxAltitude(); try { seekbar.setProgress((int) ((mMaxAltitude.current() - mMaxAltitude.min()) / (mMaxAltitude.max() - mMaxAltitude.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxAltitude(mMaxAltitude.current()); // // bebop?5-3050km/hr???13.9m/s/300.46[m/s/] mMaxTiltLabel = (TextView) root.findViewById(R.id.max_tilt_textview); seekbar = (SeekBar) root.findViewById(R.id.max_tilt_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxTilt = mFlightController.getMaxTilt(); try { seekbar.setProgress( (int) ((mMaxTilt.current() - mMaxTilt.min()) / (mMaxTilt.max() - mMaxTilt.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxTilt(mMaxTilt.current()); // /?, Bebop2?6m/s mMaxVerticalSpeedLabel = (TextView) root.findViewById(R.id.max_vertical_speed_textview); seekbar = (SeekBar) root.findViewById(R.id.max_vertical_speed_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxVerticalSpeed = mFlightController.getMaxVerticalSpeed(); try { seekbar.setProgress((int) ((mMaxVerticalSpeed.current() - mMaxVerticalSpeed.min()) / (mMaxVerticalSpeed.max() - mMaxVerticalSpeed.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxVerticalSpeed(mMaxVerticalSpeed.current()); // mMaxRotationSpeedLabel = (TextView) root.findViewById(R.id.max_rotation_speed_textview); seekbar = (SeekBar) root.findViewById(R.id.max_rotation_speed_seekbar); seekbar.setOnSeekBarChangeListener(null); seekbar.setMax(1000); mMaxRotationSpeed = mFlightController.getMaxRotationSpeed(); try { seekbar.setProgress((int) ((mMaxRotationSpeed.current() - mMaxRotationSpeed.min()) / (mMaxRotationSpeed.max() - mMaxRotationSpeed.min()) * 1000)); } catch (final Exception e) { seekbar.setProgress(0); } seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener); updateMaxRotationSpeed(mMaxRotationSpeed.current()); }