use of android.widget.CompoundButton.OnCheckedChangeListener 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.CompoundButton.OnCheckedChangeListener in project UltimateAndroid by cymcsg.
the class StyleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.switch_button_activity_style);
// getActionBar().setDisplayHomeAsUpEnabled(true);
container = (ViewGroup) findViewById(R.id.incode_container);
sbDefault = (SwitchButton) findViewById(R.id.sb_default);
sbIOS = (SwitchButton) findViewById(R.id.sb_ios);
sbChangeFaceControl = (SwitchButton) findViewById(R.id.sb_changeface_control);
sbEnable = (SwitchButton) findViewById(R.id.sb_enable);
sbMd = (SwitchButton) findViewById(R.id.sb_md);
sbInCode = new SwitchButton(this);
container.addView(sbInCode, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
sbs[0] = sbDefault;
sbs[1] = sbIOS;
sbs[2] = sbChangeFaceControl;
sbs[3] = sbInCode;
sbs[4] = sbMd;
sbDefault.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(StyleActivity.this, "Default style button, new state: " + (isChecked ? "on" : "off"), Toast.LENGTH_SHORT).show();
}
});
sbChangeFaceControl.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (!newConf) {
Configuration conf = Configuration.getDefault(getResources().getDisplayMetrics().density);
conf.setThumbMargin(2);
conf.setVelocity(8);
conf.setThumbWidthAndHeight(24, 14);
conf.setRadius(6);
conf.setMeasureFactor(2f);
sbInCode.setConfiguration(conf);
} else {
Configuration conf = Configuration.getDefault(getResources().getDisplayMetrics().density);
sbInCode.setConfiguration(conf);
}
newConf = isChecked;
}
});
sbEnable.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
for (SwitchButton sb : sbs) {
sb.setEnabled(isChecked);
}
}
});
sbEnable.setChecked(true);
}
use of android.widget.CompoundButton.OnCheckedChangeListener in project UltimateAndroid by cymcsg.
the class UseActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.switch_button_activity_use);
//getActionBar().setDisplayHomeAsUpEnabled(true);
findView();
// work with listener
mListenerSb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mListenerFinish.setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
}
});
// work with stuff takes long
longServiceReceiver = new LongServiceReceiver();
IntentFilter recevierFilter = new IntentFilter();
recevierFilter.addAction("LongServiceReceiver_ReturnIntent");
recevierFilter.addAction("PROGRESS_UPDATE");
LocalBroadcastManager.getInstance(this).registerReceiver(longServiceReceiver, recevierFilter);
mStartBt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent longService = new Intent(UseActivity.this, LongService.class);
longServiceReceiver.onPreExecute();
UseActivity.this.startService(longService);
}
});
// toggle
mToggleAniBt.setOnClickListener(this);
mToggleNotAniBt.setOnClickListener(this);
// checked
mCheckedAniBt.setOnClickListener(this);
mCheckNotAniBt.setOnClickListener(this);
}
use of android.widget.CompoundButton.OnCheckedChangeListener in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorArtistsMultiselectAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final Cursor c = (Cursor) getItem(position);
SongsListViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout, parent, false);
holder = new SongsListViewHolder();
holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor);
holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor);
convertView.setTag(holder);
} else {
holder = (SongsListViewHolder) convertView.getTag();
}
final View finalConvertView = convertView;
final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));
String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
//Set the song title.
holder.title.setText(songArtist);
mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, MusicLibraryEditorActivity.displayImageOptions);
//Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) {
holder.checkBox.setChecked(true);
convertView.setBackgroundColor(0xCC0099CC);
} else {
holder.checkBox.setChecked(false);
convertView.setBackgroundColor(0x00000000);
}
//Set a tag to the row that will attach the artist's name to it.
convertView.setTag(R.string.artist, songArtist);
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {
if (isChecked == true) {
//Only receive inputs by the user and ignore any system-made changes to the checkbox state.
if (checkbox.isPressed()) {
finalConvertView.setBackgroundColor(0xCC0099CC);
AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist);
task.execute(new String[] { "ADD" });
}
} else if (isChecked == false) {
//Only receive inputs by the user and ignore any system-made changes to the checkbox state.
if (checkbox.isPressed()) {
finalConvertView.setBackgroundColor(0x00000000);
AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist);
task.execute(new String[] { "REMOVE" });
}
}
}
});
return convertView;
}
use of android.widget.CompoundButton.OnCheckedChangeListener in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorSongsMultiselectAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final Cursor c = (Cursor) getItem(position);
SongsListViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_songs_layout, parent, false);
holder = new SongsListViewHolder();
holder.image = (ImageView) convertView.findViewById(R.id.songThumbnailMusicLibraryEditor);
holder.title = (TextView) convertView.findViewById(R.id.songNameMusicLibraryEditor);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.songCheckboxMusicLibraryEditor);
holder.subText = (TextView) convertView.findViewById(R.id.artistNameSongListView);
convertView.setTag(holder);
} else {
holder = (SongsListViewHolder) convertView.getTag();
}
final View finalConvertView = convertView;
final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
final String songTitle = c.getString(c.getColumnIndex(DBAccessHelper.SONG_TITLE));
String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));
holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
holder.subText.setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
//Set the songID as the view's tag.
convertView.setTag(R.string.song_id, songId);
//Set the song title.
holder.title.setText(songTitle);
holder.subText.setText(songArtist);
mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, MusicLibraryEditorActivity.displayImageOptions);
//Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) {
convertView.setBackgroundColor(0xCC0099CC);
holder.checkBox.setChecked(true);
} else {
convertView.setBackgroundColor(0x00000000);
holder.checkBox.setChecked(false);
}
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {
if (isChecked == true) {
//Only receive inputs by the user and ignore any system-made changes to the checkbox state.
if (checkbox.isPressed()) {
finalConvertView.setBackgroundColor(0xCC0099CC);
MusicLibraryEditorActivity.songDBIdsList.add(songId);
}
} else if (isChecked == false) {
//Only receive inputs by the user and ignore any system-made changes to the checkbox state.
if (checkbox.isPressed()) {
finalConvertView.setBackgroundColor(0xCC0099CC);
MusicLibraryEditorActivity.songDBIdsList.remove(songId);
}
}
}
});
return convertView;
}
Aggregations