Search in sources :

Example 6 with OnSeekBarChangeListener

use of android.widget.SeekBar.OnSeekBarChangeListener in project Shuttle by timusus.

the class VideoCastControllerActivity method loadAndSetupViews.

private void loadAndSetupViews() {
    mPauseDrawable = getResources().getDrawable(R.drawable.ic_pause_circle_white_80dp);
    mPlayDrawable = getResources().getDrawable(R.drawable.ic_play_circle_white_80dp);
    mStopDrawable = getResources().getDrawable(R.drawable.ic_stop_circle_white_80dp);
    mPageView = findViewById(R.id.pageview);
    mPlayPause = (ImageButton) findViewById(R.id.play_pause_toggle);
    mLiveText = (TextView) findViewById(R.id.live_text);
    mStart = (TextView) findViewById(R.id.start_text);
    mEnd = (TextView) findViewById(R.id.end_text);
    mSeekbar = (SeekBar) findViewById(R.id.seekbar);
    mLine2 = (TextView) findViewById(R.id.textview2);
    mLoading = (ProgressBar) findViewById(R.id.progressbar1);
    mControllers = findViewById(R.id.controllers);
    mClosedCaptionIcon = (ImageButton) findViewById(R.id.cc);
    mSkipNext = (ImageButton) findViewById(R.id.next);
    mSkipPrevious = (ImageButton) findViewById(R.id.previous);
    mPlaybackControls = findViewById(R.id.playback_controls);
    ((MiniController) findViewById(R.id.miniController1)).setCurrentVisibility(false);
    setClosedCaptionState(CC_DISABLED);
    mPlayPause.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                mListener.onPlayPauseClicked(v);
            } catch (TransientNetworkDisconnectionException e) {
                LOGE(TAG, "Failed to toggle playback due to temporary network issue", e);
                Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_no_connection_trans);
            } catch (NoConnectionException e) {
                LOGE(TAG, "Failed to toggle playback due to network issues", e);
                Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_no_connection);
            } catch (Exception e) {
                LOGE(TAG, "Failed to toggle playback due to other issues", e);
                Utils.showToast(VideoCastControllerActivity.this, R.string.ccl_failed_perform_action);
            }
        }
    });
    mSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            try {
                if (mListener != null) {
                    mListener.onStopTrackingTouch(seekBar);
                }
            } catch (Exception e) {
                LOGE(TAG, "Failed to complete seek", e);
                finish();
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            try {
                if (mListener != null) {
                    mListener.onStartTrackingTouch(seekBar);
                }
            } catch (Exception e) {
                LOGE(TAG, "Failed to start seek", e);
                finish();
            }
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mStart.setText(Utils.formatMillis(progress));
            try {
                if (mListener != null) {
                    mListener.onProgressChanged(seekBar, progress, fromUser);
                }
            } catch (Exception e) {
                LOGE(TAG, "Failed to set the progress result", e);
            }
        }
    });
    mClosedCaptionIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                showTracksChooserDialog();
            } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
                LOGE(TAG, "Failed to get the media", e);
            }
        }
    });
    mSkipNext.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                mListener.onSkipNextClicked(v);
            } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
                LOGE(TAG, "Failed to move to the next item in the queue", e);
            }
        }
    });
    mSkipPrevious.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                mListener.onSkipPreviousClicked(v);
            } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
                LOGE(TAG, "Failed to move to the previous item in the queue", e);
            }
        }
    });
}
Also used : SeekBar(android.widget.SeekBar) NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException) MiniController(com.google.android.libraries.cast.companionlibrary.widgets.MiniController) OnClickListener(android.view.View.OnClickListener) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException) NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException)

Example 7 with OnSeekBarChangeListener

use of android.widget.SeekBar.OnSeekBarChangeListener in project IconicDroid by atermenji.

the class SimpleSampleActivity method initSimpleSample.

private void initSimpleSample() {
    mIconicFontDrawable = new IconicFontDrawable(this);
    mIconicFontDrawableButton = new IconicFontDrawable(this);
    mIconicFontDrawableButton.setIntrinsicWidth(BUTTON_ICON_INTRINSIC_WIDTH);
    mIconicFontDrawableButton.setIntrinsicHeight(BUTTON_ICON_INTRINSIC_HEIGHT);
    if (SDK_INT < JELLY_BEAN) {
        mIconView.setBackgroundDrawable(mIconicFontDrawable);
    } else {
        mIconView.setBackground(mIconicFontDrawable);
    }
    mChangeColorButton.setCompoundDrawablesWithIntrinsicBounds(mIconicFontDrawableButton, null, null, null);
    List<Icon> icons = new ArrayList<Icon>();
    icons.addAll(Arrays.asList(EntypoIcon.values()));
    icons.addAll(Arrays.asList(EntypoSocialIcon.values()));
    icons.addAll(Arrays.asList(FontAwesomeIcon.values()));
    icons.addAll(Arrays.asList(IconicIcon.values()));
    final ArrayAdapter<Icon> adapter = new ArrayAdapter<Icon>(this, android.R.layout.simple_spinner_item, icons);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mIconsSpinner.setAdapter(adapter);
    if (mIcon != null) {
        mIconicFontDrawable.setIcon(mIcon);
        mIconicFontDrawableButton.setIcon(mIcon);
        mIconsSpinner.setSelection(adapter.getPosition(mIcon));
        firstSelect = true;
    }
    mIconsSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            if (!firstSelect) {
                Icon icon = adapter.getItem(pos);
                mIconicFontDrawable.setIcon(icon);
                mIconicFontDrawableButton.setIcon(icon);
            } else {
                firstSelect = false;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mIconicFontDrawable.setIconColor(Utils.randomColor());
    mIconicFontDrawableButton.setIconColor(Utils.randomColor());
    mCurPaddingTextView.setText("Padding: " + 0);
    mPaddingSeekBar.setMax(ICON_PADDING_MAX);
    mPaddingSeekBar.setProgress(0);
    mPaddingSeekBar.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) {
            mIconicFontDrawable.setIconPadding(progress);
            mCurPaddingTextView.setText("Padding: " + progress);
        }
    });
    mChangeColorButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mIconicFontDrawable.setIconColor(Utils.randomColor());
            mIconicFontDrawable.setContourColor(Utils.randomColor());
            mIconicFontDrawableButton.setIconColor(Utils.randomColor());
            mIconicFontDrawableButton.setContourColor(Utils.randomColor());
        }
    });
    mDrawContourCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mIconicFontDrawable.setContour(Utils.randomColor(), ICON_CONTOUR_WIDTH);
                mIconicFontDrawableButton.setContour(Utils.randomColor(), BUTTON_ICON_CONTOUR_WIDTH);
            }
            mIconicFontDrawable.drawContour(isChecked);
            mIconicFontDrawableButton.drawContour(isChecked);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) View(android.view.View) IconicFontDrawable(com.atermenji.android.iconicdroid.IconicFontDrawable) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) OnClickListener(android.view.View.OnClickListener) EntypoSocialIcon(com.atermenji.android.iconicdroid.icon.EntypoSocialIcon) EntypoIcon(com.atermenji.android.iconicdroid.icon.EntypoIcon) Icon(com.atermenji.android.iconicdroid.icon.Icon) FontAwesomeIcon(com.atermenji.android.iconicdroid.icon.FontAwesomeIcon) IconicIcon(com.atermenji.android.iconicdroid.icon.IconicIcon)

Example 8 with OnSeekBarChangeListener

use of android.widget.SeekBar.OnSeekBarChangeListener in project android_packages_apps_Torch by CyanogenMod.

the class MainActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mButtonOn = (ToggleButton) findViewById(R.id.buttonOn);
    mStrobeSwitch = (Switch) findViewById(R.id.strobe_switch);
    mStrobeLabel = (TextView) findViewById(R.id.strobeTimeLabel);
    mSlider = (SeekBar) findViewById(R.id.slider);
    mBrightSwitch = (Switch) findViewById(R.id.bright_switch);
    mStrobePeriod = 100;
    mTorchOn = false;
    mWidgetProvider = TorchWidgetProvider.getInstance();
    // Preferences
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mHasBrightSetting = getResources().getBoolean(R.bool.hasHighBrightness);
    if (mHasBrightSetting) {
        mBright = mPrefs.getBoolean("bright", false);
        mBrightSwitch.setChecked(mBright);
        mBrightSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked && mPrefs.getBoolean("bright", false)) {
                    mBright = true;
                } else if (isChecked) {
                    openBrightDialog();
                } else {
                    mBright = false;
                    mPrefs.edit().putBoolean("bright", false).commit();
                }
            }
        });
    } else {
        // Fully hide the UI elements on Crespo since we can't use them
        mBrightSwitch.setVisibility(View.GONE);
        findViewById(R.id.ruler2).setVisibility(View.GONE);
    }
    // Set the state of the strobing section and hide as appropriate
    final boolean isStrobing = mPrefs.getBoolean("strobe", false);
    final LinearLayout strobeLayout = (LinearLayout) findViewById(R.id.strobeRow);
    int visibility = isStrobing ? View.VISIBLE : View.GONE;
    strobeLayout.setVisibility(visibility);
    mStrobeSwitch.setChecked(isStrobing);
    mStrobeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            int visibility = isChecked ? View.VISIBLE : View.GONE;
            strobeLayout.setVisibility(visibility);
            mPrefs.edit().putBoolean("strobe", isChecked).commit();
        }
    });
    mButtonOn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT);
            intent.putExtra("strobe", mStrobeSwitch.isChecked());
            intent.putExtra("period", mStrobePeriod);
            intent.putExtra("bright", mBright);
            sendBroadcast(intent);
        }
    });
    // Strobe frequency slider bar handling
    setProgressBarVisibility(true);
    updateStrobePeriod(mPrefs.getInt("strobeperiod", 100));
    mSlider.setHorizontalScrollBarEnabled(true);
    mSlider.setProgress(400 - mStrobePeriod);
    mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateStrobePeriod(Math.max(20, 401 - progress));
            Intent intent = new Intent("net.cactii.flash2.SET_STROBE");
            intent.putExtra("period", mStrobePeriod);
            sendBroadcast(intent);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Show the about dialog, the first time the user runs the app.
    if (!mPrefs.getBoolean("aboutSeen", false)) {
        openAboutDialog();
        mPrefs.edit().putBoolean("aboutSeen", true).commit();
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) TextView(android.widget.TextView) View(android.view.View) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Example 9 with OnSeekBarChangeListener

use of android.widget.SeekBar.OnSeekBarChangeListener in project UltimateAndroid by cymcsg.

the class CropperSample method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.cropper_activity);
    // Sets fonts for all
    Typeface mFont = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");
    ViewGroup root = (ViewGroup) findViewById(R.id.mylayout);
    setFont(root, mFont);
    // Initialize components of the app
    final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
    final SeekBar aspectRatioXSeek = (SeekBar) findViewById(R.id.aspectRatioXSeek);
    final SeekBar aspectRatioYSeek = (SeekBar) findViewById(R.id.aspectRatioYSeek);
    final ToggleButton fixedAspectRatioToggle = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
    Spinner showGuidelinesSpin = (Spinner) findViewById(R.id.showGuidelinesSpin);
    // Sets sliders to be disabled until fixedAspectRatio is set
    aspectRatioXSeek.setEnabled(false);
    aspectRatioYSeek.setEnabled(false);
    // Set initial spinner value
    showGuidelinesSpin.setSelection(ON_TOUCH);
    //Sets the rotate button
    final Button rotateButton = (Button) findViewById(R.id.Button_rotate);
    rotateButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cropImageView.rotateImage(ROTATE_NINETY_DEGREES);
        }
    });
    // Sets fixedAspectRatio
    fixedAspectRatioToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            cropImageView.setFixedAspectRatio(isChecked);
            if (isChecked) {
                aspectRatioXSeek.setEnabled(true);
                aspectRatioYSeek.setEnabled(true);
            } else {
                aspectRatioXSeek.setEnabled(false);
                aspectRatioYSeek.setEnabled(false);
            }
        }
    });
    // Sets initial aspect ratio to 10/10, for demonstration purposes
    cropImageView.setAspectRatio(DEFAULT_ASPECT_RATIO_VALUES, DEFAULT_ASPECT_RATIO_VALUES);
    // Sets aspectRatioX
    final TextView aspectRatioX = (TextView) findViewById(R.id.aspectRatioX);
    aspectRatioXSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioXSeek, int progress, boolean fromUser) {
            try {
                mAspectRatioX = progress;
                cropImageView.setAspectRatio(progress, mAspectRatioY);
                aspectRatioX.setText(" " + progress);
            } catch (IllegalArgumentException e) {
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Sets aspectRatioY
    final TextView aspectRatioY = (TextView) findViewById(R.id.aspectRatioY);
    aspectRatioYSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioYSeek, int progress, boolean fromUser) {
            try {
                mAspectRatioY = progress;
                cropImageView.setAspectRatio(mAspectRatioX, progress);
                aspectRatioY.setText(" " + progress);
            } catch (IllegalArgumentException e) {
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Sets up the Spinner
    showGuidelinesSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            cropImageView.setGuidelines(i);
        }

        public void onNothingSelected(AdapterView<?> adapterView) {
            return;
        }
    });
    final Button cropButton = (Button) findViewById(R.id.Button_crop);
    cropButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            croppedImage = cropImageView.getCroppedImage();
            ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
            croppedImageView.setImageBitmap(croppedImage);
        }
    });
}
Also used : ToggleButton(android.widget.ToggleButton) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) Typeface(android.graphics.Typeface) ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) ImageView(android.widget.ImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) CompoundButton(android.widget.CompoundButton)

Example 10 with OnSeekBarChangeListener

use of android.widget.SeekBar.OnSeekBarChangeListener in project AnimeTaste by daimajia.

the class PlayActivity method registerCallbackForControls.

private void registerCallbackForControls() {
    OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() {

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateTextViewWithTimeFormat(mCurPosition, progress);
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            mUIHandler.removeMessages(UI_EVENT_UPDATE_CURRPOSITION);
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            int seekPosition = seekBar.getProgress();
            mVV.seekTo(seekPosition);
            mUIHandler.sendEmptyMessage(UI_EVENT_UPDATE_CURRPOSITION);
        }
    };
    mProgress.setOnSeekBarChangeListener(seekBarChangeListener);
}
Also used : SeekBar(android.widget.SeekBar) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) SuppressLint(android.annotation.SuppressLint)

Aggregations

OnSeekBarChangeListener (android.widget.SeekBar.OnSeekBarChangeListener)13 SeekBar (android.widget.SeekBar)12 View (android.view.View)9 TextView (android.widget.TextView)8 CompoundButton (android.widget.CompoundButton)6 Intent (android.content.Intent)4 AdapterView (android.widget.AdapterView)4 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)4 ImageView (android.widget.ImageView)4 OnClickListener (android.view.View.OnClickListener)3 Button (android.widget.Button)3 DialogInterface (android.content.DialogInterface)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 AlertDialog (android.support.v7.app.AlertDialog)2 ViewGroup (android.view.ViewGroup)2 CheckBox (android.widget.CheckBox)2 Spinner (android.widget.Spinner)2 ToggleButton (android.widget.ToggleButton)2 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)1 AccountManager (android.accounts.AccountManager)1