Example usage for android.widget SeekBar setMax

List of usage examples for android.widget SeekBar setMax

Introduction

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

Prototype

@Override
    public synchronized void setMax(int max) 

Source Link

Usage

From source file:com.andreadec.musicplayer.MainActivity.java

private void bassBoostSettings() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.bassBoost);
    View view = getLayoutInflater().inflate(R.layout.layout_bassboost, null);
    builder.setView(view);/*from ww w.j  a  va2 s .  co m*/

    builder.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            updateExtendedMenu();
        }
    });
    builder.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            updateExtendedMenu();
        }
    });

    CheckBox checkBoxBassBoostEnable = (CheckBox) view.findViewById(R.id.checkBoxBassBoostEnabled);
    checkBoxBassBoostEnable.setChecked(musicService.getBassBoostEnabled());
    checkBoxBassBoostEnable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            musicService.toggleBassBoost();
            updateExtendedMenu();
        }
    });

    SeekBar seekbar = (SeekBar) view.findViewById(R.id.seekBarBassBoostStrength);
    seekbar.setMax(1000);
    seekbar.setProgress(musicService.getBassBoostStrength());
    seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                musicService.setBassBoostStrength(seekBar.getProgress());
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
        }
    });

    builder.show();
}

From source file:com.javielinux.fragments.MyActivityFragment.java

public void showSizeText() {

    final int minValue = 6;

    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View sizesFontView = factory.inflate(R.layout.alert_dialog_sizes_font, null);

    ((TextView) sizesFontView.findViewById(R.id.txt_size_titles)).setText(
            getString(R.string.size_title) + " (" + PreferenceUtils.getSizeTitles(getActivity()) + ")");
    ((TextView) sizesFontView.findViewById(R.id.txt_size_text))
            .setText(getString(R.string.size_text) + " (" + PreferenceUtils.getSizeText(getActivity()) + ")");

    SeekBar sbSizeTitles = (SeekBar) sizesFontView.findViewById(R.id.sb_size_titles);

    sbSizeTitles.setMax(18);
    sbSizeTitles.setProgress(PreferenceUtils.getSizeTitles(getActivity()) - minValue);

    sbSizeTitles.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override/*www .ja v a 2  s  . c  o m*/
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progress += minValue;
            PreferenceUtils.setSizeTitles(getActivity(), progress);
            //seekBar.setProgress(progress);
            ((TextView) sizesFontView.findViewById(R.id.txt_size_titles)).setText(
                    getString(R.string.size_title) + " (" + PreferenceUtils.getSizeTitles(getActivity()) + ")");
            // TODO notificar al adapter el cambio de texto
            //mAdapterResponseList.notifyDataSetChanged();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

    });

    SeekBar sbSizeText = (SeekBar) sizesFontView.findViewById(R.id.sb_size_text);
    sbSizeText.setMax(18);
    sbSizeText.setProgress(PreferenceUtils.getSizeText(getActivity()) - minValue);

    sbSizeText.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progress += minValue;
            PreferenceUtils.setSizeText(getActivity(), progress);
            //seekBar.setProgress(progress);
            ((TextView) sizesFontView.findViewById(R.id.txt_size_text)).setText(
                    getString(R.string.size_text) + " (" + PreferenceUtils.getSizeText(getActivity()) + ")");
            // TODO notificar al adapter el cambio de texto
            //mAdapterResponseList.notifyDataSetChanged();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.font_size);
    builder.setView(sizesFontView);
    builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    builder.create();
    builder.show();
}

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  ww  .j ava 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) {
            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:com.serenegiant.aceparrot.ConfigFragment.java

/**
 * ??/*from   ww  w  .  j a  va  2  s.c  o m*/
 * @param root
 */
private void initConfigFlight(final View root) {
    if (DEBUG)
        Log.v(TAG, "initConfigFlight:");
    // 
    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());
    // /?
    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:com.rks.musicx.ui.fragments.PlayingViews.Playing3Fragment.java

@Override
protected void playingView() {
    if (getMusicXService() != null) {
        String title = getMusicXService().getsongTitle();
        String artist = getMusicXService().getsongArtistName();
        songTitle.setText(title);/*  ww  w . java 2s  .c  om*/
        songTitle.setSelected(true);
        songTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        songArtist.setText(artist);
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if (b && getMusicXService() != null
                        && (getMusicXService().isPlaying() || getMusicXService().isPaused())) {
                    getMusicXService().seekto(seekBar.getProgress());
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
        int dur = getMusicXService().getDuration();
        if (dur != -1) {
            seekbar.setMax(dur);
            totalDur.setText(Helper.durationCalculator(dur));
        }
        updateQueuePos(getMusicXService().returnpos());
        LyricsHelper.LoadLyrics(getContext(), title, artist, getMusicXService().getsongAlbumName(),
                getMusicXService().getsongData(), lrcView);
        bitmap = new bitmap() {
            @Override
            public void bitmapwork(Bitmap bitmap) {
                albumArt.setImageBitmap(bitmap);
            }

            @Override
            public void bitmapfailed(Bitmap bitmap) {
                albumArt.setImageBitmap(bitmap);
            }
        };
        palette = new palette() {
            @Override
            public void palettework(Palette palette) {
                if (Extras.getInstance().artworkColor()) {
                    final int color[] = Helper.getAvailableColor(getContext(), palette);
                    colorMode(color[0]);
                } else {
                    colorMode(accentColor);
                }
            }
        };

    }
}

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

/**
 * ???/*  ww w . ja  va 2 s.  c  om*/
 * @param root
 */
private void initConfigAutopilot(final View root) {
    // 
    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);
    mAutopilotMaxControlValue = mPref.getFloat(KEY_AUTOPILOT_MAX_CONTROL_VALUE, 100.0f);
    try {
        seekbar.setProgress((int) (mAutopilotMaxControlValue + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotMaxControlValue(mAutopilotMaxControlValue);
    // 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);
    mAutopilotScaleX = mPref.getFloat(KEY_AUTOPILOT_SCALE_X, 1.0f);
    try {
        seekbar.setProgress((int) (mAutopilotScaleX * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleX(mAutopilotScaleX);
    // 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);
    mAutopilotScaleY = mPref.getFloat(KEY_AUTOPILOT_SCALE_Y, 1.0f);
    try {
        seekbar.setProgress((int) (mAutopilotScaleY * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleY(mAutopilotScaleY);
    // 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);
    mAutopilotScaleZ = mPref.getFloat(KEY_AUTOPILOT_SCALE_Z, 1.0f);
    try {
        seekbar.setProgress((int) (mAutopilotScaleZ * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleZ(mAutopilotScaleZ);
    // 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);
    mAutopilotScaleR = mPref.getFloat(KEY_AUTOPILOT_SCALE_R, 1.0f);
    try {
        seekbar.setProgress((int) (mAutopilotScaleR * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleR(mAutopilotScaleR);
}

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

/**
 * ??// ww w  .java2  s.  c  o  m
 * @param root
 */
private void initConfigGamepad(final View root) {
    // 
    //      final CheckBox checkbox = (CheckBox)root.findViewById(R.id.usb_driver_checkbox);
    //      checkbox.setChecked(mPref.getBoolean(KEY_GAMEPAD_USE_DRIVER, false));
    //      checkbox.setOnCheckedChangeListener(mOnCheckedChangeListener);
    mGamepadMaxControlValueLabel = (TextView) root.findViewById(R.id.gamepad_sensitivity_textview);
    SeekBar seekbar = (SeekBar) root.findViewById(R.id.gamepad_sensitivity_seekbar);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadMaxControlValue = mPref.getFloat(KEY_GAMEPAD_SENSITIVITY, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadMaxControlValue + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadMaxControlValue(mGamepadMaxControlValue);
    // X
    mGamepadScaleXLabel = (TextView) root.findViewById(R.id.gamepad_scale_x_textview);
    seekbar = (SeekBar) root.findViewById(R.id.gamepad_scale_seekbar_x);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleX = mPref.getFloat(KEY_GAMEPAD_SCALE_X, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleX * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleX(mGamepadScaleX);
    // Y
    mGamepadScaleYLabel = (TextView) root.findViewById(R.id.gamepad_scale_y_textview);
    seekbar = (SeekBar) root.findViewById(R.id.gamepad_scale_seekbar_y);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleY = mPref.getFloat(KEY_GAMEPAD_SCALE_Y, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleY * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleY(mGamepadScaleY);
    // Z
    mGamepadScaleZLabel = (TextView) root.findViewById(R.id.gamepad_scale_z_textview);
    seekbar = (SeekBar) root.findViewById(R.id.gamepad_scale_seekbar_z);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleZ = mPref.getFloat(KEY_GAMEPAD_SCALE_Z, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleZ * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleZ(mGamepadScaleZ);
    // R
    mGamepadScaleRLabel = (TextView) root.findViewById(R.id.gamepad_scale_r_textview);
    seekbar = (SeekBar) root.findViewById(R.id.gamepad_scale_seekbar_r);
    seekbar.setOnSeekBarChangeListener(null);
    seekbar.setMax(1000);
    mGamepadScaleR = mPref.getFloat(KEY_GAMEPAD_SCALE_R, 1.0f);
    try {
        seekbar.setProgress((int) (mGamepadScaleR * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateGamepadScaleR(mGamepadScaleR);
}

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing4Fragment.java

@Override
protected void playingView() {
    if (getMusicXService() != null) {
        String title = getMusicXService().getsongTitle();
        String artist = getMusicXService().getsongArtistName();
        songTitle.setText(title);//w ww . j  a v  a 2 s  . c  o m
        songTitle.setSelected(true);
        songTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        songArtist.setText(artist);
        Helper.rotationAnim(albumArtwork);
        Helper.rotationAnim(playpausebutton);
        int dur = getMusicXService().getDuration();
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if (b && getMusicXService() != null
                        && (getMusicXService().isPlaying() || getMusicXService().isPaused())) {
                    getMusicXService().seekto(seekBar.getProgress());
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
        if (dur != -1) {
            seekbar.setMax(dur);
            totalDur.setText(Helper.durationCalculator(dur));
        }
        updateQueuePos(getMusicXService().returnpos());
        LyricsHelper.LoadLyrics(getContext(), title, artist, getMusicXService().getsongAlbumName(),
                getMusicXService().getsongData(), lrcview);
        bitmap = new bitmap() {
            @Override
            public void bitmapwork(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }

            @Override
            public void bitmapfailed(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }
        };
        palette = new palette() {
            @Override
            public void palettework(Palette palette) {
                final int[] colors = Helper.getAvailableColor(getContext(), palette);
                if (Extras.getInstance().artworkColor()) {
                    colorMode(colors[0]);
                } else {
                    colorMode(accentColor);
                }
                ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        ((ColorDrawable) controlsBg.getBackground()).getColor(), colors[0]);
                colorAnimation.setDuration(250); // milliseconds
                colorAnimation.addUpdateListener(
                        animator -> controlsBg.setBackgroundColor((int) animator.getAnimatedValue()));
                colorAnimation.start();
            }
        };
        if (mVisualizer != null) {
            if (vizualview != null) {
                vizualview.setEnabled(true);
            }
            mVisualizer.setEnabled(true);
        }
    }
}

From source file:im.ene.lab.toro.ext.layeredvideo.PlaybackControlLayer.java

/**
 * Perform binding to UI, setup of event handlers and initialization of values.
 *///from ww  w.j  av a  2s  .co m
private void setupView() {
    if (actionToolbar == null) {
        actionToolbar = (Toolbar) view.findViewById(R.id.playback_toolbar);
        actionToolbar.inflateMenu(R.menu.playback_actions);
        actionToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                if (settingsCallback != null) {
                    settingsCallback.onSettings();
                    return true;
                }

                return false;
            }
        });
    }
    // Bind fields to UI elements.
    pausePlayButton = (ImageButton) view.findViewById(R.id.pause);
    fullscreenButton = (ImageButton) view.findViewById((R.id.fullscreen));
    seekBar = (SeekBar) view.findViewById(R.id.media_controller_progress);
    endTime = (TextView) view.findViewById(R.id.time_duration);
    currentTime = (TextView) view.findViewById(R.id.time_current);
    logoImageView = (ImageView) view.findViewById(R.id.logo_image);
    playbackControlRootView = (FrameLayout) view.findViewById(R.id.middle_section);
    topChrome = (RelativeLayout) view.findViewById(R.id.top_chrome);
    bottomChrome = (LinearLayout) view.findViewById(R.id.bottom_chrome);
    actionButtonsContainer = (LinearLayout) view.findViewById(R.id.actions_container);

    // The play button should toggle play/pause when the play/pause button is clicked.
    pausePlayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            togglePlayPause();
            show(DEFAULT_TIMEOUT_MS);
        }
    });

    if (fullscreenCallback == null) {
        fullscreenButton.setVisibility(View.INVISIBLE);
    }
    // Go into fullscreen when the fullscreen button is clicked.
    fullscreenButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doToggleFullscreen();
            show(DEFAULT_TIMEOUT_MS);
            updateActionButtons();
            updateColors();
        }
    });

    seekBar.setMax(1000);

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromuser) {
            if (!fromuser || !canSeek) {
                // Ignore programmatic changes to seek bar position.
                // Ignore changes to seek bar position is seeking is not enabled.
                return;
            }

            ObservablePlayerControl playerControl = layerManager.getControl();
            long duration = playerControl.getDuration();
            long newPosition = (duration * progress) / 1000L;
            playerControl.seekTo((int) newPosition);
            if (currentTime != null) {
                currentTime.setText(formatTimeString((int) newPosition));
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            show(0);
            isSeekBarDragging = true;
            handler.removeMessages(SHOW_PROGRESS);
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            isSeekBarDragging = false;
            updateProgress();
            updatePlayPauseButton();
            show(DEFAULT_TIMEOUT_MS);

            handler.sendEmptyMessage(SHOW_PROGRESS);
        }
    });

    actionToolbar.setTitle(videoTitle);

    timeFormat = new StringBuilder();
    timeFormatter = new Formatter(timeFormat, Locale.getDefault());
}

From source file:systems.byteswap.publicstream.MainActivity.java

/** add all callbacks to the corresponding GUI elements:
 * -) Play the live stream/*  w w  w . j  a v a 2  s.c  om*/
 * -) Play/Pause button
 * -) Seekbar
 */
public void addGUIListener() {
    //add a click listener to the "Live" button
    Button buttonLive = (Button) findViewById(R.id.buttonLive);
    buttonLive.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mService.setUseHWAcceleration(useHWAccel);
            mService.onCommand(MediaService.ACTION_LOAD, ORFParser.ORF_LIVE_URL);
            TextView text = (TextView) findViewById(R.id.textViewCurrentStream);
            if (dataFragment != null)
                dataFragment.setTextPlayButton("LIVE");
            text.setText("LIVE");
            handler.removeCallbacks(mRunnableSeek);
            handler.postDelayed(mRunnableSeek, 1000);
            updateGUIElementsVisibility();
        }
    });

    //add a click listener to the "Play/Pause" button
    final ImageButton buttonPlayPause = (ImageButton) findViewById(R.id.buttonPause);
    buttonPlayPause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mService != null) {
                mService.setUseHWAcceleration(useHWAccel);
                mService.onCommand(MediaService.ACTION_PLAY_PAUSE, "");
            }
            handler.removeCallbacks(mRunnableSeek);
            handler.postDelayed(mRunnableSeek, 1000);
            updateGUIElementsVisibility();
        }
    });
    updateGUIElementsVisibility();

    SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
    seekBar.setMax(1000);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            if (mService != null) {
                mService.onCommand(MediaService.ACTION_SETTIME,
                        String.valueOf((float) seekBar.getProgress() / 1000));
                updateGUIElementsVisibility();
            }
        }
    });
}