-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatientDetailsAdapter.java
More file actions
104 lines (80 loc) · 3.43 KB
/
PatientDetailsAdapter.java
File metadata and controls
104 lines (80 loc) · 3.43 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
package com.example.fbans.projecthm;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import android.widget.Toast;
import com.example.fbans.projecthm.utils.Patient;
import java.util.ArrayList;
import java.util.List;
/**
* Created by user on 19-05-2018.
*/
public class PatientDetailsAdapter extends RecyclerView.Adapter<PatientDetailsAdapter.ViewHolder> {
List<Patient> patientList = new ArrayList<>();
List<Patient> searchPatientList;
Context context;
public PatientDetailsAdapter(){}
public PatientDetailsAdapter(Context context, List<Patient> patientList) {
this.patientList=patientList;
this.context=context;
}
@NonNull
@Override
public PatientDetailsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.patient_details_adapter, parent, false);
return new ViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull PatientDetailsAdapter.ViewHolder holder, final int position) {
final Patient patient = patientList.get(position);
holder.patientName.setText(patient.getName());
holder.patientAge.setText(patient.getAge());
holder.patientGender.setText(patient.getGender());
holder.patientMno.setText(patient.getMno());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int id = patientList.get(position).getId();
String pid = String.valueOf(id);
Toast.makeText(context, pid, Toast.LENGTH_SHORT).show();
}
});
}
public void filterList(ArrayList<Patient> filterdNames) {
this.patientList = filterdNames;
notifyDataSetChanged();
}
@Override
public int getItemCount() {
return patientList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView patientName, patientAge, patientGender, patientMno;
CardView card;
public ViewHolder(View itemView) {
super(itemView);
patientName = itemView.findViewById(R.id.Patient_name_display);
patientAge = itemView.findViewById(R.id.Patient_age_display);
patientGender = itemView.findViewById(R.id.Patient_gender_display);
patientMno = itemView.findViewById(R.id.Patient_mno_display);
card=itemView.findViewById(R.id.card_view);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SharedPreferences sharedPreferences = context.getSharedPreferences("hospmanagepref",Context.MODE_PRIVATE);
int temp = sharedPreferences.getInt("keyid",0);
Toast.makeText(context, "ID:"+String.valueOf(temp), Toast.LENGTH_SHORT).show();
}
});
}
}
}