use of android.widget.CompoundButton in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorAlbumsMultiselectAdapter 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_albums_layout, parent, false);
holder = new SongsListViewHolder();
holder.image = (ImageView) convertView.findViewById(R.id.albumThumbnailMusicLibraryEditor);
holder.title = (TextView) convertView.findViewById(R.id.albumNameMusicLibraryEditor);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.albumCheckboxMusicLibraryEditor);
holder.subText = (TextView) convertView.findViewById(R.id.albumArtistNameMusicLibraryEditor);
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));
final String songAlbum = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM));
final String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
//Set the album's name and artist as the row's tag.
convertView.setTag(R.string.album, songAlbum);
convertView.setTag(R.string.artist, songArtist);
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 song title.
holder.title.setText(songAlbum);
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)) {
holder.checkBox.setChecked(true);
convertView.setBackgroundColor(0xCC0099CC);
} 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);
AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(songAlbum, 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);
AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(songAlbum, songArtist);
task.execute(new String[] { "REMOVE" });
}
}
}
});
return convertView;
}
use of android.widget.CompoundButton in project android-saripaar by ragunathjawahar.
the class RemoveRulesActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remove_rules);
// UI References
mEmailEditText = (EditText) findViewById(R.id.emailEditText);
mAddQuickRuleRadioButton = (RadioButton) findViewById(R.id.addQuickRuleRadioButton);
mRemoveRulesRadioButton = (RadioButton) findViewById(R.id.removeRulesRadioButton);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
// Event listeners
mSaripaarButton.setOnClickListener(this);
mValidator.setValidationListener(this);
mAddQuickRuleRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mValidator.put(mEmailEditText, new QuickRule<EditText>() {
@Override
public boolean isValid(EditText editText) {
String email = editText.getText().toString();
return email.endsWith("mobsandgeeks.com");
}
@Override
public String getMessage(Context context) {
return "Only allow emails from \"mobsandgeeks.com\" :P";
}
});
}
});
mRemoveRulesRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mValidator.removeRules(mEmailEditText);
}
});
}
use of android.widget.CompoundButton in project PocketHub by pockethub.
the class EditIssuesFilterActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issues_filter_edit);
labelsText = finder.find(R.id.tv_labels);
milestoneText = finder.find(R.id.tv_milestone);
assigneeText = finder.find(R.id.tv_assignee);
avatarView = finder.find(R.id.iv_avatar);
if (savedInstanceState != null) {
filter = savedInstanceState.getParcelable(EXTRA_ISSUE_FILTER);
}
if (filter == null) {
filter = getIntent().getParcelableExtra(EXTRA_ISSUE_FILTER);
}
final Repository repository = filter.getRepository();
setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(R.string.filter_issues_title);
actionBar.setSubtitle(InfoUtils.createRepoId(repository));
avatars.bind(actionBar, repository.owner());
OnClickListener assigneeListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (assigneeDialog == null) {
assigneeDialog = new AssigneeDialog(EditIssuesFilterActivity.this, REQUEST_ASSIGNEE, repository);
}
assigneeDialog.show(filter.getAssignee());
}
};
findViewById(R.id.tv_assignee_label).setOnClickListener(assigneeListener);
assigneeText.setOnClickListener(assigneeListener);
OnClickListener milestoneListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (milestoneDialog == null) {
milestoneDialog = new MilestoneDialog(EditIssuesFilterActivity.this, REQUEST_MILESTONE, repository);
}
milestoneDialog.show(filter.getMilestone());
}
};
findViewById(R.id.tv_milestone_label).setOnClickListener(milestoneListener);
milestoneText.setOnClickListener(milestoneListener);
OnClickListener labelsListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (labelsDialog == null) {
labelsDialog = new LabelsDialog(EditIssuesFilterActivity.this, REQUEST_LABELS, repository);
}
labelsDialog.show(filter.getLabels());
}
};
findViewById(R.id.tv_labels_label).setOnClickListener(labelsListener);
labelsText.setOnClickListener(labelsListener);
updateAssignee();
updateMilestone();
updateLabels();
RadioButton openButton = (RadioButton) findViewById(R.id.rb_open);
openButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
filter.setOpen(true);
}
}
});
RadioButton closedButton = (RadioButton) findViewById(R.id.rb_closed);
closedButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
filter.setOpen(false);
}
}
});
if (filter.isOpen()) {
openButton.setChecked(true);
} else {
closedButton.setChecked(true);
}
}
use of android.widget.CompoundButton in project TextSurface by elevenetc.
the class SampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_activity);
textSurface = (TextSurface) findViewById(R.id.text_surface);
textSurface.postDelayed(new Runnable() {
@Override
public void run() {
show();
}
}, 1000);
findViewById(R.id.btn_refresh).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
show();
}
});
CheckBox checkDebug = (CheckBox) findViewById(R.id.check_debug);
checkDebug.setChecked(Debug.ENABLED);
checkDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Debug.ENABLED = isChecked;
textSurface.invalidate();
}
});
}
use of android.widget.CompoundButton in project Libraries-for-Android-Developers by eoecn.
the class ListMenuItemView method setCheckable.
public void setCheckable(boolean checkable) {
if (!checkable && mRadioButton == null && mCheckBox == null) {
return;
}
if (mRadioButton == null) {
insertRadioButton();
}
if (mCheckBox == null) {
insertCheckBox();
}
// Depending on whether its exclusive check or not, the checkbox or
// radio button will be the one in use (and the other will be otherCompoundButton)
final CompoundButton compoundButton;
final CompoundButton otherCompoundButton;
if (mItemData.isExclusiveCheckable()) {
compoundButton = mRadioButton;
otherCompoundButton = mCheckBox;
} else {
compoundButton = mCheckBox;
otherCompoundButton = mRadioButton;
}
if (checkable) {
compoundButton.setChecked(mItemData.isChecked());
final int newVisibility = checkable ? VISIBLE : GONE;
if (compoundButton.getVisibility() != newVisibility) {
compoundButton.setVisibility(newVisibility);
}
// Make sure the other compound button isn't visible
if (otherCompoundButton.getVisibility() != GONE) {
otherCompoundButton.setVisibility(GONE);
}
} else {
mCheckBox.setVisibility(GONE);
mRadioButton.setVisibility(GONE);
}
}
Aggregations