List of usage examples for android.widget SeekBar setThumb
public void setThumb(Drawable thumb)
From source file:com.z299studio.pb.PasswordGenerator.java
private void tintSeekBar(SeekBar sb) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable thumb = ContextCompat.getDrawable(getContext(), R.drawable.thumb); LayerDrawable progress = (LayerDrawable) ContextCompat.getDrawable(getContext(), R.drawable.progress); progress.getDrawable(0).setColorFilter(C.ThemedColors[C.colorIconNormal], PorterDuff.Mode.SRC_ATOP); progress.getDrawable(1).setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP); sb.setProgressDrawable(progress); thumb.setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP); sb.setThumb(thumb); }//www. j ava 2 s. c o m }
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// w w w .j a v a 2 s .com 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.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)); }//from w w w. java 2s . c o m // 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:androidx.media.widget.MediaControlView2.java
@SuppressWarnings("deprecation") private void initControllerView(ViewGroup v) { // Relating to Title Bar View mTitleBar = v.findViewById(R.id.title_bar); mTitleView = v.findViewById(R.id.title_text); mAdExternalLink = v.findViewById(R.id.ad_external_link); mBackButton = v.findViewById(R.id.back); if (mBackButton != null) { mBackButton.setOnClickListener(mBackListener); mBackButton.setVisibility(View.GONE); }/*from ww w. j av a 2 s . c om*/ // TODO (b/77158231) revive // mRouteButton = v.findViewById(R.id.cast); // Relating to Center View mCenterView = v.findViewById(R.id.center_view); mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls); mCenterView.addView(mTransportControls); // Relating to Minimal Extra View mMinimalExtraView = (LinearLayout) v.findViewById(R.id.minimal_extra_view); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mMinimalExtraView.getLayoutParams(); int iconSize = mResources.getDimensionPixelSize(R.dimen.mcv2_embedded_icon_size); int marginSize = mResources.getDimensionPixelSize(R.dimen.mcv2_icon_margin); params.setMargins(0, (iconSize + marginSize * 2) * (-1), 0, 0); mMinimalExtraView.setLayoutParams(params); mMinimalExtraView.setVisibility(View.GONE); // Relating to Progress Bar View mProgress = v.findViewById(R.id.progress); if (mProgress != null) { if (mProgress instanceof SeekBar) { SeekBar seeker = (SeekBar) mProgress; seeker.setOnSeekBarChangeListener(mSeekListener); seeker.setProgressDrawable(mResources.getDrawable(R.drawable.custom_progress)); seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb)); } mProgress.setMax(MAX_PROGRESS); } mProgressBuffer = v.findViewById(R.id.progress_buffer); // Relating to Bottom Bar View mBottomBar = v.findViewById(R.id.bottom_bar); // Relating to Bottom Bar Left View mBottomBarLeftView = v.findViewById(R.id.bottom_bar_left); mTimeView = v.findViewById(R.id.time); mEndTime = v.findViewById(R.id.time_end); mCurrentTime = v.findViewById(R.id.time_current); mAdSkipView = v.findViewById(R.id.ad_skip_time); mFormatBuilder = new StringBuilder(); mFormatter = new Formatter(mFormatBuilder, Locale.getDefault()); // Relating to Bottom Bar Right View mBottomBarRightView = v.findViewById(R.id.bottom_bar_right); mBasicControls = v.findViewById(R.id.basic_controls); mExtraControls = v.findViewById(R.id.extra_controls); mCustomButtons = v.findViewById(R.id.custom_buttons); mSubtitleButton = v.findViewById(R.id.subtitle); if (mSubtitleButton != null) { mSubtitleButton.setOnClickListener(mSubtitleListener); } mFullScreenButton = v.findViewById(R.id.fullscreen); if (mFullScreenButton != null) { mFullScreenButton.setOnClickListener(mFullScreenListener); // TODO: Show Fullscreen button when only it is possible. } mOverflowButtonRight = v.findViewById(R.id.overflow_right); if (mOverflowButtonRight != null) { mOverflowButtonRight.setOnClickListener(mOverflowRightListener); } mOverflowButtonLeft = v.findViewById(R.id.overflow_left); if (mOverflowButtonLeft != null) { mOverflowButtonLeft.setOnClickListener(mOverflowLeftListener); } mMuteButton = v.findViewById(R.id.mute); if (mMuteButton != null) { mMuteButton.setOnClickListener(mMuteButtonListener); } mSettingsButton = v.findViewById(R.id.settings); if (mSettingsButton != null) { mSettingsButton.setOnClickListener(mSettingsButtonListener); } mVideoQualityButton = v.findViewById(R.id.video_quality); if (mVideoQualityButton != null) { mVideoQualityButton.setOnClickListener(mVideoQualityListener); } mAdRemainingView = v.findViewById(R.id.ad_remaining); // Relating to Settings List View initializeSettingsLists(); mSettingsListView = (ListView) inflateLayout(getContext(), R.layout.settings_list); mSettingsAdapter = new SettingsAdapter(mSettingsMainTextsList, mSettingsSubTextsList, mSettingsIconIdsList); mSubSettingsAdapter = new SubSettingsAdapter(null, 0); mSettingsListView.setAdapter(mSettingsAdapter); mSettingsListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mSettingsListView.setOnItemClickListener(mSettingsItemClickListener); mEmbeddedSettingsItemWidth = mResources.getDimensionPixelSize(R.dimen.mcv2_embedded_settings_width); mFullSettingsItemWidth = mResources.getDimensionPixelSize(R.dimen.mcv2_full_settings_width); mEmbeddedSettingsItemHeight = mResources.getDimensionPixelSize(R.dimen.mcv2_embedded_settings_height); mFullSettingsItemHeight = mResources.getDimensionPixelSize(R.dimen.mcv2_full_settings_height); mSettingsWindowMargin = (-1) * mResources.getDimensionPixelSize(R.dimen.mcv2_settings_offset); mSettingsWindow = new PopupWindow(mSettingsListView, mEmbeddedSettingsItemWidth, LayoutParams.WRAP_CONTENT, true); }
From source file:com.rks.musicx.ui.fragments.EqFragment.java
private void initEq(View rootView) { try {//from w w w . j av a2 s . c o 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:androidx.media.widget.MediaControlView2.java
@SuppressWarnings("deprecation") private void updateLayoutForSizeChange(int sizeType) { mSizeType = sizeType;/*w ww . java 2 s . co m*/ RelativeLayout.LayoutParams timeViewParams = (RelativeLayout.LayoutParams) mTimeView.getLayoutParams(); SeekBar seeker = (SeekBar) mProgress; switch (mSizeType) { case SIZE_TYPE_EMBEDDED: // Relating to Title Bar mTitleBar.setVisibility(View.VISIBLE); mBackButton.setVisibility(View.GONE); // Relating to Full Screen Button mMinimalExtraView.setVisibility(View.GONE); mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen); mFullScreenButton.setOnClickListener(mFullScreenListener); // Relating to Center View mCenterView.removeAllViews(); mBottomBarLeftView.removeView(mTransportControls); mBottomBarLeftView.setVisibility(View.GONE); mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls); mCenterView.addView(mTransportControls); // Relating to Progress Bar seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb)); mProgressBuffer.setVisibility(View.VISIBLE); // Relating to Bottom Bar mBottomBar.setVisibility(View.VISIBLE); if (timeViewParams.getRules()[RelativeLayout.LEFT_OF] != 0) { timeViewParams.removeRule(RelativeLayout.LEFT_OF); timeViewParams.addRule(RelativeLayout.RIGHT_OF, R.id.bottom_bar_left); } break; case SIZE_TYPE_FULL: // Relating to Title Bar mTitleBar.setVisibility(View.VISIBLE); mBackButton.setVisibility(View.VISIBLE); // Relating to Full Screen Button mMinimalExtraView.setVisibility(View.GONE); mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen); mFullScreenButton.setOnClickListener(mFullScreenListener); // Relating to Center View mCenterView.removeAllViews(); mBottomBarLeftView.removeView(mTransportControls); mTransportControls = inflateTransportControls(R.layout.full_transport_controls); mBottomBarLeftView.addView(mTransportControls, 0); mBottomBarLeftView.setVisibility(View.VISIBLE); // Relating to Progress Bar seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb)); mProgressBuffer.setVisibility(View.VISIBLE); // Relating to Bottom Bar mBottomBar.setVisibility(View.VISIBLE); if (timeViewParams.getRules()[RelativeLayout.RIGHT_OF] != 0) { timeViewParams.removeRule(RelativeLayout.RIGHT_OF); timeViewParams.addRule(RelativeLayout.LEFT_OF, R.id.bottom_bar_right); } break; case SIZE_TYPE_MINIMAL: // Relating to Title Bar mTitleBar.setVisibility(View.GONE); mBackButton.setVisibility(View.GONE); // Relating to Full Screen Button mMinimalExtraView.setVisibility(View.VISIBLE); mFullScreenButton = mMinimalExtraView.findViewById(R.id.minimal_fullscreen); mFullScreenButton.setOnClickListener(mFullScreenListener); // Relating to Center View mCenterView.removeAllViews(); mBottomBarLeftView.removeView(mTransportControls); mTransportControls = inflateTransportControls(R.layout.minimal_transport_controls); mCenterView.addView(mTransportControls); // Relating to Progress Bar seeker.setThumb(null); mProgressBuffer.setVisibility(View.GONE); // Relating to Bottom Bar mBottomBar.setVisibility(View.GONE); break; } mTimeView.setLayoutParams(timeViewParams); if (isPlaying()) { mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_pause_circle_filled, null)); mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_pause_button_desc)); } else { mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_play_circle_filled, null)); mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_play_button_desc)); } if (mIsFullScreen) { mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen_exit, null)); } else { mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen, null)); } }