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:org.ciasaboark.tacere.activity.SettingsActivity.java

private void drawMediaWidgets() {
    TextView mediaTV = (TextView) findViewById(id.settings_mediaText);
    if (prefs.getIsServiceActivated()) {
        mediaTV.setTextColor(getResources().getColor(R.color.textcolor));
    } else {//from  w w w  . j  a v  a  2  s.  c o  m
        mediaTV.setTextColor(getResources().getColor(R.color.textColorDisabled));
    }

    //the media volumes toggle
    Switch mediaSwitch = (Switch) findViewById(id.adjustMediaCheckBox);
    SeekBar mediaSB = (SeekBar) findViewById(id.mediaSeekBar);
    if (prefs.getAdjustMedia()) {
        mediaSwitch.setChecked(true);
    } else {
        mediaSwitch.setChecked(false);
    }
    mediaSwitch.setEnabled(prefs.getIsServiceActivated());
    findViewById(id.settings_mediaBox).setEnabled(prefs.getIsServiceActivated());

    //the media volumes slider
    mediaSB.setMax(VolumesManager.getMaxMediaVolume());
    mediaSB.setProgress(prefs.getCurMediaVolume());
    if (prefs.getAdjustMedia() && prefs.getIsServiceActivated()) {
        this.animateRevealView(mediaSB);
        mediaSB.setEnabled(true);
    } else {
        mediaSB.setEnabled(false);
        this.animateHideView(mediaSB);
    }
    mediaSB.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            prefs.setCurMediaVolume(progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            //required stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            //required stub
        }
    });
}

From source file:info.tellmetime.TellmetimeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_tellmetime);

    mDensity = getResources().getDisplayMetrics().density;
    mScreenWidth = getResources().getDisplayMetrics().widthPixels;
    mScreenHeight = getResources().getDisplayMetrics().heightPixels;
    mShorterEdge = Math.min(mScreenWidth, mScreenHeight);
    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
    mBacklightLight = getResources().getColor(R.color.backlight_light);
    mBacklightDark = getResources().getColor(R.color.backlight_dark);

    // Restore background and highlight colors from saved values or set defaults.
    mSettings = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
    mHighlightColor = mSettings.getInt(HIGHLIGHT, Color.WHITE);
    mBacklightColor = mSettings.getInt(BACKLIGHT, mBacklightLight);
    mBackgroundColor = mSettings.getInt(BACKGROUND, getResources().getColor(R.color.background));
    mBackgroundMode = mSettings.getInt(BACKGROUND_MODE, MODE_BACKGROUND_SOLID);
    mHighlightPosition = mSettings.getFloat(POSITION, 0.0f);
    mMinutesSize = mSettings.getInt(MINUTES_SIZE, 36);
    isNightMode = mSettings.getBoolean(NIGHTMODE, false);

    // Dim the navigation bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        getWindow().getDecorView().setSystemUiVisibility(isNightMode ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0);

    mSurface = (RelativeLayout) findViewById(R.id.surface);
    mSurface.setBackgroundColor(mBackgroundColor);

    resizeClock();//w ww  .  jav a2s  .com

    Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf");

    // Set typeface of all items in the clock to Roboto and dim each one and drop shadow on them.
    final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock);
    for (int i = 0; i < mClock.getChildCount(); i++) {
        LinearLayout row = (LinearLayout) mClock.getChildAt(i);

        for (int j = 0; j < row.getChildCount(); j++) {
            TextView tv = (TextView) row.getChildAt(j);

            tv.setTypeface(mTypefaceBold);
            tv.setTextColor(mBacklightColor);
            tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
        }
    }

    ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots);
    for (int i = 0; i < minutesDots.getChildCount(); i++) {
        TextView m = (TextView) minutesDots.getChildAt(i);

        m.setTypeface(mTypefaceBold);
        m.setTextColor(mBacklightColor);
        m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
    }

    // Set Roboto font on TextView where it isn't default.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        Typeface mTypefaceItalic = Typeface.createFromAsset(getAssets(), "Roboto-CondensedItalic.ttf");

        ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.info_background)).setTypeface(mTypefaceItalic);
        ((TextView) findViewById(R.id.info_image)).setTypeface(mTypefaceItalic);
        ((TextView) findViewById(R.id.labelHighlight)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_light)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_dark)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_highlight)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.labelMinutes)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m1)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m2)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m3)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m4)).setTypeface(mTypefaceBold);
    }

    FrameLayout mTouchZone = (FrameLayout) findViewById(R.id.touchZone);
    mTouchZone.setOnTouchListener(this);
    mTouchZone.setBackgroundColor(
            getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent));

    mBackgroundImage = (ImageView) findViewById(R.id.background_image);
    switchBackgroundMode(mBackgroundMode);

    RelativeLayout mPanel = (RelativeLayout) findViewById(R.id.panel);
    mPanel.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mHider.delayedHide(4000);
            return true;
        }
    });

    mHider = new PanelHider(mPanel, this);

    Spinner spinnerBackgroundMode = (Spinner) findViewById(R.id.spinnerBackgroundMode);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.backgrounds_modes,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerBackgroundMode.setAdapter(adapter);
    spinnerBackgroundMode.setOnItemSelectedListener(this);
    spinnerBackgroundMode.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mHider.showNoAutoHide();
            return false;
        }
    });
    spinnerBackgroundMode.setSelection(mBackgroundMode);

    mSeekBarHighlight = (SeekBar) findViewById(R.id.highlightValue);
    mSeekBarHighlight.setOnSeekBarChangeListener(this);

    // Draw rainbow gradient on #mSeekBarHighlight and set position.
    drawRainbow();

    if (mBacklightColor == mBacklightLight)
        ((RadioButton) findViewById(R.id.radio_backlight_light)).setChecked(true);
    else if (mBacklightColor == mBacklightDark)
        ((RadioButton) findViewById(R.id.radio_backlight_dark)).setChecked(true);
    else
        ((RadioButton) findViewById(R.id.radio_backlight_highlight)).setChecked(true);

    SeekBar mSeekBarMinutes = (SeekBar) findViewById(R.id.minutesSize);
    mSeekBarMinutes.setOnSeekBarChangeListener(this);
    mSeekBarMinutes.setProgress(mMinutesSize);

    mHider.hideNow();

    Color.colorToHSV(mBackgroundColor, mHSV);
    mHSV[1] = 1.0f;

    //Trigger initial tick.
    mClockAlgorithm.tickTock();

    // Schedule the clock algorithm to tick every round minute.
    Calendar time = Calendar.getInstance();
    time.set(Calendar.MILLISECOND, 0);
    time.set(Calendar.SECOND, 0);
    time.add(Calendar.MINUTE, 1);

    Timer timer = new Timer();
    timer.schedule(mClockTask, time.getTime(), 60 * 1000);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mSurface.setAlpha(0.0f);
        mSurface.animate().alpha(1.0f).setDuration(1500);
    }

    // If it is first run, hint to user that panel is available.
    if (!mSettings.contains(HIGHLIGHT))
        showToast(R.string.info_first_run);
}

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

/**
 * ??//from  w  w w. j  av a2s.c om
 * @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.cw.litenote.note.AudioUi_note.java

private static void setAudioBlockListener(final AppCompatActivity act, final String audioStr,
        final ViewPager _pager) {
    SeekBar seekBarProgress = (SeekBar) act.findViewById(R.id.pager_img_audio_seek_bar);
    ImageView mPager_audio_play_button = (ImageView) act.findViewById(R.id.pager_btn_audio_play);

    // set audio play and pause control image
    mPager_audio_play_button.setOnClickListener(new View.OnClickListener() {
        @Override/* ww w  . ja  va2s .c  om*/
        public void onClick(View v) {

            //                // check permission first time, request phone permission
            //                if(Build.VERSION.SDK_INT >= M)//API23
            //                {
            //                    int permissionPhone = ActivityCompat.checkSelfPermission(act, Manifest.permission.READ_PHONE_STATE);
            //                    if(permissionPhone != PackageManager.PERMISSION_GRANTED)
            //                    {
            //                        ActivityCompat.requestPermissions(act,
            //                                new String[]{Manifest.permission.READ_PHONE_STATE},
            //                                Util.PERMISSIONS_REQUEST_PHONE);
            //                    }
            //                    else
            //                        UtilAudio.setPhoneListener(act);
            //                }
            //                else
            //                    UtilAudio.setPhoneListener(act);

            isPausedAtSeekerAnchor = false;

            if ((Audio_manager.isRunnableOn_page) || (BackgroundAudioService.mMediaPlayer == null)) {
                // use this flag to determine new play or not in note
                BackgroundAudioService.mIsPrepared = false;
            }
            playAudioInPager(act, audioStr, _pager);
        }
    });

    // set seek bar listener
    seekBarProgress.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            if (BackgroundAudioService.mMediaPlayer != null) {
                int mPlayAudioPosition = (int) (((float) (mediaFileLength / 100)) * seekBar.getProgress());
                BackgroundAudioService.mMediaPlayer.seekTo(mPlayAudioPosition);
            } else {
                // note audio: slide seek bar anchor from stop to pause
                isPausedAtSeekerAnchor = true;
                mAnchorPosition = (int) (((float) (mediaFileLength / 100)) * seekBar.getProgress());
                playAudioInPager(act, audioStr, _pager);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // audio player is one time mode in pager
            if (Audio_manager.getAudioPlayMode() == Audio_manager.PAGE_PLAY_MODE)
                Audio_manager.stopAudioPlayer();
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                // show progress change
                int currentPos = mediaFileLength * progress / (seekBar.getMax() + 1);
                int curHour = Math.round((float) (currentPos / 1000 / 60 / 60));
                int curMin = Math.round((float) ((currentPos - curHour * 60 * 60 * 1000) / 1000 / 60));
                int curSec = Math
                        .round((float) ((currentPos - curHour * 60 * 60 * 1000 - curMin * 60 * 1000) / 1000));
                String curr_play_time_str = String.format(Locale.ENGLISH, "%2d", curHour) + ":"
                        + String.format(Locale.ENGLISH, "%02d", curMin) + ":"
                        + String.format(Locale.ENGLISH, "%02d", curSec);
                // set current play time
                TextView audio_curr_pos = (TextView) act.findViewById(R.id.pager_audio_current_pos);
                audio_curr_pos.setText(curr_play_time_str);
            }
        }
    });

}

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

/**
 * ???//from  w  w  w.  j  a v  a2s. c  o m
 * @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

/**
 * ??//w w  w .  j av  a2s .c om
 * @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.abs.mdu.bluetoothchat.BluetoothChatFragment.java

/**
 * Set up the UI and background operations for chat.
 *//*from   ww  w .  j a  v a2s .  c  om*/
private void setupChat() {
    Log.d(TAG, "setupChat()");

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);

    mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events
    mSendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            //MDu will change it to send the seekbar value when released
            View view = getView();
            if (null != view) {
                TextView textView = (TextView) view.findViewById(R.id.edit_text_out);
                String message = textView.getText().toString();
                sendMessage(message);
            }
        }
    });

    // Initialize the BluetoothChatService to perform bluetooth connections
    mChatService = new BluetoothChatService(getActivity(), mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");

    seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        float progress = 0.0f;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            progress = progresValue;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            textView2.setText(getString(R.string.temperature_string) + progress);

            try {
                sendMsg(progress, setTemperature);
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        int progress = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            progress = progresValue;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

            textView.setText(getString(R.string.current_string) + progress);
            //mOutEditText = (EditText) findViewById(R.id.edit_text_out);
            try {
                sendMsg(progress, setCurrent);
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });

}

From source file:net.sourceforge.servestream.activity.MediaPlayerActivity.java

/** Called when the activity is first created. */
@Override/*w  w w .  j a  v  a 2 s .c o  m*/
public void onCreate(Bundle icicle) {
    setTheme(UserPreferences.getTheme());
    super.onCreate(icicle);
    setContentView(R.layout.activity_media_player);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    //actionBar.setDisplayShowCustomEnabled(true);
    //actionBar.setDisplayShowTitleEnabled(false);

    LayoutInflater inflater = getLayoutInflater();
    View v = inflater.inflate(R.layout.action_bar_media_player_header, null);

    //actionBar.setCustomView(v);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mPreferences.registerOnSharedPreferenceChangeListener(this);

    mCurrentTime = (TextView) findViewById(R.id.position_text);
    mTotalTime = (TextView) findViewById(R.id.duration_text);
    mProgress = (ProgressBar) findViewById(R.id.seek_bar);

    mPrevButton = (RepeatingImageButton) findViewById(R.id.previous_button);
    mPrevButton.setOnClickListener(mPrevListener);
    mPrevButton.setRepeatListener(mRewListener, 260);
    mPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
    mPauseButton.setOnClickListener(mPauseListener);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(mNextListener);
    mNextButton.setRepeatListener(mFfwdListener, 260);
    seekmethod = 1;

    mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD);

    mShuffleButton = (ImageButton) findViewById(R.id.shuffle_button);
    mShuffleButton.setOnClickListener(mShuffleListener);
    mRepeatButton = (ImageButton) findViewById(R.id.repeat_button);
    mRepeatButton.setOnClickListener(mRepeatListener);

    if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);

    mPager = (ViewPager) findViewById(R.id.pager);
}

From source file:com.azita.iot.ioclient.activity.MainActivity.java

public void showDialog_lightingdimmer(View view) {
    View dialogView = LayoutInflater.from(this).inflate(R.layout.share_bottom_dialog_lightingdimmer, null);
    final ShareBottomPopupDialog shareBottomPopupDialog = new ShareBottomPopupDialog(this, dialogView);
    shareBottomPopupDialog.showPopup(all_layout);

    SeekBar light_dimmer_1_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_1_seekbar);
    light_dimmer_1_seekbar.setProgress(_Lightingdimmer_1_value);
    light_dimmer_1_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override// w w  w .j  ava 2s .  co  m
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_1_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #1 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_1_value = _Lightingdimmer_1_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_2_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_2_seekbar);
    light_dimmer_2_seekbar.setProgress(_Lightingdimmer_2_value);
    light_dimmer_2_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_2_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #2 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_2_value = _Lightingdimmer_2_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_3_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_3_seekbar);
    light_dimmer_3_seekbar.setProgress(_Lightingdimmer_3_value);
    light_dimmer_3_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_3_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #3 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_3_value = _Lightingdimmer_3_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
    SeekBar light_dimmer_4_seekbar = (SeekBar) dialogView.findViewById(R.id.light_dimmer_4_seekbar);
    light_dimmer_4_seekbar.setProgress(_Lightingdimmer_4_value);
    light_dimmer_4_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        int progressChanged = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            progressChanged = progress;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            _Lightingdimmer_4_dummy_value = progressChanged;
            Toast.makeText(MainActivity.this, "Light bar #4 progress: " + progressChanged, Toast.LENGTH_SHORT)
                    .show();
            _Lightingdimmer_4_value = _Lightingdimmer_4_dummy_value;
            String dummy = "{\"customerID\":2110, \"classID\":1011, \"typeID\":1001, \"DeviceID\":1001, \"value\":\"0000"
                    + Integer.toString(_Lightingdimmer_4_value * Lightingbar_4_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_3_value * Lightingbar_3_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_2_value * Lightingbar_2_btn_flag, 16)
                    + Integer.toString(_Lightingdimmer_1_value * Lightingbar_1_btn_flag, 16) + "B\"}";
            MQTTHelper_.getInstance_(mContext).publish(dummy, true);
            shareBottomPopupDialog.dismiss();
        }
    });
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

public void setSeekBarInLayout(View layout) {
    SeekBar seekBar = (SeekBar) layout.findViewById(R.id.skbSensitivity);
    seekBar.setProgress(mAlertStartAngle - ALERT_ANGLE_INITIAL_OFFSET);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // ???????
            FlurryAgent.logEvent("Setting SeekBar");
            mAlertStartAngle = progress + ALERT_ANGLE_INITIAL_OFFSET;
            if (mAlertService != null && mAlertService.isBoundService()) {
                mAlertService.setAlertStartAngle(mAlertStartAngle);
            }//w w  w. j  a v  a2 s .c  o  m
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            // ???????
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            // ???????
        }
    });
}