소스 검색

<护士主机列表界面显示,增加下拉刷新,添加测试数据>

weizhengliang 5 년 전
부모
커밋
1dbbe83710

+ 5 - 0
app/src/main/java/com/wdkl/callingmainnurse/adapter/DutyDoctorAdapter.java

@@ -41,6 +41,11 @@ public class DutyDoctorAdapter extends RecyclerView.Adapter<DutyDoctorAdapter.My
         notifyDataSetChanged();
     }
 
+    public void clear() {
+        this.list.clear();
+        notifyDataSetChanged();
+    }
+
     @Override
     public void onBindViewHolder(DutyDoctorAdapter.MyViewHolder holder, int position) {
         holder.tvName.setText("  "+list.get(position).subSequence(0, 1)+"医生  ");

+ 5 - 0
app/src/main/java/com/wdkl/callingmainnurse/adapter/DutyNurseAdapter.java

@@ -41,6 +41,11 @@ public class DutyNurseAdapter extends RecyclerView.Adapter<DutyNurseAdapter.MyVi
         notifyDataSetChanged();
     }
 
+    public void clear() {
+        this.list.clear();
+        notifyDataSetChanged();
+    }
+
     @Override
     public void onBindViewHolder(DutyNurseAdapter.MyViewHolder holder, int position) {
         holder.tvName.setText("  "+list.get(position).subSequence(0, 1)+"护士  ");

+ 23 - 0
app/src/main/java/com/wdkl/callingmainnurse/entity/NurseHostListInfo.java

@@ -1,5 +1,8 @@
 package com.wdkl.callingmainnurse.entity;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Created by fengxiangqian on 2017/11/9.
  */
@@ -24,6 +27,8 @@ public class NurseHostListInfo {
      * deviceNurse_Level4 : 国民
      * hospital : 湖南省儿童医院
      * department : 内一科
+     * dutyDoctorList : 责任医生
+     * nurseOnDutyList : 责任护士
      */
 
     private String id;
@@ -43,6 +48,8 @@ public class NurseHostListInfo {
     private String hospital;
     private String department;
     public boolean isChecked;
+    private ArrayList<String> dutyDoctorList;
+    private ArrayList<String> nurseOnDutyList;
 
     public String getId() {
         return id == null ? "0" : id;
@@ -179,4 +186,20 @@ public class NurseHostListInfo {
     public void setChecked(boolean checked) {
         isChecked = checked;
     }
+
+    public ArrayList<String> getDutyDoctorList() {
+        return dutyDoctorList;
+    }
+
+    public void setDutyDoctorList(ArrayList<String> dutyDoctorList) {
+        this.dutyDoctorList = dutyDoctorList;
+    }
+
+    public ArrayList<String> getNurseOnDutyList() {
+        return nurseOnDutyList;
+    }
+
+    public void setNurseOnDutyList(ArrayList<String> nurseOnDutyList) {
+        this.nurseOnDutyList = nurseOnDutyList;
+    }
 }

+ 125 - 26
app/src/main/java/com/wdkl/callingmainnurse/ui/fragment/CallingHostFragment.java

@@ -2,6 +2,8 @@ package com.wdkl.callingmainnurse.ui.fragment;
 
 import android.os.Bundle;
 import android.support.annotation.Nullable;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
@@ -16,6 +18,8 @@ import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.wdkl.callingmainnurse.R;
 import com.wdkl.callingmainnurse.adapter.DoctorHostAdapter;
+import com.wdkl.callingmainnurse.adapter.DutyDoctorAdapter;
+import com.wdkl.callingmainnurse.adapter.DutyNurseAdapter;
 import com.wdkl.callingmainnurse.adapter.MedicalHostsCallingQueuingInfoAdapter;
 import com.wdkl.callingmainnurse.adapter.NurseHostAdapter;
 import com.wdkl.callingmainnurse.base.BaseFragment;
@@ -36,6 +40,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import butterknife.Bind;
 import butterknife.ButterKnife;
@@ -51,10 +56,22 @@ import static com.wdkl.callingmainnurse.util.ToastUtil.showToast;
 
 public class CallingHostFragment extends BaseFragment implements DoctorHostAdapter.DoctorHostItemOnclickListener,
         NurseHostAdapter.NurseHostItemOnclickListener, View.OnClickListener,
-        MedicalHostsCallingQueuingInfoAdapter.CallingQueuingBarItemOnClickListener, RecyclerView.OnItemTouchListener {
+        MedicalHostsCallingQueuingInfoAdapter.CallingQueuingBarItemOnClickListener, RecyclerView.OnItemTouchListener, SwipeRefreshLayout.OnRefreshListener {
 
     private View mView;
 
+    //刷新控件
+    @Bind(R.id.fragment_calling_nurse_layout_sr_refresh)
+    SwipeRefreshLayout swipeNurseRefreshLayout;
+
+    //值班医生
+    @Bind(R.id.fragment_rv_doctors)
+    RecyclerView rvDutyDoctors;
+
+    //值班护士
+    @Bind(R.id.fragment_rv_nurses)
+    RecyclerView rvDutyNurses;
+
     /**
      * 医生主机RV
      */
@@ -72,7 +89,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     /**
      * 护士主机RV
      */
-    @Bind(R.id.fragment_rv_nurse)
+    @Bind(R.id.fragment_rv_nurse_host)
     RecyclerView rvNurse;
     /**
      * 护士主机的实体
@@ -127,6 +144,11 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     @Bind(R.id.fragment_tv_doctor_nurse_no)
     TextView nurse_CallStaus;
 
+    private ArrayList<String> dutyDoctorsList = new ArrayList<>();
+    private ArrayList<String> dutyNursesList = new ArrayList<>();
+    private DutyDoctorAdapter dutyDoctorAdapter;
+    private DutyNurseAdapter dutyNurseAdapter;
+
     @Nullable
     @Override
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -152,6 +174,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         ivEndCalling.setOnClickListener(this);
         rvDoctor.addOnItemTouchListener(this);
         rvNurse.addOnItemTouchListener(this);
+        swipeNurseRefreshLayout.setOnRefreshListener(this);
     }
 
     @Override
@@ -184,15 +207,30 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         rvDoctor.setAdapter(doctorHostAdapter);
         doctorHostAdapter.setDoctorHostItemOnclickListener(this);
 
-        LinearLayoutManager nurseManager = new LinearLayoutManager(getActivity());
-        nurseManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        //护士主机列表
+        //LinearLayoutManager nurseManager = new LinearLayoutManager(getActivity());
+        //nurseManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        GridLayoutManager nurseManager = new GridLayoutManager(getActivity(), 4);
         rvNurse.setLayoutManager(nurseManager);
         nurseHostAdapter = new NurseHostAdapter(getActivity(), nurseHostList);
         rvNurse.setAdapter(nurseHostAdapter);
         nurseHostAdapter.setNurseHostItemOnclickListener(this);
 
-        getNurseHostList();
-        getDoctorHostList();
+        //责任医生列表
+        GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
+        rvDutyDoctors.setLayoutManager(layoutManager);
+        dutyDoctorAdapter = new DutyDoctorAdapter(getActivity(), dutyDoctorsList);
+        rvDutyDoctors.setAdapter(dutyDoctorAdapter);
+
+        //责任护士列表
+        GridLayoutManager layoutManager2 = new GridLayoutManager(getActivity(), 3);
+        rvDutyNurses.setLayoutManager(layoutManager2);
+        dutyNurseAdapter = new DutyNurseAdapter(getActivity(), dutyNursesList);
+        rvDutyNurses.setAdapter(dutyNurseAdapter);
+
+        //getNurseHostList();
+        getNurseHostTestData();
+        //getDoctorHostList();
     }
 
     /**
@@ -215,6 +253,49 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         //getCallQueuingList();
     }
 
+    @Override
+    public void onRefresh() {
+        resetRightList();
+        //getNurseHostList();
+        getNurseHostTestData();
+    }
+
+    private void getNurseHostTestData() {
+        ArrayList<String> dutyDoctors = new ArrayList<>();
+        dutyDoctors.add("刘医生");
+        dutyDoctors.add("张医生");
+        ArrayList<String> dutyNurses = new ArrayList<>();
+        dutyNurses.add("王护士");
+        dutyNurses.add("李护士");
+        nurseHostList.clear();
+        for (int i = 0; i < 10; i++) {
+            NurseHostListInfo nurseHostListInfo = new NurseHostListInfo();
+            nurseHostListInfo.setDepartment("内一科");
+            nurseHostListInfo.setDeviceName("护士主机" + i);
+            nurseHostListInfo.setDeviceSipIp("192.168.1.11");
+            nurseHostListInfo.setDeviceSipId("111");
+            nurseHostListInfo.setDutyDoctorList(dutyDoctors);
+            nurseHostListInfo.setNurseOnDutyList(dutyNurses);
+            nurseHostList.add(nurseHostListInfo);
+        }
+        nurseHostAdapter.updateList(nurseHostList);
+
+        if (swipeNurseRefreshLayout.isRefreshing()) {
+            swipeNurseRefreshLayout.setRefreshing(false);
+        }
+    }
+
+    private void resetRightList() {
+        tvCallingTips.setText("");
+        nurse_CallStaus.setText("--");
+        ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_trusteeship_n);
+        ivEndCalling.setVisibility(View.GONE);
+        rlIncall.setVisibility(View.VISIBLE);
+        rlNotInCallBg.setVisibility(View.GONE);
+        dutyDoctorAdapter.clear();
+        dutyNurseAdapter.clear();
+    }
+
     /**
      * 获取医生主机列表信息
      */
@@ -263,26 +344,40 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
                 .execute(new StringCallback() {
                     @Override
                     public void onError(Call call, Exception e, int id) {
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
                         hideProgress();
                     }
 
                     @Override
                     public void onResponse(String response, int id) {
-                        if (notEmpty(response)) {
-                            LogUtil.d(CallingHostFragment.class, "NurseHostListresponse==" + response);
-                            String code = getStringData(response, "Code");
-                            if (code.equals("OK!")) {
-                                nurseHostList = new Gson().fromJson(getStringData(response, "hostList"), new TypeToken<ArrayList<NurseHostListInfo>>() {
-                                }.getType());
-                                if (null != nurseHostList) {
-                                    LogUtil.d(CallingHostFragment.class, "nurseHostListsize==" + nurseHostList.size());
-                                    nurseHostAdapter.updateList(nurseHostList);
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
+
+                        try {
+                            if (notEmpty(response)) {
+                                LogUtil.d(CallingHostFragment.class, "NurseHostListresponse==" + response);
+                                String code = getStringData(response, "Code");
+                                if (code.equals("OK!")) {
+                                    nurseHostList = new Gson().fromJson(getStringData(response, "hostList"), new TypeToken<ArrayList<NurseHostListInfo>>() {
+                                    }.getType());
+                                    if (null != nurseHostList) {
+                                        LogUtil.d(CallingHostFragment.class, "nurseHostListsize==" + nurseHostList.size());
+                                        nurseHostAdapter.updateList(nurseHostList);
+                                    }
+                                } else {
+                                    LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
                                 }
                             } else {
-                                LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
+                                LogUtil.i(CallingHostFragment.class, "数据返回为空!");
                             }
-                        } else {
-                            LogUtil.i(CallingHostFragment.class, "数据返回为空!");
+                        } catch (Exception e) {
+                            if (swipeNurseRefreshLayout.isRefreshing()) {
+                                swipeNurseRefreshLayout.setRefreshing(false);
+                            }
+                            e.printStackTrace();
                         }
                     }
                 });
@@ -354,25 +449,29 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     public void nurseHostItemOnclick(View view, int position) {
         if (null == nurseHostList || nurseHostList.size() <= 0 || null == nurseHostList.get(position))
             return;
-        if (nurseHostList.get(position).isChecked()) {
-            nurseHostList.get(position).setChecked(false);
-            rlIncall.setVisibility(View.GONE);
-            rlNotInCallBg.setVisibility(View.VISIBLE);
-            tvCallingTips.setText("");
+        NurseHostListInfo info = nurseHostList.get(position);
+        if (info.isChecked()) {
+            //nurseHostList.get(position).setChecked(false);
+            //rlIncall.setVisibility(View.GONE);
+            //rlNotInCallBg.setVisibility(View.VISIBLE);
+            //tvCallingTips.setText("");
         } else {
             for (NurseHostListInfo entity : nurseHostList) {
                 if (null == entity) continue;
                 entity.setChecked(false);
             }
-            nurseHostList.get(position).setChecked(true);
-            tvCallingTips.setText(nurseHostList.get(position).getDeviceName());
-            nurse_CallStaus.setText(nurseHostList.get(position).getDeviceName());
+            info.setChecked(true);
+            tvCallingTips.setText(info.getDeviceName());
+            nurse_CallStaus.setText(info.getDeviceName());
             ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_nurse_right_in_call);
             ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
+            ivEndCalling.setVisibility(View.VISIBLE);
             rlIncall.setVisibility(View.VISIBLE);
             rlNotInCallBg.setVisibility(View.GONE);
         }
         nurseHostAdapter.notifyDataSetChanged();
+        dutyDoctorAdapter.updateList(info.getDutyDoctorList());
+        dutyNurseAdapter.updateList(info.getNurseOnDutyList());
     }
 
     /**

+ 11 - 13
app/src/main/res/layout/fragment_calling_doctor_medica_hosts.xml

@@ -9,22 +9,20 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_toLeftOf="@+id/fragment_calling_host_rl_right"
+        android:layout_marginTop="15dp"
         android:orientation="vertical">
-
-
-        <LinearLayout
+        <android.support.v4.widget.SwipeRefreshLayout
+            android:id="@+id/fragment_calling_nurse_layout_sr_refresh"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginRight="@dimen/margin_10dp"
-            android:layout_weight="2"
-            android:orientation="vertical">
+            android:layout_height="match_parent"
+            android:layout_marginRight="@dimen/margin_10dp">
 
             <android.support.v7.widget.RecyclerView
-                android:id="@+id/fragment_rv_nurse"
+                android:id="@+id/fragment_rv_nurse_host"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:overScrollMode="never"></android.support.v7.widget.RecyclerView>
-        </LinearLayout>
+                android:overScrollMode="never"/>
+        </android.support.v4.widget.SwipeRefreshLayout>
 
         <LinearLayout
             android:id="@+id/fragment_rl_doctor"
@@ -32,14 +30,14 @@
             android:layout_height="wrap_content"
             android:layout_marginRight="@dimen/margin_10dp"
             android:layout_weight="2"
-            android:orientation="vertical">
+            android:orientation="vertical"
+            android:visibility="gone">
 
             <android.support.v7.widget.RecyclerView
                 android:id="@+id/fragment_rv_doctor"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:overScrollMode="never">
-            </android.support.v7.widget.RecyclerView>
+                android:overScrollMode="never"/>
         </LinearLayout>
 
     </LinearLayout>

+ 4 - 2
app/src/main/res/layout/fragment_medical_hosts_call_queuing_info_bar_layout.xml

@@ -59,6 +59,7 @@
                 android:id="@+id/fragment_rv_doctors"
                 android:layout_width="match_parent"
                 android:layout_height="100dp"
+                android:layout_marginTop="10dp"
                 android:layout_below="@id/tv_doctor_on_duty"
                 android:overScrollMode="never"
                 android:background="#2e95cf" />
@@ -79,6 +80,7 @@
                 android:id="@+id/fragment_rv_nurses"
                 android:layout_width="match_parent"
                 android:layout_height="100dp"
+                android:layout_marginTop="10dp"
                 android:layout_below="@id/tv_nurse_on_duty"
                 android:overScrollMode="never"
                 android:background="#2e95cf" />
@@ -115,8 +117,8 @@
 
             <ImageView
                 android:id="@+id/fragment_iv_end_calling"
-                android:layout_width="100dp"
-                android:layout_height="40dp"
+                android:layout_width="200dp"
+                android:layout_height="60dp"
                 android:layout_below="@+id/fragment_tv_doctor_nurse_no"
                 android:layout_centerHorizontal="true"
                 android:layout_marginTop="80dp"

+ 4 - 3
app/src/main/res/layout/item_duty_doctor_layout.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
     android:orientation="vertical">
     <TextView
         android:layout_marginLeft="@dimen/margin_15dp"
@@ -12,5 +12,6 @@
         android:background="@drawable/shape_main_text"
         android:padding="2dp"
         android:text="   李医生   "
-        android:textColor="@color/call_sickbed_room_bg_color" />
+        android:textColor="@color/call_sickbed_room_bg_color"
+        android:textSize="16sp"/>
 </RelativeLayout>

+ 4 - 3
app/src/main/res/layout/item_duty_nurse_layout.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
     android:orientation="vertical">
 
     <TextView
@@ -13,5 +13,6 @@
         android:background="@drawable/shape_main_text"
         android:padding="2dp"
         android:text="   李医生   "
-        android:textColor="@color/call_sickbed_room_bg_color" />
+        android:textColor="@color/call_sickbed_room_bg_color"
+        android:textSize="16sp"/>
 </RelativeLayout>