List of usage examples for android.widget RadioButton performClick
@Override public boolean performClick()
From source file:org.gnucash.android.ui.export.ExportDialogFragment.java
private void bindViews() { View v = getView();//from w ww.j av a 2 s . c o m assert v != null; mDestinationSpinner = (Spinner) v.findViewById(R.id.spinner_export_destination); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.export_destinations, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDestinationSpinner.setAdapter(adapter); mDestinationSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { View recurrenceOptionsView = getView().findViewById(R.id.recurrence_options); switch (position) { case 0: mExportTarget = ExportParams.ExportTarget.SD_CARD; recurrenceOptionsView.setVisibility(View.VISIBLE); break; case 1: recurrenceOptionsView.setVisibility(View.VISIBLE); mExportTarget = ExportParams.ExportTarget.DROPBOX; String dropboxAppKey = getString(R.string.dropbox_app_key, SettingsActivity.DROPBOX_APP_KEY); String dropboxAppSecret = getString(R.string.dropbox_app_secret, SettingsActivity.DROPBOX_APP_SECRET); DbxAccountManager mDbxAccountManager = DbxAccountManager .getInstance(getActivity().getApplicationContext(), dropboxAppKey, dropboxAppSecret); if (!mDbxAccountManager.hasLinkedAccount()) { mDbxAccountManager.startLink(getActivity(), 0); } break; case 2: recurrenceOptionsView.setVisibility(View.VISIBLE); mExportTarget = ExportParams.ExportTarget.GOOGLE_DRIVE; SettingsActivity.mGoogleApiClient = SettingsActivity.getGoogleApiClient(getActivity()); SettingsActivity.mGoogleApiClient.connect(); break; case 3: mExportTarget = ExportParams.ExportTarget.SHARING; recurrenceOptionsView.setVisibility(View.GONE); break; default: mExportTarget = ExportParams.ExportTarget.SD_CARD; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mExportAllCheckBox = (CheckBox) v.findViewById(R.id.checkbox_export_all); mExportAllCheckBox .setChecked(sharedPrefs.getBoolean(getString(R.string.key_export_all_transactions), false)); mDeleteAllCheckBox = (CheckBox) v.findViewById(R.id.checkbox_post_export_delete); mDeleteAllCheckBox.setChecked( sharedPrefs.getBoolean(getString(R.string.key_delete_transactions_after_export), false)); mSaveButton = (Button) v.findViewById(R.id.btn_save); mSaveButton.setText(R.string.btn_export); mCancelButton = (Button) v.findViewById(R.id.btn_cancel); mCancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mSaveButton.setOnClickListener(new ExportClickListener()); mRecurrenceTextView = (TextView) v.findViewById(R.id.input_recurrence); mRecurrenceTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FragmentManager fm = getActivity().getSupportFragmentManager(); Bundle b = new Bundle(); Time t = new Time(); t.setToNow(); b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, t.toMillis(false)); b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, t.timezone); // may be more efficient to serialize and pass in EventRecurrence b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRecurrenceRule); RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag("recurrence_picker"); if (rpd != null) { rpd.dismiss(); } rpd = new RecurrencePickerDialog(); rpd.setArguments(b); rpd.setOnRecurrenceSetListener(ExportDialogFragment.this); rpd.show(fm, "recurrence_picker"); } }); mExportWarningTextView = (TextView) v.findViewById(R.id.export_warning); //this part (setting the export format) must come after the recurrence view bindings above String defaultExportFormat = sharedPrefs.getString(getString(R.string.key_default_export_format), ExportFormat.QIF.name()); mExportFormat = ExportFormat.valueOf(defaultExportFormat); View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View view) { onRadioButtonClicked(view); } }; RadioButton ofxRadioButton = (RadioButton) v.findViewById(R.id.radio_ofx_format); ofxRadioButton.setOnClickListener(clickListener); if (defaultExportFormat.equalsIgnoreCase(ExportFormat.OFX.name())) { ofxRadioButton.performClick(); } RadioButton qifRadioButton = (RadioButton) v.findViewById(R.id.radio_qif_format); qifRadioButton.setOnClickListener(clickListener); if (defaultExportFormat.equalsIgnoreCase(ExportFormat.QIF.name())) { qifRadioButton.performClick(); } RadioButton xmlRadioButton = (RadioButton) v.findViewById(R.id.radio_xml_format); xmlRadioButton.setOnClickListener(clickListener); if (defaultExportFormat.equalsIgnoreCase(ExportFormat.XML.name())) { xmlRadioButton.performClick(); } }