Java Code Examples for android.widget.RadioGroup#getCheckedRadioButtonId()

The following examples show how to use android.widget.RadioGroup#getCheckedRadioButtonId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From WindView with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
    switch (radioGroup.getCheckedRadioButtonId()) {
        case R.id.rv_up:
            windView.setTrendType(TrendType.UP);
            windView.start();
            break;
        case R.id.rv_down:
            windView.setTrendType(TrendType.DOWN);
            windView.start();
            break;
        case R.id.rv_none:
            windView.setTrendType(TrendType.NONE);
            windView.start();
            break;
    }

}
 
Example 2
Source File: MainActivity.java    From cute-pets-example-android-app with Apache License 2.0 6 votes vote down vote up
@Nullable
private String getSelectedAge(RadioGroup rgAge) {
    String age = null;

    switch (rgAge.getCheckedRadioButtonId()) {
        case R.id.young:
            age = "Young";
            break;
        case R.id.middle:
            age = "Middle";
            break;
        case R.id.old:
            age = "Old";
            break;
    }
    return age;
}
 
Example 3
Source File: MainActivity.java    From QNRTC-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (group.getCheckedRadioButtonId()) {
        case R.id.camera_capture_button:
            mCaptureMode = Config.CAMERA_CAPTURE;
            break;
        case R.id.screen_capture_button:
            mCaptureMode = Config.SCREEN_CAPTURE;
            break;
        case R.id.audio_capture_button:
            mCaptureMode = Config.ONLY_AUDIO_CAPTURE;
            break;
        case R.id.muti_track_button:
            mCaptureMode = Config.MUTI_TRACK_CAPTURE;
            break;
    }
}
 
Example 4
Source File: SettingActivity.java    From QNRTC-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (group.getCheckedRadioButtonId()) {
        case R.id.hw_radio_button:
            mEncodeMode = Config.HW;
            mMaintainResRadioGroup.setVisibility(View.GONE);
            break;
        case R.id.sw_radio_button:
            mEncodeMode = Config.SW;
            mMaintainResRadioGroup.setVisibility(View.VISIBLE);
            break;
        case R.id.low_sample_rate_button:
            mSampleRatePos = Config.LOW_SAMPLE_RATE;
            break;
        case R.id.high_sample_rate_button:
            mSampleRatePos = Config.HIGH_SAMPLE_RATE;
            break;
    }
}
 
Example 5
Source File: VisibilityMetadataFragment.java    From android-LNotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@link NotificationVisibility} depending on which RadioButton in the radiogroup
 * is selected.
 *
 * @param radiogroup The RadioGroup.
 * @return The instance of {@link NotificationVisibility} corresponding to RadioButton.
 */
private NotificationVisibility getVisibilityFromSelectedRadio(RadioGroup radiogroup) {
    switch (radiogroup.getCheckedRadioButtonId()) {
        case R.id.visibility_public_radio_button:
            return NotificationVisibility.PUBLIC;
        case R.id.visibility_private_radio_button:
            return NotificationVisibility.PRIVATE;
        case R.id.visibility_secret_radio_button:
            return NotificationVisibility.SECRET;
        default:
            //If not selected, returns PUBLIC as default.
            return NotificationVisibility.PUBLIC;
    }
}
 
Example 6
Source File: AddAccountActivity.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
public void onNavigateNext(View nextButton) {
    RadioGroup addAccountOptions = findViewById(R.id.add_account_options);
    switch (addAccountOptions.getCheckedRadioButtonId()) {
        case R.id.add_account:
            addAccount(null);
            break;
        case R.id.add_account_with_name:
            final View view = getLayoutInflater().inflate(R.layout.simple_edittext, null);
            new AlertDialog.Builder(this)
                    .setTitle(R.string.add_account_dialog_title)
                    .setView(view)
                    .setPositiveButton(android.R.string.ok,
                            (dialogInterface, i) -> {
                                EditText editText = (EditText) view.findViewById(
                                        R.id.input);
                                String accountName = editText.getText().toString();
                                addAccount(accountName);
                            })
                    .show();
            break;
        case R.id.add_account_skip:
            if (mNextActivityIntent != null) {
                startActivity(mNextActivityIntent);
            }
            finish();
            break;
    }
}
 
Example 7
Source File: TGTempoDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Integer parseApplyTo() {
	RadioGroup radioGroup = (RadioGroup) this.getView().findViewById(R.id.tempo_dlg_options_group);

	int radioButtonId = radioGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) radioGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return TGChangeTempoRangeAction.APPLY_TO_ALL;
}
 
Example 8
Source File: TGTripletFeelDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Integer parseTripletFeelValue() {
	RadioGroup radioGroup = (RadioGroup) this.getView().findViewById(R.id.triplet_feel_dlg_value);
	int radioButtonId = radioGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) radioGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return TGMeasureHeader.TRIPLET_FEEL_NONE;
}
 
Example 9
Source File: TGGraceDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public boolean findSelectedOnBeat() {
	RadioGroup radioGroup = (RadioGroup) this.getView().findViewById(R.id.grace_dlg_position_group);
	int radioButtonId = radioGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) radioGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Boolean)radioButton.getTag()).booleanValue();
		}
	}
	return false;
}
 
Example 10
Source File: MainActivity.java    From AndroidHeros with MIT License 5 votes vote down vote up
public void visibilityNotify(View view){
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.visibility_radio_group);
    Notification.Builder builder = new Notification.Builder(this).
            setContentTitle("Notification for Visibility Test");
    switch (radioGroup.getCheckedRadioButtonId()){
        case R.id.radio_button_public:
            builder.setVisibility(Notification.VISIBILITY_PUBLIC);
            builder.setContentText("Public");
            builder.setSmallIcon(R.mipmap.ic_public);
            break;
        case R.id.radio_button_private:
            builder.setVisibility(Notification.VISIBILITY_PRIVATE);
            builder.setContentText("Private");
            builder.setSmallIcon(R.mipmap.ic_private);
            break;
        case R.id.radio_button_secret:
            builder.setVisibility(Notification.VISIBILITY_SECRET);
            builder.setContentText("Secret");
            builder.setSmallIcon(R.mipmap.ic_secret);
            break;
        default:
            break;
    }

    NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID_VISIBILITY, builder.build());
}
 
Example 11
Source File: TGMeasurePasteDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public int findSelectedMode() {
	RadioGroup optionsGroup = (RadioGroup) this.getView().findViewById(R.id.measure_paste_dlg_options_group);
	
	int radioButtonId = optionsGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) optionsGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return 1;
}
 
Example 12
Source File: TGStrokeDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public int findSelectedDuration() {
	RadioGroup radioGroup = (RadioGroup) this.getView().findViewById(R.id.stroke_dlg_duration_group);
	int radioButtonId = radioGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) radioGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return 0;
}
 
Example 13
Source File: TGTremoloPickingDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public int findSelectedDuration() {
	RadioGroup optionsGroup = (RadioGroup) this.getView().findViewById(R.id.tremolo_picking_dlg_duration_group);
	
	int radioButtonId = optionsGroup.getCheckedRadioButtonId();
	if( radioButtonId != -1 ) {
		RadioButton radioButton = (RadioButton) optionsGroup.findViewById(radioButtonId);
		if( radioButton != null ) {
			return ((Integer)radioButton.getTag()).intValue();
		}
	}
	return TGDuration.EIGHTH;
}
 
Example 14
Source File: ThemeSwitcherDialogFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private int getThemeOverlayResId(RadioGroup radioGroup) {
  if (radioGroup.getCheckedRadioButtonId() == View.NO_ID) {
    return 0;
  }

  ThemeAttributeValues overlayFeature =
        (ThemeAttributeValues)
            getDialog().findViewById(radioGroup.getCheckedRadioButtonId()).getTag();

  return overlayFeature.themeOverlay;
}
 
Example 15
Source File: IntroActivity.java    From habpanelviewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isPolicyRespected() {
    View v = getView();
    if (v != null) {
        final RadioGroup rg = getView().findViewById(R.id.intro_discover_radioGroup);
        return rg.getCheckedRadioButtonId() != -1;
    }

    return true;
}
 
Example 16
Source File: CallSettingsFragment.java    From sealrtc-android with MIT License 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {

    switch (radioGroup.getCheckedRadioButtonId()) {
        case R.id.rb_call_settings_tab_video:
            {
                pvCallSettingsPager.showVideoPager();
                break;
            }
        case R.id.rb_call_settings_tab_audio:
            {
                Log.d(TAG, "onCheckedChanged: rb_call_settings_tab_audio");
                pvCallSettingsPager.showAudioPager();
                pvCallSettingsPager.setAudioOn(
                        SessionManager.getInstance()
                                .getBoolean(
                                        SettingActivity.IS_AUDIO_MUSIC,
                                        getResources()
                                                .getBoolean(R.bool.def_audio_music_mode)));
                break;
            }

        case R.id.rb_call_settings_tab_other:
            {
                Log.d(TAG, "onCheckedChanged: rb_call_settings_tab_other");
                pvCallSettingsPager.showOtherPager();
                break;
            }
        default:
            {
            }
    }
}
 
Example 17
Source File: LoginActivity.java    From secure-quick-reliable-login with MIT License 5 votes vote down vote up
private boolean decryptIdentityInternal(SQRLStorage storage, boolean useQuickPass) {
    final RadioGroup radgrpAccountOptions = findViewById(R.id.radgrpAccountOptions);

    if (radgrpAccountOptions.getCheckedRadioButtonId() == R.id.radEnableAccount ||
            radgrpAccountOptions.getCheckedRadioButtonId() == R.id.radRemoveAccount) {

        try {
            if (!storage.decryptUnlockKey(mRescueCodeInputHelper.getRescueCodeInput())) {
                showErrorMessage(R.string.decrypt_identity_fail);
                handler.post(() -> hideProgressPopup());
                return false;
            }
            storage.reInitializeMasterKeyIdentity();
            return true;
        } catch (Exception e) {
            showErrorMessage(e.getMessage());
            Log.e(TAG, e.getMessage(), e);
            this.closeActivity();
            storage.clear();
            storage.clearQuickPass();
            return false;
        } finally {
            handler.post(() -> mRescueCodeInputHelper.clearForm());
        }
    } else {
        if(!storage.decryptIdentityKey(txtLoginPassword.getText().toString(), entropyHarvester, useQuickPass)) {
            showErrorMessage(R.string.decrypt_identity_fail);
            handler.post(() -> {
                txtLoginPassword.setHint(R.string.login_identity_password);
                txtLoginPassword.setText("");
                hideProgressPopup();
            });
            storage.clear();
            storage.clearQuickPass();
            return false;
        }
        return true;
    }
}
 
Example 18
Source File: SettingActivity.java    From QNRTC-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (group.getCheckedRadioButtonId()) {
        case R.id.maintain_res_button_yes:
            mMaintainResolution = true;
            break;
        case R.id.maintain_res_button_no:
            mMaintainResolution = false;
            break;
    }
}
 
Example 19
Source File: ProfileActivity.java    From medical-data-android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * To update the user's personal information. It checks that that the PIN is correct and, in
 * that case, saves the data in the database and the app and finishes. A {@link Toast} message
 * is used to inform the user if the data has been successfully updated or there has been any
 * problem while connecting with the database.
 *
 * @param view the clicked {@link View}.
 * @see #finish()
 * @see TextView#setError(CharSequence)
 * @see EditText#setError(CharSequence)
 */
public void btnFinish(View view) {
    boolean error = false;

    // check name correction
    EditText name = (EditText) findViewById(R.id.name_answer);
    String name_text = name.getText().toString();
    if (name_text.equals("")) {
        name.setError(getString(R.string.name_blank));
        focusFirstError(name, R.id.name);
        error = true;
    }

    // check email correction
    EditText email = (EditText) findViewById(R.id.email_answer);
    String email_text = email.getText().toString();
    if (email_text.equals("")) {
        email.setError(getString(R.string.email_blank));
        if (!error) {
            focusFirstError(email, R.id.email);
            error = true;
        }
    } else if (!email_text.matches(Variables.emailPattern)) {
        email.setError(getString(R.string.email_format));
        if (!error) {
            focusFirstError(email, R.id.email);
            error = true;
        }
    }

    // check PIN correction
    EditText pin = (EditText) findViewById(R.id.pin_answer);
    String pin_text = pin.getText().toString();
    int pin_number = settings.getInt("pin", -1);
    String original_pin = String.valueOf(pin_number);
    if (!pin_text.equals(original_pin)) {
        pin.setError(getString(R.string.incorrect_pin));
        if (!error) {
            focusFirstError(pin, R.id.pin);
            error = true;
        }
    }

    // ¿Everything correct?
    if (!error) {
        String user_id = settings.getString("user_id", "");
        DatePicker birthDate = (DatePicker) findViewById(R.id.age_answer);
        // gender = false => male, gender = true => female
        RadioGroup radioGroup = (RadioGroup) findViewById(R.id.gender_answer);
        boolean gender = radioGroup.getCheckedRadioButtonId() == R.id.radio_female;
        User user = new User(
                email_text,
                name_text,
                pin_number,
                birthDate.getDayOfMonth(),
                birthDate.getMonth(),
                birthDate.getYear(),
                gender,
                user_id);

        //Save changes in the server database
        try {
            UpdateRegistration runner = new UpdateRegistration();
            runner.execute(user);
            int option = runner.get();
            if (option == 0) {
                // Save register in the app
                user.save(this);
                // Feedback: update profile has been completed
                Toast.makeText(this, R.string.changes_saved, Toast.LENGTH_LONG).show();
            } else if (option == 1) {
                Toast.makeText(this, R.string.repeated_email2, Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(this, R.string.update_error, Toast.LENGTH_LONG).show();
            }
        } catch (Exception e) {
            Toast.makeText(this, R.string.update_error, Toast.LENGTH_LONG).show();
        }

        Variables.hideKeyboard(this);
        finish();
    }
}
 
Example 20
Source File: OnRadioButtonCheckedChangeListener.java    From Briefness with Apache License 2.0 4 votes vote down vote up
public OnRadioButtonCheckedChangeListener(RadioGroup radioGroup) {
    this.checkedId = radioGroup.getCheckedRadioButtonId();
}