Search in sources :

Example 46 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener 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);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) TextView(android.widget.TextView) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Example 47 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project coursera-android by aporter.

the class AudioRecordingActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    mRecordButton = findViewById(R.id.record_button);
    mPlayButton = findViewById(R.id.play_button);
    if (checkSelfPermission(mPermissions[0]) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(mPermissions[1]) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(mPermissions, APP_PERMS_REQUEST_CODE);
    }
    // Set up record Button
    mRecordButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // Set enabled state
            mPlayButton.setEnabled(!isChecked);
            // Start/stop recording
            onRecordPressed(isChecked);
        }
    });
    // Set up play Button
    mPlayButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // Set enabled state
            mRecordButton.setEnabled(!isChecked);
            // Start/stop playback
            onPlayPressed(isChecked);
        }
    });
    // Get AudioManager
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    // Request audio focus
    if (null != mAudioManager) {
        mAudioManager.requestAudioFocus(afChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CompoundButton(android.widget.CompoundButton)

Example 48 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project XPrivacy by M66B.

the class ActivityMain method optionFilter.

@SuppressLint("InflateParams")
private void optionFilter() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.filters, null);
    final CheckBox cbFUsed = (CheckBox) view.findViewById(R.id.cbFUsed);
    final CheckBox cbFInternet = (CheckBox) view.findViewById(R.id.cbFInternet);
    final CheckBox cbFPermission = (CheckBox) view.findViewById(R.id.cbFPermission);
    final CheckBox cbFRestriction = (CheckBox) view.findViewById(R.id.cbFRestriction);
    final CheckBox cbFRestrictionNot = (CheckBox) view.findViewById(R.id.cbFRestrictionNot);
    final CheckBox cbFOnDemand = (CheckBox) view.findViewById(R.id.cbFOnDemand);
    final CheckBox cbFOnDemandNot = (CheckBox) view.findViewById(R.id.cbFOnDemandNot);
    final CheckBox cbFUser = (CheckBox) view.findViewById(R.id.cbFUser);
    final CheckBox cbFSystem = (CheckBox) view.findViewById(R.id.cbFSystem);
    final Button btnDefault = (Button) view.findViewById(R.id.btnDefault);
    // Get settings
    final int userId = Util.getUserId(Process.myUid());
    boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
    boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
    boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
    boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
    boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false);
    boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
    boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false);
    boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
    boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
    boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
    // Setup checkboxes
    cbFUsed.setChecked(fUsed);
    cbFInternet.setChecked(fInternet);
    cbFPermission.setChecked(fPermission);
    cbFRestriction.setChecked(fRestriction);
    cbFRestrictionNot.setChecked(fRestrictionNot);
    cbFOnDemand.setChecked(fOnDemand && ondemand);
    cbFOnDemandNot.setChecked(fOnDemandNot && ondemand);
    cbFUser.setChecked(fUser);
    cbFSystem.setChecked(fSystem);
    cbFRestrictionNot.setEnabled(fRestriction);
    cbFOnDemand.setEnabled(ondemand);
    cbFOnDemandNot.setEnabled(fOnDemand && ondemand);
    // Manage user/system filter exclusivity
    OnCheckedChangeListener checkListener = new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView == cbFUser) {
                if (isChecked)
                    cbFSystem.setChecked(false);
            } else if (buttonView == cbFSystem) {
                if (isChecked)
                    cbFUser.setChecked(false);
            } else if (buttonView == cbFRestriction)
                cbFRestrictionNot.setEnabled(cbFRestriction.isChecked());
            else if (buttonView == cbFOnDemand)
                cbFOnDemandNot.setEnabled(cbFOnDemand.isChecked());
        }
    };
    cbFUser.setOnCheckedChangeListener(checkListener);
    cbFSystem.setOnCheckedChangeListener(checkListener);
    cbFRestriction.setOnCheckedChangeListener(checkListener);
    cbFOnDemand.setOnCheckedChangeListener(checkListener);
    // Clear button
    btnDefault.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            cbFUsed.setChecked(false);
            cbFInternet.setChecked(false);
            cbFPermission.setChecked(true);
            cbFRestriction.setChecked(false);
            cbFRestrictionNot.setChecked(false);
            cbFOnDemand.setChecked(false);
            cbFOnDemandNot.setChecked(false);
            cbFUser.setChecked(true);
            cbFSystem.setChecked(false);
        }
    });
    // Build dialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
    alertDialogBuilder.setTitle(R.string.menu_filter);
    alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
    alertDialogBuilder.setView(view);
    alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUsed, Boolean.toString(cbFUsed.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFInternet, Boolean.toString(cbFInternet.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestriction, Boolean.toString(cbFRestriction.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestrictionNot, Boolean.toString(cbFRestrictionNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFPermission, Boolean.toString(cbFPermission.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemand, Boolean.toString(cbFOnDemand.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemandNot, Boolean.toString(cbFOnDemandNot.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUser, Boolean.toString(cbFUser.isChecked()));
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingFSystem, Boolean.toString(cbFSystem.isChecked()));
            invalidateOptionsMenu();
            applyFilter();
        }
    });
    alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    // Show dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView) ScrollView(android.widget.ScrollView) ExpandableListView(android.widget.ExpandableListView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) CompoundButton(android.widget.CompoundButton) SuppressLint(android.annotation.SuppressLint)

Example 49 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project Etar-Calendar by Etar-Group.

the class RecurrencePickerDialog method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    boolean endCountHasFocus = false;
    if (savedInstanceState != null) {
        RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
        if (m != null) {
            mModel = m;
        }
        endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
    } else {
        Bundle b = getArguments();
        if (b != null) {
            mTime.set(b.getLong(BUNDLE_START_TIME_MILLIS));
            String tz = b.getString(BUNDLE_TIME_ZONE);
            if (!TextUtils.isEmpty(tz)) {
                mTime.timezone = tz;
            }
            mTime.normalize(false);
            // Time days of week: Sun=0, Mon=1, etc
            mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
            String rrule = b.getString(BUNDLE_RRULE);
            if (!TextUtils.isEmpty(rrule)) {
                mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
                mRecurrence.parse(rrule);
                copyEventRecurrenceToModel(mRecurrence, mModel);
                // Leave today's day of week as checked by default in weekly view.
                if (mRecurrence.bydayCount == 0) {
                    mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
                }
            }
        } else {
            mTime.setToNow();
        }
    }
    mResources = getResources();
    mView = inflater.inflate(R.layout.recurrencepicker, container, true);
    final Activity activity = getActivity();
    final Configuration config = activity.getResources().getConfiguration();
    mRepeatSwitch = mView.findViewById(R.id.repeat_switch);
    mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
    mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE : RecurrenceModel.STATE_NO_RECURRENCE;
            togglePickerOptions();
        }
    });
    mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
    freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mFreqSpinner.setAdapter(freqAdapter);
    mInterval = (EditText) mView.findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {

        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);
    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);
    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);
    mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray, R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
    mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);
    mEndCount = (EditText) mView.findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {

        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);
    mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime);
        switch(mModel.freq) {
            case RecurrenceModel.FREQ_DAILY:
            case RecurrenceModel.FREQ_WEEKLY:
                mModel.endDate.month += 1;
                break;
            case RecurrenceModel.FREQ_MONTHLY:
                mModel.endDate.month += 3;
                break;
            case RecurrenceModel.FREQ_YEARLY:
                mModel.endDate.year += 3;
                break;
        }
        mModel.endDate.normalize(false);
    }
    mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);
    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();
    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);
    // In Time.java day of week order e.g. Sun = 0
    int idx = Utils.getFirstDayOfWeek(getActivity());
    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    dayOfWeekString = new DateFormatSymbols().getShortWeekdays();
    int numOfButtonsInRow1;
    int numOfButtonsInRow2;
    if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
        numOfButtonsInRow1 = 7;
        numOfButtonsInRow2 = 0;
        mWeekGroup2.setVisibility(View.GONE);
        mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
    } else {
        numOfButtonsInRow1 = 4;
        numOfButtonsInRow2 = 3;
        mWeekGroup2.setVisibility(View.VISIBLE);
        // Set rightmost button on the second row invisible so it takes up
        // space and everything centers properly
        mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
    }
    /* First row */
    for (int i = 0; i < 7; i++) {
        if (i >= numOfButtonsInRow1) {
            mWeekGroup.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
        if (++idx >= 7) {
            idx = 0;
        }
    }
    /* 2nd Row */
    for (int i = 0; i < 3; i++) {
        if (i >= numOfButtonsInRow2) {
            mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
        if (++idx >= 7) {
            idx = 0;
        }
    }
    mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);
    mDone = (Button) mView.findViewById(R.id.done);
    mDone.setOnClickListener(this);
    togglePickerOptions();
    updateDialog();
    if (endCountHasFocus) {
        mEndCount.requestFocus();
    }
    return mView;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Configuration(android.content.res.Configuration) Bundle(android.os.Bundle) Activity(android.app.Activity) Time(android.text.format.Time) DateFormatSymbols(java.text.DateFormatSymbols) CompoundButton(android.widget.CompoundButton)

Example 50 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project Notes by MiCode.

the class NoteEditActivity method getListItem.

private View getListItem(String item, int index) {
    View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
    final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
    edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
    CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
    cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
                edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
            }
        }
    });
    if (item.startsWith(TAG_CHECKED)) {
        cb.setChecked(true);
        edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        item = item.substring(TAG_CHECKED.length(), item.length()).trim();
    } else if (item.startsWith(TAG_UNCHECKED)) {
        cb.setChecked(false);
        edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
        item = item.substring(TAG_UNCHECKED.length(), item.length()).trim();
    }
    edit.setOnTextViewChangeListener(this);
    edit.setIndex(index);
    edit.setText(getHighlightQueryResult(item, mUserQuery));
    return view;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CheckBox(android.widget.CheckBox) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Aggregations

OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)101 CompoundButton (android.widget.CompoundButton)98 View (android.view.View)78 TextView (android.widget.TextView)66 ImageView (android.widget.ImageView)40 OnClickListener (android.view.View.OnClickListener)31 CheckBox (android.widget.CheckBox)30 DialogInterface (android.content.DialogInterface)27 AdapterView (android.widget.AdapterView)24 AlertDialog (android.app.AlertDialog)23 ListView (android.widget.ListView)20 Button (android.widget.Button)19 LayoutInflater (android.view.LayoutInflater)17 ArrayList (java.util.ArrayList)17 List (java.util.List)15 OnClickListener (android.content.DialogInterface.OnClickListener)12 SuppressLint (android.annotation.SuppressLint)11 Intent (android.content.Intent)11 ViewGroup (android.view.ViewGroup)10 Cursor (android.database.Cursor)9