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.serenegiant.autoparrot.BaseAutoPilotFragment.java

/**
 * ???/*w w  w  .java2s .  c  o m*/
 * @param root
 */
private void initConfigAutopilot(final View root) {
    mAutopilotScaleXFormat = getString(R.string.config_scale_x);
    mAutopilotScaleYFormat = getString(R.string.config_scale_y);
    mAutopilotScaleZFormat = getString(R.string.config_scale_z);
    mAutopilotScaleRFormat = getString(R.string.config_scale_r);
    mAutopilotMaxControlValueFormat = getString(R.string.config_control_max);
    // 
    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);
    mMaxControlValue = mPref.getFloat(KEY_AUTOPILOT_MAX_CONTROL_VALUE, DEFAULT_AUTOPILOT_MAX_CONTROL_VALUE);
    try {
        seekbar.setProgress((int) (mMaxControlValue + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotMaxControlValue(mMaxControlValue);
    // 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);
    mScaleX = mPref.getFloat(KEY_AUTOPILOT_SCALE_X, DEFAULT_AUTOPILOT_SCALE_X);
    try {
        seekbar.setProgress((int) (mScaleX * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleX(mScaleX);
    // 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);
    mScaleY = mPref.getFloat(KEY_AUTOPILOT_SCALE_Y, DEFAULT_AUTOPILOT_SCALE_Y);
    try {
        seekbar.setProgress((int) (mScaleY * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleY(mScaleY);
    // 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);
    mScaleZ = mPref.getFloat(KEY_AUTOPILOT_SCALE_Z, DEFAULT_AUTOPILOT_SCALE_Z);
    try {
        seekbar.setProgress((int) (mScaleZ * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleZ(mScaleZ);
    // 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);
    mScaleR = mPref.getFloat(KEY_AUTOPILOT_SCALE_R, DEFAULT_AUTOPILOT_SCALE_R);
    try {
        seekbar.setProgress((int) (mScaleR * SCALE_FACTOR + SCALE_OFFSET));
    } catch (final Exception e) {
        seekbar.setProgress(SCALE_OFFSET);
    }
    seekbar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAutopilotScaleR(mScaleR);
}

From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java

private void initAutoTrace(final View rootView) {
    SeekBar sb;
    ////from   w  ww  . j  av  a  2  s. c  o  m
    mTraceDirectionalReverseBiasFormat = getString(R.string.trace_config_trace_reverse_bias);
    mTraceMovingAveTapFormat = getString(R.string.trace_config_moving_ave_tap);
    mTraceDecayRateFormat = getString(R.string.trace_config_decay_rate);
    mTraceSensitivityFormat = getString(R.string.trace_config_trace_sensitivity);
    // ??
    mTraceDirectionalReverseBias = mPref.getFloat(KEY_TRACE_DIR_REVERSE_BIAS, DEFAULT_TRACE_DIR_REVERSE_BIAS);
    mTraceDirectionalReverseBiasLabel = (TextView) rootView
            .findViewById(R.id.trace_flight_reverse_bias_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_reverse_bias_seekbar);
    sb.setMax(200);
    sb.setProgress((int) (mTraceDirectionalReverseBias * 100)); // [0.0f, 2.0f] => [0, 200]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceDirectionalReverseBias(mTraceDirectionalReverseBias);
    // ?
    mTraceMovingAveTap = mPref.getInt(KEY_TRACE_MOVING_AVE_TAP, DEFAULT_TRACE_MOVING_AVE_TAP);
    mTraceMovingAveTapLabel = (TextView) rootView.findViewById(R.id.trace_flight_moving_ave_tap_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_moving_ave_tap_seekbar);
    sb.setMax(19);
    sb.setProgress(mTraceMovingAveTap - 1); // [1, 20] => [0, 19]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceMovingAveTap(mTraceMovingAveTap);
    // 
    mTraceDecayRate = mPref.getFloat(KEY_TRACE_DECAY_RATE, DEFAULT_TRACE_DECAY_RATE);
    mTraceDecayRateLabel = (TextView) rootView.findViewById(R.id.trace_flight_decay_rate_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_decay_rate_seekbar);
    sb.setMax(1000);
    sb.setProgress((int) (mTraceDecayRate * 1000.0f)); // [0.000f, 1.000f] => [0, 1000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceDecayRate(mTraceDecayRate);
    // 
    mTraceSensitivity = mPref.getFloat(KEY_TRACE_SENSITIVITY, DEFAULT_TRACE_SENSITIVITY);
    mTraceSensitivityLabel = (TextView) rootView.findViewById(R.id.trace_flight_sensitivity_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_sensitivity_seekbar);
    sb.setMax(100);
    sb.setProgress((int) (mTraceSensitivity)); // [0f, 100f] => [0, 100]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceSensitivity(mTraceSensitivity);
}

From source file:com.example.android.lightcontrol.MainActivity.java

private void setupChat() {
    Log.d(TAG, "setupChat()");

    seekBar = (SeekBar) findViewById(R.id.seekBar1);
    seekBar.setMax(Max_Value);//from  ww w  . j a v a2s .  c om
    textView_progress = (TextView) findViewById(R.id.textView1);
    textView_progress.setText(seekBar.getProgress() + "%");
    seekBar.setProgress(0);
    seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { // progress = progresValue; }
            textView_progress.setText(String.valueOf(progress1) + "%");
            if (seekBar.getProgress() == Min_Value) {
                progress1 = Min_Value;
                progrss_change_1();
            } else if (progress1 <= Max_Value) {
                progress1 = seekBar.getProgress();
                progrss_change_1();
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            textView_progress.setText(String.valueOf(progress1) + "%");

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

            textView_progress.setText(String.valueOf(progress1) + "%");
        }
    });

    mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
    ListView mConversationViewnew = (ListView) findViewById(R.id.Query_log);
    mConversationViewnew.setAdapter(mConversationArrayAdapter);

    Button light_off = (Button) findViewById(R.id.light_off);
    Button light_on = (Button) findViewById(R.id.light_on);
    // Button light_query = (Button) findViewById(R.id.light_query);
    Button send_free = (Button) findViewById(R.id.sendfreetyping);
    final EditText free_typing = (EditText) findViewById(R.id.freetyping);
    Switch ON_OFF = (Switch) findViewById(R.id.switch1);

    ON_OFF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                light_on();
            } else {
                light_off();
            }
        }
    });

    send_free.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
                Toast.makeText(MainActivity.this, R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            mConversationArrayAdapter.clear();

            String free = free_typing.getText().toString();
            sendMessage(free);
            try {
                Thread.sleep(300);
            } catch (InterruptedException ignored) {
            }
            //freetyping.setText("");

        }
    });
    light_on.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            light_on();
        }
    });
    light_off.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            light_off();
        }
    });

    /*        light_query.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
            Toast.makeText(MainActivity.this, R.string.not_connected,
                    Toast.LENGTH_SHORT).show();
            return;
        }
        //new Query_Short().execute();
        new query_is_zigbee_exist_or_not_Async().execute();
    }
            });*/

}

From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java

private void initAutoTrace2(final View rootView) {
    SeekBar sb;
    Switch sw;/*from  w  w w.  j a  va  2  s. co  m*/
    //
    mTraceAttitudeYawFormat = getString(R.string.trace_config_trace_attitude_yaw);
    mTraceSpeedFormat = getString(R.string.trace_config_trace_speed);
    mTraceAltitudeFormat = getString(R.string.trace_config_trace_altitude);
    // (yaw)
    mTraceAttitudeYaw = mPref.getFloat(KEY_TRACE_ATTITUDE_YAW, DEFAULT_TRACE_ATTITUDE_YAW);
    mTraceAttitudeYawLabel = (TextView) rootView.findViewById(R.id.trace_flight_attitude_yaw_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_attitude_yaw_seekbar);
    sb.setMax(180);
    sb.setProgress((int) (mTraceAttitudeYaw + 90)); // [-90,+90] => [0, 180]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceAttitudeYaw(mTraceAttitudeYaw);
    // 
    mTraceSpeed = mPref.getFloat(KEY_TRACE_SPEED, DEFAULT_TRACE_SPEED);
    mTraceSpeedLabel = (TextView) rootView.findViewById(R.id.trace_flight_speed_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_speed_seekbar);
    sb.setMax(200);
    sb.setProgress((int) (mTraceSpeed + 100)); // [-100,+100] => [0, 200]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceSpeed(mTraceSpeed);
    // 
    mTraceAltitudeEnabled = mPref.getBoolean(KEY_TRACE_ALTITUDE_ENABLED, DEFAULT_TRACE_ALTITUDE_ENABLED);
    sw = (Switch) rootView.findViewById(R.id.trace_flight_altitude_enable_switch);
    sw.setChecked(mTraceAltitudeEnabled);
    sw.setOnCheckedChangeListener(mOnCheckedChangeListener);
    // 
    mTraceAltitude = Math.min(mPref.getFloat(KEY_TRACE_ALTITUDE, DEFAULT_TRACE_ALTITUDE),
            mFlightController.getMaxAltitude().current());
    mTraceAltitudeLabel = (TextView) rootView.findViewById(R.id.trace_flight_altitude_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_altitude_seekbar);
    sb.setMax(45);
    sb.setProgress((int) ((mTraceAltitude - 0.5f) * 10.0f)); // [0.5,+5.0] => [0, 45]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceAltitude(mTraceAltitude);
}

From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java

private void initPreprocess(final View rootView) {
    mExposureFormat = getString(R.string.trace_use_exposure);
    mSaturationFormat = getString(R.string.trace_use_saturation);
    mBrightnessFormat = getString(R.string.trace_use_brightness);
    //      mPosterizeFormat = getString(R.string.trace_use_posterize);
    mBinarizeThresholdFormat = getString(R.string.trace_binarize_threshold);
    mTrapeziumRateFormat = getString(R.string.trace_trapezium_rate);

    Switch sw;//from w w w.ja  va  2  s .  co m
    SeekBar sb;
    Button btn;
    //      // ?
    //      mAutoWhiteBlance = mPref.getBoolean(KEY_AUTO_WHITE_BLANCE, true);
    //      mAutoWhiteBlanceSw = (Switch)rootView.findViewById(R.id.white_balance_sw);
    //      mAutoWhiteBlanceSw.setChecked(mAutoWhiteBlance);
    //      mAutoWhiteBlanceSw.setOnCheckedChangeListener(mOnCheckedChangeListener);
    // 
    mExposure = mPref.getFloat(KEY_EXPOSURE, DEFAULT_EXPOSURE);
    mExposureLabel = (TextView) rootView.findViewById(R.id.exposure_textview);
    sb = (SeekBar) rootView.findViewById(R.id.exposure_seekbar);
    sb.setMax(6000);
    sb.setProgress(exposureToProgress(mExposure)); // [-3,+ 3] => [0, 6000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateExposure(mExposure);
    // 
    mSaturation = mPref.getFloat(KEY_SATURATION, DEFAULT_SATURATION);
    mSaturationLabel = (TextView) rootView.findViewById(R.id.saturation_textview);
    sb = (SeekBar) rootView.findViewById(R.id.saturation_seekbar);
    sb.setMax(200);
    sb.setProgress((int) (mSaturation * 100.0f) + 100); // [-1.0f, +1.0f] => [0, 200]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateSaturation(mSaturation);
    // ?
    mBrightness = mPref.getFloat(KEY_BRIGHTNESS, DEFAULT_BRIGHTNESS);
    mBrightnessLabel = (TextView) rootView.findViewById(R.id.brightness_textview);
    sb = (SeekBar) rootView.findViewById(R.id.brightness_seekbar);
    sb.setMax(200);
    sb.setProgress((int) (mBrightness * 100.0f) + 100); // [-1.0f, +1.0f] => [0, 200]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateBrightness(mBrightness);
    //      // ?
    //      mPosterize = mPref.getFloat(KEY_POSTERIZE, DEFAULT_POSTERIZE);
    //      mPosterizeLabel = (TextView)rootView.findViewById(R.id.posterize_textview);
    //      sb = (SeekBar)rootView.findViewById(R.id.posterize_seekbar);
    //      sb.setMax(255);
    //      sb.setProgress((int)(mPosterize - 1));   // [1, 256] => [0, 255]
    //      sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    //      mEnablePosterize = mPref.getBoolean(KEY_ENABLE_POSTERIZE, false);
    //      sw = (Switch)rootView.findViewById(R.id.use_posterize_sw);
    //      sw.setChecked(mEnablePosterize);
    //      sw.setOnCheckedChangeListener(mOnCheckedChangeListener);
    //      updatePosterize(mPosterize);
    // 
    mBinarizeThreshold = mPref.getFloat(KEY_BINARIZE_THRESHOLD, DEFAULT_BINARIZE_THRESHOLD);
    mBinarizeThresholdLabel = (TextView) rootView.findViewById(R.id.binarize_threshold_textview);
    sb = (SeekBar) rootView.findViewById(R.id.binarize_threshold_seekbar);
    sb.setMax(100);
    sb.setProgress((int) (mBinarizeThreshold * 100.0f)); // [0.0f, +1.0f] => [0, 100]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateBinarizeThreshold(mBinarizeThreshold);
    // ?
    mTrapeziumRate = (float) Double.parseDouble(mPref.getString(KEY_TRAPEZIUM_RATE, "0.0"));
    if (Math.abs(mTrapeziumRate) < 0.01f)
        mTrapeziumRate = 0.0f;
    mTrapeziumRateLabel = (TextView) rootView.findViewById(R.id.trapezium_rate_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trapezium_rate_seekbar);
    sb.setMax(4000);
    sb.setProgress(trapeziumRateToProgress(mTrapeziumRate)); // [-2.0f, +2.0f] => [0, 4000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTrapeziumRate(mTrapeziumRate);
}

From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java

private void initDetect(final View rootView) {
    Button btn;/*ww  w. j a v a  2  s. co m*/
    SeekBar sb;

    mAreaLimitMinFormat = getString(R.string.trace_config_detect_area_limit_min);
    mAspectLimitMinFormat = getString(R.string.trace_config_detect_aspect_limit_min);
    mAreaErrLimit1Format = getString(R.string.trace_config_detect_area_err_limit1);
    mAreaErrLimit2Format = getString(R.string.trace_config_detect_area_err_limit2);

    // ????
    mAreaLimitMin = mPref.getFloat(KEY_AREA_LIMIT_MIN, DEFAULT_AREA_LIMIT_MIN);
    mAreaLimitMinLabel = (TextView) rootView.findViewById(R.id.area_limit_min_textview);
    sb = (SeekBar) rootView.findViewById(R.id.area_limit_min_seekbar);
    sb.setMax(9500);
    sb.setProgress(areaLimitMinToProgress(mAreaLimitMin - 500)); // [0,10000] => [0, 10000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAreaLimitMin(mAreaLimitMin);
    // ???1
    mAreaErrLimit1 = mPref.getFloat(KEY_AREA_ERR_LIMIT1, DEFAULT_AREA_ERR_LIMIT1);
    mAreaErrLimit1Label = (TextView) rootView.findViewById(R.id.area_err_limit1_textview);
    sb = (SeekBar) rootView.findViewById(R.id.area_err_limit1_seekbar);
    sb.setMax(100);
    sb.setProgress((int) ((mAreaErrLimit1 - 1.0f) * 100.0f)); // [1,2] => [0, 100]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAreaErrLimit1(mAreaErrLimit1);
    // ???2
    mAreaErrLimit2 = mPref.getFloat(KEY_AREA_ERR_LIMIT2, DEFAULT_AREA_ERR_LIMIT2);
    mAreaErrLimit2Label = (TextView) rootView.findViewById(R.id.area_err_limit2_textview);
    sb = (SeekBar) rootView.findViewById(R.id.area_err_limit2_seekbar);
    sb.setMax(100);
    sb.setProgress((int) ((mAreaErrLimit2 - 1.0f) * 100.0f)); // [1,2] => [0, 100]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAreaErrLimit2(mAreaErrLimit2);
    // ??
    mAspectLimitMin = mPref.getFloat(KEY_ASPECT_LIMIT_MIN, DEFAULT_ASPECT_LIMIT_MIN);
    mAspectLimitMinLabel = (TextView) rootView.findViewById(R.id.aspect_limit_min_textview);
    sb = (SeekBar) rootView.findViewById(R.id.aspect_limit_min_seekbar);
    sb.setMax(190);
    sb.setProgress((int) ((mAspectLimitMin - 1.0f) * 10)); // [1,20] => [0, 190]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateAspectLimitMin(mAspectLimitMin);
}

From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java

private void initCamera(final View rootView) {
    mCameraExposureFormat = getString(R.string.trace_camera_exposure);
    mCameraSaturationFormat = getString(R.string.trace_camera_saturation);
    mCameraPanFormat = getString(R.string.trace_camera_pan);
    mCameraTiltFormat = getString(R.string.trace_camera_tilt);

    SeekBar sb;
    // ?/*from   w w  w .ja v  a2 s. com*/
    mCameraAutoWhiteBlance = getInt(mPref, KEY_CAMERA_WHITE_BLANCE, DEFAULT_CAMERA_WHITE_BLANCE);
    final Spinner spinner = (Spinner) rootView.findViewById(R.id.camera_white_blance_spinner);
    spinner.setAdapter(new WhiteBlanceAdapter(getActivity()));
    spinner.setSelection(mCameraAutoWhiteBlance + 1);
    spinner.setOnItemSelectedListener(mOnItemSelectedListener);
    // 
    mCameraExposure = mPref.getFloat(KEY_CAMERA_EXPOSURE, DEFAULT_CAMERA_EXPOSURE);
    mCameraExposureLabel = (TextView) rootView.findViewById(R.id.camera_exposure_textview);
    sb = (SeekBar) rootView.findViewById(R.id.camera_exposure_seekbar);
    sb.setMax(3000);
    sb.setProgress(cameraExposureToProgress(mCameraExposure)); // [-1.5,+ 1.5] => [0, 3000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateCameraExposure(mCameraExposure);
    // 
    mCameraSaturation = mPref.getFloat(KEY_CAMERA_SATURATION, DEFAULT_CAMERA_SATURATION);
    mCameraSaturationLabel = (TextView) rootView.findViewById(R.id.camera_saturation_textview);
    sb = (SeekBar) rootView.findViewById(R.id.camera_saturation_seekbar);
    sb.setMax(2000);
    sb.setProgress((int) (mCameraSaturation * 10.0f) + 1000); // [-100.0f, +100.0f] => [0, 2000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateCameraSaturation(mCameraSaturation);
    // 
    mCameraPan = getInt(mPref, KEY_CAMERA_PAN, DEFAULT_CAMERA_PAN);
    mCameraPanLabel = (TextView) rootView.findViewById(R.id.camera_pan_textview);
    sb = (SeekBar) rootView.findViewById(R.id.camera_pan_seekbar);
    sb.setMax(40);
    sb.setProgress(cameraPanTiltToProgress(mCameraPan)); // [-100,+100] => [0, 40]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateCameraPan(mCameraPan);
    // ?
    mCameraTilt = getInt(mPref, KEY_CAMERA_TILT, DEFAULT_CAMERA_TILT);
    mCameraTiltLabel = (TextView) rootView.findViewById(R.id.camera_tilt_textview);
    sb = (SeekBar) rootView.findViewById(R.id.camera_tilt_seekbar);
    sb.setMax(40);
    sb.setProgress(cameraPanTiltToProgress(mCameraTilt)); // [-100,+100] => [0, 40]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateCameraTilt(mCameraTilt);
}

From source file:com.serenegiant.autoparrot.BaseAutoPilotFragment.java

private void initAutoTrace(final View rootView) {
    SeekBar sb;
    Switch sw;//from   w  w  w .j  a  va2s  .  c  o  m
    //
    mTraceDirectionalReverseBiasFormat = getString(R.string.trace_config_trace_reverse_bias);
    mTraceMovingAveTapFormat = getString(R.string.trace_config_moving_ave_tap);
    mTraceDecayRateFormat = getString(R.string.trace_config_decay_rate);
    mTraceSensitivityFormat = getString(R.string.trace_config_trace_sensitivity);
    // ??
    mTraceDirectionalReverseBias = mPref.getFloat(KEY_TRACE_DIR_REVERSE_BIAS, DEFAULT_TRACE_DIR_REVERSE_BIAS);
    mTraceDirectionalReverseBiasLabel = (TextView) rootView
            .findViewById(R.id.trace_flight_reverse_bias_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_reverse_bias_seekbar);
    sb.setMax(200);
    sb.setProgress((int) (mTraceDirectionalReverseBias * 100)); // [0.0f, 2.0f] => [0, 200]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceDirectionalReverseBias(mTraceDirectionalReverseBias);
    // ?
    mTraceMovingAveTap = mPref.getInt(KEY_TRACE_MOVING_AVE_TAP, DEFAULT_TRACE_MOVING_AVE_TAP);
    mTraceMovingAveTapLabel = (TextView) rootView.findViewById(R.id.trace_flight_moving_ave_tap_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_moving_ave_tap_seekbar);
    sb.setMax(19);
    sb.setProgress(mTraceMovingAveTap - 1); // [1, 20] => [0, 19]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceMovingAveTap(mTraceMovingAveTap);
    // 
    mTraceDecayRate = mPref.getFloat(KEY_TRACE_DECAY_RATE, DEFAULT_TRACE_DECAY_RATE);
    mTraceDecayRateLabel = (TextView) rootView.findViewById(R.id.trace_flight_decay_rate_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_decay_rate_seekbar);
    sb.setMax(1000);
    sb.setProgress((int) (mTraceDecayRate * 1000.0f)); // [0.000f, 1.000f] => [0, 1000]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceDecayRate(mTraceDecayRate);
    // 
    mTraceSensitivity = mPref.getFloat(KEY_TRACE_SENSITIVITY, DEFAULT_TRACE_SENSITIVITY);
    mTraceSensitivityLabel = (TextView) rootView.findViewById(R.id.trace_flight_sensitivity_textview);
    sb = (SeekBar) rootView.findViewById(R.id.trace_flight_sensitivity_seekbar);
    sb.setMax(100);
    sb.setProgress((int) (mTraceSensitivity)); // [0f, 100f] => [0, 100]
    sb.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
    updateTraceSensitivity(mTraceSensitivity);
}

From source file:com.vaquerosisd.projectmanager.NewTask.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_task);

    //Set navigation up
    getActionBar().setDisplayHomeAsUpEnabled(true);

    //Initialize database
    db = new ProjectOperations(this);
    db.open();/*  www .j  a  v  a 2  s  .c  o  m*/

    //Initialize file operations instance
    fO = new FileOperations(this);

    //Get intent from Projects.class
    Bundle data = getIntent().getExtras();
    projectId = data.getInt("ProjectID");
    projectName = data.getString("ProjectName");

    //Get UI handler references
    final EditText taskNameEditText = (EditText) findViewById(R.id.newTask_TaskName);
    final Spinner statusSpinner = (Spinner) findViewById(R.id.newTask_StatusSpinner);
    final Spinner prioritySpinner = (Spinner) findViewById(R.id.newTask_Priority);
    final EditText percentageDoneEditText = (EditText) findViewById(R.id.newTask_PercentageDone);
    final SeekBar percentageDoneSeekBar = (SeekBar) findViewById(R.id.newTask_PercentageDoneSeekBar);
    final EditText startDateEditText = (EditText) findViewById(R.id.newTask_StartDate);
    final EditText dueDateEditText = (EditText) findViewById(R.id.newTask_DueDate);
    final EditText descriptionEditText = (EditText) findViewById(R.id.newTask_Description);
    final Button addTaskButton = (Button) findViewById(R.id.newTask_AddTask);
    final int[] startDateStrings = { 0, 0, 0 };
    final int[] dueDateStrings = { 0, 0, 0 };

    //Set files they doesn't exist
    String statusItemsString = "New\nIn progress\nPrinting\nOn hold\nCancelled\nReviewing\nDelegated\nCompleted\n";
    fO.createStringFile(statusFileName, statusItemsString);
    String priorityItemsString = "High\nMedium\nLow\n";
    fO.createStringFile(priorityFileName, priorityItemsString);

    //Create and set content for the status and priority spinners
    setSpinner(statusFileName, statusSpinnerAdapter, statusSpinner, true);
    setSpinner(priorityFileName, prioritySpinnerAdapter, prioritySpinner, false);

    percentageDoneEditText.setText("0%");
    //      int statusPosition = statusSpinnerAdapter.getPosition("New");
    //      statusSpinner.setSelection(statusPosition, true);

    addTaskButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            //Get values for the add task
            String projectDir = db.getProjectContentPath(projectId);
            String taskName = taskNameEditText.getText().toString();
            String status = statusSpinner.getSelectedItem().toString();
            String priority = prioritySpinner.getSelectedItem().toString();
            String percentage = percentageDoneEditText.getText().toString();
            int percentageDone = Integer.parseInt(percentage.substring(0, percentage.length() - 1));
            String startDate = startDateEditText.getText().toString();
            String dueDate = dueDateEditText.getText().toString();
            String photoPath = "";
            String description = descriptionEditText.getText().toString();
            String contentPath = projectDir + "/" + taskName;
            Log.i("DEBUG", contentPath);
            File taskContentPath = new File(contentPath);
            taskContentPath.mkdir();

            boolean dueDateBeforeStartDate = true;

            Calendar startDateCalendar = Calendar.getInstance();
            startDateCalendar.set(startDateStrings[0], startDateStrings[1], startDateStrings[2]);
            Calendar dueDateCalendar = Calendar.getInstance();
            dueDateCalendar.set(dueDateStrings[0], dueDateStrings[1], dueDateStrings[2]);

            if (startDateCalendar.before(dueDateCalendar) || startDateCalendar.equals(dueDateCalendar))
                dueDateBeforeStartDate = false;

            if (dueDateBeforeStartDate) {
                Toast.makeText(getApplicationContext(), R.string.dueDateError, Toast.LENGTH_SHORT).show();
                return;
            } else if (!taskName.equals("") && !startDate.equals("") && !dueDate.equals("")) {
                db.addTask(projectId, taskName, status, priority, percentageDone, startDateStrings,
                        dueDateStrings, photoPath, description, contentPath);
                Toast.makeText(getApplicationContext(), R.string.taskAdded, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), R.string.incomplete, Toast.LENGTH_SHORT).show();
                return;
            }

            //Inform of successful adding
            Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
        }
    });

    //SeekBar listener
    percentageDoneSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            percentageDoneEditText.setText(String.valueOf(progress) + "%");
        }
    });

    //StartDate click listener
    startDateEditText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            showDatePickerDialog(arg0, STARTDATE_DIALOG_TAG, startDateEditText, startDateStrings);
        }
    });

    //StartDate click listener
    dueDateEditText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            showDatePickerDialog(arg0, DUEDATE_DIALOG_TAG, dueDateEditText, dueDateStrings);
        }
    });
}

From source file:uf.edu.encDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.encdetail_activity);
    context = this.getApplicationContext();
    TextView tv = null;/*from  w  ww  . j  ava2s .co  m*/
    SeekBar sb = null;
    Button b = null;
    Bundle bundle = this.getIntent().getExtras();
    Log.i("TAG", "encDetailActivity:onCreate,  Max Trust =" + getString(R.string.TrustSliderMax));
    MaxTrust = Integer.parseInt(getString(R.string.TrustSliderMax)) / 2;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                //Okay clicked.
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                //No button clicked
                break;
            }
        }
    };

    //builder.setMessage("Are you sure?").setPositiveButton("Okay", dialogClickListener);

    final EncUser encUser = (EncUser) bundle.getSerializable("userdata");
    final ArrayList<String> Address = (ArrayList<String>) bundle.getSerializable("useraddress");
    if (encUser == null) {
        Log.i(TAG, "encDetailsActivity: parameter received was null");
    }
    //Name
    tv = (TextView) findViewById(R.id.encdetail_name);
    tv.setText(encUser.Name);
    //Mac
    tv = (TextView) findViewById(R.id.encdetail_mac);
    tv.setText(encUser.Mac);
    tv.setOnClickListener(new View.OnClickListener() { //event listener to fetch more info abt a user.
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Registration Lookup requested for " + encUser.Mac);
            Toast.makeText(encDetailActivity.this, "Please wait while we lookup the information",
                    Toast.LENGTH_LONG).show();
            String data = getData(encUser.Mac).replace('\n', ' ').trim();
            String message = null;
            if (data.substring(0, 5).compareToIgnoreCase("Error") == 0) {
                message = "No more info available for this device";
            } else {
                data = data.replace('\'', ' '); //remove single quotes
                data = data.replace(')', ' ').trim(); //remove closing brackets.
                StringTokenizer tok = new StringTokenizer(data.substring(1), ",");
                message = "Name: " + tok.nextToken() + " " + tok.nextToken() + "\n" + "Email: "
                        + tok.nextToken() + "\n" + "Profile: " + tok.nextToken();
            }
            //Toast.makeText(encDetailActivity.this, getData(encUser.Mac), Toast.LENGTH_LONG).show();
            builder.setMessage(message);
            builder.show();
        }
    });
    //lasttime
    tv = (TextView) findViewById(R.id.encdetail_lasttime);
    tv.setText((new java.util.Date((long) encUser.lastEncounterTime * 1000)).toString());
    tv.setOnClickListener(new View.OnClickListener() { //To generate graph
        @Override
        public void onClick(View v) {
            Intent intent = barchartIntent(encUser.timeSeries, encUser.Mac, encUser.Name);
            startActivity(intent);
        }
    });

    //tv.setText(Integer.toString(encUser.lastEncounterTime)); 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_FE);
    tv.setText(Float.toString(encUser.score[0]));
    tv = (TextView) findViewById(R.id.encdetail_decayFE);
    tv.setText(Float.toString(encUser.decayScore[0] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //DE
    tv = (TextView) findViewById(R.id.encdetail_DE);
    tv.setText(Float.toString(encUser.score[1]));
    tv = (TextView) findViewById(R.id.encdetail_decayDE);
    tv.setText(Float.toString(encUser.decayScore[1] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //LV-C
    tv = (TextView) findViewById(R.id.encdetail_LVC);
    tv.setText(Float.toString(encUser.score[2]));
    //LV-D
    tv = (TextView) findViewById(R.id.encdetail_LVD);
    tv.setText(Float.toString(encUser.score[3]));
    //combined 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_comb);
    tv.setText(Float.toString(encUser.score[4]));

    //check the toggle button state

    sb = (SeekBar) findViewById(R.id.encdetail_trust);
    //since Seekbar cannot go into -ve values we scale -Max Value to Max Value
    sb.setProgress(encUser.trusted + MaxTrust);
    tv = (TextView) findViewById(R.id.CurrentTrustValue);
    tv.setText(TrustArray[encUser.trusted + MaxTrust]);

    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        TextView tvcurrent = (TextView) findViewById(R.id.CurrentTrustValue);

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser == true) {
                Log.i(TAG, "encDetailsActivity: User changed value for Trust to " + progress);
                encUser.trusted = progress - MaxTrust;
                tvcurrent.setText(TrustArray[progress]);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }
    });

    b = (Button) findViewById(R.id.encdetail_done);
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            iTrust.cd.write("Trust Value changed for this user :" + encUser.Mac + " to:" + encUser.trusted);
            Bundle bundle = new Bundle();
            Intent returnIntent = new Intent();
            bundle.putSerializable("Object", encUser);
            returnIntent.putExtras(bundle);
            //returnIntent.putExtra("TrustSet",trustResult);
            encDetailActivity.this.setResult(Activity.RESULT_OK, returnIntent);
            finish();
        }
    });

    //show map
    tv = (TextView) findViewById(R.id.encdetail_map);
    tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Map lookup for encounter user " + encUser.Mac);
            Bundle bundle = new Bundle();
            Intent newIntent = new Intent(context, map.class);
            bundle.putSerializable("useraddress", Address);
            newIntent.putExtras(bundle);
            startActivity(newIntent);
        }
    });

}