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.scooter1556.sms.android.activity.FullScreenPlayerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_full_screen_player);
    initialiseToolbar();//from ww  w . ja  va2  s .c  o  m
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("");
    }

    backgroundImage = (ImageView) findViewById(R.id.background_image);
    pauseDrawable = ContextCompat.getDrawable(this, R.drawable.ic_pause_white_48dp);
    playDrawable = ContextCompat.getDrawable(this, R.drawable.ic_play_arrow_white_48dp);
    playPause = (ImageView) findViewById(R.id.play_pause);
    skipNext = (ImageView) findViewById(R.id.next);
    skipPrev = (ImageView) findViewById(R.id.prev);
    shuffle = (ImageView) findViewById(R.id.shuffle);
    repeat = (ImageView) findViewById(R.id.repeat);
    start = (TextView) findViewById(R.id.startText);
    end = (TextView) findViewById(R.id.endText);
    seekbar = (SeekBar) findViewById(R.id.seekBar);
    title = (TextView) findViewById(R.id.title);
    subtitle = (TextView) findViewById(R.id.subtitle);
    extra = (TextView) findViewById(R.id.extra);
    loading = (ProgressBar) findViewById(R.id.progressBar);
    controllers = findViewById(R.id.controllers);

    skipNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MediaControllerCompat.TransportControls controls = mediaController.getTransportControls();
            controls.skipToNext();
        }
    });

    skipPrev.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MediaControllerCompat.TransportControls controls = mediaController.getTransportControls();
            controls.skipToPrevious();
        }
    });

    playPause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PlaybackStateCompat state = mediaController.getPlaybackState();
            if (state != null) {
                MediaControllerCompat.TransportControls controls = mediaController.getTransportControls();
                switch (state.getState()) {
                case PlaybackStateCompat.STATE_PLAYING: // fall through
                case PlaybackStateCompat.STATE_BUFFERING:
                    controls.pause();
                    stopSeekbarUpdate();
                    break;
                case PlaybackStateCompat.STATE_PAUSED:
                case PlaybackStateCompat.STATE_STOPPED:
                    controls.play();
                    scheduleSeekbarUpdate();
                    break;
                }
            }
        }
    });

    shuffle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PlaybackStateCompat state = mediaController.getPlaybackState();
            MediaControllerCompat.TransportControls controls = mediaController.getTransportControls();

            if (state == null) {
                return;
            }

            for (PlaybackStateCompat.CustomAction action : state.getCustomActions()) {
                switch (action.getAction()) {
                case MediaService.STATE_SHUFFLE_ON:
                    controls.sendCustomAction(MediaService.STATE_SHUFFLE_ON, null);
                    break;

                case MediaService.STATE_SHUFFLE_OFF:
                    controls.sendCustomAction(MediaService.STATE_SHUFFLE_OFF, null);
                    break;
                }
            }

            updatePlaybackState(state);
        }
    });

    repeat.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PlaybackStateCompat state = mediaController.getPlaybackState();
            MediaControllerCompat.TransportControls controls = mediaController.getTransportControls();

            if (state == null) {
                return;
            }

            for (PlaybackStateCompat.CustomAction action : state.getCustomActions()) {
                switch (action.getAction()) {
                case MediaService.STATE_REPEAT_NONE:
                case MediaService.STATE_REPEAT_ALL:
                case MediaService.STATE_REPEAT_ONE:
                    controls.sendCustomAction(action.getAction(), null);
                    break;
                }
            }

            updatePlaybackState(state);
        }
    });

    seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            start.setText(DateUtils.formatElapsedTime(progress / 1000));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            stopSeekbarUpdate();
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            mediaController.getTransportControls().seekTo(seekBar.getProgress());
            scheduleSeekbarUpdate();
        }
    });

    // Only update from the intent if we are not recreating from a config change:
    if (savedInstanceState == null) {
        updateFromParams(getIntent());
    }

    mediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MediaService.class), connectionCallback,
            null);
}

From source file:com.dosse.bwentrain.androidPlayer.MainActivity.java

@Override
protected void onResume() {
    try {//from ww w  . ja v  a  2s  . co  m
        ((AdView) findViewById(R.id.banner)).resume();
    } catch (Throwable t) {
    }
    TextView status = (TextView) findViewById(R.id.textView1);
    SeekBar bar = (SeekBar) findViewById(R.id.seekBar1);
    Button playPause = (Button) findViewById(R.id.button1);
    //add action listener for seek bar
    bar.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) {
            if (!fromUser)
                return;
            pc.setPosition((float) progress / (float) seekBar.getMax());
        }
    });
    //add action listener for play/pause button
    playPause.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (pc.isPlaying())
                pc.pause();
            else
                pc.play();
        }
    });
    if (pc == null) {
        pc = new PlayerController(this, status, bar, playPause); //playercontroller not initialized, do it now
    } else {
        //playercontroller already initialized, give it pointers to the newly created views
        pc.setMainUI(this);
        pc.setStatusView(status);
        pc.setProgressView(bar);
        pc.setButton(playPause);
    }
    populatePresetList();
    ((NavigationView) findViewById(R.id.nav_view)).getMenu().getItem(0).setChecked(true);
    super.onResume();
}

From source file:com.wallerlab.compcellscope.Image_Gallery.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image__gallery);
    counter = 0;//from w w w. jav a 2 s.c o  m
    final ImageView currPic = new ImageView(this);

    DisplayMetrics metrics = this.getResources().getDisplayMetrics();
    final int screen_width = metrics.widthPixels;

    SharedPreferences settings = getSharedPreferences(Folder_Chooser.PREFS_NAME, 0);
    //SharedPreferences.Editor edit = settings.edit();
    String path = settings.getString(Folder_Chooser.location_name,
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString());

    //Log.d(LOG, "  |  " + path + " |  ");
    TextView text1 = (TextView) findViewById(R.id.text1);
    final TextView text2 = (TextView) findViewById(R.id.text2);

    text1.setText(path);

    File directory = new File(path);

    // get all the files from a directory
    File[] dump_files = directory.listFiles();
    Log.d(LOG, dump_files.length + " ");

    final File[] fList = removeElements(dump_files, "info.json");

    Log.d(LOG, "Filtered Length: " + fList.length);

    Arrays.sort(fList, new Comparator<File>() {
        @Override
        public int compare(File file, File file2) {
            String one = file.toString();
            String two = file2.toString();
            //Log.d(LOG, "one: " + one);
            //Log.d(LOG, "two: " + two);
            int num_one = Integer.parseInt(one.substring(one.lastIndexOf("(") + 1, one.lastIndexOf(")")));
            int num_two = Integer.parseInt(two.substring(two.lastIndexOf("(") + 1, two.lastIndexOf(")")));
            return num_one - num_two;
        }
    });

    try {
        writeJsonFile(fList);
    } catch (JSONException e) {
        Log.d(LOG, "JSON WRITE FAILED");
    }
    //List names programattically
    LinearLayout myLinearLayout = (LinearLayout) findViewById(R.id.linear_table);
    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, screen_width + 4);

    myLinearLayout.setOrientation(LinearLayout.VERTICAL);

    if (fList != null) {
        File cur_pic = fList[0];

        BitmapFactory.Options opts = new BitmapFactory.Options();
        Log.d(LOG, "\n File Location: " + cur_pic.getAbsolutePath() + " \n" + " Parent: "
                + cur_pic.getParent().toString() + "\n");

        Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);

        currPic.setLayoutParams(params);
        currPic.setImageBitmap(myImage);
        currPic.setId(View.generateViewId());
        text2.setText(cur_pic.getName());
    }

    myLinearLayout.addView(currPic);

    //Seekbar
    seekBar = (SeekBar) findViewById(R.id.seekBar);
    seekBar.setEnabled(true);
    seekBar.setMax(fList.length - 1);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        int progress = 0;
        int length = fList.length;

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            setCounter(i);
            if (getCounter() <= fList.length) {
                File cur_pic = fList[getCounter()];
                BitmapFactory.Options opts = new BitmapFactory.Options();
                opts.inJustDecodeBounds = true;
                Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                int image_width = opts.outWidth;
                int image_height = opts.outHeight;
                int sampleSize = image_width / screen_width;
                opts.inSampleSize = sampleSize;

                text2.setText(cur_pic.getName());

                opts.inJustDecodeBounds = false;
                myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);

                currPic.setImageBitmap(myImage);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    //Make Button Layout
    LinearLayout buttonLayout = new LinearLayout(this);
    buttonLayout.setOrientation(LinearLayout.HORIZONTAL);

    LinearLayout.LayoutParams LLParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f);
    buttonLayout.setLayoutParams(LLParams);
    buttonLayout.setId(View.generateViewId());

    //Button Layout Params
    LinearLayout.LayoutParams param_button = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);

    //Prev Pic
    Button prevPic = new Button(this);
    prevPic.setText("Previous");
    prevPic.setId(View.generateViewId());
    prevPic.setLayoutParams(param_button);

    prevPic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fList != null) {
                decrementCounter();
                if (getCounter() >= 0) {
                    File cur_pic = fList[getCounter()];
                    BitmapFactory.Options opts = new BitmapFactory.Options();
                    opts.inJustDecodeBounds = true;
                    Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    int image_width = opts.outWidth;
                    int image_height = opts.outHeight;
                    int sampleSize = image_width / screen_width;
                    opts.inSampleSize = sampleSize;

                    text2.setText(cur_pic.getName());

                    opts.inJustDecodeBounds = false;
                    myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    //Log.d(LOG, getCounter() + "");
                    seekBar.setProgress(getCounter());
                    currPic.setImageBitmap(myImage);

                } else {
                    setCounter(0);
                }

            } else {
                Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT);
                setCounter(getCounter() - 1);
            }
        }
    });

    buttonLayout.addView(prevPic);

    // Next Picture  Button
    Button nextPic = new Button(this);
    nextPic.setText("Next");
    nextPic.setId(View.generateViewId());
    nextPic.setLayoutParams(param_button);

    buttonLayout.addView(nextPic);
    nextPic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fList != null) {
                incrementCounter();
                if (getCounter() < fList.length) {
                    File cur_pic = fList[getCounter()];
                    BitmapFactory.Options opts = new BitmapFactory.Options();
                    opts.inJustDecodeBounds = true;
                    Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    int image_width = opts.outWidth;
                    int image_height = opts.outHeight;
                    int sampleSize = image_width / screen_width;
                    opts.inSampleSize = sampleSize;

                    text2.setText(cur_pic.getName());

                    opts.inJustDecodeBounds = false;
                    myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    //Log.d(LOG, getCounter() + "");
                    seekBar.setProgress(getCounter());

                    currPic.setImageBitmap(myImage);
                } else {
                    setCounter(getCounter() - 1);
                }

            } else {
                Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT);
                setCounter(getCounter() - 1);
            }
        }
    });

    myLinearLayout.addView(buttonLayout);
}

From source file:com.twjg.chromecast2048.activities.MainActivity.java

private void attachDragListeners() {
    // Capture all UI elements
    SeekBar seekbar = (SeekBar) findViewById(R.id.seekBar);
    final DragTriggerView dragArea = (DragTriggerView) findViewById(R.id.dragArea);

    // Update seek bar with default values
    this.seekbarUpdated();

    // Attach observer to seekBar
    seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override//from  w  w  w .j a  va 2s .c  om
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            MainActivity.this.seekbarUpdated();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

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

    // Attach observer for dragTrigger to dragArea
    dragArea.setOnDragTriggerListener(new DragTriggerView.OnDragTriggerListener() {
        @Override
        public void onTrigger(DragTriggerEvent e) {
            Log.d(TAG, "Drag trigger: " + e.getAction());
            MainActivity.this.sendMessage("" + e.getAction(), MainActivity.this.mChromecast2048ChannelGame,
                    true);
        }
    });
}

From source file:com.example.h.medapp.QuestionActivity.java

private void addItem() {
    answered_flag = false;/*from  w w w .  j a  va2s  .  co m*/
    textView.setText("Question " + (count + 1) + " / 10");

    // Instantiate a new "row" view.
    final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.row, mContainerView,
            false);

    mContainerView.addView(newView);

    SeekBar seekBar = (SeekBar) newView.findViewById(R.id.progress_bar);
    TextView question_text_view = (TextView) newView.findViewById(R.id.question_text);
    Button next_button = (Button) newView.findViewById(R.id.next_button);
    final TextView slider_textView = (TextView) newView.findViewById(R.id.slider_text);

    scrollView.scrollBy(0, +1000);

    slider_textView.setVisibility(View.INVISIBLE);
    question_text_view.setText(questions_array[count]);

    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) {
            answered_flag = true;
            Toast.makeText(getApplicationContext(), "Stopped tracking seekbar", Toast.LENGTH_SHORT).show();
            //TODO: save the result to an array
            result_array[count] = progress;
            slider_textView.setVisibility(View.VISIBLE);
            slider_textView.setText("you have chosen: " + seekBar.getProgress() + "/" + seekBar.getMax()
                    + " as your degree of symptom.");

        }
    });

    next_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (answered_flag) {
                //MAKE SURE THIS QUESTION IS NOT THE LAST QUESTION.
                //IF IT IS THE LAST QUESTION GO TO THANK YOU ACTIVITY
                if (count == total_number_of_question - 1) {
                    //TODO: save to parse

                    //TODO: go to thank you activity
                    Intent intent = new Intent(QuestionActivity.this, activity_T.class);
                    startActivity(intent);

                } else {
                    //IF NOT GO TO NEXT QUESTION
                    count++;
                    addItem();
                }

            }
        }
    });

}

From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();/*from w  w w. j av  a 2 s  . co  m*/

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

    // Creating the PopupWindow
    PopupWindow popup = new PopupWindow(getActivity());
    popup.setContentView(isErasing ? popupEraserLayout : popupLayout);
    popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setFocusable(true);
    popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {

            if (mColorPicker.getColor() != oldColor)
                mColorPicker.setOldCenterColor(oldColor);
        }
    });

    // Clear the default translucent background
    popup.setBackgroundDrawable(new BitmapDrawable());

    // Displaying the popup at the specified location, + offsets (transformed 
    // dp to pixel to support multiple screen sizes)
    popup.showAsDropDown(anchor);

    // Stroke size seekbar initialization and event managing
    SeekBar mSeekBar;
    mSeekBar = (SeekBar) (isErasing ? popupEraserLayout.findViewById(R.id.stroke_seekbar)
            : popupLayout.findViewById(R.id.stroke_seekbar));
    mSeekBar.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) {
            // When the seekbar is moved a new size is calculated and the new shape
            // is positioned centrally into the ImageView
            setSeekbarProgress(progress, eraserOrStroke);
        }
    });
    int progress = isErasing ? seekBarEraserProgress : seekBarStrokeProgress;
    mSeekBar.setProgress(progress);
}

From source file:org.musicmod.android.dialog.EqualizerDialog.java

private void setupEqualizerFxAndUI(int audioSessionId) {

    // Create the Equalizer object (an AudioEffect subclass) and attach it
    // to our media player, with a default priority (0).
    mEqualizer = new EqualizerWrapper(0, audioSessionId);
    if (mEqualizer == null) {
        finish();//  w  w w. ja va  2s .  c  o m
        return;
    }
    mEqualizer.setEnabled(false);

    short bands = mEqualizer.getNumberOfBands();

    final short minEQLevel = mEqualizer.getBandLevelRange()[0];
    final short maxEQLevel = mEqualizer.getBandLevelRange()[1];

    mLinearLayout.removeAllViews();

    for (short i = 0; i < bands; i++) {
        final short band = i;

        TextView freqTextView = new TextView(this);
        freqTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        freqTextView.setGravity(Gravity.CENTER_HORIZONTAL);

        if (mEqualizer.getCenterFreq(band) / 1000 < 1000) {
            freqTextView.setText((mEqualizer.getCenterFreq(band) / 1000) + " Hz");
        } else {
            freqTextView.setText(((float) mEqualizer.getCenterFreq(band) / 1000 / 1000) + " KHz");
        }

        mLinearLayout.addView(freqTextView);

        LinearLayout row = new LinearLayout(this);
        row.setOrientation(LinearLayout.HORIZONTAL);

        TextView minDbTextView = new TextView(this);
        minDbTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        minDbTextView.setText((minEQLevel / 100) + " dB");

        TextView maxDbTextView = new TextView(this);
        maxDbTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        maxDbTextView.setText((maxEQLevel / 100) + " dB");

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        SeekBar bar = new SeekBar(this);
        bar.setLayoutParams(layoutParams);
        bar.setMax(maxEQLevel - minEQLevel);
        bar.setProgress(mPrefs.getEqualizerSetting(band, (short) ((maxEQLevel + minEQLevel) / 2)) - minEQLevel);
        mEqualizer.setBandLevel(band,
                mPrefs.getEqualizerSetting(band, (short) ((maxEQLevel + minEQLevel) / 2)));

        bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

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

                mEqualizer.setBandLevel(band, (short) (minEQLevel + progress));
                mPrefs.setEqualizerSetting(band, (short) (minEQLevel + progress));
                reloadEqualizer();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        row.addView(minDbTextView);
        row.addView(bar);
        row.addView(maxDbTextView);

        mLinearLayout.addView(row);
    }
}

From source file:layout.BeaconTabFragment.java

/**
 * Setting up the radio tx power component with a seek bar which reads the supported tx powers
 * and only allows the user to set these. There is also a tracking TextView which shows the
 * numeric representation of the tx power.
 *
 * @param v container for the radio tx power component. This is usually the main container in
 *          the tab. It has to be added to the activity before calling this method.
 *//*from  www. j a  v a2 s .com*/
private void setUpRadioTxPower(View v) {
    if (txPower != null) {
        v.findViewById(R.id.tx_power_info).setVisibility(View.VISIBLE);

        final TextView txPowerView = (TextView) v.findViewById(R.id.radio_tx_power);
        txPowerView.setText(txPower);
        SeekBar seekBar = (SeekBar) v.findViewById(R.id.tx_power_seek_bar);

        final byte[] allowedValues = capabilities.getSupportedTxPowers();
        final int maxValue = Utils.findMaxValue(allowedValues);
        final int minValue = Utils.findMinValue(allowedValues);

        seekBar.setMax(maxValue - minValue);
        seekBar.setProgress(Integer.parseInt(txPower) - minValue);

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

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                int newValue;
                if (allowedValues != null) {
                    newValue = Utils.findValueClosestTo(progress + minValue, allowedValues);
                } else {
                    newValue = progress + minValue;
                }
                seekBar.setProgress(newValue - minValue);
                txPowerView.setText(Integer.toString(newValue));
                BeaconTabFragment.this.txPower = Integer.toString(newValue);
            }
        });
    }
}

From source file:com.doubleTwist.drawerlib.exampleapp.ExampleFragment.java

private void setupSettingsPanel(int panel, View v) {
    TextView label1 = (TextView) v.findViewById(R.id.progress1_label);
    TextView label2 = (TextView) v.findViewById(R.id.progress2_label);
    TextView label3 = (TextView) v.findViewById(R.id.progress3_label);
    TextView label4 = (TextView) v.findViewById(R.id.progress4_label);

    SeekBar seek1 = (SeekBar) v.findViewById(R.id.progress1);
    SeekBar seek2 = (SeekBar) v.findViewById(R.id.progress2);
    SeekBar seek3 = (SeekBar) v.findViewById(R.id.progress3);
    SeekBar seek4 = (SeekBar) v.findViewById(R.id.progress4);

    boolean centerContent = panel == ADrawerLayout.NO_DRAWER;

    if (label1 != null)
        label1.setText(centerContent ? "X axis paralax [-1, 1]" : "Scale");
    if (seek1 != null) {
        seek1.setMax(1000);/*from w ww.jav a  2  s.c  om*/
        seek1.setOnSeekBarChangeListener(this);
    }

    if (label2 != null)
        label2.setText(centerContent ? "Y axis paralax [-1, 1]" : "Alpha");
    if (seek2 != null) {
        seek2.setMax(1000);
        seek2.setOnSeekBarChangeListener(this);
    }

    if (label3 != null)
        label3.setText(centerContent ? "Content dim" : "Rot X");
    if (seek3 != null) {
        seek3.setMax(1000);
        seek3.setOnSeekBarChangeListener(this);
    }

    if (centerContent) {
        label4.setVisibility(View.GONE);
        seek4.setVisibility(View.GONE);
    } else {
        if (label4 != null)
            label4.setText("Rot Y");
        if (seek4 != null) {
            seek4.setMax(1000);
            seek4.setOnSeekBarChangeListener(this);
        }
    }
}

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);/*from  w w w . ja  v a2  s  .  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);
                }
            }
        };

    }
}