Search in sources :

Example 51 with OnCheckedChangeListener

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);
        }
    });
}
Also used : ToggleButton(android.widget.ToggleButton) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) Spinner(android.widget.Spinner) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) CropImageView(com.edmodo.cropper.CropImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) Bitmap(android.graphics.Bitmap) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) CropImageView(com.edmodo.cropper.CropImageView) ImageView(android.widget.ImageView) CropImageView(com.edmodo.cropper.CropImageView) CompoundButton(android.widget.CompoundButton)

Example 52 with OnCheckedChangeListener

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);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Configuration(com.marshalchen.common.uimodule.switchbutton.Configuration) SwitchButton(com.marshalchen.common.uimodule.switchbutton.SwitchButton) CompoundButton(android.widget.CompoundButton)

Example 53 with OnCheckedChangeListener

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

Example 54 with OnCheckedChangeListener

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;
}
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 55 with OnCheckedChangeListener

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;
}
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)

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