Search in sources :

Example 46 with RadioGroup

use of android.widget.RadioGroup in project android_frameworks_base by ParanoidAndroid.

the class HugeBackupActivity method populateUI.

/**
     * Configure the UI based on our persistent data, creating the
     * data file and establishing defaults if necessary.
     */
void populateUI() {
    RandomAccessFile file;
    // Default values in case there's no data file yet
    int whichFilling = R.id.pastrami;
    boolean addMayo = false;
    boolean addTomato = false;
    /** Hold the data-access lock around access to the file */
    synchronized (HugeBackupActivity.sDataLock) {
        boolean exists = mDataFile.exists();
        try {
            file = new RandomAccessFile(mDataFile, "rw");
            if (exists) {
                Log.v(TAG, "datafile exists");
                whichFilling = file.readInt();
                addMayo = file.readBoolean();
                addTomato = file.readBoolean();
                Log.v(TAG, "  mayo=" + addMayo + " tomato=" + addTomato + " filling=" + whichFilling);
            } else {
                // The default values were configured above: write them
                // to the newly-created file.
                Log.v(TAG, "creating default datafile");
                writeDataToFileLocked(file, addMayo, addTomato, whichFilling);
                // We also need to perform an initial backup; ask for one
                mBackupManager.dataChanged();
            }
        } catch (IOException ioe) {
        }
    }
    /** Now that we've processed the file, build the UI outside the lock */
    mFillingGroup.check(whichFilling);
    mAddMayoCheckbox.setChecked(addMayo);
    mAddTomatoCheckbox.setChecked(addTomato);
    /**
         * We also want to record the new state when the user makes changes,
         * so install simple observers that do this
         */
    mFillingGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // As with the checkbox listeners, rewrite the
            // entire state file
            Log.v(TAG, "New radio item selected: " + checkedId);
            recordNewUIState();
        }
    });
    CompoundButton.OnCheckedChangeListener checkListener = new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // Whichever one is altered, we rewrite the entire UI state
            Log.v(TAG, "Checkbox toggled: " + buttonView);
            recordNewUIState();
        }
    };
    mAddMayoCheckbox.setOnCheckedChangeListener(checkListener);
    mAddTomatoCheckbox.setOnCheckedChangeListener(checkListener);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) RadioGroup(android.widget.RadioGroup) IOException(java.io.IOException) CompoundButton(android.widget.CompoundButton)

Example 47 with RadioGroup

use of android.widget.RadioGroup in project android_frameworks_base by ParanoidAndroid.

the class NotificationBuilderTest method getRadioTag.

private String getRadioTag(int id) {
    final RadioGroup g = (RadioGroup) findViewById(id);
    final View v = findViewById(g.getCheckedRadioButtonId());
    return (String) v.getTag();
}
Also used : RadioGroup(android.widget.RadioGroup) View(android.view.View)

Example 48 with RadioGroup

use of android.widget.RadioGroup in project MultiImageSelector by lovetuzitong.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.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("");
            }
        }
    });
    View button = findViewById(R.id.button);
    if (button != null) {
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                pickImage();
            }
        });
    }
}
Also used : RadioGroup(android.widget.RadioGroup) TextView(android.widget.TextView) View(android.view.View)

Example 49 with RadioGroup

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

the class StudyOptionsFragment method onCreateDialog.

protected StyledDialog onCreateDialog(int id) {
    StyledDialog dialog = null;
    Resources res = getResources();
    StyledDialog.Builder builder1 = new StyledDialog.Builder(this.getActivity());
    switch(id) {
        case DIALOG_STATISTIC_TYPE:
            dialog = ChartBuilder.getStatisticsDialog(getActivity(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    DeckTask.launchDeckTask(DeckTask.TASK_TYPE_LOAD_STATISTICS, mLoadStatisticsHandler, new DeckTask.TaskData(AnkiDroidApp.getCol(), which, false));
                }
            }, mFragmented);
            break;
        case DIALOG_CUSTOM_STUDY:
            builder1.setTitle(res.getString(R.string.custom_study));
            builder1.setIcon(android.R.drawable.ic_menu_sort_by_size);
            builder1.setItems(res.getStringArray(R.array.custom_study_options_labels), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mCustomDialogChoice = which;
                    if (which == CUSTOM_STUDY_TAGS - 1) {
                        /*
                    		 * There is a special Dialog for CUSTOM STUDY, where instead of only collecting
                    		 * a number, it is necessary to collect a list of tags. This case handles the
                    		 * creation of that Dialog.
                    		 */
                        showDialog(DIALOG_CUSTOM_STUDY_TAGS);
                        return;
                    }
                    showDialog(DIALOG_CUSTOM_STUDY_DETAILS);
                }
            });
            builder1.setCancelable(true);
            dialog = builder1.create();
            break;
        case DIALOG_CUSTOM_STUDY_TAGS:
            /*
            	  * This handles the case where we want to create a Custom Study Deck using tags.
            	  * This dialog needs to be different from the normal Custom Study dialogs, because
            	  * more information is required:
            	  * --List of Tags to select.
            	  * --Which cards to select 
            	  * 	--(New cards, Due cards, or all cards, as in the desktop version)
            	  */
            if (!AnkiDroidApp.colIsOpen()) {
            //TODO how should this error be handled?
            }
            Context context = getActivity().getBaseContext();
            /*
                 * The following RadioButtons and RadioGroup are to select the category of cards
                 * to select for the Custom Study Deck (New, Due or All cards).
                 */
            RadioGroup rg = formatRGCardType(context, res);
            mSelectWhichCards = rg;
            builder1.setView(rg, false, true);
            //Here we add the list of tags for the whole collection.
            Collection col;
            col = AnkiDroidApp.getCol();
            allTags = col.getTags().all();
            builder1.setTitle(R.string.studyoptions_limit_select_tags);
            builder1.setMultiChoiceItems(allTags, new boolean[allTags.length], new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String tag = allTags[which];
                    if (mSelectedTags.contains(tag)) {
                        Log.i(AnkiDroidApp.TAG, "unchecked tag: " + tag);
                        mSelectedTags.remove(tag);
                    } else {
                        Log.i(AnkiDroidApp.TAG, "checked tag: " + tag);
                        mSelectedTags.add(tag);
                    }
                }
            });
            /*
                 * Here's the method that gathers the final selection of tags, type of cards
                 * and generates the search screen for the custom study deck.
                 */
            builder1.setPositiveButton(res.getString(R.string.select), new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mCustomStudyEditText.setText("");
                    String tags = mSelectedTags.toString();
                    mCustomStudyEditText.setHint(getResources().getString(R.string.card_browser_tags_shown, tags.substring(1, tags.length() - 1)));
                    StringBuilder sb = new StringBuilder();
                    switch(mSelectedOption) {
                        case 1:
                            sb.append("is:new ");
                            break;
                        case 2:
                            sb.append("is:due ");
                            break;
                        default:
                            // Logging here might be appropriate : )
                            break;
                    }
                    int i = 0;
                    for (String tag : mSelectedTags) {
                        if (i != 0) {
                            sb.append("or ");
                        } else {
                            //Only if we really have selected tags
                            sb.append("(");
                        }
                        sb.append("tag:").append(tag).append(" ");
                        i++;
                    }
                    if (i > 0) {
                        //Only if we added anything to the tag list 
                        sb.append(")");
                    }
                    mSearchTerms = sb.toString();
                    createFilteredDeck(new JSONArray(), new Object[] { mSearchTerms, 9999, Sched.DYN_RANDOM }, false);
                }
            });
            builder1.setNegativeButton(res.getString(R.string.cancel), new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mSelectedTags.clear();
                }
            });
            builder1.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    mSelectedTags.clear();
                }
            });
            dialog = builder1.create();
            break;
        case DIALOG_CUSTOM_STUDY_DETAILS:
            /*
                 * This is the normal case for creating a custom study deck, where the dialog
                 * requires only a numeric input.
                 */
            builder1.setContentView(mCustomStudyDetailsView);
            builder1.setCancelable(true);
            builder1.setNegativeButton(R.string.cancel, null);
            builder1.setPositiveButton(R.string.ok, null);
            dialog = builder1.create();
            break;
        default:
            dialog = null;
            break;
    }
    dialog.setOwnerActivity(getActivity());
    return dialog;
}
Also used : Context(android.content.Context) RadioGroup(android.widget.RadioGroup) DialogInterface(android.content.DialogInterface) ChartBuilder(com.ichi2.charts.ChartBuilder) StyledDialog(com.ichi2.themes.StyledDialog) JSONArray(org.json.JSONArray) TaskData(com.ichi2.async.DeckTask.TaskData) DeckTask(com.ichi2.async.DeckTask) OnClickListener(android.content.DialogInterface.OnClickListener) OnClickListener(android.content.DialogInterface.OnClickListener) Collection(com.ichi2.libanki.Collection) JSONObject(org.json.JSONObject) Resources(android.content.res.Resources) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 50 with RadioGroup

use of android.widget.RadioGroup in project RoboBinding by RoboBinding.

the class AbstractRadioGroupAttributeTest method initializeViewAndListeners.

@Before
public void initializeViewAndListeners() {
    view = new RadioGroup(RuntimeEnvironment.application);
    viewAddOn = new MockRadioGroupAddOn(view);
}
Also used : RadioGroup(android.widget.RadioGroup) Before(org.junit.Before)

Aggregations

RadioGroup (android.widget.RadioGroup)70 View (android.view.View)30 TextView (android.widget.TextView)23 RadioButton (android.widget.RadioButton)17 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)13 Button (android.widget.Button)10 CompoundButton (android.widget.CompoundButton)9 Validator (com.mobsandgeeks.saripaar.Validator)8 DialogInterface (android.content.DialogInterface)7 EditText (android.widget.EditText)7 Intent (android.content.Intent)6 AlertDialog (android.support.v7.app.AlertDialog)6 CheckBox (android.widget.CheckBox)6 LinearLayout (android.widget.LinearLayout)6 ImageView (android.widget.ImageView)5 IOException (java.io.IOException)5 RandomAccessFile (java.io.RandomAccessFile)5 Test (org.junit.Test)5 CardView (android.support.v7.widget.CardView)4 ScrollView (android.widget.ScrollView)4