Search in sources :

Example 1 with RadioGroup

use of android.widget.RadioGroup in project UltimateAndroid by cymcsg.

the class MultiImageSelectorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.multi_image_select_activity_main);
    mResultText = (TextView) findViewById(R.id.result);
    mChoiceMode = (RadioGroup) findViewById(R.id.choice_mode);
    mShowCamera = (RadioGroup) findViewById(R.id.show_camera);
    mRequestNum = (EditText) findViewById(R.id.request_num);
    mChoiceMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
            if (checkedId == R.id.multi) {
                mRequestNum.setEnabled(true);
            } else {
                mRequestNum.setEnabled(false);
                mRequestNum.setText("");
            }
        }
    });
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int selectedMode = com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.MODE_MULTI;
            if (mChoiceMode.getCheckedRadioButtonId() == R.id.single) {
                selectedMode = com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.MODE_SINGLE;
            } else {
                selectedMode = com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.MODE_MULTI;
            }
            boolean showCamera = mShowCamera.getCheckedRadioButtonId() == R.id.show;
            int maxNum = 9;
            if (!TextUtils.isEmpty(mRequestNum.getText())) {
                maxNum = Integer.valueOf(mRequestNum.getText().toString());
            }
            Intent intent = new Intent(MultiImageSelectorActivity.this, com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.class);
            // 是否显示拍摄图片
            intent.putExtra(com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, showCamera);
            // 最大可选择图片数量
            intent.putExtra(com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.EXTRA_SELECT_COUNT, maxNum);
            // 选择模式
            intent.putExtra(com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.EXTRA_SELECT_MODE, selectedMode);
            // 默认选择
            if (mSelectPath != null && mSelectPath.size() > 0) {
                intent.putExtra(com.marshalchen.common.uimodule.multi_image_selector.MultiImageSelectorActivity.EXTRA_DEFAULT_SELECTED_LIST, mSelectPath);
            }
            startActivityForResult(intent, REQUEST_IMAGE);
        }
    });
/*        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, GestureImageActivity.class);
                startActivity(intent);
            }
        });*/
}
Also used : RadioGroup(android.widget.RadioGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View)

Example 2 with RadioGroup

use of android.widget.RadioGroup in project UltimateAndroid by cymcsg.

the class TransitionEverywhereActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.transition_everwhere_activity_basic_transitions);
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) findViewById(R.id.scene_root);
    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = new Scene(mSceneRoot, mSceneRoot.findViewById(R.id.container));
    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_everwhere_scene2, this);
    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_everwhere_scene3, this);
    // We create a custom TransitionManager for Scene 3, in which ChangeBounds, Fade and
    // ChangeImageTransform take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(this).inflateTransitionManager(R.anim.transition_everwhere_scene3_transition_manager, mSceneRoot);
}
Also used : RadioGroup(android.widget.RadioGroup) Scene(android.transitions.everywhere.Scene)

Example 3 with RadioGroup

use of android.widget.RadioGroup in project SimplifyReader by chentao0707.

the class CaptureActivity method initViewsAndEvents.

@Override
protected void initViewsAndEvents() {
    hasSurface = false;
    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);
    initCropViewAnimator();
    capturePictureBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            readyGoForResult(CommonImagePickerListActivity.class, IMAGE_PICKER_REQUEST_CODE);
        }
    });
    captureLightBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isLightOn) {
                cameraManager.setTorch(false);
                captureLightBtn.setSelected(false);
            } else {
                cameraManager.setTorch(true);
                captureLightBtn.setSelected(true);
            }
            isLightOn = !isLightOn;
        }
    });
    captureModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.capture_mode_barcode) {
                PropertyValuesHolder qr2barWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mBarcodeCropWidth / mQrcodeCropWidth);
                PropertyValuesHolder qr2barHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mBarcodeCropHeight / mQrcodeCropHeight);
                ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(qr2barWidthVH, qr2barHeightVH);
                valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        Float fractionW = (Float) animation.getAnimatedValue("width");
                        Float fractionH = (Float) animation.getAnimatedValue("height");
                        RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
                        parentLayoutParams.width = (int) (mQrcodeCropWidth * fractionW);
                        parentLayoutParams.height = (int) (mQrcodeCropHeight * fractionH);
                        captureCropView.setLayoutParams(parentLayoutParams);
                    }
                });
                valueAnimator.addListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        initCrop();
                        setDataMode(DecodeUtils.DECODE_DATA_MODE_BARCODE);
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                });
                valueAnimator.start();
            } else if (checkedId == R.id.capture_mode_qrcode) {
                PropertyValuesHolder bar2qrWidthVH = PropertyValuesHolder.ofFloat("width", 1.0f, (float) mQrcodeCropWidth / mBarcodeCropWidth);
                PropertyValuesHolder bar2qrHeightVH = PropertyValuesHolder.ofFloat("height", 1.0f, (float) mQrcodeCropHeight / mBarcodeCropHeight);
                ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(bar2qrWidthVH, bar2qrHeightVH);
                valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        Float fractionW = (Float) animation.getAnimatedValue("width");
                        Float fractionH = (Float) animation.getAnimatedValue("height");
                        RelativeLayout.LayoutParams parentLayoutParams = (RelativeLayout.LayoutParams) captureCropView.getLayoutParams();
                        parentLayoutParams.width = (int) (mBarcodeCropWidth * fractionW);
                        parentLayoutParams.height = (int) (mBarcodeCropHeight * fractionH);
                        captureCropView.setLayoutParams(parentLayoutParams);
                    }
                });
                valueAnimator.addListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        initCrop();
                        setDataMode(DecodeUtils.DECODE_DATA_MODE_QRCODE);
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                });
                valueAnimator.start();
            }
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) InactivityTimer(com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.InactivityTimer) BeepManager(com.github.obsessive.simplifyreader.ui.activity.qrcode.utils.BeepManager) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) CommonImagePickerListActivity(com.github.obsessive.simplifyreader.ui.activity.picker.CommonImagePickerListActivity) RelativeLayout(android.widget.RelativeLayout) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 4 with RadioGroup

use of android.widget.RadioGroup in project Anki-Android by Ramblurr.

the class StudyOptionsFragment method formatRGCardType.

/**
     * formatRGCardType
     * Returns: RadioGroup - A radio group that contains the options of All Cards, New, and Due cards,
     * 			for the selection of cards when creating a CUSTOM_STUDY_DECKS based on TAGS.
     * Takes: context, and resources of the App.
     * 
     * This method just creates the RadioGroup required for the dialog to select tags for a new 
     * custom study deck.
     */
private RadioGroup formatRGCardType(Context context, Resources res) {
    RadioGroup rg = new RadioGroup(context);
    final RadioButton[] radioButtonCards = new RadioButton[3];
    rg.setOrientation(RadioGroup.HORIZONTAL);
    RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
    int height = context.getResources().getDrawable(R.drawable.white_btn_radio).getIntrinsicHeight();
    //This array contains "All Cards", "New", and "Due", in that order. 
    String[] text = res.getStringArray(R.array.cards_for_tag_filtered_deck_labels);
    for (int i = 0; i < radioButtonCards.length; i++) {
        radioButtonCards[i] = new RadioButton(context);
        radioButtonCards[i].setClickable(true);
        radioButtonCards[i].setText(text[i]);
        radioButtonCards[i].setHeight(height * 2);
        radioButtonCards[i].setSingleLine();
        radioButtonCards[i].setGravity(Gravity.CENTER_VERTICAL);
        rg.addView(radioButtonCards[i], lp);
    }
    rg.check(0);
    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup arg0, int arg1) {
            int checked = arg0.getCheckedRadioButtonId();
            for (int i = 0; i < 3; i++) {
                if (arg0.getChildAt(i).getId() == checked) {
                    mSelectedOption = i;
                    break;
                }
            }
        }
    });
    rg.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, height));
    return rg;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) RadioButton(android.widget.RadioButton) LinearLayout(android.widget.LinearLayout)

Example 5 with RadioGroup

use of android.widget.RadioGroup in project Anki-Android by Ramblurr.

the class ChartBuilder method getStatisticsDialog.

public static StyledDialog getStatisticsDialog(Context context, DialogInterface.OnClickListener listener, boolean showWholeDeckSelection) {
    StyledDialog.Builder builder = new StyledDialog.Builder(context);
    builder.setTitle(context.getString(R.string.statistics_type_title));
    builder.setIcon(android.R.drawable.ic_menu_sort_by_size);
    // set items
    String[] items = new String[3];
    items[0] = context.getResources().getString(R.string.stats_forecast);
    items[1] = context.getResources().getString(R.string.stats_review_count);
    items[2] = context.getResources().getString(R.string.stats_review_time);
    builder.setItems(items, listener);
    // period selection
    final RadioButton[] statisticRadioButtons = new RadioButton[3];
    RadioGroup rg = new RadioGroup(context);
    rg.setOrientation(RadioGroup.HORIZONTAL);
    RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
    Resources res = context.getResources();
    String[] text = res.getStringArray(R.array.stats_period);
    int height = context.getResources().getDrawable(R.drawable.white_btn_radio).getIntrinsicHeight();
    for (int i = 0; i < statisticRadioButtons.length; i++) {
        statisticRadioButtons[i] = new RadioButton(context);
        statisticRadioButtons[i].setClickable(true);
        statisticRadioButtons[i].setText("         " + text[i]);
        statisticRadioButtons[i].setHeight(height * 2);
        statisticRadioButtons[i].setSingleLine();
        statisticRadioButtons[i].setBackgroundDrawable(null);
        statisticRadioButtons[i].setGravity(Gravity.CENTER_VERTICAL);
        rg.addView(statisticRadioButtons[i], lp);
    }
    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup arg0, int arg1) {
            int checked = arg0.getCheckedRadioButtonId();
            for (int i = 0; i < 3; i++) {
                if (arg0.getChildAt(i).getId() == checked) {
                    AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext()).edit().putInt("statsType", i).commit();
                    break;
                }
            }
        }
    });
    rg.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, height));
    statisticRadioButtons[Math.min(AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext()).getInt("statsType", Stats.TYPE_MONTH), Stats.TYPE_LIFE)].setChecked(true);
    if (showWholeDeckSelection) {
        // collection/current deck
        final RadioButton[] statisticRadioButtons2 = new RadioButton[2];
        RadioGroup rg2 = new RadioGroup(context);
        rg2.setOrientation(RadioGroup.HORIZONTAL);
        String[] text2 = res.getStringArray(R.array.stats_range);
        for (int i = 0; i < statisticRadioButtons2.length; i++) {
            statisticRadioButtons2[i] = new RadioButton(context);
            statisticRadioButtons2[i].setClickable(true);
            statisticRadioButtons2[i].setText("         " + text2[i]);
            statisticRadioButtons2[i].setHeight(height * 2);
            statisticRadioButtons2[i].setSingleLine();
            statisticRadioButtons2[i].setBackgroundDrawable(null);
            statisticRadioButtons2[i].setGravity(Gravity.CENTER_VERTICAL);
            rg2.addView(statisticRadioButtons2[i], lp);
        }
        rg2.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(RadioGroup arg0, int arg1) {
                AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext()).edit().putBoolean("statsRange", arg0.getCheckedRadioButtonId() == arg0.getChildAt(0).getId()).commit();
            }
        });
        rg2.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));
        statisticRadioButtons2[AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext()).getBoolean("statsRange", true) ? 0 : 1].setChecked(true);
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        ll.addView(rg);
        ll.addView(rg2);
        builder.setView(ll, false, true);
    } else {
        builder.setView(rg, false, true);
    }
    return builder.create();
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) StyledDialog(com.ichi2.themes.StyledDialog) RadioButton(android.widget.RadioButton) Resources(android.content.res.Resources) LinearLayout(android.widget.LinearLayout)

Aggregations

RadioGroup (android.widget.RadioGroup)62 View (android.view.View)26 TextView (android.widget.TextView)19 RadioButton (android.widget.RadioButton)13 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)13 Button (android.widget.Button)9 CompoundButton (android.widget.CompoundButton)8 Validator (com.mobsandgeeks.saripaar.Validator)8 CheckBox (android.widget.CheckBox)5 IOException (java.io.IOException)5 RandomAccessFile (java.io.RandomAccessFile)5 Test (org.junit.Test)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 ImageView (android.widget.ImageView)4 ScrollView (android.widget.ScrollView)4 Paint (android.graphics.Paint)3 AlertDialog (android.support.v7.app.AlertDialog)3 LinearLayout (android.widget.LinearLayout)3 SeekBar (android.widget.SeekBar)3