Example usage for android.widget SeekBar setOnSeekBarChangeListener

List of usage examples for android.widget SeekBar setOnSeekBarChangeListener

Introduction

In this page you can find the example usage for android.widget SeekBar setOnSeekBarChangeListener.

Prototype

public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) 

Source Link

Document

Sets a listener to receive notifications of changes to the SeekBar's progress level.

Usage

From source file:com.orange.ocara.ui.dialog.AudioPlayerDialog.java

void initPlayer() {
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setOnCompletionListener(this);

    formatBuilder = new StringBuilder();
    formatter = new Formatter(formatBuilder, Locale.getDefault());

    if (progressBar instanceof SeekBar) {
        SeekBar seeker = (SeekBar) progressBar;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }/*from   w  w  w  . j ava 2s.c  om*/
    progressBar.setMax(1000);

    reset();
}

From source file:com.example.levelup.core.app.example3.TipSelectorFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    SeekBar tipSelector = (SeekBar) view.findViewById(R.id.tip_selector);

    mTipValueView = (TextView) view.findViewById(R.id.tip_value);

    // The progress on the SeekBar represents the indices of valid tip values.
    tipSelector.setMax(ALLOWED_TIPS.length - 1);
    tipSelector.setOnSeekBarChangeListener(mOnSeekBarChange);

    mOnSeekBarChange.onProgressChanged(tipSelector, 0, false);
}

From source file:net.sourceforge.servestream.utils.SleepTimerDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int MAX_SLEEP_TIMER_MINUTES = 120;
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View sleepTimerView = factory.inflate(R.layout.alert_dialog_sleep_timer, null);
    final TextView sleepTimerText = (TextView) sleepTimerView.findViewById(R.id.sleep_timer_text);

    final SeekBar seekbar = (SeekBar) sleepTimerView.findViewById(R.id.seekbar);
    sleepTimerText.setText(makeTimeString(mSleepTimerMode));
    seekbar.setProgress(mSleepTimerMode);
    seekbar.setMax(MAX_SLEEP_TIMER_MINUTES);
    seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override/*from  www .  j a v  a 2 s.c om*/
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            sleepTimerText.setText(makeTimeString(progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }

    });

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.sleep_timer_label);
    builder.setCancelable(true);
    builder.setView(sleepTimerView);
    builder.setOnCancelListener(this);
    builder.setPositiveButton(R.string.enable_sleeptimer_label, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            mListener.onSleepTimerSet(SleepTimerDialog.this, seekbar.getProgress());
        }
    });
    return builder.create();
}

From source file:com.ultrafunk.network_info.config.ConfigActivity.java

private void initTransparencyView() {
    bgTransValTextView = (TextView) findViewById(R.id.bgTransValTextView);
    bgTransValTextView.setText(String.format("%d%%", widgetConfig.getBackgroundTransparency()));

    SeekBar bgTransSeekBar = (SeekBar) findViewById(R.id.bgTransSeekBar);
    bgTransSeekBar.setProgress(widgetConfig.getBackgroundTransparency());

    bgTransSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override/*from ww w  . j av  a  2 s.  c om*/
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            widgetConfig.setBackgroundTransparency(progress);
            bgTransValTextView.setText(String.format("%d%%", progress));
        }
    });
}

From source file:com.serenegiant.aceparrot.ConfigAppFragment.java

private void initVoice(final View rootView) {
    // ??????(Android>=6)
    mOfflineVoiceRecognition = mPref.getBoolean(KEY_CONFIG_VOICE_RECOGNITION_PREFER_OFFLINE, false)
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
    Switch sw = (Switch) rootView.findViewById(R.id.enable_offline_voice_recognition_switch);
    sw.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
    sw.setChecked(mOfflineVoiceRecognition);
    sw.setOnCheckedChangeListener(mOnCheckedChangeListener);
    // //from  w  w w  .  j a  v a 2s .c  om
    mDampingRateTv = (TextView) rootView.findViewById(R.id.damping_rate_textview);
    mDampingRate = mPref.getInt(KEY_CONFIG_VOICE_RECOGNITION_DAMPING_RATE,
            DEFAULT_VOICE_RECOGNITION_DAMPING_RATE);
    final SeekBar seekBar = (SeekBar) rootView.findViewById(R.id.damping_rate_seekbar);
    seekBar.setProgress(mDampingRate);
    seekBar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateDampingRate(mDampingRate);
    // ?????????
    mScriptVoiceRecognition = mPref.getBoolean(KEY_CONFIG_VOICE_RECOGNITION_ENABLE_SCRIPT, false);
    sw = (Switch) rootView.findViewById(R.id.enable_voice_recognition_script_switch);
    sw.setChecked(mScriptVoiceRecognition);
    sw.setOnCheckedChangeListener(mOnCheckedChangeListener);
}

From source file:ar.com.martineo14.spotifystreamer2.ui.fragment.TrackPlayerActivityFragment.java

public void addListenerOnButton(View rootView) {

    buttonPlayPause = (ImageButton) rootView.findViewById(R.id.player_media_play_pause);
    buttonPlayPause.setEnabled(false);// w  w  w.j  a  va 2 s. co m

    buttonPlayPause.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            playerPlayPause();
        }
    });

    buttonNext = (ImageButton) rootView.findViewById(R.id.player_media_next);
    buttonNext.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mediaPlayer.reset();
            if (mActualPosition < ArtistDetailActivityFragment.tracksResult.size() - 1) {
                int nextPosition = mActualPosition + 1;
                displayTrack(getTrackModel(nextPosition));
            } else {
                displayTrack(getTrackModel(0));
            }
        }
    });

    buttonPrevious = (ImageButton) rootView.findViewById(R.id.player_media_previous);
    buttonPrevious.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mediaPlayer.reset();
            if (mActualPosition == 0) {
                displayTrack(getTrackModel(ArtistDetailActivityFragment.tracksResult.size() - 1));
            } else {
                int prevPosition = mActualPosition - 1;
                displayTrack(getTrackModel(prevPosition));
            }
        }
    });

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (mediaPlayer != null && fromUser) {
                mediaPlayer.seekTo(progress * 1000);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

    });

}

From source file:com.glabs.homegenie.adapters.MediaRendererWidgetAdapter.java

@Override
public View getView(LayoutInflater inflater) {
    View v = _module.View;
    if (v == null) {
        v = inflater.inflate(R.layout.widget_item_upnprenderer, null);
        _module.View = v;//from  ww  w.  ja  v  a 2 s .c o  m
        v.setTag(_module);
        //
        Button play = (Button) v.findViewById(R.id.playButton);
        play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!_playbackstatus.equals("PLAYING")) {
                    _mediaPlay();
                } else {
                    _mediaPause();
                }
            }
        });
        Button stop = (Button) v.findViewById(R.id.stopButton);
        stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaStop();
            }
        });
        Button prev = (Button) v.findViewById(R.id.prevButton);
        prev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaPrev();
            }
        });
        Button next = (Button) v.findViewById(R.id.nextButton);
        next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaNext();
            }
        });
        Button mute = (Button) v.findViewById(R.id.muteButton);
        mute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (_currentmute.equals("1")) {
                    _mediaSetMute(0);
                } else {
                    _mediaSetMute(1);
                }
            }
        });
        SeekBar volbar = (SeekBar) v.findViewById(R.id.volumeSlider);
        volbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                _mediaSetVolume(i);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    } else {
        v = _module.View;
    }
    return v;
}

From source file:com.example.android.supportv4.media.MediaController.java

private void initControllerView() {
    mPauseButton = (ImageButton) findViewById(R.id.pause);
    if (mPauseButton != null) {
        mPauseButton.requestFocus();//  ww w  . j  a  v a2s. c om
        mPauseButton.setOnClickListener(mPauseListener);
    }

    mFfwdButton = (ImageButton) findViewById(R.id.ffwd);
    if (mFfwdButton != null) {
        mFfwdButton.setOnClickListener(mFfwdListener);
        mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
    }

    mRewButton = (ImageButton) findViewById(R.id.rew);
    if (mRewButton != null) {
        mRewButton.setOnClickListener(mRewListener);
        mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
    }

    // By default these are hidden. They will be enabled when setPrevNextListeners() is called
    mNextButton = (ImageButton) findViewById(R.id.next);
    if (mNextButton != null && !mListenersSet) {
        mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) findViewById(R.id.prev);
    if (mPrevButton != null && !mListenersSet) {
        mPrevButton.setVisibility(View.GONE);
    }

    mProgress = (ProgressBar) findViewById(R.id.mediacontroller_progress);
    if (mProgress != null) {
        if (mProgress instanceof SeekBar) {
            SeekBar seeker = (SeekBar) mProgress;
            seeker.setOnSeekBarChangeListener(mSeekListener);
        }
        mProgress.setMax(1000);
    }

    mEndTime = (TextView) findViewById(R.id.time);
    mCurrentTime = (TextView) findViewById(R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();
}

From source file:com.racoon.ampdroid.views.CurrentPlaylistView.java

public void updateSongData() {
    mHandler = new Handler();
    mRunnable = new Runnable() {
        @Override/* w w  w.j  a v a  2 s  .c  om*/
        public void run() {
            Log.d("bugs", "Thread luft noch");
            final MainActivity main = (MainActivity) getActivity();
            if (main != null && main.getService() != null) {
                if (main.getService().isPlaying()) {
                    controller.setPlayingNow(main.getService().getCurrentSong());
                    songTitle.setText(main.getService().getCurrentSong().toString());
                    String artist = "Unknown";
                    if (controller.getPlayingNow().getArtist() != null) {
                        artist = controller.getPlayingNow().getArtist().toString();
                    }
                    songArtist.setText(artist);
                    togglePlayButton.setBackground(getResources().getDrawable(R.drawable.ic_action_pause));
                    int songDuration = main.getService().getMediaPlayer().getDuration() / 1000;
                    duration.setText(
                            String.format("%02d:%02d", (songDuration % 3600) / 60, (songDuration % 60)));
                    songDuration = main.getService().getMediaPlayer().getCurrentPosition() / 1000;
                    currentDuration.setText(
                            String.format("%02d:%02d", (songDuration % 3600) / 60, (songDuration % 60)));
                    int mCurrentPosition = main.getService().getMediaPlayer().getCurrentPosition();
                    seekBar.setMax(main.getService().getMediaPlayer().getDuration());
                    seekBar.setProgress(mCurrentPosition);
                    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                        @Override
                        public void onStopTrackingTouch(SeekBar seekBar) {
                            main.getService().getMediaPlayer().seekTo(seekBar.getProgress());
                        }

                        @Override
                        public void onStartTrackingTouch(SeekBar seekBar) {

                        }

                        @Override
                        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                        }
                    });
                    mHandler.postDelayed(this, 1000);
                } else {
                    updateAttempts++;
                    Log.d("bugs", "attempt " + String.valueOf(updateAttempts));
                    if (updateAttempts >= 3) {
                        Log.d("bugs", "thread pause");
                        pauseView();
                        mHandler.removeCallbacks(mRunnable);
                    }
                }
            } else {
                Log.d("bugs", "service ist nicht vorhanden");
                cleanView();
                mHandler.removeCallbacks(mRunnable);
            }

        }
    };
    mHandler.post(mRunnable);
}

From source file:com.saulcintero.moveon.fragments.Summary2.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = getActivity().getApplicationContext();

    prefs = PreferenceManager.getDefaultSharedPreferences(mContext);

    LinearLayout fragmentView = (LinearLayout) inflater.inflate(R.layout.summary2, container, false);
    summary2ListView = (ListView) fragmentView.findViewById(R.id.summary2_list_splitlaps);
    summary2ListView.setSelector(android.R.color.transparent);
    label1 = (TextView) fragmentView.findViewById(R.id.summary2_item_one);
    label2 = (TextView) fragmentView.findViewById(R.id.summary2_label_one);

    isMetric = FunctionUtils.checkIfUnitsAreMetric(mContext);

    unit = (isMetric ? 1000 : 1609);//from  www. ja v  a 2  s.c  o  m

    label1.setText((isMetric ? getString(R.string.long_unit1_detail_1).toUpperCase(Locale.getDefault())
            : getString(R.string.long_unit2_detail_1).toUpperCase(Locale.getDefault())) + ".");
    label2.setText("1 " + (isMetric ? getString(R.string.long_unit1_detail_1).toUpperCase(Locale.getDefault())
            : getString(R.string.long_unit2_detail_1).toUpperCase(Locale.getDefault())) + ".");

    seekBar = (SeekBar) fragmentView.findViewById(R.id.summary2_slider);
    seekBar.setMax(49);

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            splitData(progress * unit);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progr, boolean fromUser) {
            progress = progr + 1;

            label2.setText(String.valueOf(progress) + " "
                    + (isMetric ? getString(R.string.long_unit1_detail_1).toUpperCase(Locale.getDefault())
                            : getString(R.string.long_unit2_detail_1).toUpperCase(Locale.getDefault()))
                    + ".");
        }
    });

    return fragmentView;
}