List of usage examples for android.widget SeekBar setOnSeekBarChangeListener
public void setOnSeekBarChangeListener(OnSeekBarChangeListener l)
From source file:com.example.slidingmenuexample.ui.NXTRemoteControl.java
private void setupUI() { if (mControlsMode == MODE_BUTTONS) { setContentView(R.layout.remote_control); ImageView buttonUp = (ImageView) findViewById(R.id.button_up); buttonUp.setOnTouchListener(new DirectionButtonOnTouchListener(1, 1)); ImageView buttonLeft = (ImageView) findViewById(R.id.button_left); buttonLeft.setOnTouchListener(new DirectionButtonOnTouchListener(-0.6, 0.6)); ImageView buttonDown = (ImageView) findViewById(R.id.button_down); buttonDown.setOnTouchListener(new DirectionButtonOnTouchListener(-1, -1)); ImageView buttonRight = (ImageView) findViewById(R.id.button_right); buttonRight.setOnTouchListener(new DirectionButtonOnTouchListener(0.6, -0.6)); SeekBar powerSeekBar = (SeekBar) findViewById(R.id.power_seekbar); powerSeekBar.setProgress(mPower); powerSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override//from w w w .j a va2 s.c om public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPower = progress; } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStateDisplay = (TextView) findViewById(R.id.state_display); mConnectButton = (ImageView) findViewById(R.id.button_b); mConnectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!NO_BT) { findBrick(); } else { mState = NXTTalker.STATE_CONNECTED; displayState(); } } }); mDisconnectButton = (ImageView) findViewById(R.id.button_a); mDisconnectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mNXTTalker.stop(); } }); displayState(); } }
From source file:com.rks.musicx.ui.fragments.EqFragment.java
private void initEq(View rootView) { try {/* www.j av a2 s. co m*/ for (short i = 0; i < Equalizers.getNumberOfBands(); i++) { short eqbands = i; short[] bandLevel = Equalizers.getBandLevelRange(); seekBar = new VerticalSeekBar(getContext()); textView = new TextView(getContext()); switch (i) { case 0: seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar1); textView = (TextView) rootView.findViewById(R.id.level1); break; case 1: seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar2); textView = (TextView) rootView.findViewById(R.id.level2); break; case 2: seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar3); textView = (TextView) rootView.findViewById(R.id.level3); break; case 3: seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar4); textView = (TextView) rootView.findViewById(R.id.level4); break; case 4: seekBar = (VerticalSeekBar) rootView.findViewById(R.id.seek_bar5); textView = (TextView) rootView.findViewById(R.id.level5); break; } seekBarFinal[eqbands] = seekBar; seekBar.setId(i); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { textView.setTextColor(Color.WHITE); seekBar.setThumb(ContextCompat.getDrawable(getContext(), R.drawable.thumb)); seekBar.getThumb().setTint(accentcolor); seekBar.setProgressTintMode(PorterDuff.Mode.SRC_ATOP); seekBar.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP); } else { textView.setTextColor(Color.WHITE); seekBar.setThumb(ContextCompat.getDrawable(getContext(), R.drawable.thumb)); seekBar.getThumb().setTint(accentcolor); seekBar.setProgressTintMode(PorterDuff.Mode.SRC_ATOP); seekBar.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP); } if (bandLevel != null) { seekBar.setMax(bandLevel[1] - bandLevel[0]); int presetPos = Extras.getInstance().getPresetPos(); if (presetPos < Equalizers.getPresetNo()) { seekBarFinal[eqbands].setProgress(Equalizers.getBandLevel(eqbands) - bandLevel[0]); } else { seekBarFinal[i].setProgress( Extras.getInstance().saveEq().getInt(BAND_LEVEL + i, 0) - bandLevel[0]); } } int frequency = Equalizers.getCenterFreq(eqbands); if (frequency < 1000 * 1000) { textView.setText((frequency / 1000) + "Hz"); } else { textView.setText((frequency / (1000 * 1000)) + "kHz"); } seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { try { if (fromUser) { if (bandLevel != null) { int level = seekbar.getProgress() + bandLevel[0]; Equalizers.setBandLevel(eqbands, (short) level); int presetNo = Equalizers.getPresetNo(); if (presetNo != 0) { appCompatSpinner.setSelection(Equalizers.getPresetNo()); } else { appCompatSpinner.setSelection(0); } Equalizers.savePrefs(eqbands, level); } } } catch (Exception e) { e.printStackTrace(); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } } catch (Exception e) { e.printStackTrace(); Log.d(TAG, "Failed to init eq"); } }
From source file:sandra.examples.oneshot.voicelaunch.VoiceLaunch.java
private void initializeSeekBar() { final SeekBar seekT = (SeekBar) findViewById(R.id.threshold_seekBar); seekT.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override//from w w w .j a v a 2 s . c o m public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { seekT.setThumb(writeOnDrawable(R.drawable.barpointershadow, String.format("%.1f", seekBarValueToFloat(progress)))); } }); seekT.setMax(10); //SeekBar does not admit decimals, so instead of having it from 0 to 1, we will use it from 0 to 10 seekT.setProgress(floatToSeekBarValue(DEFAULT_THRESHOLD)); }
From source file:org.jsampler.android.view.classic.MainFrame.java
private void installListeners() { SeekBar sliderVolume = (SeekBar) view.findViewById(R.id.main_slider_volume); int i = CC.preferences().getIntProperty(MAXIMUM_MASTER_VOLUME); sliderVolume.setMax(i);/* w w w.j av a 2s. c o m*/ CC.preferences().addPropertyChangeListener(MAXIMUM_MASTER_VOLUME, getHandler()); sliderVolume.setOnSeekBarChangeListener(getHandler()); CC.getSamplerModel().addSamplerListener(getHandler()); CC.preferences().addPropertyChangeListener(VOL_MEASUREMENT_UNIT_DECIBEL, getHandler()); ImageButton btn = (ImageButton) view.findViewById(R.id.classic_main_flip_back); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { panesFlipper.setInAnimation(AHF.inFromLeftAnimation()); panesFlipper.setOutAnimation(AHF.outToRightAnimation()); panesFlipper.showPrevious(); updateMainTitle(); } }); btn = (ImageButton) view.findViewById(R.id.classic_main_flip_forward); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { panesFlipper.setInAnimation(AHF.inFromRightAnimation()); panesFlipper.setOutAnimation(AHF.outToLeftAnimation()); panesFlipper.showNext(); updateMainTitle(); } }); }
From source file:com.willowtreeapps.spurceexampleapp.fragments.ControlsFragment.java
@Nullable @Override//w w w . j av a 2 s. co m public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.controls_fragment, container, false); parent = (GridLayout) ((SpruceActivity) getActivity()).parent; children = ((SpruceActivity) getActivity()).children; sortDropDown = ((SpruceActivity) getActivity()).sortDropDown; linearRadioGroup = (RadioGroup) rootView.findViewById(R.id.directional_radio_group); corneredRadioGroup = (RadioGroup) rootView.findViewById(R.id.cornered_radio_group); positionalRadioGroup = (RadioGroupGridLayout) rootView.findViewById(R.id.positional_radio_group); RadioGroup verticalWeightedRadioGroup = (RadioGroup) rootView .findViewById(R.id.vertical_weighted_radio_group); RadioGroup horizontalWeightedRadioGroup = (RadioGroup) rootView .findViewById(R.id.horizontal_weighted_radio_group); verticalWeightLayout = (LinearLayout) rootView.findViewById(R.id.vertical_weight); horizontalWeightLayout = (LinearLayout) rootView.findViewById(R.id.horizontal_weight); linearReversed = (CheckBox) rootView.findViewById(R.id.linear_reversed); seekBar = (SeekBar) rootView.findViewById(R.id.animation_seek); animationEndText = (TextView) rootView.findViewById(R.id.animation_end); seekBarTitle = (TextView) rootView.findViewById(R.id.seek_bar_title); codeSample = (EditText) rootView.findViewById(R.id.code_sample); animators = new Animator[] { DefaultAnimations.shrinkAnimator(parent, /*duration=*/800), DefaultAnimations.fadeInAnimator(parent, /*duration=*/800) }; View.OnClickListener click = new View.OnClickListener() { @Override public void onClick(View v) { resetChildViewsAndStartSort(); } }; container.setOnClickListener(click); parent.setOnClickListener(click); sortDropDown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case CORNERED_SORT: case INLINE_SORT: linearRadioGroup.setVisibility(View.GONE); linearReversed.setVisibility(View.VISIBLE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.VISIBLE); break; case LINEAR_SORT: linearRadioGroup.setVisibility(View.VISIBLE); linearReversed.setVisibility(View.VISIBLE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; case CONTINUOUS_SORT: case RADIAL_SORT: positionalRadioGroup.setVisibility(View.VISIBLE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); linearReversed.setVisibility(View.VISIBLE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; case CONTINUOUS_WEIGHTED_SORT: positionalRadioGroup.setVisibility(View.VISIBLE); verticalWeightLayout.setVisibility(View.VISIBLE); horizontalWeightLayout.setVisibility(View.VISIBLE); linearReversed.setVisibility(View.VISIBLE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; default: linearReversed.setVisibility(View.GONE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; } resetChildViewsAndStartSort(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); // set default vertical weight verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; verticalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.vertical_light: verticalWeight = ContinuousWeightedSort.LIGHT_WEIGHT; break; case R.id.vertical_medium: verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; break; case R.id.vertical_heavy: verticalWeight = ContinuousWeightedSort.HEAVY_WEIGHT; break; } resetChildViewsAndStartSort(); } }); // set default horizontal weight horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; horizontalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.horizontal_light: horizontalWeight = ContinuousWeightedSort.LIGHT_WEIGHT; break; case R.id.horizontal_medium: horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; break; case R.id.horizontal_heavy: horizontalWeight = ContinuousWeightedSort.HEAVY_WEIGHT; break; } resetChildViewsAndStartSort(); } }); // set default direction direction = LinearSort.Direction.BOTTOM_TO_TOP; linearRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.bottom_to_top: direction = LinearSort.Direction.BOTTOM_TO_TOP; break; case R.id.top_to_bottom: direction = LinearSort.Direction.TOP_TO_BOTTOM; break; case R.id.left_to_right: direction = LinearSort.Direction.LEFT_TO_RIGHT; break; case R.id.right_to_left: direction = LinearSort.Direction.RIGHT_TO_LEFT; break; } resetChildViewsAndStartSort(); } }); // set default corner corner = CorneredSort.Corner.TOP_LEFT; corneredRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.top_left: corner = CorneredSort.Corner.TOP_LEFT; break; case R.id.top_right: corner = CorneredSort.Corner.TOP_RIGHT; break; case R.id.bottom_left: corner = CorneredSort.Corner.BOTTOM_LEFT; break; case R.id.bottom_right: corner = CorneredSort.Corner.BOTTOM_RIGHT; break; } resetChildViewsAndStartSort(); } }); linearReversed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { resetChildViewsAndStartSort(); } }); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { resetChildViewsAndStartSort(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); positionalRadioGroup.setGroupChildChangedListener(this); resetChildViewsAndStartSort(); return rootView; }
From source file:com.doctoror.fuckoffmusicplayer.presentation.nowplaying.NowPlayingActivity.java
@Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); Dart.inject(this); AndroidInjection.inject(this); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { final Intent intent = Intent.makeMainActivity(new ComponentName(this, HomeActivity.class)); startActivity(intent);//from w w w. j a va 2 s .co m return; } if (TransitionUtils.supportsActivityTransitions()) { NowPlayingActivityLollipop.applyTransitions(this); } mRequestManager = Glide.with(this); mTransitionPostponed = false; mTransitionStarted = false; final ActivityNowplayingBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_nowplaying); ButterKnife.bind(this); ViewCompat.setTransitionName(albumArt, TRANSITION_NAME_ALBUM_ART); ViewCompat.setTransitionName(root, TRANSITION_NAME_ROOT); mModel.setBtnPlayRes(R.drawable.ic_play_arrow_white_36dp); mModel.setShuffleEnabled(mPlaybackParams.isShuffleEnabled()); mModel.setRepeatMode(mPlaybackParams.getRepeatMode()); binding.setModel(mModel); setSupportActionBar(toolbar); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(final SeekBar seekBar, final int i, final boolean b) { } @Override public void onStartTrackingTouch(final SeekBar seekBar) { mSeekBarTracking = true; } @Override public void onStopTrackingTouch(final SeekBar seekBar) { mPlaybackServiceControl.seek((float) seekBar.getProgress() / (float) seekBar.getMax()); mSeekBarTracking = false; } }); mIntentHandler = new NowPlayingActivityIntentHandler(this); mIntentHandler.handleIntent(getIntent()); mNavigationController = new NavigationController(this, findViewById(R.id.drawerLayout)); mNavigationController.bind(); }
From source file:com.xperia64.timidityae.TrackFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { reset();//from w ww . j ava 2 s. c o m fileList = new ArrayAdapter<String>(getActivity(), R.layout.row); for (int i = 0; i < JNIHandler.MAX_CHANNELS; i++) { fileList.add(String.format(getActivity().getResources().getString(R.string.trk_form), (getActivity().getResources() .getString(JNIHandler.drums.get(i) ? R.string.trk_drum : R.string.trk_inst2)), (i + 1), JNIHandler.drums.get(i) ? 0 : localInst.get(i) + 1, localVol.get(i))); } channelList.setAdapter(fileList); channelList.setOnItemClickListener(new OnItemClickListener() { @SuppressLint("InflateParams") @Override public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); View v = getActivity().getLayoutInflater().inflate(R.layout.track_dialog, null); final Spinner instSpin = (Spinner) v.findViewById(R.id.instSpin); instSpin.setClickable(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2)); instSpin.setOnLongClickListener(null); instSpin.setEnabled(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2)); List<String> arrayAdapter = new ArrayList<String>(); final int offset = (!JNIHandler.drums.get(arg2)) ? 0 : 34; if (!JNIHandler.drums.get(arg2)) { for (String inst : getActivity().getResources().getStringArray(R.array.midi_instruments)) arrayAdapter.add(inst); } else { for (String inst : getActivity().getResources().getStringArray(R.array.midi_drums)) arrayAdapter.add(inst); } ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arrayAdapter); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item); } else { dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } dataAdapter.setNotifyOnChange(false); if (!JNIHandler.drums.get(arg2)) { instSpin.setAdapter(dataAdapter); instSpin.setSelection(localInst.get(arg2) - offset); } final EditText txtVol = (EditText) v.findViewById(R.id.txtVol); txtVol.setText(Integer.toString(localVol.get(arg2))); txtVol.setClickable(JNIHandler.custVol.get(arg2)); txtVol.setEnabled(JNIHandler.custVol.get(arg2)); final SeekBar volSeek = (SeekBar) v.findViewById(R.id.volSeek); volSeek.setClickable(JNIHandler.custVol.get(arg2)); volSeek.setEnabled(JNIHandler.custVol.get(arg2)); volSeek.setMax(127); volSeek.setProgress(localVol.get(arg2)); volSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) { if (arg2 && !fromUser) { fromUser = true; txtVol.setText(Integer.toString(arg0.getProgress())); } else { fromUser = false; } } @Override public void onStartTrackingTouch(SeekBar arg0) { } @Override public void onStopTrackingTouch(SeekBar arg0) { } }); txtVol.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { if (!fromUser) { if (s.length() > 0) { int numm = Integer.parseInt(s.toString()); if (numm > 127) { fromUser = true; numm = 127; } if (numm < 0) { fromUser = true; numm = 0; } if (fromUser) { txtVol.setText(Integer.toString(numm)); } fromUser = true; volSeek.setProgress(numm); fromUser = false; } } else { fromUser = false; } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final CheckBox inst = (CheckBox) v.findViewById(R.id.defInstr); inst.setEnabled(!JNIHandler.drums.get(arg2)); inst.setChecked(!JNIHandler.custInst.get(arg2)); inst.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { instSpin.setClickable(!arg1); instSpin.setEnabled(!arg1); } }); final CheckBox vol = (CheckBox) v.findViewById(R.id.defVol); vol.setChecked(!JNIHandler.custVol.get(arg2)); //System.out.println("Def inst: "+(!JNIHandler.custInst.get(arg2)?"true":"false")+" def vol: "+(!JNIHandler.custVol.get(arg2)?"true":"false")); vol.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { volSeek.setClickable(!arg1); volSeek.setEnabled(!arg1); txtVol.setClickable(!arg1); txtVol.setEnabled(!arg1); } }); if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK); b.setView(v); b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { JNIHandler.custInst.set(arg2, !inst.isChecked()); JNIHandler.custVol.set(arg2, !vol.isChecked()); JNIHandler.setChannelVolumeTimidity(arg2 | (JNIHandler.custVol.get(arg2) ? 0x800 : 0x8000), volSeek.getProgress()); JNIHandler.setChannelTimidity(arg2 | (JNIHandler.custInst.get(arg2) ? 0x800 : 0x8000), instSpin.getSelectedItemPosition()); if (!JNIHandler.paused && Globals.isPlaying == 0) JNIHandler.seekTo(JNIHandler.currTime); //bigCounter=12; updateList(); } }); b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); b.setTitle(String.format((getActivity().getResources().getString(R.string.trk_form2)), (arg2 + 1))); ddd = b.create(); ddd.show(); } }); }
From source file:pl.mg6.android.maps.extensions.demo.DemoActivity.java
private void setUpClusteringViews() { CheckBox clusterCheckbox = (CheckBox) findViewById(R.id.checkbox_cluster); final SeekBar clusterSizeSeekbar = (SeekBar) findViewById(R.id.seekbar_cluster_size); clusterCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override//from w ww. j a v a2 s . c o m public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { clusterSizeSeekbar.setEnabled(isChecked); updateClustering(clusterSizeSeekbar.getProgress(), isChecked); } }); clusterSizeSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { updateClustering(progress, true); } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }
From source file:org.starfishrespect.myconsumption.android.ui.ChartChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_chart_choice, container, false); // Register to the EventBus EventBus.getDefault().register(this); listViewSensor = (ListView) view.findViewById(R.id.listViewSensors); mLinearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutDateSelectionItems); mTextView = (TextView) view.findViewById(R.id.textViewUsername); spinnerDate = (Spinner) view.findViewById(R.id.spinnerDate); spinnerFrequency = (Spinner) view.findViewById(R.id.spinnerFrequency); spinnerPrecision = (Spinner) view.findViewById(R.id.spinnerPrecision); seekBar = (SeekBar) view.findViewById(R.id.seekBar); seekBarPosition = 0;//from w w w .ja v a 2 s .c o m seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // Called when the slider moves to another value @Override public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { seekBarPosition = progresValue; } // Called when you start moving the slider @Override public void onStartTrackingTouch(SeekBar seekBar) { } // Called when it seems that you are done moving the slider @Override public void onStopTrackingTouch(SeekBar seekBar) { // Tell ChartViewFragment to update the graph EventBus.getDefault().post(new UpdateMovingAverageEvent(seekBarPosition)); } }); listViewSensor.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { lastLongClickItem = position; PopupMenu popup = new PopupMenu(mActivity, view); popup.inflate(R.menu.menu_sensor_dropdown); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_delete_sensor: if (!MiscFunctions.isOnline(mActivity)) { MiscFunctions.makeOfflineDialog(mActivity).show(); return false; } deleteSensor(lastLongClickItem); break; case R.id.action_edit_sensor: if (!MiscFunctions.isOnline(mActivity)) { MiscFunctions.makeOfflineDialog(mActivity).show(); return false; } editSensor(lastLongClickItem); break; } return false; } }); popup.show(); return false; } }); return view; }
From source file:org.schabi.newpipe.download.DownloadDialog.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle arguments = getArguments();/*from www . j a v a 2s. com*/ final Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); final EditText name = (EditText) view.findViewById(R.id.file_name); final TextView tCount = (TextView) view.findViewById(R.id.threads_count); final SeekBar threads = (SeekBar) view.findViewById(R.id.threads); toolbar.setTitle(R.string.download_dialog_title); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp); toolbar.inflateMenu(R.menu.dialog_url); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getDialog().dismiss(); } }); threads.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { tCount.setText(String.valueOf(progress + 1)); } @Override public void onStartTrackingTouch(SeekBar p1) { } @Override public void onStopTrackingTouch(SeekBar p1) { } }); checkDownloadOptions(); //int def = mPrefs.getInt("threads", 4); int def = 3; threads.setProgress(def - 1); tCount.setText(String.valueOf(def)); name.setText(createFileName(arguments.getString(TITLE))); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.okay) { download(); return true; } else { return false; } } }); }