List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects)
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public static AlertDialog getaddtextdialog(String title, final int itemnumber, Context ctx) { AlertDialog.Builder getaddtext = new AlertDialog.Builder(ctx); final LinearLayout linearlayout = new LinearLayout(ctx); linearlayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); linearlayout.setOrientation(LinearLayout.VERTICAL); final EditText nameet = new EditText(ctx); nameet.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView fontname = new TextView(ctx); fontname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final TextView colorname = new TextView(ctx); colorname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner fontsizespinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); final Spinner colorspinner = new Spinner(ctx); fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); List<String> fontsizelist = new ArrayList<String>(); for (int t = 1; t < 200; t++) { fontsizelist.add(u.s(t));//from w w w. ja v a 2 s.c o m } ArrayAdapter<String> fontsizearrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, fontsizelist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); List<String> colorlist = new ArrayList<String>(); { colorlist.add("RED"); colorlist.add("BLACK"); colorlist.add("BLUE"); colorlist.add("GREEN"); colorlist.add("WHITE"); colorlist.add("GRAY"); } ArrayAdapter<String> colorlistarrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview, colorlist); fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview); colorspinner.setAdapter(colorlistarrayadapter); fontsizespinner.setAdapter(fontsizearrayadapter); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, "25")); fontname.setText("Select Font Size"); fontname.setTextSize(20f); colorname.setText("Select Color"); colorname.setTextSize(20f); linearlayout.addView(nameet); linearlayout.addView(fontname); linearlayout.addView(fontsizespinner); linearlayout.addView(colorname); linearlayout.addView(colorspinner); if (!(itemnumber == view.i)) { nameet.setText(view.ITEMstring[itemnumber]); fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, u.s(view.ITEMfontsize[itemnumber]))); colorspinner.setSelection(getIndexofSpinner(colorspinner, u.s(view.ITEMfontcolor[itemnumber]))); } getaddtext.setView(linearlayout); getaddtext.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); getaddtext.setTitle(title); getaddtext.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub String string = nameet.getText().toString(); float fontsize = fontsizespinner.getSelectedItemPosition() + 1; //ITEMelcnumber[itemselectednumber]=u.i(string); int colpos = colorspinner.getSelectedItemPosition(); int[] col = new int[] { Color.RED, Color.BLACK, Color.BLUE, Color.GREEN, Color.WHITE, Color.GRAY }; int color = col[colpos]; Log.d("addtext", u.s((int) fontsize) + colpos + color); view.ITEMstring[itemnumber] = string; view.ITEMfontsize[itemnumber] = (int) fontsize; view.ITEMfontcolor[itemnumber] = color; view.itemname = string; view.fontsize = (int) fontsize; view.color = color; view.invalidate(); dialog.dismiss(); FloorPlanActivity.writeonedbitem(itemnumber); } }); return getaddtext.create(); }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
private void setModelSpinner(final Series series) { ArrayAdapter<String> adapter; if (series == null) { adapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_item, Helper.getEmptyStringList()); } else {// w ww. j a v a2 s . co m adapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_item, series.getModelNames()); } modelSpinner.setAdapter(adapter); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // ??? if (series != null && series.getModelNames().size() == 2) { modelSpinner.setSelection(1); } else { modelSpinner.setSelection(lastModelIndex); } lastModelIndex = 0; }
From source file:com.fvd.nimbus.BrowseActivity.java
@Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub if (!isInitNow) { ArrayList<HistoryItem> history = getHistoryItems(); /*m_arrHistoryItems.clear(); m_arrHistoryItems.addAll(history);*/ arrHistoryItems.clear();// www. j av a 2 s .com for (HistoryItem historyItem : history) { arrHistoryItems.add(historyItem.url); } //adapter.notifyDataSetChanged(); //urlField.setAdapter(new TextAdapter(ctx)); urlField.setAdapter( new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, arrHistoryItems)); } }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnHomeObjectFragmentCreated(View v) { // TODO Auto-generated method stub LinearLayout ll = (LinearLayout) v.findViewById(R.id.ingredient_categories_buttons); ll.removeAllViews();//from w w w .java 2 s. com String values[] = { "Combos", "Productos", "Ingredientes", "+Vendido", "Nuevo" }; for (int i = 0; i < values.length; i++) { Button btnTag = (Button) getLayoutInflater().inflate(R.layout.template_button, null); btnTag.setText((values[i])); btnTag.setId(i); btnTag.setOnClickListener(typeButtonClickListener); ll.addView(btnTag); } SharedPreferences defaultprefs = PreferenceManager.getDefaultSharedPreferences(mContext); boolean layouttables = defaultprefs.getBoolean("arrange_tables", false); itemsView = (GridView) v.findViewById(R.id.gridview); statusText = (TextView) v.findViewById(R.id.group_owner); deviceText = (TextView) v.findViewById(R.id.device_info); saleValue = (TextView) v.findViewById(R.id.sale_info); autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autocomplete_registrable); if (layouttables) { statusText.setVisibility(View.VISIBLE); //statusText.setText("No hay Mesa Seleccionada."); } else { statusText.setVisibility(View.INVISIBLE); statusText.setText(""); } updateSaleValue(); pagarButton = (Button) v.findViewById(R.id.pay_register); guardarButton = (Button) v.findViewById(R.id.save_register); pagarButton.setOnClickListener(payListener); guardarButton.setOnClickListener(saveListener); registerList = new ArrayList<Registrable>(); gridAdapter = new ImageAdapter(mContext, registerList, inflater, gridButtonListener); setGridContent(gridAdapter, comboList); ArrayList<String> registrables = new ArrayList<String>(); for (Registrable actual : allRegistrables) { registrables.add(actual.name); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, registrables); autoCompleteTextView.setAdapter(adapter); autoCompleteTextView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { String selection = (String) parent.getItemAtPosition(position); int pos = -1; for (int i = 0; i < allRegistrables.size(); i++) { if (allRegistrables.get(i).name.equalsIgnoreCase(selection)) { pos = i; break; } } if (pos > -1) { if (currentOrder.containsKey(allRegistrables.get(pos))) { currentOrder.put(allRegistrables.get(pos), currentOrder.get(allRegistrables.get(pos)) + 1); } else { currentOrder.put(allRegistrables.get(pos), 1); } makeTable(allRegistrables.get(pos).name); } else { Toast.makeText(mContext, "No Existe el tem", Toast.LENGTH_LONG).show(); } autoCompleteTextView.setText(""); autoCompleteTextView.setHint("Buscar tems para Registrar"); } }); autoCompleteTextView.setText(""); autoCompleteTextView.setHint("Buscar tems para Registrar"); // Tomar la tabla de la izquierda del home view table = (TableLayout) v.findViewById(R.id.my_table); makeTable("NA"); deviceText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mTCPPrint != null) { mTCPPrint.stopClient(); } new connectTask().execute(""); } }); }
From source file:knayi.delevadriver.JobDetailActivity.java
@Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); final long timestamp = System.currentTimeMillis(); final String token = sPref.getString(Config.TOKEN, null); switch (v.getId()) { case R.id.job_reject: if (job_reject.getText().toString().equals("Reject")) { MaterialDialog dialog = new MaterialDialog.Builder(this).titleColor(R.color.white) .customView(R.layout.reject_layout, true).positiveText("REJECT") .positiveColor(R.color.white).positiveColorRes(R.color.white).negativeText("CANCEL") .negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); if (!et_message.getText().toString().equals("")) { AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, et_message.getText().toString(), "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Job is successfully rejected", Toast.LENGTH_SHORT) .show(); dialog.dismiss(); //remove job id that is saved to use in locatin update sPref.edit().putString(Config.TOKEN_JOBID, null).commit(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); //check report service is alive //if alive stop service if (sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)) { Intent intentservice = new Intent(JobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(JobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); }/*from ww w . j a v a2s . c om*/ progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); et_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); } /*else{ final Dialog msgDialog = new Dialog(JobDetailActivity.this); msgDialog.setTitle("Why do u reject?"); msgDialog.setCancelable(true); msgDialog.setContentView(R.layout.custom_dialog_reason); final EditText message = (EditText) msgDialog.findViewById(R.id.messagebox); Button submit = (Button) msgDialog.findViewById(R.id.submitbutton); msgDialog.show(); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(message.getText().toString().equals("") && message.getText().toString().equals(null)){ Toast.makeText(getApplicationContext(), "Please input message to submit", Toast.LENGTH_SHORT).show(); }else{ msgDialog.dismiss(); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(token == null){ new SweetAlertDialog(JobDetailActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("") .setContentText("Please Login again!") .show(); finish(); startActivity(new Intent(JobDetailActivity.this, LoginActivity.class)); } else{ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, location, String.valueOf(timestamp), message.getText().toString(), new Callback<String>() { @Override public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); startActivity(new Intent(JobDetailActivity.this, TabMainActivity.class)); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); Toast.makeText(getApplicationContext(), "Something Went Wrong!", Toast.LENGTH_SHORT).show(); } }); } } } }); }*/ break; case R.id.job_bid: progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (token == null) { MaterialDialog dialog = new MaterialDialog.Builder(this) .customView(R.layout.custom_message_dialog, false).positiveText("OK") .positiveColor(R.color.white).positiveColorRes(R.color.white) .backgroundColorRes(R.color.primary).typeface("ciclefina.ttf", "ciclegordita.ttf").build(); dialog.show(); TextView txt_title = (TextView) dialog.findViewById(R.id.dialog_title); TextView txt_message = (TextView) dialog.findViewById(R.id.dialog_message); txt_title.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); txt_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); txt_title.setText("Please Login again!"); txt_message.setText("Server doesn't know this account!"); Intent intent = new Intent(JobDetailActivity.this, LoginActivity.class); startActivity(intent); finish(); } if (job_bid.getText().toString().equals("Bid")) { final long ts1 = System.currentTimeMillis(); Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } acceptJob(token, String.valueOf(ts1), ""); /*MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Estimate time of arrival to pick up point") .customView(R.layout.estimatetime_layout, true) .positiveText("BID") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .cancelable(false) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); if(!et_estimatetime.getText().toString().equals("")) { acceptJob(token, String.valueOf(ts1), et_estimatetime.getText().toString()); }else{ Toast.makeText(JobDetailActivity.this, "Please Input Fields!", Toast.LENGTH_SHORT).show(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); final EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); et_estimatetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar mcurrentTime = Calendar.getInstance(); int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY); int minute = mcurrentTime.get(Calendar.MINUTE); TimePickerDialog mTimePicker; mTimePicker = new TimePickerDialog(JobDetailActivity.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { et_estimatetime.setText( selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle("Select Time"); mTimePicker.show(); } });*/ } else if (job_bid.getText().toString().equals("Agree")) { AvaliableJobsAPI.getInstance().getService().agreeJob(jobitem.get_id(), token, "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Success", Toast.LENGTH_SHORT).show(); getDataFromServer(job_id); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } } }); } else if (job_bid.getText().toString().equals("Finished")) { MaterialDialog dialog = new MaterialDialog.Builder(this).titleColor(R.color.white) .customView(R.layout.custom_request_message_dialog, true).positiveText("SEND") .positiveColor(R.color.white).positiveColorRes(R.color.white).negativeText("CANCEL") .negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText request_secret_code = (EditText) dialog .findViewById(R.id.request_secret_code); /*EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg);*/ if (request_secret_code != null) { if (request_secret_code.getText().toString() != null && request_secret_code.getText().toString() != "") { Location mLastLocation = LocationServices.FusedLocationApi .getLastLocation(mGoogleApiClient); Long tsLong = System.currentTimeMillis(); String ts = tsLong.toString(); String location = "96,16"; if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } final long timestamp = System.currentTimeMillis(); JSONObject obj = new JSONObject(); try { obj.put("location", location); obj.put("timestamp", String.valueOf(timestamp)); obj.put("secret_code", request_secret_code.getText().toString()); obj.put("message", "");//request_msg.getText().toString()); } catch (JSONException e) { e.printStackTrace(); } String json = obj.toString(); try { TypedInput in = new TypedByteArray("application/json", json.getBytes("UTF-8")); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); AvaliableJobsAPI.getInstance().getService().jobDone(jobitem.get_id(), token, in, new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Message is sent successfully", Toast.LENGTH_SHORT).show(); sPref.edit().putString(Config.TOKEN_DELAY, null) .commit(); if (sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)) { Intent intentservice = new Intent( JobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); bitLayout.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { //Toast.makeText(JobDetailActivity.this, "Failed, Please Try Again!", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } }); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); /*EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg);*/ request_secret_code.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); /*request_msg.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL));*/ } break; case R.id.job_report: isFirstDialog = true; totalprice = Double.parseDouble(jobitem.get_price()); final MaterialDialog dialog = new MaterialDialog.Builder(this).customView(R.layout.report_layout, true) .positiveText("REPORT").positiveColor(R.color.white).positiveColorRes(R.color.white) .negativeText("CANCEL").negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf").callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); //CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); //Refrage if (!et_message.getText().toString().equals("") && et_message.getText().toString() != null) { if (cb_weight.isChecked() || cb_express.isChecked() || cb_refrig.isChecked()) { String message = "";//et_message.getText().toString(); if (cb_express.isChecked()) { message += "true,"; } else { message += "false,"; } if (cb_refrig.isChecked()) { message += "true,"; } else { message += "false,"; } if (cb_weight.isChecked()) { message += weightlist.get(sp_weight.getSelectedItemPosition()) + ","; } else { message += ","; } AvaliableJobsAPI.getInstance().getService().reportJob(jobitem.get_id(), token, message, "0", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Your report has successfully sent", Toast.LENGTH_SHORT) .show(); dialog.dismiss(); } @Override public void failure(RetrofitError error) { //Toast.makeText(JobDetailActivity.this, "Report is Failed", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(JobDetailActivity.this, "Please select report reason", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(JobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); final CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); //final CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); et_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_weight.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_express.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_refrig.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); if (jobitem.getIsExpress().equals("true")) { cb_express.setChecked(true); } if (jobitem.getIsRefrigerated().equals("true")) { cb_refrig.setChecked(true); } //final TextView tv_price = (TextView) dialog.findViewById(R.id.report_price_tag); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); sp_weight.setEnabled(false); //sp_type.setEnabled(false); //tv_price.setText("price " + jobitem.get_price()); sp_weight.setAdapter(new ArrayAdapter<String>(JobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, weightshowlist)); //sp_type.setAdapter(new ArrayAdapter<String>(JobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, new String[]{"Other", "Express", "Refrigerated"})); sp_weight.setSelection(weightpos); //sp_type.setSelection(typepos); sp_weight.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (!isFirstDialog) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } else { isFirstDialog = false; } /*if(cb_type.isChecked()){ totalprice += typepricelist.get(position); }*/ // tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); /*sp_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { totalprice = Double.parseDouble(jobitem.get_price()); if (!isFirstDialog) { totalprice += typepricelist.get(position); } else { isFirstDialog = false; } if (cb_weight.isChecked()) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } });*/ cb_weight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sp_weight.setEnabled(true); totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } else { sp_weight.setEnabled(false); totalprice -= weightPricelist.get(sp_weight.getSelectedItemPosition()); } //tv_price.setText("price " + String.valueOf(totalprice)); } }); /*cb_type.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_type.setEnabled(true); totalprice += typepricelist.get(sp_type.getSelectedItemPosition()); }else{ sp_type.setEnabled(false); totalprice -= typepricelist.get(sp_type.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } });*/ break; default: Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); break; } }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnInventoryObjectFragmentCreated(View v) { // llenar el spinner con los ingredientes disponibles inventoryTable = (TableLayout) v.findViewById(R.id.inventory_my_table); List<Ingredient> ingres = ingredientDatasource.getAllIngredient(); Spinner ingSpin = (Spinner) v.findViewById(R.id.inventory_ingredient_spinner); List<String> nombres = new ArrayList<String>(); String nombreActual = ""; for (Ingredient current : ingres) { String name = current.getName().trim().toLowerCase(Locale.getDefault()); if (!nombreActual.equals(name)) { nombreActual = name;/* w w w . jav a 2 s. c o m*/ nombres.add(nombreActual); } } ArrayAdapter<String> adapt = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_single_choice, nombres); ingSpin.setAdapter(adapt); ingSpin.setOnItemSelectedListener(ingSpinListener); }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnOrderFomrFragmentCreatedListener(View v) { Spinner addToOpenTable = (Spinner) v.findViewById(R.id.open_tables_add_order); TextView title = (TextView) v.findViewById(R.id.add_toopentable_title); if (openTables.size() > 0) { title.setVisibility(View.VISIBLE); addToOpenTable.setVisibility(View.VISIBLE); ArrayList<String> nameTables = new ArrayList<String>(); nameTables.add("No, es una mesa nueva."); for (CurrentTable<Table, Integer> current : openTables) { nameTables.add(current.getTable().getName()); }/*from www .j a va2 s .c o m*/ ArrayAdapter<String> adapter = new ArrayAdapter<String>(Initialactivity.this, android.R.layout.simple_spinner_item, nameTables); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); addToOpenTable.setAdapter(adapter); addToOpenTable.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { int pos = position - 1; currentSelectedAddTable = pos; if (pos > -1) currentTable = openTables.get(pos); } @Override public void onNothingSelected(AdapterView<?> arg0) { //currentSelectedAddTable = -1; } }); } else { title.setVisibility(View.INVISIBLE); addToOpenTable.setVisibility(View.INVISIBLE); } }
From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java
/** * Helper function to add links from mVoteTargetThing to the button * @param linkButton Button that should open list of links *//* w w w.ja va2 s. c o m*/ private void linkToEmbeddedURLs(Button linkButton) { final ArrayList<String> urls = new ArrayList<String>(); final ArrayList<MarkdownURL> vtUrls = mVoteTargetThing.getUrls(); int urlsCount = vtUrls.size(); for (int i = 0; i < urlsCount; i++) { urls.add(vtUrls.get(i).url); } if (urlsCount == 0) { linkButton.setEnabled(false); } else { linkButton.setEnabled(true); linkButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_COMMENT_CLICK); ArrayAdapter<MarkdownURL> adapter = new ArrayAdapter<MarkdownURL>(CommentsListActivity.this, android.R.layout.select_dialog_item, vtUrls) { public View getView(int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { tv = (TextView) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(android.R.layout.select_dialog_item, null); } else { tv = (TextView) convertView; } String url = getItem(position).url; String anchorText = getItem(position).anchorText; if (Constants.LOGGING) Log.d(TAG, "links url=" + url + " anchorText=" + anchorText); Drawable d = null; try { d = getPackageManager() .getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (NameNotFoundException ignore) { } if (d != null) { d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight()); tv.setCompoundDrawablePadding(10); tv.setCompoundDrawables(d, null, null, null); } final String telPrefix = "tel:"; if (url.startsWith(telPrefix)) { url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length())); } if (anchorText != null) tv.setText(Html.fromHtml( "<span>" + anchorText + "</span><br /><small>" + url + "</small>")); else tv.setText(Html.fromHtml(url)); return tv; } }; AlertDialog.Builder b = new AlertDialog.Builder( new ContextThemeWrapper(CommentsListActivity.this, mSettings.getDialogTheme())); DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() { public final void onClick(DialogInterface dialog, int which) { if (which >= 0) { Common.launchBrowser(CommentsListActivity.this, urls.get(which), Util.createThreadUri(getOpThingInfo()).toString(), false, false, mSettings.isUseExternalBrowser(), mSettings.isSaveHistory()); } } }; b.setTitle(R.string.select_link_title); b.setCancelable(true); b.setAdapter(adapter, click); b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public final void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); b.show(); } }); } }
From source file:com.example.sensingapp.SensingApp.java
public void show_screen1() { int nIndex = -1; setContentView(R.layout.screen_1_user_project); m_rdgpProjectNameType = (RadioGroup) findViewById(R.id.RdGpProjectNameType); m_rdProjectNameType_New = (RadioButton) findViewById(R.id.RdProjectNameType_New); m_rdProjectNameType_Existing = (RadioButton) findViewById(R.id.RdProjectNameType_Existing); m_rdgpUsernameType = (RadioGroup) findViewById(R.id.RdGpUsernameType); m_rdUsernameType_New = (RadioButton) findViewById(R.id.RdUsernameType_New); m_rdUsernameType_Existing = (RadioButton) findViewById(R.id.RdUsernameType_Existing); m_etProjectName_New = (EditText) findViewById(R.id.etProjectNameNew); m_etUsername_New = (EditText) findViewById(R.id.etUsernameNew); m_spnScreen1_ExistingProjectName = (Spinner) findViewById(R.id.spnSelectExistingProjectName); m_spnScreen1_ExistingUsername = (Spinner) findViewById(R.id.spnSelectExistingUsername); m_btnScreen1_Next = (Button) findViewById(R.id.Screen1_Next); m_btnScreen1_Next.setOnClickListener(m_btnScreen1_Next_Listener); m_btnScreen1_Upload = (Button) findViewById(R.id.btScreen1_Upload); m_btnScreen1_Upload.setOnClickListener(m_btnScreen1_Upload_Listener); m_adpExistingProjectName = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m_lstExistingProjectName);//from w ww . j ava 2 s . co m m_adpExistingProjectName.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); m_spnScreen1_ExistingProjectName.setAdapter(m_adpExistingProjectName); m_adpExistingUsername = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m_lstExistingUsername); m_adpExistingUsername.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); m_spnScreen1_ExistingUsername.setAdapter(m_adpExistingUsername); if (m_nProjectNameType == 0) { m_rdProjectNameType_New.setChecked(true); if (m_sProjectName.length() > 0) { m_etProjectName_New.setText(m_sProjectName); } } else if (m_nProjectNameType == 1) { m_rdProjectNameType_Existing.setChecked(true); if (m_lstExistingProjectName.size() > 0) { nIndex = m_lstExistingProjectName.indexOf(m_sProjectName); if (nIndex != -1) { m_spnScreen1_ExistingProjectName.setSelection(nIndex); } } } if (m_nUsernameType == 0) { m_rdUsernameType_New.setChecked(true); if (m_sUsername.length() > 0) { m_etUsername_New.setText(m_sUsername); } } else if (m_nUsernameType == 1) { m_rdUsernameType_Existing.setChecked(true); if (m_lstExistingUsername.size() > 0) { nIndex = m_lstExistingUsername.indexOf(m_sUsername); if (nIndex != -1) { m_spnScreen1_ExistingUsername.setSelection(nIndex); } } } }
From source file:com.example.sensingapp.SensingApp.java
public void show_screen2() { int i;/*from w w w . j a v a2 s. c om*/ Location location = null; setContentView(R.layout.screen_2_sensors); m_chkAccl = (CheckBox) findViewById(R.id.chkAccl); m_chkLinearAccl = (CheckBox) findViewById(R.id.chkLinearAccl); m_chkGravity = (CheckBox) findViewById(R.id.chkGravity); m_chkGyro = (CheckBox) findViewById(R.id.chkGyro); m_chkOrient = (CheckBox) findViewById(R.id.chkOrient); m_chkMagnet = (CheckBox) findViewById(R.id.chkMagnetic); m_chkLight = (CheckBox) findViewById(R.id.chkLight); m_chkBarometer = (CheckBox) findViewById(R.id.chkBarometer); m_chkMic = (CheckBox) findViewById(R.id.chkMic); m_chkCellular = (CheckBox) findViewById(R.id.chkCellular); m_chkGPS = (CheckBox) findViewById(R.id.chkGPS); m_chkWifi = (CheckBox) findViewById(R.id.chkWifi); m_chkAccl.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkLinearAccl.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkGravity.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkGyro.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkOrient.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkMagnet.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkLight.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkBarometer.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkMic.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkCellular.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkGPS.setOnCheckedChangeListener(m_chkSensorEnableListener); m_chkWifi.setOnCheckedChangeListener(m_chkSensorEnableListener); m_spnScreen2_WiFiScanSpeed = (Spinner) findViewById(R.id.Screen2_spnWiFiScanSpeed); m_adpWiFiScanSpeed = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m_arrsWiFiScanSpeed); m_adpWiFiScanSpeed.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); m_spnScreen2_WiFiScanSpeed.setAdapter(m_adpWiFiScanSpeed); m_spnScreen2_WiFiScanSpeed.setSelection(m_nWifiScanSpeedIndex); m_rdgpSensor = (RadioGroup) findViewById(R.id.RdGpSensor); m_rdSensorAccl = (RadioButton) findViewById(R.id.RdSensor_Accl); m_rdSensorLinearAccl = (RadioButton) findViewById(R.id.RdSensor_LinearAccl); m_rdSensorGravity = (RadioButton) findViewById(R.id.RdSensor_Gravity); m_rdSensorGyro = (RadioButton) findViewById(R.id.RdSensor_Gyro); m_rdSensorOrient = (RadioButton) findViewById(R.id.RdSensor_Orient); m_rdSensorMagnet = (RadioButton) findViewById(R.id.RdSensor_Magnetic); m_rdSensorLight = (RadioButton) findViewById(R.id.RdSensor_Light); m_rdSensorBarometer = (RadioButton) findViewById(R.id.RdSensor_Barometer); m_rdgpSensorMode = (RadioGroup) findViewById(R.id.RdGpSensorMode); m_rdSensorModeFastest = (RadioButton) findViewById(R.id.RdSensorMode_Fastest); m_rdSensorModeGame = (RadioButton) findViewById(R.id.RdSensorMode_Game); m_rdSensorModeNormal = (RadioButton) findViewById(R.id.RdSensorMode_Normal); m_rdSensorModeUI = (RadioButton) findViewById(R.id.RdSensorMode_UI); m_rdgpSensor.setOnCheckedChangeListener(m_rdgpSensorListener); m_rdgpSensorMode.setOnCheckedChangeListener(m_rdgpSensorModeListener); configSensorOptionStatus(); m_mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (m_mainWifi.getWifiState() == WifiManager.WIFI_STATE_ENABLED) { m_blnWifiSignalEnabled = true; } else { m_blnWifiSignalEnabled = false; m_chkWifi.setEnabled(false); } this.registerReceiver(m_brcvWifiStateChangedReceiver, new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION)); m_locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); m_blnGPSSignalEnabled = m_locManager.isProviderEnabled(m_sGPSProvider); if ((m_locManager != null) && (m_blnGPSSignalEnabled == true)) { location = m_locManager.getLastKnownLocation(m_sGPSProvider); if (location != null) { float fLat = (float) (location.getLatitude()); float fLng = (float) (location.getLongitude()); if (location.hasAltitude()) { float fAlt = (float) (location.getAltitude()); } } } m_btnScreen2_Back = (Button) findViewById(R.id.btScreen2_Back); m_btnScreen2_Back.setOnClickListener(m_btnScreen2_Back_Listener); m_btnScreen2_Next = (Button) findViewById(R.id.btScreen2_Next); m_btnScreen2_Next.setOnClickListener(m_btnScreen2_Next_Listener); /* No sensor is installed, disable other widgets and show information to user */ if ((m_blnOrientPresent == false) && (m_blnGyroPresent == false) && (m_blnAcclPresent == false) && (m_blnLinearAcclPresent == false) && (m_blnGravityPresent == false) && (m_blnMagnetPresent == false) && (m_blnLightPresent == false) && (m_blnBarometerPresent == false)) { m_rdSensorModeFastest.setEnabled(false); m_rdSensorModeGame.setEnabled(false); m_rdSensorModeNormal.setEnabled(false); m_rdSensorModeUI.setEnabled(false); } if (m_blnAcclEnabled == true) { m_chkAccl.setChecked(true); } if (m_blnLinearAcclEnabled == true) { m_chkLinearAccl.setChecked(true); } if (m_blnGravityEnabled == true) { m_chkGravity.setChecked(true); } if (m_blnGyroEnabled == true) { m_chkGyro.setChecked(true); } if (m_blnOrientEnabled == true) { m_chkOrient.setChecked(true); } if (m_blnMagnetEnabled == true) { m_chkMagnet.setChecked(true); } if (m_blnLightEnabled == true) { m_chkLight.setChecked(true); } if (m_blnBarometerEnabled == true) { m_chkBarometer.setChecked(true); } if (m_blnMicEnabled == true) { m_chkMic.setChecked(true); } if (m_blnCellularEnabled == true) { m_chkCellular.setChecked(true); } if (m_blnGPSEnabled == true) { m_chkGPS.setChecked(true); } if (m_blnWifiEnabled == true) { m_chkWifi.setChecked(true); } Settings.System.putInt(getContentResolver(), Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_NEVER); }