Search in sources :

Example 71 with CompoundButton

use of android.widget.CompoundButton in project CircularReveal by ozodrukh.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    final ViewRevealManager revealManager = new ViewRevealManager();
    final SpringViewAnimatorManager springManager = new SpringViewAnimatorManager();
    springManager.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
    springManager.setStiffness(SpringForce.STIFFNESS_LOW);
    parent.setViewRevealManager(revealManager);
    settingsView.addSwitch("Enable Spring", false, new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            parent.setViewRevealManager(isChecked ? springManager : revealManager);
        }
    });
    settingsView.setAnimatorManager(springManager);
    final BottomSheetBehavior behavior = BottomSheetBehavior.from(settingsView);
    behavior.setPeekHeight(getResources().getDimensionPixelSize(R.dimen.bottom_peek_height));
    behavior.setSkipCollapsed(false);
    behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
Also used : BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) ViewRevealManager(io.codetail.animation.ViewRevealManager) SpringViewAnimatorManager(io.codetail.animation.SpringViewAnimatorManager) CompoundButton(android.widget.CompoundButton)

Example 72 with CompoundButton

use of android.widget.CompoundButton in project CircularReveal by ozodrukh.

the class SpringSettingsBottomDialog method addSwitch.

public void addSwitch(String label, boolean defaultState, final CompoundButton.OnCheckedChangeListener listener) {
    if (switchAdded) {
        return;
    }
    switchAdded = true;
    final SwitchCompat switchView = new SwitchCompat(getContext());
    switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            listener.onCheckedChanged(buttonView, isChecked);
            if (springManagerAdded) {
                stiffnessView.setEnabled(isChecked);
                dampingView.setEnabled(isChecked);
            }
        }
    });
    switchView.setChecked(defaultState);
    switchView.setText(label);
    addView(switchView, createMarginLayoutParams(MATCH_PARENT, WRAP_CONTENT, 0, 0, 0, dp(16)));
    if (springManagerAdded) {
        stiffnessView.setEnabled(defaultState);
        dampingView.setEnabled(defaultState);
    }
}
Also used : CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 73 with CompoundButton

use of android.widget.CompoundButton in project android by owncloud.

the class EditShareFragment method refreshUiFromState.

/**
     * Updates the UI with the current permissions in the edited {@OCShare}
     *
     * @param editShareView     Root view in the fragment.
     */
private void refreshUiFromState(View editShareView) {
    if (editShareView != null) {
        setPermissionsListening(editShareView, false);
        int sharePermissions = mShare.getPermissions();
        boolean isFederated = ShareType.FEDERATED.equals(mShare.getShareType());
        OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount);
        boolean isNotReshareableFederatedSupported = (serverVersion != null && serverVersion.isNotReshareableFederatedSupported());
        CompoundButton compound;
        compound = (CompoundButton) editShareView.findViewById(R.id.canShareSwitch);
        if (isFederated && !isNotReshareableFederatedSupported) {
            compound.setVisibility(View.INVISIBLE);
        }
        compound.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0);
        compound = (CompoundButton) editShareView.findViewById(R.id.canEditSwitch);
        int anyUpdatePermission = OCShare.CREATE_PERMISSION_FLAG | OCShare.UPDATE_PERMISSION_FLAG | OCShare.DELETE_PERMISSION_FLAG;
        boolean canEdit = (sharePermissions & anyUpdatePermission) > 0;
        compound.setChecked(canEdit);
        boolean areEditOptionsAvailable = !isFederated || isNotReshareableFederatedSupported;
        if (mFile.isFolder() && areEditOptionsAvailable) {
            /// TODO change areEditOptionsAvailable in order to delete !isFederated
            // from checking when iOS is ready
            compound = (CompoundButton) editShareView.findViewById(R.id.canEditCreateCheckBox);
            compound.setChecked((sharePermissions & OCShare.CREATE_PERMISSION_FLAG) > 0);
            compound.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
            compound = (CompoundButton) editShareView.findViewById(R.id.canEditChangeCheckBox);
            compound.setChecked((sharePermissions & OCShare.UPDATE_PERMISSION_FLAG) > 0);
            compound.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
            compound = (CompoundButton) editShareView.findViewById(R.id.canEditDeleteCheckBox);
            compound.setChecked((sharePermissions & OCShare.DELETE_PERMISSION_FLAG) > 0);
            compound.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
        }
        setPermissionsListening(editShareView, true);
    }
}
Also used : OwnCloudVersion(com.owncloud.android.lib.resources.status.OwnCloudVersion) CompoundButton(android.widget.CompoundButton)

Example 74 with CompoundButton

use of android.widget.CompoundButton in project GalleryFinal by pengjianbo.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mLvPhoto = (HorizontalListView) findViewById(R.id.lv_photo);
    mPhotoList = new ArrayList<>();
    mChoosePhotoListAdapter = new ChoosePhotoListAdapter(this, mPhotoList);
    mLvPhoto.setAdapter(mChoosePhotoListAdapter);
    mOpenGallery = (Button) findViewById(R.id.btn_open_gallery);
    mRbMutiSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mLlMaxSize.setVisibility(View.VISIBLE);
                mLlForceCrop.setVisibility(View.GONE);
            } else {
                if (mCbEdit.isChecked()) {
                    mLlForceCrop.setVisibility(View.VISIBLE);
                }
                mLlMaxSize.setVisibility(View.GONE);
            }
        }
    });
    mCbEdit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mLlEdit.setVisibility(View.VISIBLE);
            } else {
                mLlEdit.setVisibility(View.GONE);
            }
        }
    });
    mCbCrop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mLlCropSize.setVisibility(View.VISIBLE);
                mCbCropReplaceSource.setVisibility(View.VISIBLE);
                if (mRbSingleSelect.isChecked()) {
                    mLlForceCrop.setVisibility(View.VISIBLE);
                }
            } else {
                mLlCropSize.setVisibility(View.GONE);
                mCbCropReplaceSource.setVisibility(View.INVISIBLE);
                mLlForceCrop.setVisibility(View.GONE);
            }
        }
    });
    mCbRotate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mCbRotateReplaceSource.setVisibility(View.VISIBLE);
            } else {
                mCbRotateReplaceSource.setVisibility(View.INVISIBLE);
            }
        }
    });
    mCbOpenForceCrop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mCbOpenForceCropEdit.setVisibility(View.VISIBLE);
            } else {
                mCbOpenForceCropEdit.setVisibility(View.INVISIBLE);
            }
        }
    });
    mOpenGallery.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //公共配置都可以在application中配置,这里只是为了代码演示而写在此处
            ThemeConfig themeConfig = null;
            if (mRbThemeDefault.isChecked()) {
                themeConfig = ThemeConfig.DEFAULT;
            } else if (mRbThemeDark.isChecked()) {
                themeConfig = ThemeConfig.DARK;
            } else if (mRbThemeCyan.isChecked()) {
                themeConfig = ThemeConfig.CYAN;
            } else if (mRbThemeOrange.isChecked()) {
                themeConfig = ThemeConfig.ORANGE;
            } else if (mRbThemeGreen.isChecked()) {
                themeConfig = ThemeConfig.GREEN;
            } else if (mRbThemeTeal.isChecked()) {
                themeConfig = ThemeConfig.TEAL;
            } else if (mRbThemeCustom.isChecked()) {
                ThemeConfig theme = new ThemeConfig.Builder().setTitleBarBgColor(Color.rgb(0xFF, 0x57, 0x22)).setTitleBarTextColor(Color.BLACK).setTitleBarIconColor(Color.BLACK).setFabNornalColor(Color.RED).setFabPressedColor(Color.BLUE).setCheckNornalColor(Color.WHITE).setCheckSelectedColor(Color.BLACK).setIconBack(R.mipmap.ic_action_previous_item).setIconRotate(R.mipmap.ic_action_repeat).setIconCrop(R.mipmap.ic_action_crop).setIconCamera(R.mipmap.ic_action_camera).build();
                themeConfig = theme;
            }
            FunctionConfig.Builder functionConfigBuilder = new FunctionConfig.Builder();
            cn.finalteam.galleryfinal.ImageLoader imageLoader;
            PauseOnScrollListener pauseOnScrollListener = null;
            if (mRbUil.isChecked()) {
                imageLoader = new UILImageLoader();
                pauseOnScrollListener = new UILPauseOnScrollListener(false, true);
            } else if (mRbXutils.isChecked()) {
                imageLoader = new XUtils2ImageLoader(MainActivity.this);
            } else if (mRbXutils3.isChecked()) {
                imageLoader = new XUtilsImageLoader();
            } else if (mRbGlide.isChecked()) {
                imageLoader = new GlideImageLoader();
                pauseOnScrollListener = new GlidePauseOnScrollListener(false, true);
            } else if (mRbFresco.isChecked()) {
                imageLoader = new FrescoImageLoader(MainActivity.this);
            } else {
                imageLoader = new PicassoImageLoader();
                pauseOnScrollListener = new PicassoPauseOnScrollListener(false, true);
            }
            boolean muti = false;
            if (mRbSingleSelect.isChecked()) {
                muti = false;
            } else {
                muti = true;
                if (TextUtils.isEmpty(mEtMaxSize.getText().toString())) {
                    Toast.makeText(getApplicationContext(), "请输入MaxSize", Toast.LENGTH_SHORT).show();
                    return;
                }
                int maxSize = Integer.parseInt(mEtMaxSize.getText().toString());
                functionConfigBuilder.setMutiSelectMaxSize(maxSize);
            }
            final boolean mutiSelect = muti;
            if (mCbEdit.isChecked()) {
                functionConfigBuilder.setEnableEdit(true);
            }
            if (mCbRotate.isChecked()) {
                functionConfigBuilder.setEnableRotate(true);
                if (mCbRotateReplaceSource.isChecked()) {
                    functionConfigBuilder.setRotateReplaceSource(true);
                }
            }
            if (mCbCrop.isChecked()) {
                functionConfigBuilder.setEnableCrop(true);
                if (!TextUtils.isEmpty(mEtCropWidth.getText().toString())) {
                    int width = Integer.parseInt(mEtCropWidth.getText().toString());
                    functionConfigBuilder.setCropWidth(width);
                }
                if (!TextUtils.isEmpty(mEtCropHeight.getText().toString())) {
                    int height = Integer.parseInt(mEtCropHeight.getText().toString());
                    functionConfigBuilder.setCropHeight(height);
                }
                if (mCbCropSquare.isChecked()) {
                    functionConfigBuilder.setCropSquare(true);
                }
                if (mCbCropReplaceSource.isChecked()) {
                    functionConfigBuilder.setCropReplaceSource(true);
                }
                if (mCbOpenForceCrop.isChecked() && mRbSingleSelect.isChecked()) {
                    functionConfigBuilder.setForceCrop(true);
                    if (mCbOpenForceCropEdit.isChecked()) {
                        functionConfigBuilder.setForceCropEdit(true);
                    }
                }
            }
            if (mCbShowCamera.isChecked()) {
                functionConfigBuilder.setEnableCamera(true);
            }
            if (mCbPreview.isChecked()) {
                functionConfigBuilder.setEnablePreview(true);
            }
            //添加过滤集合
            functionConfigBuilder.setSelected(mPhotoList);
            final FunctionConfig functionConfig = functionConfigBuilder.build();
            CoreConfig coreConfig = new CoreConfig.Builder(MainActivity.this, imageLoader, themeConfig).setFunctionConfig(functionConfig).setPauseOnScrollListener(pauseOnScrollListener).setNoAnimcation(mCbNoAnimation.isChecked()).build();
            GalleryFinal.init(coreConfig);
            ActionSheet.createBuilder(MainActivity.this, getSupportFragmentManager()).setCancelButtonTitle("取消(Cancel)").setOtherButtonTitles("打开相册(Open Gallery)", "拍照(Camera)", "裁剪(Crop)", "编辑(Edit)").setCancelableOnTouchOutside(true).setListener(new ActionSheet.ActionSheetListener() {

                @Override
                public void onDismiss(ActionSheet actionSheet, boolean isCancel) {
                }

                @Override
                public void onOtherButtonClick(ActionSheet actionSheet, int index) {
                    String path = "/sdcard/pk1-2.jpg";
                    switch(index) {
                        case 0:
                            if (mutiSelect) {
                                GalleryFinal.openGalleryMuti(REQUEST_CODE_GALLERY, functionConfig, mOnHanlderResultCallback);
                            } else {
                                GalleryFinal.openGallerySingle(REQUEST_CODE_GALLERY, functionConfig, mOnHanlderResultCallback);
                            }
                            break;
                        case 1:
                            GalleryFinal.openCamera(REQUEST_CODE_CAMERA, functionConfig, mOnHanlderResultCallback);
                            break;
                        case 2:
                            if (new File(path).exists()) {
                                GalleryFinal.openCrop(REQUEST_CODE_CROP, functionConfig, path, mOnHanlderResultCallback);
                            } else {
                                Toast.makeText(MainActivity.this, "图片不存在", Toast.LENGTH_SHORT).show();
                            }
                            break;
                        case 3:
                            if (new File(path).exists()) {
                                GalleryFinal.openEdit(REQUEST_CODE_EDIT, functionConfig, path, mOnHanlderResultCallback);
                            } else {
                                Toast.makeText(MainActivity.this, "图片不存在", Toast.LENGTH_SHORT).show();
                            }
                            break;
                        default:
                            break;
                    }
                }
            }).show();
        }
    });
    initImageLoader(this);
    initFresco();
    x.Ext.init(getApplication());
}
Also used : FunctionConfig(cn.finalteam.galleryfinal.FunctionConfig) CoreConfig(cn.finalteam.galleryfinal.CoreConfig) XUtilsImageLoader(cn.finalteam.galleryfinal.sample.loader.XUtilsImageLoader) ActionSheet(com.baoyz.actionsheet.ActionSheet) PicassoImageLoader(cn.finalteam.galleryfinal.sample.loader.PicassoImageLoader) PicassoPauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.PicassoPauseOnScrollListener) GlideImageLoader(cn.finalteam.galleryfinal.sample.loader.GlideImageLoader) Toolbar(android.support.v7.widget.Toolbar) XUtils2ImageLoader(cn.finalteam.galleryfinal.sample.loader.XUtils2ImageLoader) UILPauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.UILPauseOnScrollListener) UILImageLoader(cn.finalteam.galleryfinal.sample.loader.UILImageLoader) View(android.view.View) HorizontalListView(cn.finalteam.galleryfinal.widget.HorizontalListView) ThemeConfig(cn.finalteam.galleryfinal.ThemeConfig) UILPauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.UILPauseOnScrollListener) PauseOnScrollListener(cn.finalteam.galleryfinal.PauseOnScrollListener) GlidePauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.GlidePauseOnScrollListener) PicassoPauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.PicassoPauseOnScrollListener) FrescoImageLoader(cn.finalteam.galleryfinal.sample.loader.FrescoImageLoader) XUtils2ImageLoader(cn.finalteam.galleryfinal.sample.loader.XUtils2ImageLoader) XUtilsImageLoader(cn.finalteam.galleryfinal.sample.loader.XUtilsImageLoader) UILImageLoader(cn.finalteam.galleryfinal.sample.loader.UILImageLoader) GlideImageLoader(cn.finalteam.galleryfinal.sample.loader.GlideImageLoader) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) FrescoImageLoader(cn.finalteam.galleryfinal.sample.loader.FrescoImageLoader) PicassoImageLoader(cn.finalteam.galleryfinal.sample.loader.PicassoImageLoader) GlidePauseOnScrollListener(cn.finalteam.galleryfinal.sample.listener.GlidePauseOnScrollListener) File(java.io.File) CompoundButton(android.widget.CompoundButton)

Example 75 with CompoundButton

use of android.widget.CompoundButton in project bee by orhanobut.

the class SettingsAdapter method createCheckBox.

private View createCheckBox(ViewGroup parent, MethodInfo methodInfo) {
    final Method method = methodInfo.getMethod();
    final Object instance = methodInfo.getInstance();
    final Context context = parent.getContext();
    View view = inflater.inflate(R.layout.item_settings_checkbox, parent, false);
    ((TextView) view.findViewById(R.id.title)).setText(methodInfo.getTitle());
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            try {
                method.invoke(instance, isChecked);
            } catch (Exception e) {
                Log.e("Bee", e.getMessage());
            }
            PrefHelper.setBoolean(context, method.getName(), isChecked);
        }
    });
    checkBox.setChecked(PrefHelper.getBoolean(context, method.getName()));
    return view;
}
Also used : Context(android.content.Context) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) Method(java.lang.reflect.Method) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) 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