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);
}
}
});
}
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);
}
});
}
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();
}
}
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);
}
});
}
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);
}
Aggregations