List of usage examples for android.widget RadioGroup getCheckedRadioButtonId
@IdRes public int getCheckedRadioButtonId()
Returns the identifier of the selected radio button in this group.
From source file:com.nachiket.titan.LibraryActivity.java
@Override public void onDismiss(DialogInterface dialog) { ListView list = ((AlertDialog) dialog).getListView(); // subtract 1 for header int which = list.getCheckedItemPosition() - 1; RadioGroup group = (RadioGroup) list.findViewById(R.id.sort_direction); if (group.getCheckedRadioButtonId() == R.id.descending) which = ~which;/*from w w w . ja va 2 s. c o m*/ mPagerAdapter.setSortMode(which); }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
/** * Start the search./*from w w w. j av a2 s . c o m*/ * * @param startPoint * the start point * @param endPoint * the end point * @param time * the departure time or null to use current time */ private void onSearchRoutes(Site startPoint, Site endPoint, Site viaPoint, Time time) { // TODO: We should not handle point-on-map this way. But for now we just // want it to work. if (!mStartPointAutoComplete.getText().toString().equals(getString(R.string.point_on_map))) { mHistoryDbAdapter.create(HistoryDbAdapter.TYPE_JOURNEY_PLANNER_SITE, startPoint); } if (!mEndPointAutoComplete.getText().toString().equals(getString(R.string.point_on_map))) { mHistoryDbAdapter.create(HistoryDbAdapter.TYPE_JOURNEY_PLANNER_SITE, endPoint); } if (!TextUtils.isEmpty(mViaPointAutoComplete.getText().toString())) { mHistoryDbAdapter.create(HistoryDbAdapter.TYPE_JOURNEY_PLANNER_SITE, endPoint); } boolean alternativeStops = false; boolean isTimeDeparture = true; RadioGroup chooseTimeGroup = (RadioGroup) mSearchView.findViewById(R.id.planner_choose_time_group); int checkedId = chooseTimeGroup.getCheckedRadioButtonId(); if (checkedId == R.id.planner_check_more_choices) { isTimeDeparture = mWhenSpinner.getSelectedItemId() == 0; CheckBox alternativeCheckBox = (CheckBox) getActivity().findViewById(R.id.planner_alternative_stops); alternativeStops = alternativeCheckBox.isChecked(); } else { // User has checked the "now" checkbox, this forces the time to // be set in the RoutesActivity upon search. time = null; } Log.i(TAG, "START POINT: " + startPoint.toDump()); Log.i(TAG, "END POINT: " + endPoint.toDump()); JourneyQuery journeyQuery = new JourneyQuery.Builder().origin(startPoint).destination(endPoint) .via(viaPoint).isTimeDeparture(isTimeDeparture).time(time) .transportModes(getSelectedTransportModes()).alternativeStops(alternativeStops).create(); Intent routesIntent = new Intent(getActivity(), RoutesActivity.class); routesIntent.putExtra(RoutesActivity.EXTRA_JOURNEY_QUERY, journeyQuery); startActivity(routesIntent); /* * Uri routesUri = RoutesActivity.createRoutesUri( startPoint, endPoint, * time, isTimeDeparture); Intent i = new Intent(Intent.ACTION_VIEW, * routesUri, this, RoutesActivity.class); startActivity(i); */ }
From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java
public void alertFormElements() { /*//from w w w . ja v a2s . com * Inflate the XML view. activity_main is in * res/layout/form_elements.xml */ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View formElementsView = inflater.inflate(R.layout.font_size_chooser, null, false); final RadioGroup rgFontSize = (RadioGroup) formElementsView.findViewById(R.id.genderRadioGroup); // the alert dialog new AlertDialog.Builder(MainActivity.this).setView(formElementsView).setTitle("Set Font Size") .setNegativeButton("OK", new DialogInterface.OnClickListener() { @TargetApi(11) public void onClick(DialogInterface dialog, int id) { int selectedId = rgFontSize.getCheckedRadioButtonId(); // find the radiobutton by returned id RadioButton selectedRadioButton = (RadioButton) formElementsView.findViewById(selectedId); if (selectedRadioButton.getId() == R.id.radNormal) { pm.setMinimumFontSize(8); } else if (selectedRadioButton.getId() == R.id.radLarge) { pm.setMinimumFontSize(16); } else if (selectedRadioButton.getId() == R.id.radLarger) { pm.setMinimumFontSize(20); } wSettings.setMinimumFontSize(pm.getMinimumFontSize()); if (Helpers.isOnline(MainActivity.this)) { webView.loadUrl(webView.getUrl()); } else { Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_LONG).show(); } dialog.cancel(); } }).show(); }
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
public void initPageLayoutScreen() { ImageButton close = (ImageButton) findMyViewById(R.id.options_close); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // int did = ((RadioGroup) findMyViewById(R.id.directionGroup)).getCheckedRadioButtonId(); // int lid = ((RadioGroup) findMyViewById(R.id.layoutGroup)).getCheckedRadioButtonId(); // controller.setDirectionAndLayout(did == R.id.direction1 ? 0 : 1, lid == R.id.layout1 ? 0 : lid == R.id.layout2 ? 1 : 2); //main menu onAnimatorCancel();// w w w.java2 s .c o m updatePageLayout(); //animator.setDisplayedChild(MAIN_SCREEN); } }); ImageButton view = (ImageButton) findMyViewById(R.id.options_apply); view.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onApplyAction(); RadioGroup group = ((RadioGroup) findMyViewById(R.id.directionGroup)); int walkOrderButtonId = group.getCheckedRadioButtonId(); universe.constellation.orion.viewer.android.RadioButton button = (universe.constellation.orion.viewer.android.RadioButton) group .findViewById(walkOrderButtonId); int lid = ((RadioGroup) findMyViewById(R.id.layoutGroup)).getCheckedRadioButtonId(); controller.setDirectionAndLayout(button.getWalkOrder(), lid == R.id.layout1 ? 0 : lid == R.id.layout2 ? 1 : 2); } }); getSubscriptionManager().addDocListeners(new DocumentViewAdapter() { public void documentOpened(Controller controller) { updatePageLayout(); } }); }
From source file:com.google.code.twisty.Twisty.java
/** Have our activity manage and persist dialogs, showing and hiding them */ @Override//from ww w. ja v a2s . c o m protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ENTER_WRITEFILE: LayoutInflater factory = LayoutInflater.from(this); final View textEntryView = factory.inflate(R.layout.save_file_prompt, null); final EditText et = (EditText) textEntryView.findViewById(R.id.savefile_entry); return new AlertDialog.Builder(Twisty.this).setTitle("Write to file").setView(textEntryView) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { savefile_path = savegame_dir + "/" + et.getText().toString(); // Directly modify the message-object passed to us by the terp thread: dialog_message.path = savefile_path; // Wake up the terp thread again synchronized (glkLayout) { glkLayout.notify(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // This makes op_save() fail. dialog_message.path = ""; // Wake up the terp thread again synchronized (glkLayout) { glkLayout.notify(); } } }).create(); case DIALOG_ENTER_READFILE: restoredialog = new Dialog(Twisty.this); restoredialog.setContentView(R.layout.restore_file_prompt); restoredialog.setTitle("Read a file"); android.widget.RadioGroup rg = (RadioGroup) restoredialog.findViewById(R.id.radiomenu); updateRestoreRadioButtons(rg); android.widget.Button okbutton = (Button) restoredialog.findViewById(R.id.restoreokbutton); okbutton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { android.widget.RadioGroup rg = (RadioGroup) restoredialog.findViewById(R.id.radiomenu); int checkedid = rg.getCheckedRadioButtonId(); if (rg.getChildCount() == 0) { // no saved games: FAIL savefile_path = ""; } else if (checkedid == -1) { // no game selected RadioButton firstbutton = (RadioButton) rg.getChildAt(0); // default to first game savefile_path = savegame_dir + "/" + firstbutton.getText(); } else { RadioButton checkedbutton = (RadioButton) rg.findViewById(checkedid); savefile_path = savegame_dir + "/" + checkedbutton.getText(); } dismissDialog(DIALOG_ENTER_READFILE); // Return control to the z-machine thread dialog_message.path = savefile_path; synchronized (glkLayout) { glkLayout.notify(); } } }); android.widget.Button cancelbutton = (Button) restoredialog.findViewById(R.id.restorecancelbutton); cancelbutton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismissDialog(DIALOG_ENTER_READFILE); // Return control to the z-machine thread dialog_message.path = ""; synchronized (glkLayout) { glkLayout.notify(); } } }); return restoredialog; case DIALOG_CHOOSE_GAME: choosegamedialog = new Dialog(Twisty.this); choosegamedialog.setContentView(R.layout.choose_game_prompt); choosegamedialog.setTitle("Choose Game"); android.widget.RadioGroup zrg = (RadioGroup) choosegamedialog.findViewById(R.id.game_radiomenu); updateGameRadioButtons(zrg); zrg.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { dismissDialog(DIALOG_CHOOSE_GAME); String path = (String) game_paths.get(checkedId); if (path != null) { stopTerp(); startTerp(path); } } }); return choosegamedialog; case DIALOG_CANT_SAVE: return new AlertDialog.Builder(Twisty.this).setTitle("Cannot Access Games") .setMessage("Twisty Games folder is not available on external media.") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // A path of "" makes op_save() fail. dialog_message.path = ""; // Wake up the terp thread again synchronized (glkLayout) { glkLayout.notify(); } } }).create(); case DIALOG_NO_SDCARD: return new AlertDialog.Builder(Twisty.this).setTitle("No External Media") .setMessage("Cannot find sdcard or other media.") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }).create(); } return null; }
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
public void onClickSearch(View view) { final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null); final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText); final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup); new AlertDialog.Builder(EditFeedActivity.this) // .setIcon(R.drawable.action_search) // .setTitle(R.string.feed_search) // .setView(dialogView) // .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() { @Override// w ww . j av a 2 s. com public void onClick(DialogInterface dialog, int which) { if (searchText.getText().length() > 0) { String tmp = searchText.getText().toString(); try { tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8); } catch (UnsupportedEncodingException ignored) { } final String text = tmp; switch (radioGroup.getCheckedRadioButtonId()) { case R.id.byWebSearch: final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this); pd.setMessage(getString(R.string.loading)); pd.setCancelable(true); pd.setIndeterminate(true); pd.show(); getLoaderManager().restartLoader(1, null, new LoaderCallbacks<ArrayList<HashMap<String, String>>>() { @Override public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) { return new GetFeedSearchResultsLoader(EditFeedActivity.this, text); } @Override public void onLoadFinished( Loader<ArrayList<HashMap<String, String>>> loader, final ArrayList<HashMap<String, String>> data) { pd.cancel(); if (data == null) { Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); } else if (data.isEmpty()) { Toast.makeText(EditFeedActivity.this, R.string.no_result, Toast.LENGTH_SHORT).show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder( EditFeedActivity.this); builder.setTitle(R.string.feed_search); // create the grid item mapping String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC }; int[] to = new int[] { android.R.id.text1, android.R.id.text2 }; // fill in the grid_item layout SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data, R.layout.item_search_result, from, to); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mNameEditText.setText( data.get(which).get(FEED_SEARCH_TITLE)); mUrlEditText.setText( data.get(which).get(FEED_SEARCH_URL)); } }); builder.show(); } } @Override public void onLoaderReset( Loader<ArrayList<HashMap<String, String>>> loader) { } }).forceLoad(); break; case R.id.byTopic: mUrlEditText.setText("http://www.faroo.com/api?q=" + text + "&start=1&length=10&l=en&src=news&f=rss"); break; case R.id.byYoutube: mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "") + "/videos.rss"); break; } } } }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:co.nerdart.ourss.activity.EditFeedActivity.java
public void onClickSearch(View view) { final View dialogView = getLayoutInflater().inflate(R.layout.search_feed, null); final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText); final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup); new AlertDialog.Builder(EditFeedActivity.this) // .setIcon(R.drawable.action_search) // .setTitle(R.string.feed_search) // .setView(dialogView) // .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a 2 s .c o m*/ public void onClick(DialogInterface dialog, int which) { if (searchText.getText().length() > 0) { String tmp = searchText.getText().toString(); try { tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8); } catch (UnsupportedEncodingException ignored) { } final String text = tmp; switch (radioGroup.getCheckedRadioButtonId()) { case R.id.byWebSearch: final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this); pd.setMessage(getString(R.string.loading)); pd.setCancelable(true); pd.setIndeterminate(true); pd.show(); getLoaderManager().restartLoader(1, null, new LoaderCallbacks<ArrayList<HashMap<String, String>>>() { @Override public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) { return new GetFeedSearchResultsLoader(EditFeedActivity.this, text); } @Override public void onLoadFinished( Loader<ArrayList<HashMap<String, String>>> loader, final ArrayList<HashMap<String, String>> data) { pd.cancel(); if (data == null) { Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO); } else if (data.isEmpty()) { Crouton.makeText(EditFeedActivity.this, R.string.no_result, Style.INFO); } else { AlertDialog.Builder builder = new AlertDialog.Builder( EditFeedActivity.this); builder.setTitle(R.string.feed_search); // create the grid item mapping String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC }; int[] to = new int[] { android.R.id.text1, android.R.id.text2 }; // fill in the grid_item layout SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data, R.layout.search_result_item, from, to); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mNameEditText.setText( data.get(which).get(FEED_SEARCH_TITLE)); mUrlEditText.setText( data.get(which).get(FEED_SEARCH_URL)); } }); builder.show(); } } @Override public void onLoaderReset( Loader<ArrayList<HashMap<String, String>>> loader) { } }).forceLoad(); break; case R.id.byTopic: mUrlEditText.setText("http://www.faroo.com/api?q=" + text + "&start=1&length=10&l=en&src=news&f=rss"); break; case R.id.byYoutube: mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "") + "/videos.rss"); break; } } } }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:mp.teardrop.LibraryActivity.java
@Override public void onDismiss(DialogInterface dialog) { ListView list = ((AlertDialog) dialog).getListView(); // subtract 1 for header int which = list.getCheckedItemPosition() - 1; RadioGroup group = (RadioGroup) list.findViewById(R.id.sort_direction); if (group.getCheckedRadioButtonId() == R.id.descending) { which = ~which;//from ww w. j a v a 2 s .c o m } mPagerAdapter.setSortMode(which); }
From source file:reportsas.com.formulapp.Formulario.java
public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) { int id;/*from w ww. j av a 2s . c om*/ int tipo_pregunta = preg.getTipoPregunta(); LinearLayout pregunta; TextView textView; TextView textAyuda; switch (tipo_pregunta) { case 1: id = R.layout.pregunta_texto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloPregunta); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 2: id = R.layout.pregunta_multitexto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo); textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 3: id = R.layout.pregunta_seleccion; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica); ArrayList<OpcionForm> opciones = preg.getOpciones(); final ArrayList<RadioButton> rb = new ArrayList<RadioButton>(); for (int i = 0; i < opciones.size(); i++) { OpcionForm opcion = opciones.get(i); rb.add(new RadioButton(this)); rg.addView(rb.get(i)); rb.get(i).setText(opcion.getEtInicial()); } final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int radioButtonID = group.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID); respt.setText(radioButton.getText()); } }); break; case 4: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones2 = preg.getOpciones(); final EditText ediOtros = new EditText(this); ArrayList<CheckBox> cb = new ArrayList<CheckBox>(); for (int i = 0; i < opciones2.size(); i++) { OpcionForm opcion = opciones2.get(i); cb.add(new CheckBox(this)); pregunta.addView(cb.get(i)); cb.get(i).setText(opcion.getEtInicial()); if (opcion.getEditble().equals("S")) { ediOtros.setEnabled(false); ediOtros.setId(R.id.edtTexto); pregunta.addView(ediOtros); cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { ediOtros.setEnabled(true); } else { ediOtros.setText(""); ediOtros.setEnabled(false); } } }); } } TextView spacio = new TextView(this); spacio.setText(" "); spacio.setVisibility(View.INVISIBLE); pregunta.addView(spacio); break; case 5: id = R.layout.pregunta_escala; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloEscala); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial); TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal); OpcionForm opci = preg.getOpciones().get(0); etInicial.setText(opci.getEtInicial()); etFinal.setText(opci.getEtFinal()); final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala); RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala); rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion())); rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { respEscala.setText("" + Math.round(rating)); } }); break; case 6: id = R.layout.pregunta_lista; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloLista); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones3 = preg.getOpciones(); //Creamos la lista LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>(); //La poblamos con los ejemplos for (int i = 0; i < opciones3.size(); i++) { opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial())); } //Creamos el adaptador*/ Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado); ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this, android.R.layout.simple_spinner_item, opcn); //Aadimos el layout para el men y se lo damos al spinner spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); listad.setAdapter(spinner_adapter); break; case 7: id = R.layout.pregunta_tabla; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloTabla); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones); ArrayList<OpcionForm> opciones4 = preg.getOpciones(); ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>(); for (int i = 0; i < opciones4.size(); i++) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null); RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow); final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>(); ArrayList<Valor> valoresT = opciones4.get(i).getValores(); for (int k = 0; k < valoresT.size(); k++) { RadioButton rb_nuevo = new RadioButton(this); rb_nuevo.setText(valoresT.get(k).getDescripcion()); tg_valores.addView(rb_nuevo); valoOpc.add(rb_nuevo); } ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial()); tba.addView(row); } TextView espacio = new TextView(this); espacio.setText(" "); pregunta.addView(espacio); break; case 8: id = R.layout.pregunta_fecha; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloFecha); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 9: id = R.layout.pregunta_hora; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloHora); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; default: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; } return pregunta; }
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 w w w.j ava2s . c om*/ 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); }