Search in sources :

Example 46 with CompoundButton

use of android.widget.CompoundButton 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 47 with CompoundButton

use of android.widget.CompoundButton in project LollipopShowcase by mikepenz.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final SharedPreferences pref = getSharedPreferences("com.mikepenz.applicationreader", 0);
    drawer = new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new SwitchDrawerItem().withOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton compoundButton, boolean b) {
            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean("autouploadenabled", b);
            editor.apply();
        }
    }).withName(R.string.drawer_switch).withChecked(pref.getBoolean("autouploadenabled", false))).addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.drawer_opensource).withIdentifier(DRAWER_ITEM_OPEN_SOURCE).withIcon(FontAwesome.Icon.faw_github).withSelectable(false)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem drawerItem) {
            if (drawerItem.getIdentifier() == DRAWER_ITEM_OPEN_SOURCE) {
                new LibsBuilder().withFields(R.string.class.getFields()).withVersionShown(true).withLicenseShown(true).withActivityTitle(getString(R.string.drawer_opensource)).withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).start(MainActivity.this);
            }
            return false;
        }
    }).withSelectedItem(-1).withSavedInstance(savedInstanceState).build();
    // Handle ProgressBar
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    // Fab Button
    mFabButton = (FloatingActionButton) findViewById(R.id.fab_normal);
    mFabButton.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_file_upload).color(Color.WHITE).actionBar());
    mFabButton.setOnClickListener(fabClickListener);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setItemAnimator(new CustomItemAnimator());
    //mRecyclerView.setItemAnimator(new ReboundItemAnimator());
    mAdapter = new ApplicationAdapter(new ArrayList<AppInfo>(), R.layout.row_application, MainActivity.this);
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.theme_accent));
    mSwipeRefreshLayout.setRefreshing(true);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new InitializeApplicationsTask().execute();
        }
    });
    new InitializeApplicationsTask().execute();
    if (savedInstanceState != null) {
        if (uploadComponentInfoTask != null) {
            if (uploadComponentInfoTask.isRunning) {
                uploadComponentInfoTask.showProgress(this);
            }
        }
    }
    //show progress
    mRecyclerView.setVisibility(View.GONE);
    mProgressBar.setVisibility(View.VISIBLE);
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) OnCheckedChangeListener(com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) SwitchDrawerItem(com.mikepenz.materialdrawer.model.SwitchDrawerItem) Drawer(com.mikepenz.materialdrawer.Drawer) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) CustomItemAnimator(com.mikepenz.lollipopshowcase.itemanimator.CustomItemAnimator) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) ApplicationAdapter(com.mikepenz.lollipopshowcase.adapter.ApplicationAdapter) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) CompoundButton(android.widget.CompoundButton) Toolbar(android.support.v7.widget.Toolbar)

Example 48 with CompoundButton

use of android.widget.CompoundButton in project AndroidTraining by mixi-inc.

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)

Example 49 with CompoundButton

use of android.widget.CompoundButton in project SmartAndroidSource by jaychou2012.

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)

Example 50 with CompoundButton

use of android.widget.CompoundButton in project SlidingMenu by jfeinstein10.

the class PropertiesActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSlidingActionBarEnabled(true);
    setContentView(R.layout.properties);
    // left and right modes
    RadioGroup mode = (RadioGroup) findViewById(R.id.mode);
    mode.check(R.id.left);
    mode.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            SlidingMenu sm = getSlidingMenu();
            switch(checkedId) {
                case R.id.left:
                    sm.setMode(SlidingMenu.LEFT);
                    sm.setShadowDrawable(R.drawable.shadow);
                    break;
                case R.id.right:
                    sm.setMode(SlidingMenu.RIGHT);
                    sm.setShadowDrawable(R.drawable.shadowright);
                    break;
                case R.id.left_right:
                    sm.setMode(SlidingMenu.LEFT_RIGHT);
                    sm.setSecondaryMenu(R.layout.menu_frame_two);
                    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame_two, new SampleListFragment()).commit();
                    sm.setSecondaryShadowDrawable(R.drawable.shadowright);
                    sm.setShadowDrawable(R.drawable.shadow);
            }
        }
    });
    // touch mode stuff
    RadioGroup touchAbove = (RadioGroup) findViewById(R.id.touch_above);
    touchAbove.check(R.id.touch_above_full);
    touchAbove.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch(checkedId) {
                case R.id.touch_above_full:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
                    break;
                case R.id.touch_above_margin:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
                    break;
                case R.id.touch_above_none:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
                    break;
            }
        }
    });
    // scroll scale stuff
    SeekBar scrollScale = (SeekBar) findViewById(R.id.scroll_scale);
    scrollScale.setMax(1000);
    scrollScale.setProgress(333);
    scrollScale.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            getSlidingMenu().setBehindScrollScale((float) seekBar.getProgress() / seekBar.getMax());
        }
    });
    // behind width stuff
    SeekBar behindWidth = (SeekBar) findViewById(R.id.behind_width);
    behindWidth.setMax(1000);
    behindWidth.setProgress(750);
    behindWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            float percent = (float) seekBar.getProgress() / seekBar.getMax();
            getSlidingMenu().setBehindWidth((int) (percent * getSlidingMenu().getWidth()));
            getSlidingMenu().requestLayout();
        }
    });
    // shadow stuff
    CheckBox shadowEnabled = (CheckBox) findViewById(R.id.shadow_enabled);
    shadowEnabled.setChecked(true);
    shadowEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked)
                getSlidingMenu().setShadowDrawable(getSlidingMenu().getMode() == SlidingMenu.LEFT ? R.drawable.shadow : R.drawable.shadowright);
            else
                getSlidingMenu().setShadowDrawable(null);
        }
    });
    SeekBar shadowWidth = (SeekBar) findViewById(R.id.shadow_width);
    shadowWidth.setMax(1000);
    shadowWidth.setProgress(75);
    shadowWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            float percent = (float) seekBar.getProgress() / (float) seekBar.getMax();
            int width = (int) (percent * (float) getSlidingMenu().getWidth());
            getSlidingMenu().setShadowWidth(width);
            getSlidingMenu().invalidate();
        }
    });
    // fading stuff
    CheckBox fadeEnabled = (CheckBox) findViewById(R.id.fade_enabled);
    fadeEnabled.setChecked(true);
    fadeEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            getSlidingMenu().setFadeEnabled(isChecked);
        }
    });
    SeekBar fadeDeg = (SeekBar) findViewById(R.id.fade_degree);
    fadeDeg.setMax(1000);
    fadeDeg.setProgress(666);
    fadeDeg.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            getSlidingMenu().setFadeDegree((float) seekBar.getProgress() / seekBar.getMax());
        }
    });
}
Also used : SlidingMenu(com.jeremyfeinstein.slidingmenu.lib.SlidingMenu) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) SeekBar(android.widget.SeekBar) CheckBox(android.widget.CheckBox) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) 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