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.mainnew);
context = this.getApplicationContext();
buttonOn = (Button) findViewById(R.id.buttonOn);
buttonStrobe = (CheckBox) findViewById(R.id.strobe);
strobeLabel = (TextView) findViewById(R.id.strobeTimeLabel);
slider = (SeekBar) findViewById(R.id.slider);
buttonBright = (CheckBox) findViewById(R.id.bright);
strobeperiod = 100;
mTorchOn = false;
labelOn = this.getString(R.string.label_on);
labelOff = this.getString(R.string.label_off);
mWidgetProvider = TorchWidgetProvider.getInstance();
// Preferences
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// preferenceEditor
this.mPrefsEditor = this.mPrefs.edit();
bright = this.mPrefs.getBoolean("bright", false);
buttonBright.setChecked(bright);
buttonBright.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked && mPrefs.getBoolean("bright", false))
MainActivity.this.bright = true;
else if (isChecked)
openBrightDialog();
else {
bright = false;
mPrefsEditor.putBoolean("bright", false);
mPrefsEditor.commit();
}
}
});
strobeLabel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
buttonStrobe.setChecked(!buttonStrobe.isChecked());
}
});
buttonOn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT);
intent.putExtra("strobe", buttonStrobe.isChecked());
intent.putExtra("period", strobeperiod);
intent.putExtra("bright", bright);
context.sendBroadcast(intent);
}
});
// Strobe frequency slider bar handling
setProgressBarVisibility(true);
slider.setHorizontalScrollBarEnabled(true);
slider.setProgress(400 - this.mPrefs.getInt("strobeperiod", 100));
strobeperiod = this.mPrefs.getInt("strobeperiod", 100);
final String strStrobeLabel = this.getString(R.string.setting_frequency_title);
strobeLabel.setText(strStrobeLabel + ": " + 666 / strobeperiod + "Hz / " + 40000 / strobeperiod + "BPM");
slider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
strobeperiod = 401 - progress;
if (strobeperiod < 20)
strobeperiod = 20;
strobeLabel.setText(strStrobeLabel + ": " + 666 / strobeperiod + "Hz / " + 40000 / strobeperiod + "BPM");
Intent intent = new Intent("net.cactii.flash2.SET_STROBE");
intent.putExtra("period", strobeperiod);
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 (!this.mPrefs.getBoolean("aboutSeen", false)) {
this.openAboutDialog();
this.mPrefsEditor.putBoolean("aboutSeen", true);
}
}
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-stackblur by kikoso.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_stackBlurManager = new StackBlurManager(getBitmapFromAsset(this, "android_platform_256.png"));
_seekBar.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) {
onBlur();
}
});
_toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
IMAGE_TO_ANALYZE = "image_transparency.png";
_stackBlurManager = new StackBlurManager(getBitmapFromAsset(getApplicationContext(), IMAGE_TO_ANALYZE));
onBlur();
} else {
IMAGE_TO_ANALYZE = "android_platform_256.png";
_stackBlurManager = new StackBlurManager(getBitmapFromAsset(getApplicationContext(), IMAGE_TO_ANALYZE));
onBlur();
}
}
});
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.blur_modes, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
_typeSelectSpinner.setAdapter(adapter);
_typeSelectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
setBlurMode(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
use of android.widget.SeekBar.OnSeekBarChangeListener in project cropper by edmodo.
the class MainActivity method onCreate.
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
// Initialize Views.
final ToggleButton fixedAspectRatioToggleButton = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
final TextView aspectRatioXTextView = (TextView) findViewById(R.id.aspectRatioX);
final SeekBar aspectRatioXSeekBar = (SeekBar) findViewById(R.id.aspectRatioXSeek);
final TextView aspectRatioYTextView = (TextView) findViewById(R.id.aspectRatioY);
final SeekBar aspectRatioYSeekBar = (SeekBar) findViewById(R.id.aspectRatioYSeek);
final Spinner guidelinesSpinner = (Spinner) findViewById(R.id.showGuidelinesSpin);
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
final Button cropButton = (Button) findViewById(R.id.Button_crop);
// Initializes fixedAspectRatio toggle button.
fixedAspectRatioToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cropImageView.setFixedAspectRatio(isChecked);
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioXSeekBar.setEnabled(isChecked);
aspectRatioYSeekBar.setEnabled(isChecked);
}
});
// Set seek bars to be disabled until toggle button is checked.
aspectRatioXSeekBar.setEnabled(false);
aspectRatioYSeekBar.setEnabled(false);
aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
aspectRatioYTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
// Initialize aspect ratio X SeekBar.
aspectRatioXSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioXSeekBar, int progress, boolean fromUser) {
if (progress < 1) {
aspectRatioXSeekBar.setProgress(1);
}
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
});
// Initialize aspect ratio Y SeekBar.
aspectRatioYSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioYSeekBar, int progress, boolean fromUser) {
if (progress < 1) {
aspectRatioYSeekBar.setProgress(1);
}
cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
aspectRatioYTextView.setText(String.valueOf(aspectRatioYSeekBar.getProgress()));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing.
}
});
// Set up the Guidelines Spinner.
guidelinesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
cropImageView.setGuidelines(i);
}
public void onNothingSelected(AdapterView<?> adapterView) {
// Do nothing.
}
});
guidelinesSpinner.setSelection(GUIDELINES_ON_TOUCH);
// Initialize the Crop button.
cropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
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