-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructionsDisplay.java
More file actions
91 lines (83 loc) · 3.6 KB
/
InstructionsDisplay.java
File metadata and controls
91 lines (83 loc) · 3.6 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
package com.example.fbans.projecthm;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
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.Constants;
import com.example.fbans.projecthm.utils.Instructions;
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;
//detail ins
public class InstructionsDisplay extends AppCompatActivity {
RecyclerView recyclerView;
InstructionDisplayAdapter adapter;
List<Instructions> instructionsList;
String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_instructions_display);
instructionsList = new ArrayList<>();
recyclerView = (RecyclerView) findViewById(R.id.recycler);
recyclerView.setHasFixedSize(true);
if (recyclerView!=null){
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
adapter = new InstructionDisplayAdapter();
recyclerView.setAdapter(adapter);
loadIns();
Bundle intent = getIntent().getExtras();
name = intent.getString("ID");
}
private void loadIns() {
final StringRequest request = new StringRequest(Request.Method.POST, Constants.STAFF_INS, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.i("Response:" ,"JSON Response");
try {
JSONArray array = new JSONArray(response);
for (int i = 0;i<array.length();i++) {
Log.i("Loop","Response LOOP");
JSONObject object = array.getJSONObject(i);
//if (object.getString("staff_name").equalsIgnoreCase(name)) {
Log.i("Response:", object.getString("patient_name"));
Instructions instructions = new Instructions(object.getString("patient_name"), object.getString("room_no"), object.getString("description"));
instructionsList.add(instructions);
//}
}
adapter = new InstructionDisplayAdapter(InstructionsDisplay.this,instructionsList);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("Volley Error:",error.getMessage());
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<>();
params.put("f1",name);
return params;
}
};
RequestHandler.getInstance(this).addToRequestQueue(request);
}
}