Search in sources :

Example 41 with CompoundButton

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;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Example 42 with CompoundButton

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);
        }
    });
}
Also used : QuickRule(com.mobsandgeeks.saripaar.QuickRule) EditText(android.widget.EditText) Context(android.content.Context) Validator(com.mobsandgeeks.saripaar.Validator) CompoundButton(android.widget.CompoundButton)

Example 43 with CompoundButton

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);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Repository(com.meisolsson.githubsdk.model.Repository) OnClickListener(android.view.View.OnClickListener) ActionBar(android.support.v7.app.ActionBar) CompoundButton(android.widget.CompoundButton)

Example 44 with CompoundButton

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();
        }
    });
}
Also used : CheckBox(android.widget.CheckBox) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Example 45 with CompoundButton

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);
    }
}
Also used : CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)249 View (android.view.View)129 TextView (android.widget.TextView)102 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)63 ImageView (android.widget.ImageView)50 CheckBox (android.widget.CheckBox)45 AdapterView (android.widget.AdapterView)27 Intent (android.content.Intent)26 Button (android.widget.Button)24 DialogInterface (android.content.DialogInterface)23 LayoutInflater (android.view.LayoutInflater)23 OnClickListener (android.view.View.OnClickListener)20 Switch (android.widget.Switch)18 SeekBar (android.widget.SeekBar)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)14 RecyclerView (android.support.v7.widget.RecyclerView)13 ArrayList (java.util.ArrayList)13 LinearLayout (android.widget.LinearLayout)12 OnClickListener (android.content.DialogInterface.OnClickListener)11