@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (haveInternet(this)) { setContentView(R.layout.view_plan); ActionBar aBar = getActionBar(); Resources res = getResources(); Drawable actionBckGrnd = res.getDrawable(R.drawable.actionbar); aBar.setBackgroundDrawable(actionBckGrnd); aBar.setTitle(" Plan Information"); SharedPreferences prefs = getSharedPreferences("Prefs", Activity.MODE_PRIVATE); String userName = prefs.getString("userName", "New User"); TextView userNameValue = (TextView) findViewById(R.id.welcomeViewPlanLabel); userNameValue.setText(userName + ", here's selected plan details!"); selectedGroup = prefs.getString("selectedGroup", "New User"); selectedPlan = prefs.getString("selectedPlan", "New User"); TextView selectedPlanValue = (TextView) findViewById(R.id.viewPlanTitle); selectedPlanValue.setText(" " + selectedPlan); String searchQuery = "/fetchPlan?planName=" + selectedPlan.replace(" ", "%20"); String phone = prefs.getString("phone", ""); WebServiceClient restClient = new WebServiceClient(this); restClient.execute(new String[] {searchQuery, phone}); } else { Intent intent = new Intent(this, RetryActivity.class); startActivity(intent); } }
/** Called when the user clicks the rsvp plan button */ public void rsvpPlan(View view) { Button rsvpPlanButton = (Button) findViewById(R.id.rsvpPlanButton); rsvpPlanButton.setTextColor(getResources().getColor(R.color.click_button_2)); SharedPreferences prefs = getSharedPreferences("Prefs", Activity.MODE_PRIVATE); String phone = prefs.getString("phone", ""); String selectedPlan = prefs.getString("selectedPlan", ""); String rsvp = "no"; if (rsvpPlanButton.getText().equals("Say Yes")) { rsvp = "yes"; } String updateQuery = "/rsvpPlan?planName=" + selectedPlan.replace(" ", "%20") + "&phone=" + phone + "&rsvp=" + rsvp; WebServiceClient restClient = new WebServiceClient(this); restClient.execute(new String[] {updateQuery, phone}); }
protected Void doInBackground(Context... args) { // WebServiceClient.SendDummySurvey(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US); while (true) { try { ArrayList<PollingStation> toDelete = new ArrayList<PollingStation>(); for (PollingStation ps : FinishedListFragment.psArray) { // Survey survey = SurveyAdapterBuilder.surveys.get(ps.id); Survey survey = ps.survey; if (ps.transmitted == false) { AnswersVector av = new AnswersVector(); if (survey.pages != null) { for (ArrayList<Question> page : survey.pages) { for (Question q : page) { if (q.dependency.equals("") && q.answer != null && !q.answer.equals("")) { if (q.getClass().toString().contains("MultiOption")) { String answers[] = q.answer.split("/"); for (String answer : answers) { String values[] = answer.split("-"); av.setProperty(0, new StringVector(values[0], values[1])); } } else av.setProperty(0, new StringVector(q.name, q.answer)); } } } } // ADDING ALL THE DEPENDENCIES if (survey.dependentSurveys != null) { for (int k = 0; k < survey.dependentSurveys.size(); k++) { Survey child = survey.dependentSurveys.get(k); for (ArrayList<Question> page : child.pages) { for (Question q : page) { if (q.answer != null && !q.answer.equals("")) av.setProperty(0, new StringVector(q.name, q.answer)); } } } } // String prueba = ps.survey.startDate; if (WebServiceClient.SendSurvey( args[0], new DataSurvey( LoginActivity.login, ps.survey.startDate, format.format(new Date()), survey.parentId, av)) == true) { toDelete.add(ps); } } } if (toDelete.size() > 0) { for (final PollingStation ps : toDelete) { myHandler.post( new Runnable() { @Override public void run() { FinishedListFragment.SetAsTransmitted(ps); } }); } } Thread.sleep(10000); } catch (Exception e) { e.printStackTrace(); } } }
@Override protected void init() { super.init(); root = target.path("/coupon"); }