-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocStaffAttendanceDisplay.java
More file actions
96 lines (87 loc) · 3.63 KB
/
DocStaffAttendanceDisplay.java
File metadata and controls
96 lines (87 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.example.fbans.projecthm;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.StringRequest;
import com.example.fbans.projecthm.utils.Absent;
import com.example.fbans.projecthm.utils.Constants;
import com.example.fbans.projecthm.utils.Patient;
import com.example.fbans.projecthm.utils.RequestHandler;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DocStaffAttendanceDisplay extends AppCompatActivity {
String name,from,to;
RecyclerView recyclerView;
AttendanceAdapter attendanceAdapter;
List<Absent> absentList;
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doc_staff_attendance_display);
Bundle intent = getIntent().getExtras();
name = intent.getString("name");
from = intent.getString("from");
to = intent.getString("to");
absentList = new ArrayList<>();
progressDialog = new ProgressDialog(this);
recyclerView = (RecyclerView) findViewById(R.id.absenties);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(attendanceAdapter);
absentDet();
}
public void absentDet() {
progressDialog.setMessage("Adding...");
progressDialog.show();
final StringRequest request = new StringRequest(Request.Method.POST, Constants.VIEW_ATTENDANCE_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
progressDialog.dismiss();
try {
JSONArray array = new JSONArray(response);
for (int i = 0;i<array.length();i++){
JSONObject object = array.getJSONObject(i);
Absent absent = new Absent(object.getString("5"));
absentList.add(absent);
}
attendanceAdapter = new AttendanceAdapter(getApplicationContext(),absentList);
recyclerView.setAdapter(attendanceAdapter);
attendanceAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
Log.i("Volley Error:",error.getMessage());
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<>();
params.put("f1",name);
params.put("f2",from);
params.put("f3",to);
return params;
}
};
RequestHandler.getInstance(this).addToRequestQueue(request);
}
}