|
@@ -41,6 +41,9 @@ import com.dbs.mplus.knuh.util.Util;
|
|
|
import org.ksoap2.serialization.SoapObject;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
import javax.security.auth.callback.Callback;
|
|
@@ -61,6 +64,10 @@ public class LeftMenu {
|
|
|
|
|
|
public String patientState = "";
|
|
|
|
|
|
+ private boolean pidSortFlag = false;
|
|
|
+ private boolean patientNameSortFlag = false;
|
|
|
+ private boolean wardSortFlag = false;
|
|
|
+
|
|
|
public LeftMenu(Context context, AppCompatActivity activity) {
|
|
|
this.mContext = context;
|
|
|
this.mActivity = activity;
|
|
@@ -235,6 +242,93 @@ public class LeftMenu {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ public View.OnClickListener sortOnClickListener = new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (patientListAdapter != null) {
|
|
|
+
|
|
|
+ if (instance.llPatientSort == v) {
|
|
|
+ Collections.sort(patientListAdapter.arrayList, new Comparator<PatientListVO>() {
|
|
|
+ @Override
|
|
|
+ public int compare(PatientListVO o1, PatientListVO o2) {
|
|
|
+ if (pidSortFlag == false) {
|
|
|
+ return (int) (Double.parseDouble(o1.getPid()) - Double.parseDouble(o2.getPid()));
|
|
|
+ } else {
|
|
|
+ return (int) (Double.parseDouble(o2.getPid()) - Double.parseDouble(o1.getPid()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (pidSortFlag == false) {
|
|
|
+ instance.column1.setText(mContext.getString(R.string.patientId) + " ▲");
|
|
|
+ pidSortFlag = true;
|
|
|
+ } else {
|
|
|
+ instance.column1.setText(mContext.getString(R.string.patientId) + " ▼");
|
|
|
+ pidSortFlag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ instance.column4.setText(mContext.getString(R.string.patientName));
|
|
|
+ if (instance.indexPage.equals("I")) {
|
|
|
+ instance.column6.setText(mContext.getString(R.string.wardRoom));
|
|
|
+ }
|
|
|
+ } else if (instance.llPatientNmSort == v) {
|
|
|
+ Collections.sort(patientListAdapter.arrayList, new Comparator<PatientListVO>() {
|
|
|
+ @Override
|
|
|
+ public int compare(PatientListVO o1, PatientListVO o2) {
|
|
|
+ if (patientNameSortFlag == false) {
|
|
|
+ return o1.getHngNm().compareTo(o2.getHngNm());
|
|
|
+ } else {
|
|
|
+ return o2.getHngNm().compareTo(o1.getHngNm());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (patientNameSortFlag == false) {
|
|
|
+ instance.column4.setText(mContext.getString(R.string.patientName) + " ▲");
|
|
|
+ patientNameSortFlag = true;
|
|
|
+ } else {
|
|
|
+ instance.column4.setText(mContext.getString(R.string.patientName) + " ▼");
|
|
|
+ patientNameSortFlag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ instance.column1.setText(mContext.getString(R.string.patientId));
|
|
|
+ if (instance.indexPage.equals("I")) {
|
|
|
+ instance.column6.setText(mContext.getString(R.string.wardRoom));
|
|
|
+ }
|
|
|
+ } else if (instance.llRoomSort == v) {
|
|
|
+ if (instance.indexPage.equals("I")) {
|
|
|
+ Collections.sort(patientListAdapter.arrayList, new Comparator<PatientListVO>() {
|
|
|
+ @Override
|
|
|
+ public int compare(PatientListVO o1, PatientListVO o2) {
|
|
|
+ if (wardSortFlag == false) {
|
|
|
+ return o1.getRoomCd().compareTo(o2.getRoomCd());
|
|
|
+ } else {
|
|
|
+ return o2.getRoomCd().compareTo(o1.getRoomCd());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (wardSortFlag == false) {
|
|
|
+ instance.column6.setText(mContext.getString(R.string.wardRoom) + " ▲");
|
|
|
+ wardSortFlag = true;
|
|
|
+ } else {
|
|
|
+ instance.column6.setText(mContext.getString(R.string.wardRoom) + " ▼");
|
|
|
+ wardSortFlag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ instance.column1.setText(mContext.getString(R.string.patientId));
|
|
|
+ instance.column4.setText(mContext.getString(R.string.patientName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ linearLayoutManager.scrollToPositionWithOffset(0, 0);
|
|
|
+ patientListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
public EditText.OnEditorActionListener onEditorActionListener = new EditText.OnEditorActionListener() {
|
|
|
@Override
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
@@ -527,7 +621,9 @@ public class LeftMenu {
|
|
|
@Override
|
|
|
public void result(SoapObject result) {
|
|
|
ArrayList<PatientListVO> arrayList = SoapParser.getPatientList(result);
|
|
|
- setPatientListAdapter(arrayList);
|
|
|
+ if (arrayList.size() > 0) {
|
|
|
+ setPatientListAdapter(arrayList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|