public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case 1: setDefaultValues(); break; case Constants.LOGOUT: CoreComponent.LOGOUT_CALL = true; Log.i("logging out", "here"); if (!NetworkCallRequirements.isNetworkAvailable(this)) { Log.i("got it", "the network info"); ToastUI.showToast(getApplicationContext(), getString(string.networkunavailable)); } else { Log.i(getClass().getSimpleName(), "logging out"); ProgressDialogHelper.showProgressDialog(this, "", getString(string.loading)); Log.i(getClass().getSimpleName(), URLList.getURL(Constants.LOGOUT)); CoreComponent.logout(this); } break; case 2: Intent intent = new Intent(getApplicationContext(), PasswordReset.class); Log.i(getClass().getSimpleName(), "Starting activity for result"); startActivity(intent); break; } return true; }
@SuppressWarnings("unchecked") private void getSealedValues() { // Requirement - 1 . sealed_lables, 2. // sealed_values values = new ArrayList<String>(); sealed_labels.clear(); if (DamageClaimApp.sealed_labels != null && DamageClaimApp.sealed_values != null) { values = (ArrayList<String>) DamageClaimApp.sealed_values.clone(); sealed_labels = (ArrayList<String>) DamageClaimApp.sealed_labels.clone(); return; } if (!NetworkCallRequirements.isNetworkAvailable(this)) { Log.i("got it", "the network info"); ToastUI.showToast(getApplicationContext(), getString(string.networkunavailable)); return; } ProgressDialogHelper.showProgressDialog(this, "", getString(string.loading)); CoreComponent.processRequest(Constants.GET, Constants.HELPDESK, this, createRequest()); Utility.waitForThread(); if (this.response == null) { values = null; return; } if (this.response != null) { try { object = new JSONObject(response); array = object.getJSONArray("result"); for (int i = 0; i < array.length(); i++) { if (array.getJSONObject(i).getString("label").equalsIgnoreCase("yes")) values.add(getString(string.sealed_yes)); if (array.getJSONObject(i).getString("label").equalsIgnoreCase("no")) values.add(getString(string.sealed_no)); sealed_labels.add(array.getJSONObject(i).getString("label")); Log.i("sealed label", sealed_labels.get(i)); Log.i(getClass().getSimpleName(), values.get(i)); } } catch (Exception e) { e.printStackTrace(); } DamageClaimApp.sealed_labels = (ArrayList<String>) sealed_labels.clone(); DamageClaimApp.sealed_values = (ArrayList<String>) values.clone(); } }
@SuppressWarnings("unchecked") private void getPlaceValues() // To be fetched from URL { values = new ArrayList<String>(); if (DamageClaimApp.places_values != null) { values = (ArrayList<String>) DamageClaimApp.places_values.clone(); return; } if (!NetworkCallRequirements.isNetworkAvailable(this)) { Log.i("got it", "the network info"); ToastUI.showToast(getApplicationContext(), getString(string.networkunavailable)); return; } ProgressDialogHelper.showProgressDialog(this, "", getString(string.loading)); CoreComponent.processRequest(Constants.GET, Constants.HELPDESK, this, createRequest()); Utility.waitForThread(); if (this.response == null) { values = null; return; } try { object = new JSONObject(this.response); array = object.getJSONArray("result"); for (int i = 0; i < array.length(); i++) { values.add(array.getJSONObject(i).getString("value")); } } catch (Exception e) { Log.i(getClass().getSimpleName(), "---------------------------------------"); e.printStackTrace(); } DamageClaimApp.places_values = (ArrayList<String>) values.clone(); }
public void onClick(View v) { if (v == trailertype) { selection = Constants.TRAILER_TYPE; getTrailerTypeValues(); id.setText(getString(string.homepage_textview_ID)); new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_trailertype), values, Constants.HOMEPAGE); } if (v == id) { selection = Constants.ID; getIDValues(); if (this.response != null || values != null) new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_ID), values, Constants.HOMEPAGE); } if (v == place) { selection = Constants.PLACE; getPlaceValues(); if (this.response != null || values != null) new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_place), values, Constants.HOMEPAGE); } if (v == sealed) { selection = Constants.SEALED; getSealedValues(); if (this.response != null || values != null) new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_sealed), values, Constants.HOMEPAGE); } if (v == plates) { selection = Constants.PLATES; getPlateValues(); if (this.response != null || values != null) new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_plates), values, Constants.HOMEPAGE); } if (v == straps) { selection = Constants.STRAPS; getStrapsValues(); if (this.response != null || values != null) new ListViewDialog( this, layout.listviewdialog, getString(string.homepage_textview_straps), values, Constants.HOMEPAGE); } if (v == damages) { if (performChecks()) { Intent intent = new Intent(getApplicationContext(), ReportDamage.class); startActivity(intent); } else ToastUI.showToast(getApplicationContext(), getString(string.enterfields)); } if (v == submit) { if (!performChecks()) { ToastUI.showToast(getApplicationContext(), getString(string.enterfields)); return; } selection = Constants.SUBMIT; if (!NetworkCallRequirements.isNetworkAvailable(this)) { Log.i("got it", "the network info"); ToastUI.showToast(getApplicationContext(), getString(string.networkunavailable)); return; } ProgressDialogHelper.showProgressDialog(this, "", getString(string.loading)); HTTPRequest request = CoreComponent.getRequest(Constants.HELPDESK_URL); request.addParam( "ticket_title", getString(string.surveyticketby) + CoreComponent.getUserinfo().getContactname()); request.addParam("ticketstatus", getClosedTicketStatusValue()); request.addParam("trailerid", CoreComponent.trailerid); request.addParam("reportdamage", getReportDamageValueNo()); /* * need to check the sealed condition what about trailer type? */ if (DamageClaimApp.place != null) request.addParam("damagereportlocation", DamageClaimApp.place); if (DamageClaimApp.sealed != null) request.addParam("sealed", DamageClaimApp.sealed); if (DamageClaimApp.sealed.equalsIgnoreCase(getString(string.sealed_no))) { if (DamageClaimApp.straps != null) request.addParam("straps", DamageClaimApp.straps); if (DamageClaimApp.plates != null) request.addParam("plates", DamageClaimApp.plates); } CoreComponent.processRequest(Constants.POST, Constants.HELPDESK, this, request); Utility.waitForThread(); if (this.response != null) { ToastUI.showToast(getApplicationContext(), getString(string.submit_survey)); setDefaultValues(); } } }
@SuppressWarnings("unchecked") private void getIDValues() // To be fetched from URL { values = new ArrayList<String>(); values.clear(); if (DamageClaimApp.id_rented != null && DamageClaimApp.id_own != null) { if (Utility.getParsedString(trailertype.getText().toString()) .equalsIgnoreCase(getString(string.trailer_type_own))) values = (ArrayList<String>) DamageClaimApp.id_own.clone(); else values = (ArrayList<String>) DamageClaimApp.id_rented.clone(); return; } if (!NetworkCallRequirements.isNetworkAvailable(this)) { Log.i("got it", "the network info"); ToastUI.showToast(getApplicationContext(), getString(string.networkunavailable)); return; } ProgressDialogHelper.showProgressDialog(this, "", getString(string.loading)); CoreComponent.processRequest(Constants.GET, Constants.ASSETS, this, createRequest()); DamageClaimApp.id_own = new ArrayList<String>(); DamageClaimApp.id_rented = new ArrayList<String>(); Utility.waitForThread(); if (this.response == null) { values = null; return; } if (this.response != null) { try { object = new JSONObject(response); array = object.getJSONArray("result"); for (int i = 0; i < array.length(); i++) { if (array.getJSONObject(i).getString("assetstatus").equalsIgnoreCase("In Service")) { if (array.getJSONObject(i).getString("trailertype").equalsIgnoreCase("own")) DamageClaimApp.id_own.add(array.getJSONObject(i).getString("assetname")); else DamageClaimApp.id_rented.add(array.getJSONObject(i).getString("assetname")); } } if (Utility.getParsedString(trailertype.getText().toString()) .equalsIgnoreCase(getString(string.trailer_type_own))) values = (ArrayList<String>) DamageClaimApp.id_own.clone(); else values = (ArrayList<String>) DamageClaimApp.id_rented.clone(); if (values == null) { Log.i(getClass().getSimpleName(), "values = null"); } } catch (Exception e) { e.printStackTrace(); } } }