Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. simpleCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
  2. @Override
  3. public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
  4. // display the selected date by using a toast
  5. int y = year;
  6. int m = month + 1;
  7. int d = dayOfMonth;
  8. final String date = d + "/" + m + "/" + y;
  9. final ProgressDialog loading = ProgressDialog.show(Daily_Attendance.this, "Processing...", "Please wait...", false, false);
  10.  
  11. StringRequest stringRequest = new StringRequest(Request.Method.POST, url3, new Response.Listener<String>() {
  12. @Override
  13. public void onResponse(String response) {
  14. try {
  15. Log.d("rr",response);
  16. loading.dismiss();
  17. JSONArray j = new JSONArray(response);
  18. JSONObject jo = j.getJSONObject(0);
  19. String res = jo.getString("result");
  20. if (res.equals("true")) {
  21. alert.setMessage("You Were Present on " + date)
  22. .setPositiveButton("ok", new DialogInterface.OnClickListener() {
  23. @Override
  24. public void onClick(DialogInterface dialog, int which) {
  25. dialog.dismiss();
  26. }
  27. })
  28. .show();
  29. }
  30. if (res.equals("false")) {
  31.  
  32. alert.setMessage("You were Absent on " + date)
  33. .setPositiveButton("ok", new DialogInterface.OnClickListener() {
  34. @Override
  35. public void onClick(DialogInterface dialog, int which) {
  36. dialog.dismiss();
  37. }
  38. })
  39. .show();
  40. }
  41. } catch (JSONException e) {
  42. e.printStackTrace();
  43. }
  44.  
  45. }
  46. }, new Response.ErrorListener() {
  47. @Override
  48. public void onErrorResponse(VolleyError error) {
  49. loading.dismiss();
  50. Toast.makeText(Daily_Attendance.this, "Connection Error..", Toast.LENGTH_SHORT).show();
  51. }
  52. }) {
  53. @Override
  54. protected Map<String, String> getParams() throws AuthFailureError {
  55. Map<String, String> param = new HashMap<>();
  56. param.put("date", date);
  57. param.put("semester", semester);
  58. param.put("section", section);
  59. param.put("subject_name", subject_name);
  60. param.put("subject_type", subject_type);
  61. param.put("subject_code", subject_code);
  62. param.put("registration_number",user.get(sessionManagement.KEY_REGISTRATION_NUMBER));
  63. return param;
  64. }
  65. };
  66. AppController.getInstance().addToRequestQueue(stringRequest);
  67.  
  68. }
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement