-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatientVA.java
More file actions
110 lines (97 loc) · 4.15 KB
/
PatientVA.java
File metadata and controls
110 lines (97 loc) · 4.15 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.example.fbans.projecthm;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
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.StringRequest;
import com.example.fbans.projecthm.utils.Appointment;
import com.example.fbans.projecthm.utils.Constants;
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 PatientVA extends Fragment {
View vi;
RecyclerView recyclerView;
PatientsViewAppoinAdap adapter;
List<Appointment> patientAppoList=new ArrayList<>();
ProgressDialog progressDialog;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
vi = inflater.inflate(R.layout.layout_apva,container,false);
return vi;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
progressDialog = new ProgressDialog(getContext());
recyclerView = vi.findViewById(R.id.apva_rv);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
viewAppo();
}
private void viewAppo() {
progressDialog.setMessage("Loading...");
progressDialog.show();
final StringRequest request = new StringRequest(Request.Method.POST, Constants.PAT_APPO, 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);
Appointment appointment = new Appointment(object.getString("name"),
object.getString("time"),
object.getString("purpose"),object.getString("date"));
patientAppoList.add(appointment);
}
adapter = new PatientsViewAppoinAdap(getContext(),patientAppoList);
recyclerView.setAdapter(adapter);
adapter.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<>();
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("hospmanagepref", Context.MODE_PRIVATE);
String temp = sharedPreferences.getString("keynum",null);
if (temp!=null) {
params.put("f1", temp);
}
return params;
}
};
RequestHandler.getInstance(getContext()).addToRequestQueue(request);
}
}