Java Code Examples for android.widget.SeekBar

The following examples show how to use android.widget.SeekBar. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
    if (t_prevProgress == -1) {
        t_prevProgress = seek_now;
    }

    if (fromUser)
    {
        long offset = progress - t_prevProgress;
        boolean speed_1d = WorldMapWidgetSettings.loadWorldMapPref(getContext(), 0, WorldMapWidgetSettings.PREF_KEY_WORLDMAP_SPEED1D, WorldMapWidgetSettings.MAPTAG_3x2);
        long scaledOffset = (speed_1d ? ((offset * ((SEEK_TOTALMINUTES_1d) / seek_totalMinutes)) / SEEK_STEPSIZE_1d) * SEEK_STEPSIZE_1d : offset);
        worldmap.setOffsetMinutes(worldmap.getOffsetMinutes() + scaledOffset);
        updateTimeText();
    }

    t_prevProgress = progress;
}
 
Example 2
@Override
                public void onProgressChanged(SeekBar seekBar, int progress,
                                              boolean fromUser) {
                    if (progress == 0) progress = 1;
                    mCurrentColorStrokeObject.strokeWidth = progress;

                    int tmpColor = Color.BLACK;
//                    if (mCurrentColorStrokeObject.hasStroke)
//                        tmpColor = mCurrentColorStrokeObject.strokeColor;
                    // configure a Paint object for the current SeekBar value
                    Paint p = new Paint();
                    p.setColor(tmpColor);
                    p.setStrokeCap(Paint.Cap.ROUND);
                    p.setStrokeWidth(progress);

                    // erase the bitmap and redraw the line
                    bitmap.eraseColor(Compat.getColor(getContext(), android.R.color.transparent));
                    canvas.drawLine(30, 50, 370, 50, p);
                    mWidthImageView.setImageBitmap(bitmap);
                    mWidthTextView.setText(String.valueOf(progress));
                }
 
Example 3
Source Project: My-MVP   Source File: SeekbarFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void subscribe() {
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeAdapterListener(){
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            super.onProgressChanged(seekBar, progress, fromUser);
            if (fromUser) {
                mSeekbarViewModel.seekbarValue.setValue(progress);
            }
        }
    });

    mSeekbarViewModel.seekbarValue.observe(this, new Observer<Integer>() {
        @Override
        public void onChanged(@Nullable Integer integer) {
            if (integer != null) {
                mSeekBar.setProgress(integer);
            }
        }
    });
}
 
Example 4
@Override
protected View onCreateDialogView() {
    final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View view = inflater.inflate(R.layout.pref_seek_dialog, null);

    try {
        currentValue = Integer.parseInt(getPersistedString(Integer.toString(defaultValue)));
    } catch (NumberFormatException ex) {
        currentValue = minValue;
    }

    ((TextView) view.findViewById(R.id.pref_seek_min_value)).setText(Integer.toString(minValue));
    ((TextView) view.findViewById(R.id.pref_seek_max_value)).setText(Integer.toString(maxValue));

    seekBar = (SeekBar) view.findViewById(R.id.pref_seek_bar);
    seekBar.setMax(maxValue - minValue);
    seekBar.setProgress(currentValue - minValue);
    seekBar.setKeyProgressIncrement(1);
    seekBar.setOnSeekBarChangeListener(this);

    text = (TextView) view.findViewById(R.id.pref_seek_current_value);
    text.setText(Integer.toString(currentValue));

    handler.init(new IViewContainer.ViewBridge(view), seekBar, R.id.pref_seek_bar_minus, R.id.pref_seek_bar_plus);
    return view;
}
 
Example 5
Source Project: FimiX8-RE   Source File: X8AiReturnConfirmUi.java    License: MIT License 6 votes vote down vote up
public void initViews(View rootView) {
    this.imgReturn = rootView.findViewById(R.id.img_ai_follow_return);
    this.btnOk = rootView.findViewById(R.id.btn_ai_follow_confirm_ok);
    this.prex = rootView.getContext().getString(R.string.x8_ai_fly_return_home_tip);
    this.prex2 = rootView.getContext().getString(R.string.x8_ai_fly_return_home_tip2);
    this.tvCuurentHeight = (TextView) rootView.findViewById(R.id.tv_ai_follow_confirm_title1);
    this.tvHeight = (TextView) rootView.findViewById(R.id.tv_limit_height);
    this.rlMinus = rootView.findViewById(R.id.rl_minus);
    this.rlPlus = rootView.findViewById(R.id.rl_plus);
    this.mSeekBar = (SeekBar) rootView.findViewById(R.id.sb_value);
    this.mSeekBar.setMax(this.MAX);
    this.imgFlag = (ImageView) rootView.findViewById(R.id.img_ai_return_flag);
    AutoFcSportState state = StateManager.getInstance().getX8Drone().getFcSportState();
    if (state != null) {
        showSportState(state);
    }
}
 
Example 6
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    switch (seekBar.getId()) {
        case R.id.sb_item_space:
            int itemSpace = progress * 5;
            carouselLayoutManager.setItemSpace(itemSpace);
            itemSpaceValue.setText(String.valueOf(itemSpace));
            break;
        case R.id.sb_min_scale:
            final float scale = progress / 100f;
            carouselLayoutManager.setMinScale(scale);
            minScaleValue.setText(Util.formatFloat(scale));
            break;
        case R.id.sb_speed:
            final float speed = progress * 0.05f;
            carouselLayoutManager.setMoveSpeed(speed);
            speedValue.setText(Util.formatFloat(speed));
            break;
    }
}
 
Example 7
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_chromecast_controller, container);
	ButterKnife.bind(this, view);
	videoDescriptionLayout = new VideoDescriptionLayout();
	ButterKnife.bind(videoDescriptionLayout, videoDescriptionInclude);

	// Set the background color of the video description layout since by default it doesn't match the background color of the Chromecast controller
	TypedValue typedValue = new TypedValue();
	getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
	videoDescriptionLayout.linearLayout.setBackgroundResource(typedValue.resourceId);

	Linker.configure(videoDescriptionLayout.videoDescription);

	((SeekBar)chromecastPlaybackProgressBar).setOnSeekBarChangeListener(this);
	if(savedInstanceState != null) {
		setupDescription();
	}
	return view;
}
 
Example 8
Source Project: TextPathView   Source File: FifthActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (seekBar.getId() == R.id.sb_start) {
        start = progress;
        if (start > stop) {
            stop = start;
            sbStop.setProgress(stop);
        }
    } else {
        stop = progress;
        if (stop < start) {
            start = stop;
            sbStart.setProgress(start);
        }
    }

    float startF = start / 1000f;
    float stopF = stop / 1000f;
    atpv.drawPath(startF, stopF);
    stpv.drawPath(startF, stopF);
    spv.drawPath(startF, stopF);
    aspv.drawPath(startF, stopF);
}
 
Example 9
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (polyline == null || !fromUser) {
        return;
    }

    if (seekBar == hueBar) {
        polyline.setColor(
            Color.HSVToColor(Color.alpha(polyline.getColor()), new float[] {progress, 1, 1}));
    } else if (seekBar == alphaBar) {
        float[] prevHSV = new float[3];
        Color.colorToHSV(polyline.getColor(), prevHSV);
        polyline.setColor(Color.HSVToColor(progress, prevHSV));
    }

    argbTextView.setText(String.format("0x%08X", polyline.getColor()));
}
 
Example 10
Source Project: mollyim-android   Source File: AudioView.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public synchronized void onStartTrackingTouch(SeekBar seekBar) {
  wasPlaying = isPlaying;
  if (audioSlidePlayer != null && isPlaying) {
    audioSlidePlayer.stop();
  }
}
 
Example 11
private void setUpProgressSlider() {
    int color = MaterialValueHelper.getPrimaryTextColor(getContext(), false);
    progressSlider.getThumb().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
    progressSlider.getProgressDrawable().mutate().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);

    progressSlider.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                MusicPlayerRemote.seekTo(progress);
                onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(), MusicPlayerRemote.getSongDurationMillis());
            }
        }
    });
}
 
Example 12
Source Project: MediaSDK   Source File: PlayerActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
    if (mPlayer != null) {
        mHandler.removeMessages(MSG_UPDATE_PROGRESS);
    }
    LogUtils.d("onStartTrackingTouch progress="+mProgressView.getProgress());
}
 
Example 13
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    switch (seekBar.getId()) {
        case R.id.seekbar_player_position:
            controlPeriodicSeekBarUpdating();
            break;
    }
}
 
Example 14
Source Project: DesignOverlay-Android   Source File: SeekBarPreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    mTrackingTouch = false;
    if (seekBar.getProgress() != mProgress) {
        syncProgress(seekBar);
    }
}
 
Example 15
Source Project: FimiX8-RE   Source File: CustomVideoView.java    License: MIT License 5 votes vote down vote up
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (fromUser) {
        LogUtil.i(TAG, "onProgressChanged:" + this.isUpdateProgressed);
        this.isUpdateProgressed = true;
        this.showTopBottomBarTime = 0;
        this.mCurrentTimeTv.setText(setTimeFormatter(seekBar.getProgress()));
    }
}
 
Example 16
Source Project: fullscreen-video-view   Source File: VideoControllerView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    setIsDragging(false);
    setProgress();
    updatePausePlay();
    show(DEFAULT_CONTROLLER_TIMEOUT);

    // Ensure that progress is properly updated in the future,
    // the call to show() does not guarantee this because it is a
    // no-op if we are already showing.
    refreshProgress();
}
 
Example 17
protected void initView() {
    mPauseButton = (ImageButton) findViewById(R.id.pause);
    mProgress = (SeekBar) findViewById(R.id.mediacontroller_progress);
    mEndTime = (TextView) findViewById(R.id.time);
    mCurrentTime = (TextView) findViewById(R.id.time_current);
    mFullscreenButton = (ImageButton) findViewById(R.id.fullscreen);
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
    mProgress.setOnSeekBarChangeListener(mSeekListener);
    mProgress.setMax(1000);
}
 
Example 18
Source Project: ShareBox   Source File: SimpleMediaController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar bar) {
    mDragging = false;
    mPlayer.seekTo((int) position);
    setProgress();
    updatePausePlay();
    show(sDefaultTimeout);

    // Ensure that progress is properly updated in the future,
    // the call to show() does not guarantee this because it is a
    // no-op if we are already showing.
    mHandler.sendEmptyMessage(SHOW_PROGRESS);
}
 
Example 19
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (!fromUser) {
        // We're not interested in programmatically generated changes to
        // the progress bar's position.
        return;
    }

    long duration = mPlayer.getDuration();
    long newPosition = (duration * progress) / 1000L;
    mPlayer.seekTo((int) newPosition);
    if (mCurrentTime != null)
        mCurrentTime.setText(Util.stringForTime((int) newPosition));
}
 
Example 20
Source Project: preferencebinder   Source File: SampleFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.activity_main, container, false);
    booleanPreferenceDisplay = (CheckBox) view.findViewById(R.id.pref_boolean);
    integerPreferenceDisplay = (SeekBar) view.findViewById(R.id.pref_integer);
    PreferenceBinder.bind(this);

    startHandlerOnBackgroundThread();
    return view;
}
 
Example 21
Source Project: media-for-mobile   Source File: PlaybackToolbar.java    License: Apache License 2.0 5 votes vote down vote up
private void bindControls()
{
	mPlayButton = (ImageButton) findViewById(R.id.playButton);		
	mPlayButton.setOnClickListener(this);
	
	mPauseButton = (ImageButton) findViewById(R.id.pauseButton);		
	mPauseButton.setOnClickListener(this);

	mPlayTimeText = (TextView)findViewById(R.id.playTimeText);
	
	mPlayProgress = (SeekBar)findViewById(R.id.playProgress);
	mPlayProgress.setOnSeekBarChangeListener(this);
}
 
Example 22
private ViewGroup getPanel(Context context, int type) {
    final ViewGroup mViewGroup = new LinearLayout(context);
    LinearLayout.LayoutParams btnParam =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    //   btnParam.weight = 1;
    btnParam.gravity = Gravity.CENTER_VERTICAL;
    LinearLayout.LayoutParams seekBarParam =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    seekBarParam.weight = 1;
    seekBarParam.gravity = Gravity.CENTER;

    ImageButton btnBack = new ImageButton(context);
    btnBack.setImageBitmap(backBitmap);
    btnBack.setScaleType(ImageView.ScaleType.FIT_CENTER);
    btnBack.setBackgroundColor(Color.alpha(255));

    SeekBar seekBar = getSeekBar(context, type);

    ImageButton btnFunc = new ImageButton(context);
    btnFunc.setImageBitmap(funcBitmap);
    btnFunc.setScaleType(ImageView.ScaleType.FIT_CENTER);
    btnFunc.setBackgroundColor(Color.alpha(255));

    mViewGroup.addView(btnBack, btnParam);
    mViewGroup.addView(seekBar, seekBarParam);
    mViewGroup.addView(btnFunc, btnParam);

    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mViewGroup.setBackgroundColor(Color.BLACK);
    btnBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            wm.removeView(mViewGroup);
        }
    });

    return mViewGroup;
}
 
Example 23
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (mApp.isServiceRunning()) {
        try {
            long currentSongDuration = mApp.getService().getMediaPlayer().getDuration();
            seekBar.setMax((int) currentSongDuration);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example 24
Source Project: no-player   Source File: AndroidControllerView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    LayoutInflater.from(getContext()).inflate(R.layout.merge_player_controls, this, true);

    playPauseButton = (ImageView) findViewById(R.id.player_controls_play_pause);
    elapsedTimeView = (TextView) findViewById(R.id.player_controls_elapsed_time);
    progressView = (SeekBar) findViewById(R.id.player_controls_progress);
    timeRemainingView = (TextView) findViewById(R.id.player_controls_time_remaining);
    volumeOnOffView = findViewById(R.id.player_controls_volume_on_off);
}
 
Example 25
Source Project: GravityBox   Source File: SeekBarPreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (!fromUser) return;

    progress = Math.round(((float) progress) / mInterval) * mInterval + mMinimum;
    if (mTracking) {
        setMonitorBoxText(progress);
    } else {
        setValue(progress);
    }
}
 
Example 26
Source Project: delion   Source File: SeekBarPreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
    seekBar.setOnSeekBarChangeListener(this);
    seekBar.setMax(prefValueToSeekBarProgress(mMax));
    seekBar.setProgress(prefValueToSeekBarProgress(mValue));
    seekBar.setEnabled(isEnabled());
    mSummaryView = (TextView) view.findViewById(R.id.seekbar_amount);
    mSummaryView.setText(mSummary);
}
 
Example 27
Source Project: Chimee   Source File: PhotoOverlayActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    switch (selectedView.getId()) {
        case R.id.fl_photo_overlay_border:
            updateStrokeWidthFromProgress(progress);
            break;
        case R.id.fl_photo_overlay_shadow:
            updateShadowXyFromProgress(progress);
            break;
        case R.id.fl_photo_overlay_background:
            updatePaddingFromProgress(progress);
            break;
    }

}
 
Example 28
Source Project: ExVidPlayer   Source File: ExVpCompleteFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void initViews() {
  progressBar = (ProgressBar) mView.findViewById(R.id.pbar);
  surfaceView = (SurfaceView) mView.findViewById(R.id.surface_view);
  //controls
  root = (LinearLayout) mView.findViewById(R.id.root);
  ivLock = (ImageButton) mView.findViewById(R.id.btn_lock);
  ivRev = (ImageButton) mView.findViewById(R.id.btn_rev);
  ivForword = (ImageButton) mView.findViewById(R.id.btn_fwd);
  ivNext = (ImageButton) mView.findViewById(R.id.btn_next);
  ivPrev = (ImageButton) mView.findViewById(R.id.btn_prev);
  ivPlayPause = (ImageButton) mView.findViewById(R.id.btn_pause);
  ivSetting = (ImageButton) mView.findViewById(R.id.btn_settings);
  mProgress = (SeekBar) mView.findViewById(R.id.seekbar);
  tvCurrent = (TextView) mView.findViewById(R.id.txt_currentTime);
  tvTotal = (TextView) mView.findViewById(R.id.txt_totalDuration);
  prgCenterText = (LinearLayout) mView.findViewById(R.id.seekbar_center_text);
  tvCenterCurrent = (TextView) mView.findViewById(R.id.txt_seek_currTime);
  tvCenterProg = (TextView) mView.findViewById(R.id.txt_seek_secs);
  //brightness
  brightnessSlider = (LinearLayout) getView(R.id.brightness_slider_container);
  ivBrightness = (ImageView) getView(R.id.brightness_image);
  ivBrightnessImage = (ImageView) getView(R.id.brightnessIcon);
  pBarBrighness = (ProgressBar) getView(R.id.brightness_slider);
  tvBrightnessPercent = (TextView) getView(R.id.brigtness_perc_center_text);
  brightnessCenterText = (LinearLayout) getView(R.id.brightness_center_text);
  //volume
  volumeSlider = (LinearLayout) getView(R.id.volume_slider_container);
  ivVolume = (ImageView) getView(R.id.vol_image);
  ivVolumeImage = (ImageView) getView(R.id.volIcon);
  pBarVolume = (VolBar) getView(R.id.volume_slider);
  tvVolumePercent = (TextView) getView(R.id.vol_perc_center_text);
  volumeCenterText = (LinearLayout) getView(R.id.vol_center_text);

  aspectRatioFrameLayout=(AspectRatioFrameLayout)getView(R.id.video_frame);
}
 
Example 29
Source Project: xDrip-plus   Source File: ProfileAdapter.java    License: GNU General Public License v3.0 4 votes vote down vote up
MyViewHolder(View view) {
    super(view);
    title = (TextView) view.findViewById(R.id.title);

    day = (TextView) view.findViewById(R.id.whichday);
    carbsSeekBar = (SeekBar) view.findViewById(R.id.carbsSeekBar);
    sensSeekBar = (SeekBar) view.findViewById(R.id.sensitivitySeekBar);

    carbsresult = (EditText) view.findViewById(R.id.profileCarbsText);
    sensresult = (EditText) view.findViewById(R.id.profileSensText);

    startTime = (TextView) view.findViewById(R.id.profileTextClockStart);
    endTime = (TextView) view.findViewById(R.id.profileTextClockEnd);

    wholeBlock = (RelativeLayout) view.findViewById(R.id.profile_list_row_block);


}
 
Example 30
Source Project: android-samples   Source File: TileOverlayDemoActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}