Example usage for android.widget SeekBar.OnSeekBarChangeListener SeekBar.OnSeekBarChangeListener

List of usage examples for android.widget SeekBar.OnSeekBarChangeListener SeekBar.OnSeekBarChangeListener

Introduction

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

Prototype

SeekBar.OnSeekBarChangeListener

Source Link

Usage

From source file:org.debian.paulliu.kajiradoubra.controller.LevelFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mActivity = (KajiraDouBraController) getActivity();

    SeekBar seekBarLeft = (SeekBar) mActivity.findViewById(R.id.seekbar_level_left);
    seekBarLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override//www  .  j a  v a 2  s .  c o  m
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

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

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

    SeekBar seekBarRight = (SeekBar) mActivity.findViewById(R.id.seekbar_level_right);
    seekBarRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

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

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

From source file:com.esri.arcgisruntime.sample.blendrenderer.ParametersDialogFragment.java

/**
 * Builds parameter dialog with values pulled through from MainActivity.
 *
 * @param savedInstanceState/*from w  w w . j av  a  2s  . c  om*/
 * @return create parameter dialog box
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Bundle blendParameters = getArguments();
    if (blendParameters != null) {
        mAltitude = blendParameters.getInt("altitude");
        mAzimuth = blendParameters.getInt("azimuth");
        mSlopeType = (SlopeType) blendParameters.getSerializable("slope_type");
        mColorRampType = (ColorRamp.PresetType) blendParameters.getSerializable("color_ramp_type");
    }

    final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext());
    @SuppressLint("InflateParams")
    View dialogView = inflater.inflate(R.layout.dialog_box, null);
    paramDialog.setView(dialogView);
    paramDialog.setTitle(R.string.dialog_title);
    paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            ParametersListener activity = (ParametersListener) getActivity();
            activity.returnParameters(mAltitude, mAzimuth, mSlopeType, mColorRampType);
        }
    });

    mCurrAltitudeTextView = (TextView) dialogView.findViewById(R.id.curr_altitude_text);
    SeekBar altitudeSeekBar = (SeekBar) dialogView.findViewById(R.id.altitude_seek_bar);
    altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90
    //set initial altitude value
    updateAltitudeSeekBar(altitudeSeekBar);
    altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAltitude = progress;
            updateAltitudeSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

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

    mCurrAzimuthTextView = (TextView) dialogView.findViewById(R.id.curr_azimuth_text);
    SeekBar azimuthSeekBar = (SeekBar) dialogView.findViewById(R.id.azimuth_seek_bar);
    azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360
    //set initial azimuth value
    updateAzimuthSeekBar(azimuthSeekBar);
    azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAzimuth = progress;
            updateAzimuthSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

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

    List<String> slopeTypeArray = new ArrayList<>();
    slopeTypeArray.add("None"); //ordinals:0
    slopeTypeArray.add("Degree"); //1
    slopeTypeArray.add("Percent rise"); //2
    slopeTypeArray.add("Scaled"); //3

    ArrayAdapter<String> slopeTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view,
            slopeTypeArray);

    Spinner slopeTypeSpinner = (Spinner) dialogView.findViewById(R.id.slope_type_spinner);
    slopeTypeSpinner.setAdapter(slopeTypeSpinnerAdapter);
    slopeTypeSpinner.setSelection(mSlopeType.ordinal());
    slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                mSlopeType = SlopeType.NONE;
                break;
            case 1:
                mSlopeType = SlopeType.DEGREE;
                break;
            case 2:
                mSlopeType = SlopeType.PERCENT_RISE;
                break;
            case 3:
                mSlopeType = SlopeType.SCALED;
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    List<String> colorRampTypeArray = new ArrayList<>();
    colorRampTypeArray.add("None"); //ordinals:0
    colorRampTypeArray.add("Elevation"); //1
    colorRampTypeArray.add("DEM screen"); //2
    colorRampTypeArray.add("DEM light"); //3

    ArrayAdapter<String> colorRampSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view,
            colorRampTypeArray);

    Spinner colorRampSpinner = (Spinner) dialogView.findViewById(R.id.color_ramp_spinner);
    colorRampSpinner.setAdapter(colorRampSpinnerAdapter);
    colorRampSpinner.setSelection(mColorRampType.ordinal());
    colorRampSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                mColorRampType = ColorRamp.PresetType.NONE;
                break;
            case 1:
                mColorRampType = ColorRamp.PresetType.ELEVATION;
                break;
            case 2:
                mColorRampType = ColorRamp.PresetType.DEM_SCREEN;
                break;
            case 3:
                mColorRampType = ColorRamp.PresetType.DEM_LIGHT;
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    return paramDialog.create();
}

From source file:org.starfishrespect.myconsumption.android.ui.ChartChoiceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_chart_choice, container, false);

    // Register to the EventBus
    EventBus.getDefault().register(this);

    listViewSensor = (ListView) view.findViewById(R.id.listViewSensors);
    mLinearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutDateSelectionItems);
    mTextView = (TextView) view.findViewById(R.id.textViewUsername);

    spinnerDate = (Spinner) view.findViewById(R.id.spinnerDate);
    spinnerFrequency = (Spinner) view.findViewById(R.id.spinnerFrequency);
    spinnerPrecision = (Spinner) view.findViewById(R.id.spinnerPrecision);

    seekBar = (SeekBar) view.findViewById(R.id.seekBar);
    seekBarPosition = 0;//from   www .ja v  a 2s .  c  o m

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        // Called when the slider moves to another value
        @Override
        public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
            seekBarPosition = progresValue;
        }

        // Called when you start moving the slider
        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        // Called when it seems that you are done moving the slider
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // Tell ChartViewFragment to update the graph
            EventBus.getDefault().post(new UpdateMovingAverageEvent(seekBarPosition));
        }
    });

    listViewSensor.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            lastLongClickItem = position;
            PopupMenu popup = new PopupMenu(mActivity, view);
            popup.inflate(R.menu.menu_sensor_dropdown);
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()) {
                    case R.id.action_delete_sensor:
                        if (!MiscFunctions.isOnline(mActivity)) {
                            MiscFunctions.makeOfflineDialog(mActivity).show();
                            return false;
                        }
                        deleteSensor(lastLongClickItem);
                        break;
                    case R.id.action_edit_sensor:
                        if (!MiscFunctions.isOnline(mActivity)) {
                            MiscFunctions.makeOfflineDialog(mActivity).show();
                            return false;
                        }
                        editSensor(lastLongClickItem);
                        break;
                    }
                    return false;
                }
            });
            popup.show();
            return false;
        }
    });

    return view;
}

From source file:com.jaguarlandrover.hvacdemo.MainActivity.java

private void configureSeekBar(SeekBar seekBar) {
    seekBar.setMax(MAX_FAN_SPEED);/*  w w  w . jav a 2 s. co  m*/
    seekBar.setOnSeekBarChangeListener(mFanSpeedSeekBarListener = new SeekBar.OnSeekBarChangeListener() {
        /* USER INTERFACE CALLBACK */
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            Log.d(TAG, Util.getMethodName());

            if (fromUser) {
                HVACManager.invokeService(getServiceIdentifiersFromViewId(seekBar.getId()),
                        Integer.toString(progress));

                if (progress == 0) {
                    setAirflowDirectionButtons(0);
                    HVACManager.invokeService(HVACServiceIdentifier.AIRFLOW_DIRECTION.value(),
                            Integer.toString(0));
                }
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = View.inflate(getActivity(), R.layout.search_geo_fragment, null);

    useGeo = (CheckBox) view.findViewById(R.id.cb_use_geo);
    typeGeo = (RadioGroup) view.findViewById(R.id.rg_type_geo);
    typeGeoGPS = (RadioButton) view.findViewById(R.id.rb_use_gps);
    typeGeoMap = (RadioButton) view.findViewById(R.id.rb_use_map);
    typeDistance = (RadioGroup) view.findViewById(R.id.rg_type_distance);
    typeDistanceMiles = (RadioButton) view.findViewById(R.id.rb_distance_miles);
    typeDistanceKM = (RadioButton) view.findViewById(R.id.rb_distance_km);

    llLocation = (LinearLayout) view.findViewById(R.id.ll_location);
    llMap = (LinearLayout) view.findViewById(R.id.ll_map);
    llDistance = (LinearLayout) view.findViewById(R.id.ll_distance);

    place = (AutoCompleteTextView) view.findViewById(R.id.et_place);

    address_list = new ArrayList<Address>();
    address_adapter = new AddressAdapter(getActivity(), address_list);
    place.setAdapter(address_adapter);//from  w  w  w .  java2 s .c  o  m

    place.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Address address = address_adapter.getAddressItem(i);

            if (address != null) {
                latitude.setText(String.valueOf(address.getLatitude()));
                longitude.setText(String.valueOf(address.getLongitude()));
            }
        }
    });

    latitude = (EditText) view.findViewById(R.id.et_latitude);
    longitude = (EditText) view.findViewById(R.id.et_longitude);
    distance = (SeekBar) view.findViewById(R.id.sb_distance);
    distanceTxt = (TextView) view.findViewById(R.id.distance);

    distance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            changeTextDistance(arg1);
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
        }

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

    useGeo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFields();
            } else {
                hideFields();
            }
        }
    });

    typeGeoGPS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                hideFieldsMap();
            }
        }
    });

    typeGeoMap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFieldsMap();
            }
        }
    });

    typeDistanceMiles.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    typeDistanceKM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    place.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String currentText = place.getText().toString();

            if (currentText.length() >= 3)
                APITweetTopics.execute(getActivity(), getLoaderManager(), SearchGeoFragment.this,
                        new GetGeolocationAddressRequest(getActivity(), currentText, false));
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable editable) {
        }
    });

    populateFields();

    return view;
}

From source file:ca.xef6.firecamp.ProfilePictureSampleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false);

    randomGenerator = new Random((new Date()).getTime());

    profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic);
    smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton);
    largerButton = (Button) fragmentView.findViewById(R.id.largerButton);
    sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel);
    presetSizeView = fragmentView.findViewById(R.id.presetSizeView);
    customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView);
    cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle);

    LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer);
    int numChildren = container.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        View childView = container.getChildAt(i);
        Object tag = childView.getTag();
        if (childView instanceof Button) {
            setupUserButton((Button) childView);
            if (i == 0) {
                // Initialize the image to the first user
                firstUserId = tag.toString();
            }/*w w  w .  java 2s  .co m*/
        }
    }

    cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
            profilePic.setCropped(checked);
        }
    });

    final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle);
    sizeToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (pictureSizeType != ProfilePictureView.CUSTOM) {
                sizeToggle.setText("preset size button text");
                switchToCustomSize();
            } else {
                sizeToggle.setText("custom size button text");
                switchToPresetSize(ProfilePictureView.LARGE);
            }
        }
    });

    smallerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.LARGE:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.SMALL);
                break;
            }
        }
    });

    largerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.LARGE);
                break;
            case ProfilePictureView.SMALL:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            }
        }
    });

    // We will fetch a new image for each change in the SeekBar. So keeping the count low
    // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1
    // notifications of change.
    customSizeView.setMax(MAX_CUSTOM_SIZES);
    customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            updateProfilePicForCustomSizeIncrement(i);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }
    });

    restoreState(savedInstanceState);

    return fragmentView;
}

From source file:com.facebook.samples.profilepicture.ProfilePictureSampleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false);

    randomGenerator = new Random((new Date()).getTime());

    profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic);
    smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton);
    largerButton = (Button) fragmentView.findViewById(R.id.largerButton);
    sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel);
    presetSizeView = fragmentView.findViewById(R.id.presetSizeView);
    customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView);
    cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle);

    LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer);
    int numChildren = container.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        View childView = container.getChildAt(i);
        Object tag = childView.getTag();
        if (childView instanceof Button) {
            setupUserButton((Button) childView);
            if (i == 0) {
                // Initialize the image to the first user
                firstUserId = tag.toString();
            }/*from ww  w.  java  2 s.  c  o m*/
        }
    }

    cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
            profilePic.setCropped(checked);
        }
    });

    final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle);
    sizeToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (pictureSizeType != ProfilePictureView.CUSTOM) {
                sizeToggle.setText(R.string.preset_size_button_text);
                switchToCustomSize();
            } else {
                sizeToggle.setText(R.string.custom_size_button_text);
                switchToPresetSize(ProfilePictureView.LARGE);
            }
        }
    });

    smallerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.LARGE:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.SMALL);
                break;
            }
        }
    });

    largerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.LARGE);
                break;
            case ProfilePictureView.SMALL:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            }
        }
    });

    // We will fetch a new image for each change in the SeekBar. So keeping the count low
    // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1
    // notifications of change.
    customSizeView.setMax(MAX_CUSTOM_SIZES);
    customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            updateProfilePicForCustomSizeIncrement(i);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }
    });

    restoreState(savedInstanceState);

    return fragmentView;
}

From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setHasOptionsMenu(true);//w ww .  ja  v a2 s  . c om
    this.bookView.init();

    this.progressBar.setFocusable(true);
    this.progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        private int seekValue;

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            bookView.navigateToPercentage(this.seekValue);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                seekValue = progress;
                percentageField.setText(progress + "% ");
            }
        }
    });

    this.mediaProgressBar.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) {
            if (fromUser) {
                seekToPointInPlayback(progress);
            }
        }
    });

    this.textToSpeech = new TextToSpeech(context, this::onTextToSpeechInit);

    this.bookView.addListener(this);
    this.bookView.setTextSelectionCallback(this);
}

From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setHasOptionsMenu(true);/*w w  w . j av a  2  s.c  o  m*/
    this.bookView.init();

    this.progressBar.setFocusable(true);
    this.progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        private int seekValue;

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            bookView.navigateToPercentage(this.seekValue);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                seekValue = progress;
                percentageField.setText(progress + "% ");
            }
        }
    });

    this.mediaProgressBar.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) {
            if (fromUser) {
                seekToPointInPlayback(progress);
            }
        }
    });

    this.textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            onTextToSpeechInit(status);
        }
    });

    this.bookView.addListener(this);
    this.bookView.setTextSelectionCallback(this);
}

From source file:nf.frex.android.FrexActivity.java

private void prepareColorsDialog(final Dialog dialog) {

    //Log.d(TAG, "prepareColorsDialog() entered");

    getColorSchemes();//from   w w w .j a  v a 2s.  c om

    //Log.d(TAG, "prepareColorsDialog: new bitmaps are being created");
    Bitmap[] colorSchemeIcons = new Bitmap[colorSchemes.getSize()];
    for (int i = 0; i < colorSchemeIcons.length; i++) {
        ColorScheme colorScheme = colorSchemes.getValue(i);
        colorSchemeIcons[i] = colorScheme.getGradientIcon();
    }

    int checkedIndex = Registries.colorSchemes.getIndex(view.getColorSchemeId());
    //Log.d(TAG, "prepareColorsDialog: checkedIndex = " + checkedIndex);
    final Spinner colorTableSpinner = (Spinner) dialog.findViewById(R.id.color_table_spinner);
    colorTableSpinner.setAdapter(new ImageArrayAdapter(this, 0, colorSchemeIcons));
    colorTableSpinner.setSelection(checkedIndex, false);
    colorTableSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) {
            view.setColorSchemeId(Registries.colorSchemes.getId(position));
            view.setColorScheme(Registries.colorSchemes.getValue(position));
            view.recomputeColors();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final SeekBar colorFactorSeekBar = (SeekBar) dialog.findViewById(R.id.color_gain_seek_bar);
    final double colorFactorMin = -3.0;
    final double colorFactorMax = 2.0;
    final SeekBarConfigurer colorFactorSeekBarConfigurer = SeekBarConfigurer.create(colorFactorSeekBar,
            colorFactorMin, colorFactorMax, true, view.getColorGain());
    colorFactorSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            view.setColorGain((float) colorFactorSeekBarConfigurer.getValue());
            view.recomputeColors();
        }
    });

    final SeekBar colorBiasSeekBar = (SeekBar) dialog.findViewById(R.id.color_offset_seek_bar);
    final double colorBiasMin = 0;
    final double colorBiasMax = 1024;
    final SeekBarConfigurer colorBiasSeekBarConfigurer = SeekBarConfigurer.create(colorBiasSeekBar,
            colorBiasMin, colorBiasMax, false, view.getColorOffset());
    colorBiasSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            view.setColorOffset((float) colorBiasSeekBarConfigurer.getValue());
            view.recomputeColors();
        }
    });

    final CheckBox colorRepeatCheckBox = (CheckBox) dialog.findViewById(R.id.color_repeat);
    colorRepeatCheckBox.setChecked(view.isColorRepeat());
    colorRepeatCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            view.setColorRepeat(isChecked);
            view.recomputeColors();
        }
    });

    Button randomButton = (Button) dialog.findViewById(R.id.random_button);
    randomButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            colorTableSpinner.setSelection((int) (Math.random() * colorSchemes.getSize()));
            colorFactorSeekBarConfigurer.setRandomValue();
            colorBiasSeekBarConfigurer.setRandomValue();
            view.recomputeColors();
        }
    });

    Button getPalFromImgButton = (Button) dialog.findViewById(R.id.get_pal_from_img_button);
    getPalFromImgButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            dialog.dismiss();
            startActivityForResult(photoPickerIntent, SELECT_PICTURE_REQUEST_CODE);
        }
    });

    //Log.d(TAG, "prepareColorsDialog() exited");
}