List of usage examples for android.widget RadioGroup check
public void check(@IdRes int id)
Sets the selection to the radio button whose identifier is passed in parameter.
From source file:com.bellman.bible.android.view.activity.search.Search.java
/** * Called when the activity is first created. *///from w w w . j a va 2s .c om @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, true); Log.i(TAG, "Displaying Search view"); setContentView(R.layout.search); if (!searchControl.validateIndex(getDocumentToSearch())) { Dialogs.getInstance().showErrorMsg(R.string.error_occurred, new Callback() { @Override public void okay() { finish(); } }); } mSearchTextInput = (EditText) findViewById(R.id.searchText); mSearchTextInput.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press onSearch(null); return true; } return false; } }); // pre-load search string if passed in Bundle extras = getIntent().getExtras(); if (extras != null) { String searchText = extras.getString(SEARCH_TEXT_SAVE); if (StringUtils.isNotEmpty(searchText)) { mSearchTextInput.setText(searchText); } } RadioGroup wordsRadioGroup = (RadioGroup) findViewById(R.id.wordsGroup); wordsRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { wordsRadioSelection = checkedId; } }); if (extras != null) { int wordsSelection = extras.getInt(WORDS_SELECTION_SAVE, -1); if (wordsSelection != -1) { wordsRadioGroup.check(wordsSelection); } } RadioGroup sectionRadioGroup = (RadioGroup) findViewById(R.id.bibleSectionGroup); sectionRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { sectionRadioSelection = checkedId; } }); if (extras != null) { int sectionSelection = extras.getInt(SECTION_SELECTION_SAVE, -1); if (sectionSelection != -1) { sectionRadioGroup.check(sectionSelection); } } // set text for current bible book on appropriate radio button RadioButton currentBookRadioButton = (RadioButton) findViewById(R.id.searchCurrentBook); // set current book to default and allow override if saved - implies returning via Back button currentBookName = searchControl.getCurrentBookName(); if (extras != null) { String currentBibleBookSaved = extras.getString(CURRENT_BIBLE_BOOK_SAVE); if (currentBibleBookSaved != null) { currentBookName = currentBibleBookSaved; } } currentBookRadioButton.setText(currentBookName); Log.d(TAG, "Finished displaying Search view"); }
From source file:jp.co.rediscovery.firstflight.ConfigFragment.java
/** * ??? FIXME /*from w w w . j a va 2s .com*/ * @param root */ private void initConfigNetwork(final View root) { final IWiFiController wifi = (mController instanceof IWiFiController) ? (IWiFiController) mController : null; final RadioGroup group = root.findViewById(R.id.network_wifi_mode_radiogroup); if (wifi != null) { final boolean outdoor = wifi.isOutdoor(); group.check(outdoor ? R.id.network_outdoor_radiobutton : R.id.network_indoor_radiobutton); group.setOnCheckedChangeListener(mOnRadioButtonCheckedChangeListener); } else { group.check(R.id.network_indoor_radiobutton); group.setEnabled(false); } }
From source file:jp.co.rediscovery.firstflight.ConfigFragment.java
/** * ???// w ww . j a v a2s.com * @param root */ private void initConfigOperation(final View root) { if (DEBUG) Log.v(TAG, "initConfigOperation:"); final RadioGroup group = root.findViewById(R.id.operation_radiogroup); switch (mPref.getInt(APP_CONFIG_KEY_OPERATION_TYPE, 0)) { case 1: // 2 group.check(R.id.operation_mode2_radiobutton); break; case 0: // 1 group.check(R.id.operation_mode1_radiobutton); default: break; } group.setOnCheckedChangeListener(mOnRadioButtonCheckedChangeListener); }
From source file:com.kyakujin.android.autoeco.ui.SilentModeSettingFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = getActivity();/*from ww w . j av a 2s.c o m*/ LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.fragment_dialog_silentmode, null, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupSilentMode); // ????????? radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radioNormal: mSilentMode = AudioManager.RINGER_MODE_NORMAL; break; case R.id.radioSilent: mSilentMode = AudioManager.RINGER_MODE_SILENT; break; case R.id.radioVibrate: mSilentMode = AudioManager.RINGER_MODE_VIBRATE; break; default: } } }); mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID); mSilentMode = getArguments().getInt(Conf.SHARED_SILENTMODE); switch (mSilentMode) { case AudioManager.RINGER_MODE_NORMAL: radioGroup.check(R.id.radioNormal); break; case AudioManager.RINGER_MODE_SILENT: radioGroup.check(R.id.radioSilent); break; case AudioManager.RINGER_MODE_VIBRATE: radioGroup.check(R.id.radioVibrate); break; default: } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.setting_silent); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EcoDAO dao = new EcoDAO(mActivity); dao.updateSilentMode(mCurrentEcoId, mSilentMode); } }); builder.setNegativeButton("Cancel", null); builder.setView(view); return builder.create(); }
From source file:com.nachiket.titan.LibraryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SEARCH: setSearchBoxVisible(!mSearchBoxVisible); return true; case MENU_PLAYBACK: openPlaybackActivity();//from ww w . j av a 2 s . c o m return true; case MENU_SORT: { MediaAdapter adapter = (MediaAdapter) mCurrentAdapter; int mode = adapter.getSortMode(); int check; if (mode < 0) { check = R.id.descending; mode = ~mode; } else { check = R.id.ascending; } int[] itemIds = adapter.getSortEntries(); String[] items = new String[itemIds.length]; Resources res = getResources(); for (int i = itemIds.length; --i != -1;) { items[i] = res.getString(itemIds[i]); } RadioGroup header = (RadioGroup) getLayoutInflater().inflate(R.layout.sort_dialog, null); header.check(check); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.sort_by); builder.setSingleChoiceItems(items, mode + 1, this); // add 1 for header builder.setNeutralButton(R.string.done, null); AlertDialog dialog = builder.create(); dialog.getListView().addHeaderView(header); dialog.setOnDismissListener(this); dialog.show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.serenegiant.aceparrot.ConfigFragment.java
/** * ??? FIXME /*from ww w .java 2 s . c om*/ * @param root */ private void initConfigNetwork(final View root) { final IWiFiController wifi = (mController instanceof IWiFiController) ? (IWiFiController) mController : null; final RadioGroup group = (RadioGroup) root.findViewById(R.id.network_wifi_mode_radiogroup); if (wifi != null) { final boolean outdoor = wifi.isOutdoor(); group.check(outdoor ? R.id.network_outdoor_radiobutton : R.id.network_indoor_radiobutton); group.setOnCheckedChangeListener(mOnRadioButtonCheckedChangeListener); } else { group.check(R.id.network_indoor_radiobutton); group.setEnabled(false); } }
From source file:com.serenegiant.aceparrot.ConfigFragment.java
/** * ???//from w w w . j a v a2 s. c om * @param root */ private void initConfigOperation(final View root) { if (DEBUG) Log.v(TAG, "initConfigOperation:"); final RadioGroup group = (RadioGroup) root.findViewById(R.id.operation_radiogroup); switch (mPref.getInt(KEY_OPERATION_TYPE, 0)) { case 1: // ??? group.check(R.id.operation_reverse_radiobutton); break; case 2: // 1 group.check(R.id.operation_mode1_radiobutton); break; case 3: // 2 group.check(R.id.operation_mode2_radiobutton); break; case 0: default: // group.check(R.id.operation_normal_radiobutton); break; } group.setOnCheckedChangeListener(mOnRadioButtonCheckedChangeListener); final CheckBox checkbox = (CheckBox) root.findViewById(R.id.operation_touch_checkbox); checkbox.setChecked(mPref.getBoolean(KEY_OPERATION_TOUCH, false)); checkbox.setOnCheckedChangeListener(mOnCheckedChangeListener); }
From source file:com.google.code.twisty.Twisty.java
private void updateRestoreRadioButtons(RadioGroup rg) { rg.removeAllViews();// ww w . j a v a2 s. com int id = 0; String[] gamelist = new File(savegame_dir).list(); for (String filename : gamelist) { RadioButton rb = new RadioButton(Twisty.this); rb.setText(filename); rg.addView(rb); id = rb.getId(); } rg.check(id); // by default, check the last item }
From source file:am.project.x.business.widgets.statelayout.StateLayoutActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { setSupportActionBar(R.id.sl_toolbar); mVState = findViewById(R.id.sl_lyt_state); final RadioGroup state = findViewById(R.id.sl_rg_state); final RadioGroup mode = findViewById(R.id.sl_rg_mode); mDLoading = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_loading); mDError = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_error); mDEmpty = ContextCompat.getDrawable(this, R.drawable.ic_statelayout_empty); final AppCompatTextView loading = new AppCompatTextView(this); loading.setText(R.string.sl_change_state_loading); loading.setTextColor(0xfff2f71c);/*from w ww. j a va 2 s . c o m*/ loading.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 64); mVLoading = loading; final AppCompatTextView error = new AppCompatTextView(this); error.setText(R.string.sl_change_state_error); error.setTextColor(0xffff4081); error.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 64); mVError = error; final AppCompatTextView empty = new AppCompatTextView(this); empty.setText(R.string.sl_change_state_empty); empty.setTextColor(0xff092d6d); empty.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 64); mVEmpty = empty; mVState.setOnStateClickListener(this); state.setOnCheckedChangeListener(this); state.check(R.id.sl_rb_normal); mode.setOnCheckedChangeListener(this); mode.check(R.id.sl_rb_drawable); }
From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register_driver); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from www. j ava 2 s .c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); context = this; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); appBarLayout.setExpanded(false, true); mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver); mainScrollView.setSmoothScrollingEnabled(true); selectorsLayouts = new ArrayList<>(); editDriver = new Driver(); preferredPlace = new PrologixPlace(); if (currentDriver == null) { getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver)); if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) { editDriver = tempDriver; if (editDriver == null) editDriver = new Driver(); } vehiclesList = new ArrayList<>(); } else { getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver)); editDriver = currentDriver.clone(); if (editDriver.getPreferredAddress() != null) { preferredPlace.setAddress( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class)); preferredPlace.setLocation( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class)); } } storagePermission = new PermissionManager(this); if (!storagePermission.checkReadStoragePermission()) storagePermission.getReadStoragePermission(); registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver); vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator); if (editDriver.getVehicles() == null) editDriver.setVehicles(new ArrayList<Vehicle>()); vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false); if (!editDriver.getVehicles().isEmpty()) setIndicator(context, vehicleIndicator, true); if (!editDriver.getVehicles().contains(createVehicle)) { editDriver.getVehicles().add(new Vehicle()); //TODO remove this.. just for testing only /*String vehicleId = "SA-3184VLB"; DriverTask driverTask = new DriverTask(vehicleFetcher, "en"); driverTask.getVehicle.execute(vehicleId);*/ } vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view); vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); vehicleListView.setHasFixedSize(true); vehicleListView.setAdapter(vehicleRecyclerAdapter); vehicleListView.setNestedScrollingEnabled(false); licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator); licenseValueNumber = (TextView) findViewById(R.id.license_info_number); licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry); licenseImage = (ImageView) findViewById(R.id.license_image); licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded); licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout); if (editDriver.getLicenseNumber() != null) { setIndicator(context, licenseIndicator, true); licenseValueNumber.setText(editDriver.getLicenseNumber()); licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry())); if (editDriver.getLicenseImage() != null) licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(), DataHolder.getInstance().getImageLoader()); } if (photo1 != null) licenseImage.setImageBitmap(photo1); licenseInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE); startActivity(scanIdIntent); } }); residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator); residenceValueNumber = (TextView) findViewById(R.id.residence_info_number); residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry); residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name); residenceImage = (ImageView) findViewById(R.id.residence_image); residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded); residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout); if (editDriver.getResidenceNumber() != null) { setIndicator(context, residenceIndicator, true); residenceValueNumber.setText(editDriver.getResidenceNumber()); residenceValueLegalName.setText(editDriver.getLegalName()); if (editDriver.getResidenceImage() != null) residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(), DataHolder.getInstance().getImageLoader()); } if (photo2 != null) residenceImage.setImageBitmap(photo2); residenceInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID); startActivity(scanIdIntent); } }); nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator); nationalityValue = (TextView) findViewById(R.id.nationality_value); nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout); nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout); final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector); selectorsLayouts.add(nationalitySelector); nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content); countryTask = new CountryTask(countryListHandler, "en"); countryTask.getCountryList.execute("en"); if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); } nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto); nationalityLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (nationalitySelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, nationalityLayout.getTop()); nationalityAuto.showDropDown(); } }, 1000); } if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) { nationalityProgressLayout.setVisibility(View.VISIBLE); nationalitySelectorContent.setVisibility(View.GONE); } LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); addressLayout.postDelayed(new Runnable() { @Override public void run() { addressLayout.performClick(); } }, 1000); } else { setIndicator(context, nationalityIndicator, false); nationalitySelector.setVisibility(View.GONE); } } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nationalitySelector.setVisibility(View.GONE); } }); } }); addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator); addressValue = (TextView) findViewById(R.id.preferred_address_value); addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout); if (editDriver.getPreferredAddress() != null) { setIndicator(context, addressIndicator, true); preferredPlace.setAddress(transform(editDriver.getPreferredAddress())); preferredPlace.setLocation(transform(editDriver.getPreferredLocation())); addressValue.setText(preferredPlace.getAddress().getFullAddress()); } addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser); selectorsLayouts.add(addressChooser); addressLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); try { if (addressChooser.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser); getSupportFragmentManager().beginTransaction() .replace(R.id.preferred_address_chooser, PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler)) .commit(); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, addressLayout.getTop()); } }, 1500); } else { addressChooser.setVisibility(View.GONE); getSupportFragmentManager().popBackStack(); } } catch (Resources.NotFoundException | OutOfMemoryError ignored) { } } }); final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator); final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value); if (editDriver.getPhoneNumber() != null) { setIndicator(context, phoneIndicator, true); phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); } final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector); selectorsLayouts.add(phoneSelector); phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout); phoneLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (phoneSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, phoneLayout.getTop()); } }, 1000); } final EditText input = (EditText) findViewById(R.id.phone_number); if (editDriver.getPhoneNumber() != null) input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); TextView phoneCode = (TextView) findViewById(R.id.country_code); phoneCode.setText(currentCountry.getPhoneCode()); NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag); countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader()); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!input.getText().toString().isEmpty()) { String phoneNumberEdit = currentCountry.getPhoneCode() + input.getText().toString().replaceAll(" ", ""); editDriver.setPhoneNumber(phoneNumberEdit); phoneValue.setText(phoneNumberEdit); setIndicator(context, phoneIndicator, true); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, dobLayout.getTop()); } }, 1000); } else { phoneValue.setText(getString(R.string.driver_phone_hint)); setIndicator(context, phoneIndicator, false); } phoneSelector.setVisibility(View.GONE); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneSelector.setVisibility(View.GONE); } }); } }); dobValue = (TextView) findViewById(R.id.driver_dob_value); if (editDriver.getDob() != null) dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout); dobLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar calendar = Calendar.getInstance(); if (editDriver.getDob() != null) { dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); calendar.setTimeInMillis(editDriver.getDob()); } DatePickerDialog datePickerDialog = DatePickerDialog .newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); editDriver.setDob(calendar.getTimeInMillis()); dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); } }); final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value); if (editDriver.getGender() != null) genderValue.setText( editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option)); final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector); selectorsLayouts.add(genderSelector); final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout); genderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (genderSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, genderLayout.getTop()); } }, 1000); } else genderSelector.setVisibility(View.GONE); final int checkedPos = editDriver.getGender() == null ? -1 : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female); final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group); if (checkedPos != -1) insuranceRadioGroup.check(checkedPos); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (insuranceRadioGroup.getCheckedRadioButtonId()) { case R.id.driver_gender_male: editDriver.setGender(true); genderValue.setText(getString(R.string.male_option)); break; case R.id.driver_gender_female: editDriver.setGender(false); genderValue.setText(getString(R.string.female_option)); break; default: break; } mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, 0); } }, 500); appBarLayout.postDelayed(new Runnable() { @Override public void run() { appBarLayout.setExpanded(true, true); } }, 1500); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { genderSelector.setVisibility(View.GONE); } }); } }); //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie uploadCount = new AtomicInteger(0); saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id); saveDriverAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean error = false; hideKeyboard(context); if (editDriver.getVehicles().size() == 1) { setIndicator(context, vehicleIndicator, false); error = true; } if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null || editDriver.getLicenseNumber() == null) { setIndicator(context, licenseIndicator, false); error = true; } if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) { setIndicator(context, residenceIndicator, false); error = true; } if (editDriver.getNationality() == null) { setIndicator(context, nationalityIndicator, false); error = true; } if (editDriver.getPreferredAddress() == null) { setIndicator(context, addressIndicator, false); error = true; } if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) { setIndicator(context, phoneIndicator, false); error = true; } if (user == null && !registerEmailHeaderFragment.setCustomerValues()) error = true; if (error) Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG) .show(); else if (user != null) { signUpAnalytics(user.getProviderId()); editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1); uploadImage("driver_license_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getLicenseNumber() + ".jpg", ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE); uploadImage("driver_residence_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getResidenceNumber() + ".jpg", ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID); crossFade(context, findViewById(R.id.driver_progress_layout), findViewById(R.id.driver_main_layout), null); //TODO verify registration details for duplicate, correctness, etc } } }); imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status); imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView switcherTextView = new TextView(getApplicationContext()); switcherTextView.setTextSize(16); switcherTextView.setTypeface(null, Typeface.BOLD); switcherTextView.setText(getString(R.string.uploading_images)); switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent)); return switcherTextView; } }); Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); imageUploadStatus.setOutAnimation(animationOut); imageUploadStatus.setInAnimation(animationIn); }