Browse Source

1.优化厕所状态界面逻辑。
2.增加签到侧边栏。

Administrator 4 năm trước cách đây
mục cha
commit
6bc681b3ec
27 tập tin đã thay đổi với 655 bổ sung297 xóa
  1. 64 0
      app/src/main/java/com/sunzee/adapter/HomePageAAdapter.java
  2. 81 0
      app/src/main/java/com/sunzee/mvp/home/HomePresenter.java
  3. 4 0
      app/src/main/java/com/sunzee/mvp/home/HomeView.java
  4. 5 2
      app/src/main/java/com/sunzee/mvp/homepage/HomePagePresenter.java
  5. 4 1
      app/src/main/java/com/sunzee/retrofit/ApiClient.java
  6. 1 0
      app/src/main/java/com/sunzee/retrofit/ApiStores.java
  7. 1 4
      app/src/main/java/com/sunzee/service/MyIntentService.java
  8. 150 111
      app/src/main/java/com/sunzee/service/MyService.java
  9. 52 30
      app/src/main/java/com/sunzee/ui/activity/HomeActivity.java
  10. 134 34
      app/src/main/java/com/sunzee/ui/activity/HomePageAActivity.java
  11. 5 12
      app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java
  12. BIN
      app/src/main/res/drawable-hdpi/icon_no_gongzonghao.jpg
  13. BIN
      app/src/main/res/drawable-mdpi/icon_no_gongzonghao.jpg
  14. BIN
      app/src/main/res/drawable-xhdpi/icon_no_gongzonghao.jpg
  15. BIN
      app/src/main/res/drawable-xxhdpi/icon_no_gongzonghao.jpg
  16. BIN
      app/src/main/res/drawable-xxxhdpi/icon_no_gongzonghao.jpg
  17. 22 0
      app/src/main/res/drawable/shape_radio_signin.xml
  18. 0 1
      app/src/main/res/layout/activity_home.xml
  19. 34 99
      app/src/main/res/layout/activity_homeactivity.xml
  20. 2 3
      app/src/main/res/layout/fragment_other.xml
  21. 42 0
      app/src/main/res/layout/header.xml
  22. 18 0
      app/src/main/res/layout/item_nobody_homepage.xml
  23. 31 0
      app/src/main/res/layout/sidebar_layout.xml
  24. 4 0
      app/src/main/res/values-en/strings.xml
  25. 1 0
      app/src/main/res/values/strings.xml
  26. BIN
      serialportlib/.cxx/cmake/debug/arm64-v8a/CMakeFiles/hboxs_serial_port.dir/src/main/cpp/SerialPort.c.o
  27. BIN
      serialportlib/.cxx/cmake/debug/x86_64/CMakeFiles/hboxs_serial_port.dir/src/main/cpp/SerialPort.c.o

+ 64 - 0
app/src/main/java/com/sunzee/adapter/HomePageAAdapter.java

@@ -0,0 +1,64 @@
+package com.sunzee.adapter;
+
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.sunzee.model.HoleInformation;
+import com.sunzee.service.MyService;
+
+import java.util.List;
+
+/**
+ * 厕所状态适配器
+ */
+public class HomePageAAdapter  extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+    private final List<HoleInformation> holeInformations;
+    private static final String TAG = "HomePageAAdapter";
+    //构造方法,传入数据
+    public HomePageAAdapter(List<HoleInformation> holeInformations){
+        this.holeInformations = holeInformations;
+    }
+
+    @NonNull
+    @Override
+    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+        //创建ViewHolder,返回每一项的布局
+            View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_nobody_homepage, parent, false);
+            return new HomePageAAdapter.TitleViewHolder(inflate);
+    }
+
+    @Override
+    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+        //将数据和控件绑定
+
+    }
+
+    @Override
+    public int getItemCount() {
+        //返回Item总条数
+        Log.d(TAG, "getItemCount: "+holeInformations.size());
+        return holeInformations.size();
+    }
+
+
+    //内部类,绑定控件
+    public static class TitleViewHolder extends RecyclerView.ViewHolder {
+        private TextView tv_toiletdiagram;
+
+        public TextView getTv_toiletdiagram() {
+            return tv_toiletdiagram;
+        }
+
+        public TitleViewHolder(@NonNull View itemView) {
+            super(itemView);
+            tv_toiletdiagram = itemView.findViewById(R.id.tv_toiletdiagram2);
+        }
+    }
+}

+ 81 - 0
app/src/main/java/com/sunzee/mvp/home/HomePresenter.java

@@ -3,8 +3,10 @@ package com.sunzee.mvp.home;
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
+import android.widget.Toast;
 
 import com.google.gson.Gson;
+import com.orhanobut.hawk.Hawk;
 import com.sunzee.R;
 import com.sunzee.base.BaseApplication;
 import com.sunzee.base.BasePresenter;
@@ -19,6 +21,8 @@ import com.sunzee.utils.SharedPreferencesUtils;
 import com.sunzee.utils.ToastUtil;
 import com.sunzee.utils.UiUtil;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -127,4 +131,81 @@ public class HomePresenter extends BasePresenter<HomeView> {
         BaseApplication.getContext().startService(downloadApkIntent);
     }
 
+    public void isCleaned() {
+        addSubscription(apiStores.getBackgroundTime(), new ApiCallback<HttpResult<String>>() {
+            @Override
+            public void onSuccess(HttpResult<String> model) {
+                try {
+                    String timedata = model.getData();
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(timedata));
+                    //第一次就会出现报错。
+                    Long overdueDate = (Long) Hawk.get(Name.OVERDUE_DATE);//购买的到期的时间
+                    Long timeInMillis = calendar.getTimeInMillis();//当前时间
+                    String data = (String) Hawk.get(Name.REMAINING);
+                    long remaining = Long.valueOf(data);
+                    Log.d(TAG, "onSuccess: 时间过期remaining" + remaining);
+                    //如果时间没过期,那么可以继续制作
+                    if (overdueDate > timeInMillis) {
+                        Log.d(TAG, "onSuccess: 没有过期");
+                        ToastUtil.showToast("按天数清洗");
+                        //发送开始清洗的订单。
+                        getCleanReport(0);
+                        //如果还有次那么就开始购买。
+                    } else if (remaining > 0) {
+                        Log.d(TAG, "onSuccess: 时间过期,按次数计算");
+                        ToastUtil.showToast("按次数清洗");
+                        Hawk.put(Name.REMAINING, String.valueOf(remaining - 1));
+                        //发送开始清洗的订单。
+                        getCleanReport(0);
+                    } else {
+                        Log.d(TAG, "onSuccess: 全部过期,全部不能清洗");
+                        ToastUtil.showToast("已过期,请充值后使用哦。");
+                    }
+                } catch (Exception e) {
+                }
+            }
+
+            @Override
+            public void onFailure(String msg) {
+
+            }
+
+            @Override
+            public void onFinish() {
+
+            }
+        });
+
+    }
+
+    private void getCleanReport(int type) {
+        Map<String, String> params = new HashMap<>();
+        params.put("clientId", Heartbeat.deviceId);
+        params.put("type", type + "");
+        params.put("water", 1 + "");
+        params.put("electricity", 1 + "");
+        addSubscription(apiStores.getCleanReport(params), new ApiCallback<HttpResult<String>>() {
+
+            @Override
+            public void onSuccess(HttpResult<String> model) {
+                if ("success".equals(model.getData())) {
+                    mvpView.startClean();
+                } else {
+                    mvpView.haveExpired();
+                }
+            }
+
+            @Override
+            public void onFailure(String msg) {
+
+            }
+
+            @Override
+            public void onFinish() {
+
+            }
+        });
+    }
+
 }

+ 4 - 0
app/src/main/java/com/sunzee/mvp/home/HomeView.java

@@ -12,4 +12,8 @@ public interface HomeView extends BaseView {
     void updataSuccess(ApkInfoBean apkInfoBean);
 
     void updataFailure(String name);
+
+    void startClean();
+
+    void haveExpired();
 }

+ 5 - 2
app/src/main/java/com/sunzee/mvp/homepage/HomePagePresenter.java

@@ -10,6 +10,7 @@ import com.sunzee.model.HttpResult;
 import com.sunzee.model.domain.Name;
 import com.sunzee.retrofit.ApiCallback;
 import com.sunzee.thread.homepage.ThreadPoolHomepage;
+import com.sunzee.utils.ToastUtil;
 
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -52,16 +53,18 @@ public class HomePagePresenter extends BasePresenter<HomePageView> {
                     //如果时间没过期,那么可以继续制作
                     if (overdueDate > timeInMillis) {
                         Log.d(TAG, "onSuccess: 没有过期");
+                        ToastUtil.showToast("按天数清洗");
                         //发送开始清洗的订单。
                         getCleanReport(1);
                         //如果还有次那么就开始购买。
                     } else if (remaining > 0) {
                         Log.d(TAG, "onSuccess: 时间过期,按次数计算");
+                        ToastUtil.showToast("按次数清洗");
                         Hawk.put(Name.REMAINING, String.valueOf(remaining - 1));
                         //发送开始清洗的订单。
                         getCleanReport(1);
                     } else {
-                        Log.d(TAG, "onSuccess: 全部过期,全部不能清洗");
+                        ToastUtil.showToast("已过期,请充值后使用哦。");
                     }
                 } catch (Exception e) {
                 }
@@ -69,7 +72,7 @@ public class HomePagePresenter extends BasePresenter<HomePageView> {
 
             @Override
             public void onFailure(String msg) {
-
+                Log.d(TAG, "onFailure: "+msg);
             }
 
             @Override

+ 4 - 1
app/src/main/java/com/sunzee/retrofit/ApiClient.java

@@ -1,5 +1,7 @@
 package com.sunzee.retrofit;
 
+import android.util.Log;
+
 import com.sunzee.BuildConfig;
 
 import okhttp3.OkHttpClient;
@@ -11,7 +13,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
 
 public class ApiClient {
     public static Retrofit mRetrofit;
-
+    private static final String TAG = "ApiClient";
     public static Retrofit retrofit() {
         if (mRetrofit == null) {
             OkHttpClient.Builder builder = new OkHttpClient.Builder();
@@ -22,6 +24,7 @@ public class ApiClient {
                 //设置 Debug Log 模式
                 builder.addInterceptor(loggingInterceptor);
             }
+
             OkHttpClient okHttpClient = builder.build();
             mRetrofit = new Retrofit.Builder()
                     .baseUrl(ApiStores.API_SERVER_URL)

+ 1 - 0
app/src/main/java/com/sunzee/retrofit/ApiStores.java

@@ -103,3 +103,4 @@ public interface ApiStores {
     @POST("/api/app_equipment/index/createBox.htm")
     Observable<HttpResult<String>> createBox(@QueryMap Map<String, String> params);
 }
+

+ 1 - 4
app/src/main/java/com/sunzee/service/MyIntentService.java

@@ -120,10 +120,6 @@ public class MyIntentService extends GTIntentService {
         switch (kind) {
             case "clean":
                 //一键清洗:也就是全蹲位清洗。
-             /*   if (!HomeActivity.isStartingUp) {
-                    ToastUtil.showToast("你好,此操作需要在开机后才能操作");
-                    break;
-                }*/
                 //全蹲位清洗,需要在开机的状态才能执行。
                 synchronized (MyService.sCleaningLocationList) {//多线程操作需要加上同步锁
                     if (MyService.sCleaningLocationList.size()>0) {//大于0的时候才需要处理。
@@ -177,6 +173,7 @@ public class MyIntentService extends GTIntentService {
                 break;
             case "paySuccess":
                 // todo 客户支付成功了,我们需要获取它的日期事件
+                MyService.isCleanOK = true;
                 Log.d(TAG, "getKind: " + geTuiBean.getKind() + ";getKind_data:" + geTuiBean.getKind_data() + ":" );
                 Log.d(TAG, "getKind: "+geTuiBean.getNetTime()+";getWebTime:"+geTuiBean.getWebTime());
                 requestCleanTimeAndRemaining();

+ 150 - 111
app/src/main/java/com/sunzee/service/MyService.java

@@ -71,7 +71,6 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -109,6 +108,7 @@ public class MyService extends Service {
     private String nextTime;
     private String[] lastTimeSplit;
     private String[] nextTimeSplit;
+    public static boolean isLate = true;//记录从后台查询是否过期的情况。
 
     @Nullable
     @Override
@@ -129,6 +129,8 @@ public class MyService extends Service {
         EventBus.getDefault().register(this);
         stopRefreshTime();
         startRefreshime();
+        stopLate();
+        startLate();
     }
 
     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@@ -363,6 +365,72 @@ public class MyService extends Service {
     }
     //------------------------------------------------------------------------心跳 end---------------------------------
 
+
+    private Timer timerLate;
+    private TimerTask taskLate;
+
+    /**
+     * 开始心跳
+     */
+    private void startLate() {
+        timerLate = new Timer();
+        taskLate = new TimerTask() {
+            @Override
+            public void run() {
+                addSubscription(apiStores.getBackgroundTime(), new ApiCallback<HttpResult<String>>() {
+                    @Override
+                    public void onSuccess(HttpResult<String> model) {
+                        try {
+                            String timedata = model.getData();
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(timedata));
+                            //第一次就会出现报错。
+                            Long overdueDate = (Long) Hawk.get(Name.OVERDUE_DATE,0L);//购买的到期的时间
+                            Long timeInMillis = calendar.getTimeInMillis();//当前时间
+                            String data = (String) Hawk.get(Name.REMAINING,"0");
+                            long remaining = Long.valueOf(data);
+                            Log.d(TAG, "onSuccess: 时间过期remaining" + remaining);
+                            //如果时间没过期,那么可以继续制作
+                            if (overdueDate > timeInMillis) {
+                                Log.d(TAG, "onSuccess: 没有过期");
+                                isLate = true;
+                            } else if (remaining > 0) {
+                                Log.d(TAG, "onSuccess: 时间过期,按次数计算");
+                                isLate = true;
+                            } else {
+                                Log.d(TAG, "onSuccess: 全部过期,全部不能清洗");
+                                isLate = false;
+                            }
+                        } catch (Exception e) {
+                            Log.d(TAG, "onSuccess: "+e);
+                        }
+                    }
+
+                    @Override
+                    public void onFailure(String msg) {
+                        isLate = false;
+                        Log.d(TAG, "onSuccess onFailure: ");
+                    }
+
+                    @Override
+                    public void onFinish() {
+
+                    }
+                });
+            }
+        };
+        timerLate.schedule(taskLate, 1000, 1000 * 60 * 2);
+    }
+
+    private void stopLate() {
+        if (timerLate != null) {
+            taskLate.cancel();
+            timerLate.cancel();
+            timerLate = null;
+        }
+    }
+
+
     //——-----------------------------------------------------------------------请求 start------------------------------
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void event(ApiMessageEvent messageEvent) {
@@ -382,38 +450,8 @@ public class MyService extends Service {
                 /**
                  * 1.首先检查是否过期了,是否有次数
                  */
-//                isCleaned();//todo 不需要金额也可以清洗
-                //全蹲位清洗,需要在开机的状态才能执行。
-                synchronized (MyService.sCleaningLocationList) {//多线程操作需要加上同步锁
-                    if (MyService.sCleaningLocationList.size() > 0) {//大于0的时候才需要处理。
-                        Integer integer = MyService.sCleaningLocationList.removeFirst();//如果清洗中,那么我们不能全部移除,否则清洗完毕的时候会漏掉一个厕所没有清洗,所以我们留存下来。在假如。
-                        MyService.sCleaningLocationList.clear();
-                        MyService.sCleaningLocationList.addFirst(integer);
-                    }
-                    boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX,null);
-                    if (isSelectCheckBox != null) {
-                        for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
-                            if (!isSelectCheckBox[i - 1]) {
-                                continue;
-                            }
-                            MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
-                        }
-                    }else{
-                        for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
-                            MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
-                        }
-                    }
-                    if (!MyService.isCleanOK) {//清洗中,那麼我們就什麼都不做,如果不是清洗中,那麼我們需要進行復位。
-                        //开始清洗。
-                        //EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING,MyService. sCleaningLocationList.getFirst()));
-                        //復位成功後,會自己過去清洗的。所以我們不需要管他。
-                        EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING, MyService.sCleaningLocationList.getFirst()));
-                        ToastUtil.showToast("开始复位,准备开始全蹲位清洗,如果有人在里面使用,会等待人出来以后进行清洗。");
-                    } else {
-                        ToastUtil.showToast("已添加入清洗队列,等待本次清洗完成后开始清洗");
-                    }
+                isCleaned();//todo 不需要金额也可以清洗
 
-                }
                 break;
             case "updataParamSet":
                 if (!PreventSpeedClickUtil.isFastClick()) {
@@ -456,8 +494,8 @@ public class MyService extends Service {
                 }
                 break;
             case Name.SINGLEPOINTCLEANING://单点清洗
-                Integer needCleaning = (Integer)messageEvent.getData();
-                cleanPositionNumX20(needCleaning,5);
+                Integer needCleaning = (Integer) messageEvent.getData();
+                cleanPositionNumX20(needCleaning, 5);
                 break;
             default:
                 break;
@@ -533,6 +571,7 @@ public class MyService extends Service {
         });
 
     }
+
     //可以清洗机器开始清洗了,向上面报告 0是:定时清洗  1是:随机清洗,暂时只作为上传报告的功能。
     private void getCleanReport(int i) {
         Map<String, String> params = new HashMap<>();
@@ -545,7 +584,7 @@ public class MyService extends Service {
             @Override
             public void onSuccess(HttpResult<String> model) {
                 Log.d(TAG, "getCleanReportonSuccess: " + model);
-                /*if ("success".equals(model.getData())) {
+                if ("success".equals(model.getData())) {
                     //startClean();
                     //全蹲位清洗,需要在开机的状态才能执行。
                     synchronized (MyService.sCleaningLocationList) {//多线程操作需要加上同步锁
@@ -554,7 +593,7 @@ public class MyService extends Service {
                             MyService.sCleaningLocationList.clear();
                             MyService.sCleaningLocationList.addFirst(integer);
                         }
-                        boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX,null);
+                        boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX, null);
                         if (isSelectCheckBox != null) {
                             for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
                                 if (!isSelectCheckBox[i - 1]) {
@@ -562,7 +601,7 @@ public class MyService extends Service {
                                 }
                                 MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
                             }
-                        }else{
+                        } else {
                             for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
                                 MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
                             }
@@ -579,7 +618,7 @@ public class MyService extends Service {
 
                     }
                 } else {
-                }*/
+                }
             }
 
             @Override
@@ -1148,82 +1187,83 @@ public class MyService extends Service {
                             e.printStackTrace();
                         }
                     } else if (name.equals("X12")) {
-                        String result = AsciiUtils.asciiByteArray2HexStr(responseFrame.getData());
-                        List<String> strList = HexadecimalUtil.getStrList(result, 4);
-                        StringBuilder sb = new StringBuilder();
-                        for (int i = 0, len = strList.size(); i < len; i++) {
-                            String str = strList.get(i);
-                            //2进制
-                            String s3 = HexadecimalUtil.hexStringToByte(str);
-                            //2进制翻转
-                            String s2 = HexadecimalUtil.flipString(s3, 8);
-                            sb.append(s2);
-                        }
-                        List<String> list1 = Arrays.asList(sb.toString().split(""));
-                        ArrayList<String> list2 = new ArrayList(list1);
-                        list2.remove(0);
+                        if (isLate) {
+                            String result = AsciiUtils.asciiByteArray2HexStr(responseFrame.getData());
+                            List<String> strList = HexadecimalUtil.getStrList(result, 4);
+                            StringBuilder sb = new StringBuilder();
+                            for (int i = 0, len = strList.size(); i < len; i++) {
+                                String str = strList.get(i);
+                                //2进制
+                                String s3 = HexadecimalUtil.hexStringToByte(str);
+                                //2进制翻转
+                                String s2 = HexadecimalUtil.flipString(s3, 8);
+                                sb.append(s2);
+                            }
+                            List<String> list1 = Arrays.asList(sb.toString().split(""));
+                            ArrayList<String> list2 = new ArrayList(list1);
+                            list2.remove(0);
 
-                        String s = Arrays.toString(list2.toArray());
-                        Log.d(TAG, "X12event1: " + s);
-                        //如果没有开机,那么这里面的代码不会执行。
+                            String s = Arrays.toString(list2.toArray());
+                            Log.d(TAG, "X12event1: " + s);
+                            //如果没有开机,那么这里面的代码不会执行。
                       /*  if (!HomeActivity.isStartingUp) {
                             return;
                         }*/
-                        //监控1号厕所:门锁,以及人体传感器。根据厕所的个数来决定要监听的厕所的个数
-                        boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX, null);
-                        boolean[] isSelectPeopleCheckbox = Hawk.get(Name.ISSELECTPEOPLECHECKBOX, null);
+                            //监控1号厕所:门锁,以及人体传感器。根据厕所的个数来决定要监听的厕所的个数
+                            boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX, null);
+                            boolean[] isSelectPeopleCheckbox = Hawk.get(Name.ISSELECTPEOPLECHECKBOX, null);
 
-                        if (isSelectCheckBox == null) {//厕所状态为空,说明还没设置,也就是全部都监听
-                            for (int i = 1; i <= TOTAL_SUM; i++) {//什么都监听
-                                monitoring(list2.get(i + 1), i, list2.get(i + 7));
-                                bodySensor(i, list2.get(i + 7));
-                            }
-                        } else {//设置过厕所,说明有些不需要监听。
-                            for (int i = 1; i <= TOTAL_SUM; i++) {//判断有哪些不需要监听的。
-                                //是否监听指定的厕所。
-                                if (!isSelectCheckBox[i - 1]) {//true为选中,false为未选中,不需要监听的,我们就过。
-                                    continue;
-                                }
-                                //厕所需要监听,那么我们判断她是否监听指定的人体传感器
-                                if (isSelectPeopleCheckbox == null || isSelectPeopleCheckbox[i - 1]) {//为空,说明害没设置,就是全部监听
+                            if (isSelectCheckBox == null) {//厕所状态为空,说明还没设置,也就是全部都监听
+                                for (int i = 1; i <= TOTAL_SUM; i++) {//什么都监听
                                     monitoring(list2.get(i + 1), i, list2.get(i + 7));
                                     bodySensor(i, list2.get(i + 7));
-                                } else {
-                                    monitoring(list2.get(i + 1), i, "0");
-                                    bodySensor(i, list2.get(i + 7));
+                                }
+                            } else {//设置过厕所,说明有些不需要监听。
+                                for (int i = 1; i <= TOTAL_SUM; i++) {//判断有哪些不需要监听的。
+                                    //是否监听指定的厕所。
+                                    if (!isSelectCheckBox[i - 1]) {//true为选中,false为未选中,不需要监听的,我们就过。
+                                        continue;
+                                    }
+                                    //厕所需要监听,那么我们判断她是否监听指定的人体传感器
+                                    if (isSelectPeopleCheckbox == null || isSelectPeopleCheckbox[i - 1]) {//为空,说明害没设置,就是全部监听
+                                        monitoring(list2.get(i + 1), i, list2.get(i + 7));
+                                        bodySensor(i, list2.get(i + 7));
+                                    } else {
+                                        monitoring(list2.get(i + 1), i, "0");
+                                        bodySensor(i, list2.get(i + 7));
+                                    }
                                 }
                             }
-                        }
 
-                        /**
-                         *  if (isSelectCheckBox == null) {//厕所状态为空,说明还没设置,也就是全部都监听
-                         *                             for (int i = 1; i <= TOTAL_SUM; i++) {//什么都监听
-                         *                                 monitoring(list2.get(i + 1), i, list2.get(i + 7));
-                         *                                 bodySensor(i, list2.get(i + 7));
-                         *                             }
-                         *                         } else {//设置过厕所,说明有些不需要监听。
-                         *                             for (int i = 1; i <= TOTAL_SUM; i++) {//判断有哪些不需要监听的。
-                         *                                 //是否监听指定的厕所。
-                         *                                 if (!isSelectCheckBox[i - 1]) {//true为选中,false为未选中,不需要监听的,我们就过。
-                         *                                     continue;
-                         *                                 }
-                         *                                 //厕所需要监听,那么我们判断她是否监听指定的人体传感器
-                         *                                 if (isSelectPeopleCheckbox == null ||isSelectPeopleCheckbox[i-1]) {//为空,说明害没设置,就是全部监听
-                         *                                     monitoring(list2.get(i + 1), i, list2.get(i + 7));
-                         *                                     bodySensor(i, list2.get(i + 7));
-                         *                                 }else{
-                         *                                     if (!isSelectPeopleCheckbox[i-1]) {//true为选中,false为未选中,未选中就是不监听。
-                         *                                         monitoring(list2.get(i + 1), i, "0");
-                         *                                         bodySensor(i, list2.get(i + 7));
-                         *                                         continue;
-                         *                                     }
-                         *                                 }
-                         *
-                         *                             }
-                         *                         }
-                         */
-
-                        //监控1号厕所:门锁,以及人体传感器。
+                            /**
+                             *  if (isSelectCheckBox == null) {//厕所状态为空,说明还没设置,也就是全部都监听
+                             *                             for (int i = 1; i <= TOTAL_SUM; i++) {//什么都监听
+                             *                                 monitoring(list2.get(i + 1), i, list2.get(i + 7));
+                             *                                 bodySensor(i, list2.get(i + 7));
+                             *                             }
+                             *                         } else {//设置过厕所,说明有些不需要监听。
+                             *                             for (int i = 1; i <= TOTAL_SUM; i++) {//判断有哪些不需要监听的。
+                             *                                 //是否监听指定的厕所。
+                             *                                 if (!isSelectCheckBox[i - 1]) {//true为选中,false为未选中,不需要监听的,我们就过。
+                             *                                     continue;
+                             *                                 }
+                             *                                 //厕所需要监听,那么我们判断她是否监听指定的人体传感器
+                             *                                 if (isSelectPeopleCheckbox == null ||isSelectPeopleCheckbox[i-1]) {//为空,说明害没设置,就是全部监听
+                             *                                     monitoring(list2.get(i + 1), i, list2.get(i + 7));
+                             *                                     bodySensor(i, list2.get(i + 7));
+                             *                                 }else{
+                             *                                     if (!isSelectPeopleCheckbox[i-1]) {//true为选中,false为未选中,未选中就是不监听。
+                             *                                         monitoring(list2.get(i + 1), i, "0");
+                             *                                         bodySensor(i, list2.get(i + 7));
+                             *                                         continue;
+                             *                                     }
+                             *                                 }
+                             *
+                             *                             }
+                             *                         }
+                             */
+
+                            //监控1号厕所:门锁,以及人体传感器。
                        /* monitoring(list2.get(2), 1, list2.get(8));
                         //监控2号厕所
                         monitoring(list2.get(3), 2, list2.get(9));
@@ -1237,7 +1277,7 @@ public class MyService extends Service {
                         monitoring(list2.get(7), 6, "0" );*/
 
 
-                        //监控1号厕所
+                            //监控1号厕所
                       /*  bodySensor(1, list2.get(8));
                         //监控2号厕所
                         bodySensor(2, list2.get(9));
@@ -1249,7 +1289,7 @@ public class MyService extends Service {
                         bodySensor(5, list2.get(12));
                         //监控6号厕所
                         bodySensor(6, list2.get(13));*/
-
+                        }
                     } else if (name.equals("D2")) {
                         String data = String.valueOf(HexadecimalUtil.hex2dec(HexadecimalUtil.flipString(AsciiUtils.asciiByteArray2HexStr(responseFrame.getData())).get(0)));
                         // Log.d(TAG, "addCleanTimeD2event: " + data);
@@ -1419,14 +1459,14 @@ public class MyService extends Service {
         boolean isLastTime = false;
         boolean isNextTime = false;
         for (int i = 1; i < lastTimeSplit.length; i++) {
-            if (last==Integer.valueOf(lastTimeSplit[i])){
-                isLastTime=true;
+            if (last == Integer.valueOf(lastTimeSplit[i])) {
+                isLastTime = true;
                 break;
             }
         }
         for (int i = 1; i < nextTimeSplit.length; i++) {
-            if (first==Integer.valueOf(nextTimeSplit[i])){
-                isNextTime=true;
+            if (first == Integer.valueOf(nextTimeSplit[i])) {
+                isNextTime = true;
                 break;
             }
         }
@@ -1636,7 +1676,6 @@ public class MyService extends Service {
         Log.d(TAG, "cleanPositionNumX20厕所: " + number);
         mThreadPoolMyservice.stopWriteDD120();
         mThreadPoolMyservice.startWriteDD120("D120", "000" + data);
-        getCleanReport(1);
     }
 
     private boolean isOpenReadWarring = true;

+ 52 - 30
app/src/main/java/com/sunzee/ui/activity/HomeActivity.java

@@ -37,12 +37,14 @@ import com.sunzee.base.BaseFragment;
 import com.sunzee.base.MvpActivity;
 import com.sunzee.model.Heartbeat;
 import com.sunzee.model.HoleInformation;
+import com.sunzee.model.HttpResult;
 import com.sunzee.model.domain.ApkInfoBean;
 import com.sunzee.model.domain.Name;
 import com.sunzee.model.message.ApiMessageEvent;
 import com.sunzee.model.message.DownLoadMessageEvent;
 import com.sunzee.mvp.home.HomePresenter;
 import com.sunzee.mvp.home.HomeView;
+import com.sunzee.retrofit.ApiCallback;
 import com.sunzee.service.DownPresenter;
 import com.sunzee.service.MyService;
 import com.sunzee.ui.dialog.ManagementSystemDialog;
@@ -62,6 +64,10 @@ import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
 
 import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -503,37 +509,8 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
                             ToastUtil.showToast("你好,此操作需要在开机后才能操作");
                             break;
                         }
-                        //全蹲位清洗,需要在开机的状态才能执行。
-                        synchronized (MyService.sCleaningLocationList) {//多线程操作需要加上同步锁
-                            if (MyService.sCleaningLocationList.size() > 0) {//大于0的时候才需要处理。
-                                Integer integer = MyService.sCleaningLocationList.removeFirst();//如果清洗中,那么我们不能全部移除,否则清洗完毕的时候会漏掉一个厕所没有清洗,所以我们留存下来。在假如。
-                                MyService.sCleaningLocationList.clear();
-                                MyService.sCleaningLocationList.addFirst(integer);
-                            }
-                            boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX,null);
-                            if (isSelectCheckBox != null) {
-                                for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
-                                    if (!isSelectCheckBox[i - 1]) {
-                                        continue;
-                                    }
-                                    MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
-                                }
-                            }else{
-                                for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
-                                    MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
-                                }
-                            }
-                            if (!MyService.isCleanOK) {//清洗中,那麼我們就什麼都不做,如果不是清洗中,那麼我們需要進行復位。
-                                //开始清洗。
-                                //EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING,MyService. sCleaningLocationList.getFirst()));
-                                //復位成功後,會自己過去清洗的。所以我們不需要管他。
-                                EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING, MyService.sCleaningLocationList.getFirst()));
-                                ToastUtil.showToast("开始复位,准备开始全蹲位清洗,如果有人在里面使用,会等待人出来以后进行清洗。");
-                            } else {
-                                ToastUtil.showToast("已添加入清洗队列,等待本次清洗完成后开始清洗");
-                            }
+                        mvpPresenter.isCleaned();
 
-                        }
                         break;
                 }
             }
@@ -542,6 +519,8 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         shutdownDialog.show();
     }
 
+
+
     private Timer timerSet;
     private TimerTask timerTaskSet;
 
@@ -587,4 +566,47 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
                 break;
         }
     }
+
+    @Override
+    public void startClean() {
+        hideLoading();
+        if (MyService.isLate) {
+            //全蹲位清洗,需要在开机的状态才能执行。
+            synchronized (MyService.sCleaningLocationList) {//多线程操作需要加上同步锁
+                if (MyService.sCleaningLocationList.size() > 0) {//大于0的时候才需要处理。
+                    Integer integer = MyService.sCleaningLocationList.removeFirst();//如果清洗中,那么我们不能全部移除,否则清洗完毕的时候会漏掉一个厕所没有清洗,所以我们留存下来。在假如。
+                    MyService.sCleaningLocationList.clear();
+                    MyService.sCleaningLocationList.addFirst(integer);
+                }
+                boolean[] isSelectCheckBox = Hawk.get(Name.ISSELECTCHECKBOX,null);
+                if (isSelectCheckBox != null) {
+                    for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
+                        if (!isSelectCheckBox[i - 1]) {
+                            continue;
+                        }
+                        MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
+                    }
+                }else{
+                    for (int i = 1; i <= MyService.TOTAL_SUM; i++) {
+                        MyService.sCleaningLocationList.addLast(i);//从尾部添加。如果集合中已经存在呢?
+                    }
+                }
+                if (!MyService.isCleanOK) {//清洗中,那麼我們就什麼都不做,如果不是清洗中,那麼我們需要進行復位。
+                    //开始清洗。
+                    //EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING,MyService. sCleaningLocationList.getFirst()));
+                    //復位成功後,會自己過去清洗的。所以我們不需要管他。
+                    EventBus.getDefault().post(new ApiMessageEvent(Name.ALLCLEANING, MyService.sCleaningLocationList.getFirst()));
+                    ToastUtil.showToast("开始复位,准备开始全蹲位清洗,如果有人在里面使用,会等待人出来以后进行清洗。");
+                } else {
+                    ToastUtil.showToast("已添加入清洗队列,等待本次清洗完成后开始清洗");
+                }
+
+            }
+        }
+    }
+
+    @Override
+    public void haveExpired() {
+        ToastUtil.showToast("已过期,请充值后使用哦。");
+    }
 }

+ 134 - 34
app/src/main/java/com/sunzee/ui/activity/HomePageAActivity.java

@@ -6,12 +6,20 @@ import android.graphics.Color;
 import android.os.Bundle;
 import android.os.Handler;
 import android.support.annotation.Nullable;
+import android.support.design.widget.NavigationView;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.util.DisplayMetrics;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.KeyEvent;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.WindowManager;
-import android.widget.RelativeLayout;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.hboxs.serialport.frame.ResponseFrame;
@@ -19,12 +27,14 @@ import com.hboxs.serialport.message.Message;
 import com.hboxs.serialport.util.AsciiUtils;
 import com.orhanobut.hawk.Hawk;
 import com.sunzee.R;
+import com.sunzee.adapter.DebugParameterXAdapter;
+import com.sunzee.adapter.HomePageAAdapter;
+import com.sunzee.base.BaseApplication;
 import com.sunzee.base.MvpActivity;
 import com.sunzee.model.Global;
 import com.sunzee.model.Heartbeat;
 import com.sunzee.model.HoleInformation;
 import com.sunzee.model.domain.CleaningBean;
-import com.sunzee.model.domain.HeartbeatBean;
 import com.sunzee.model.domain.Name;
 import com.sunzee.model.domain.ParameterBean;
 import com.sunzee.mvp.homeactivity.HomePageAPresenter;
@@ -72,8 +82,6 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
     private TextView tvWashingTime;
     private TextView tvIn;
     private TextView tvOut;
-    private TextView tvToiletdiagram1;
-    private TextView tvToiletdiagram2;
     private TextView tvAmmonia;
     private TextView tvHumidity;
     private TextView tvTemperature;
@@ -82,6 +90,12 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
     private List<String> useLastToiletsStatus;//上一次厕所的使用状态
     private TextView tvCompany;
     private TextView tvContacts;
+    private NavigationView navigationView;
+    private DrawerLayout drawerLayout;
+    private ActionBarDrawerToggle toggle;//创建一个Drawerlayout和Toolbar联动的开关
+    private LinearLayout llSigin;
+    private RecyclerView rvToiletState;
+    private HomePageAAdapter homePageAAdapter;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -110,8 +124,70 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                 return false;
             }
         });
+        /*设置监听器*/
+        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
+
+            @Override
+            public boolean onNavigationItemSelected(MenuItem item) {
+                drawerLayout.closeDrawer(GravityCompat.START);
+                return true;
+            }
+        });
+        llSigin.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                drawerLayout.openDrawer(Gravity.LEFT);
+                Log.d(TAG, "openDrawer: "+navigationView.isSelected());
+            }
+        });
+        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout,
+                R.string.ad_content, R.string.ad_content) {
+            @Override
+            public void onDrawerOpened(View drawerView) {
+                super.onDrawerOpened(drawerView);
+                Log.d(TAG, "onDrawerOpened: 打开了");
+                stopSigin();
+                startSigin();
+            }
+
+            @Override
+            public void onDrawerClosed(View drawerView) {
+                super.onDrawerClosed(drawerView);
+                Log.d(TAG, "onDrawerOpened: 关闭了");
+                stopSigin();
+            }
+        };
+        drawerLayout.addDrawerListener(toggle);
+    }
+
+    private Timer timerSigin;
+    private TimerTask timeSiginTimerTak;
+
+    //签到侧栏在指定时间内需要关闭。
+    private void startSigin() {
+        timerSigin = new Timer();
+        timeSiginTimerTak = new TimerTask() {
+            @Override
+            public void run() {
+                myHandler.sendEmptyMessage(4);
+            }
+        };
+        timerSigin.schedule(timeSiginTimerTak,60*1000);
+    }
+
+    private void stopSigin(){
+        if (timerSigin != null) {
+            timerSigin.cancel();
+            timerSigin = null;
+        }
+        if (timeSiginTimerTak != null) {
+            timeSiginTimerTak.cancel();
+            timeSiginTimerTak = null;
+        }
     }
 
+
+
     private void initView() {
         myHandler = new MyHandler(this);
         mTvTime = findViewById(R.id.tv_time1);
@@ -124,18 +200,17 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
         tvIn = findViewById(R.id.tv_in);
         tvYesterday = findViewById(R.id.tv_yesterday);
         tvOut = findViewById(R.id.tv_out);
-        tvToiletdiagram1 = findViewById(R.id.tv_toiletdiagram1);
-        tvToiletdiagram2 = findViewById(R.id.tv_toiletdiagram2);
+        rvToiletState = findViewById(R.id.rv_toilet_state);
         tvAmmonia = findViewById(R.id.tv_ammonia);
         tvHumidity = findViewById(R.id.tv_humidity);
         tvTemperature = findViewById(R.id.tv_temperature);
         tvCompany = findViewById(R.id.tv_company);
         tvContacts = findViewById(R.id.tv_contacts);
+        llSigin = findViewById(R.id.ll_sigin);
         //设备编号只显示6位
         mTvEquipmentNo = findViewById(R.id.tv_equipment_no1);
         if (Heartbeat.deviceId != null && Heartbeat.deviceId.length() > 7) {
             mTvEquipmentNo.setText(UiUtil.getStringRes(R.string.equipment) + (Heartbeat.deviceId != null ? Heartbeat.deviceId.substring(Heartbeat.deviceId.length() - 6) : ""));
-
         }
         //关闭RefreshTime、UserState
         stopRefreshTime();
@@ -152,9 +227,28 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
         mvpPresenter.createBox(MyService.TOTAL_SUM);
         tvCompany.setText("公司:"+Hawk.get(Name.COMPANY,""));
         tvContacts.setText("联系人:"+Hawk.get(Name.WAYCONTACTS,""));
+
+        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+        navigationView = (NavigationView) findViewById(R.id.navigation_view);
+        navigationView.getChildAt(0).setVerticalScrollBarEnabled(false);
+        /*设置Drawerlayout的开关,并且和Home图标联动*/
+        toggle = new ActionBarDrawerToggle(this, drawerLayout, 0, 0);
+        drawerLayout.addDrawerListener(toggle);
+        /*同步drawerlayout的状态*/
+        toggle.syncState();
+
+        LinearLayoutManager layoutManagerx = new LinearLayoutManager(BaseApplication.getContext());
+        layoutManagerx.setOrientation(LinearLayoutManager.HORIZONTAL);
+        rvToiletState.setLayoutManager(layoutManagerx);
+        homePageAAdapter = new HomePageAAdapter(MyService.sHoleInformationList);
+        rvToiletState.setAdapter(homePageAAdapter);
+
     }
 
 
+
+
+
     @Override
     public void updateTime(CharSequence sysTimeStr) {
         mTvTime.setText(sysTimeStr);
@@ -176,7 +270,7 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
     @Override
     protected void onStop() {
         super.onStop();
-
+        Log.d(TAG, "onStoponStop: ");
 
     }
 
@@ -295,7 +389,7 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
     /**
      * 主要用于更新系统时间
      */
-    public static class MyHandler extends Handler {
+    public class MyHandler extends Handler {
         //持有弱引用HandlerActivity,GC回收时会被回收掉.
         private final WeakReference<HomePageAActivity> mActivty;
 
@@ -320,23 +414,8 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                     activity.tvWcEmpty.setText(activity.empty + "");
                     //厕所示意图
                     if (MyService.sHoleInformationList.size() >= 0) {
-                        if (MyService.sHoleInformationList.get(0).isUserAndEmpty()) {
-                            activity.tvToiletdiagram1.setBackgroundResource(R.drawable.shape_home_mannedtoilet);
-                            activity.tvToiletdiagram1.setText("有人");
-                            activity.tvToiletdiagram1.setTextColor(Color.WHITE);
-                        } else {
-                            activity.tvToiletdiagram1.setBackgroundResource(R.drawable.icon9);
-                            activity.tvToiletdiagram1.setText("无人");
-                            activity.tvToiletdiagram1.setTextColor(activity.getResources().getColor(R.color.state_green));
-                        }
-                        if (MyService.sHoleInformationList.get(1).isUserAndEmpty()) {
-                            activity.tvToiletdiagram2.setBackgroundResource(R.drawable.shape_home_mannedtoilet);
-                            activity.tvToiletdiagram2.setText("有人");
-                            activity.tvToiletdiagram2.setTextColor(Color.WHITE);
-                        } else {
-                            activity.tvToiletdiagram2.setBackgroundResource(R.drawable.icon9);
-                            activity.tvToiletdiagram2.setText("无人");
-                            activity.tvToiletdiagram2.setTextColor(activity.getResources().getColor(R.color.state_green));
+                        for (int i = 0; i < MyService.sHoleInformationList.size(); i++) {
+                            getXValue(MyService.sHoleInformationList.get(i),i,activity.rvToiletState);
                         }
                     }
                     break;
@@ -347,10 +426,38 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                         activity.tvYesterday.setText("昨日合计”进“:" + activity.yesterdayBean.getInCount());
                     }
                     activity.tvWashingTime.setText(activity.cleaningBean.getCleanCount());
-
+                    break;
+                case 4:
+                    if (activity.drawerLayout != null) {
+                        activity. drawerLayout.closeDrawer(GravityCompat.START);
+                    }
                     break;
             }
         }
+
+        /**
+         * 改变对应的状态
+         *
+         * @param position 要改变的图片的位置
+         */
+        private void getXValue(HoleInformation holeInformation,int position, RecyclerView recyclerView) {
+            View view = recyclerView.getLayoutManager().findViewByPosition(position);
+            if (view == null) {
+                Log.d("空1", "getXYValue: p=" + position + "  index=" + position);
+            } else {
+                HomePageAAdapter.TitleViewHolder viewHolder = (HomePageAAdapter.TitleViewHolder) recyclerView.getChildViewHolder(view);
+                if (holeInformation.isUserAndEmpty()) {
+                    viewHolder.getTv_toiletdiagram().setBackgroundResource(R.drawable.shape_home_mannedtoilet);
+                    viewHolder.getTv_toiletdiagram().setText("有人");
+                    viewHolder.getTv_toiletdiagram().setTextColor(Color.WHITE);
+                } else {
+                    viewHolder.getTv_toiletdiagram().setBackgroundResource(R.drawable.icon9);
+                    viewHolder.getTv_toiletdiagram().setText("无人");
+                    viewHolder.getTv_toiletdiagram().setTextColor(getResources().getColor(R.color.state_green));
+                }
+
+            }
+        }
     }
 
     private Timer timerGetTime;
@@ -400,7 +507,6 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
             @Override
             public void run() {
                 //上传厕所状态
-
                 if (useLastToiletsStatus==null) {
                     useLastToiletsStatus = new ArrayList<>();
                     for (int i = 0; i < MyService.TOTAL_SUM; i++) {
@@ -412,8 +518,6 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                     if (MyService.sHoleInformationList != null&& MyService.sHoleInformationList.size()>0) {
                         for (int i = 0; i < MyService.TOTAL_SUM; i++) {
                             String userStates = MyService.sHoleInformationList.get(i).getUserStates();
-                            Log.d(TAG, "useLastToiletsStatusrun1: "+useLastToiletsStatus.get(i));
-                            Log.d(TAG, "userStatesrun1: "+userStates);
                             if (!useLastToiletsStatus.get(i).equals(userStates)) {
                                 mvpPresenter.sendStatusOfToiletUse((i+1)+"号",userStates);
                                 useLastToiletsStatus.add(i,userStates);
@@ -440,8 +544,6 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                 myHandler.sendEmptyMessage(3);
             }
         }
-
-
     }
 
     /**
@@ -460,8 +562,6 @@ public class HomePageAActivity extends MvpActivity<HomePageAPresenter> implement
                         } else {                                  //无人
                             empty++;
                         }
-                        //发送太过频繁会导致出现问题。
-                        //mvpPresenter.sendStatusOfToiletUse((i+1)+"号",holeInformation.getUserStates());
                     }
                     if (myHandler != null) {
                         myHandler.sendEmptyMessage(2);

+ 5 - 12
app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java

@@ -210,19 +210,12 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
                         String[] nextTimeSplit = nextTime.split("");
                         boolean isNextTime = false;
                         for (int i = 1; i < nextTimeSplit.length; i++) {
-                           /* if (cleaningLocation==Integer.valueOf(nextTimeSplit[i])) {
-                                ToastUtil.showToast("清洗完该号厕所需要再一次开机复位才能清洗其他厕所。");
-                            }*/
                            //如果不等于这些,说明是45号厕所,那么就需要复位才能清洗。
                             if (lastTimeClean==-1) {//如果是-1,说明是第一次,说明是开机的时候。我们就直接过。
                                 isNextTime = true;
                             }else  if (lastTimeClean!=-1) {//如果不是-1,说明123,或者456.
                                 isNextTime = getLastNextCleanTitole(cleaningLocation);
-                               /*                             //如果是上一次清洗的是123,下次要清洗的是456,那么我们不需要复位,并且如果
-                                if (lastTimeClean==Integer.valueOf(nextTimeSplit[i]) ){//如果存在,那么说明不是456
-                                    Log.d(TAG, "111onClickListener: "+Integer.valueOf(nextTimeSplit[i]));
-                                    isNextTime=true;
-                                }*/
+
                             }
                         }
                         if (isNextTime) {
@@ -230,8 +223,9 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
                             showLoading();
                             Log.d(TAG, "onClickListener: " + cleaningLocation);
 //                        mvpPresenter.isCanWrite();// todo 判断是否有钱才可以清洗,我们现在使用的是无钱模式。
+                            mvpPresenter.isCanWrite();
 //                            startClean();
-                            addCleaning(cleaningLocation);
+//                            addCleaning(cleaningLocation);
                             lastTimeClean = cleaningLocation;
                         }else{
                             ToastUtil.showToast("需要再一次开机复位才能清洗其他厕所,因为轨迹不同。");
@@ -285,7 +279,8 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
     @Override
     public void startClean() {
         hideLoading();
-        startClean(cleaningLocation);
+        //startClean(cleaningLocation);
+        addCleaning(cleaningLocation);
     }
 
     @Override
@@ -306,13 +301,11 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
                 MyService.sCleaningLocationList.addLast(needCleaning);
                 if (!MyService.isCleanOK) {
                     EventBus.getDefault().post(new ApiMessageEvent(Name.SINGLEPOINTCLEANING, needCleaning));
-
                     ToastUtil.showToast("准备开始清洗,如果有人在里面使用,会等待人出来以后进行清洗。");
                 }else{
                     ToastUtil.showToast("清洗中,已添加入清洗队列,等待本次清洗完成后开始清洗");
                 }
             }
-
         }
     }
 

BIN
app/src/main/res/drawable-hdpi/icon_no_gongzonghao.jpg


BIN
app/src/main/res/drawable-mdpi/icon_no_gongzonghao.jpg


BIN
app/src/main/res/drawable-xhdpi/icon_no_gongzonghao.jpg


BIN
app/src/main/res/drawable-xxhdpi/icon_no_gongzonghao.jpg


BIN
app/src/main/res/drawable-xxxhdpi/icon_no_gongzonghao.jpg


+ 22 - 0
app/src/main/res/drawable/shape_radio_signin.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval"
+    android:useLevel="false"
+    >
+    <solid android:color="#0b62d1" />
+
+    <stroke
+        android:width="10dp"
+        android:color="#0f49b3" />
+
+    <size android:height="@dimen/dp_16"
+        android:width="@dimen/dp_16"
+        />
+    <corners
+        android:bottomLeftRadius="360dp"
+        android:bottomRightRadius="360dp"
+        android:topLeftRadius="360dp"
+        android:topRightRadius="360dp" />
+
+</shape>

+ 0 - 1
app/src/main/res/layout/activity_home.xml

@@ -23,7 +23,6 @@
             app:itemBackground="@color/white"
             app:itemTextAppearance="@style/Menu"
             app:menu="@menu/my_navigation_items"
-
             app:theme="@style/ItemHeight" />
 
 

+ 34 - 99
app/src/main/res/layout/activity_homeactivity.xml

@@ -4,9 +4,15 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:orientation="vertical"
     android:gravity="center"
     android:background="#011f4b">
 
+    <android.support.v4.widget.DrawerLayout
+        android:id="@+id/drawer_layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
     <RelativeLayout
         android:layout_width="wrap_content"
         android:layout_height="match_parent">
@@ -68,28 +74,12 @@
             android:layout_marginLeft="@dimen/dp_31"
             android:background="@drawable/icon1"
             android:orientation="horizontal"
-            android:paddingLeft="@dimen/dp_8">
-
-            <TextView
-                android:id="@+id/tv_toiletdiagram1"
-                android:layout_width="@dimen/dp_104"
-                android:layout_height="@dimen/dp_148"
-                android:background="@drawable/icon9"
-                android:gravity="center"
-                android:text="无人"
-                android:layout_marginRight="@dimen/dp_2"
-                android:textColor="@color/state_green"
-                android:textSize="@dimen/sp_14" />
-
-            <TextView
-                android:id="@+id/tv_toiletdiagram2"
-                android:layout_width="@dimen/dp_104"
-                android:layout_height="@dimen/dp_148"
-                android:background="@drawable/icon9"
-                android:gravity="center"
-                android:text="无人"
-                android:textColor="@color/state_green"
-                android:textSize="@dimen/sp_14" />
+            android:paddingLeft="@dimen/dp_4">
+            <android.support.v7.widget.RecyclerView
+                android:id="@+id/rv_toilet_state"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="@dimen/dp_6" />
         </LinearLayout>
 
 
@@ -447,91 +437,36 @@
 
             </LinearLayout>
         </LinearLayout>
-
-        <ImageView
-            android:layout_width="@dimen/dp_40"
-            android:layout_height="@dimen/dp_16"
-            android:layout_marginLeft="@dimen/dp_10"
-            android:layout_marginTop="@dimen/dp_6"
-            android:src="@drawable/login_logo"
-            android:visibility="gone" />
-
         <LinearLayout
-            android:id="@+id/ll_service"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:background="@drawable/shape_system_btn_rounded_rectangle"
-            android:orientation="vertical"
-            android:textColor="#767988"
-            android:visibility="gone">
-
-            <TextView
-                android:id="@+id/tv_servicecontact"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginRight="@dimen/dp_5"
-                android:layout_marginBottom="@dimen/dp_1"
-                android:padding="@dimen/dp_2"
-                android:textColor="#767988"
-                android:textSize="@dimen/dp_5" />
+            android:id="@+id/ll_sigin"
+            android:layout_width="@dimen/dp_41"
+            android:layout_height="@dimen/dp_41"
+            android:background="@drawable/shape_radio_signin"
+            android:gravity="center"
+            android:layout_marginLeft="@dimen/dp_8"
+            android:layout_centerVertical="true"
+            android:orientation="vertical">
 
             <TextView
-                android:id="@+id/tv_serviceline"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:padding="@dimen/dp_2"
-                android:textColor="#767988"
-                android:textSize="@dimen/dp_5" />
-
+                android:text="签到"
+                android:textColor="@color/white"
+                android:textSize="@dimen/sp_12" />
         </LinearLayout>
 
-        <RelativeLayout
-            android:id="@+id/rl_root"
-            android:layout_width="wrap_content"
-            android:layout_height="@dimen/dp_40"
-            android:layout_alignParentRight="true"
-            android:visibility="gone">
+    </RelativeLayout>
+        <android.support.design.widget.NavigationView
+            android:id="@+id/navigation_view"
+            android:layout_width="@dimen/dp_120"
+            android:layout_height="match_parent"
+            app:itemIconTint="@color/colorAccent"
+            android:layout_gravity="start"
+            android:background="#011f4b"
+            app:headerLayout="@layout/header">
+        </android.support.design.widget.NavigationView>
+    </android.support.v4.widget.DrawerLayout>
 
-            <TextView
-                android:id="@+id/tv_time"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:text="@string/current_time1"
-                android:textColor="@color/white"
-                android:textSize="@dimen/sp_8" />
 
-            <TextView
-                android:id="@+id/tv_time12"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toRightOf="@id/tv_time"
-                android:gravity="center_vertical"
-                android:text="2019-05-05 18:00:00"
-                android:textColor="@color/white"
-                android:textSize="@dimen/sp_8" />
 
-            <TextView
-                android:id="@+id/tv_equipment_no"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/tv_time"
-                android:layout_alignParentLeft="true"
-                android:text="@string/equipment_no"
-                android:textColor="@color/white"
-                android:textSize="@dimen/sp_8" />
-
-            <TextView
-                android:id="@+id/tv_equipment_no12"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/tv_time"
-                android:layout_toRightOf="@id/tv_equipment_no"
-                android:gravity="center_vertical"
-                android:text="1234567856"
-                android:textColor="@color/white"
-                android:textSize="@dimen/sp_8" />
-        </RelativeLayout>
-    </RelativeLayout>
 </LinearLayout>

+ 2 - 3
app/src/main/res/layout/fragment_other.xml

@@ -144,12 +144,11 @@
                 android:layout_toRightOf="@id/tv_robot_contacts"
                 android:background="@drawable/shape_lt_lb"
                 android:gravity="center"
-                android:text="@string/contact1"
+                android:text="公司"
                 android:textColor="@color/logo_blue"
                 android:textSize="@dimen/dp_8" />
 
             <EditText
-
                 android:id="@+id/et_contract"
                 android:layout_width="@dimen/dp_70"
                 android:layout_height="@dimen/dp_22"
@@ -157,7 +156,7 @@
                 android:layout_marginTop="@dimen/dp_40"
                 android:layout_toRightOf="@id/tv_contacts"
                 android:background="@drawable/shape_rt_rb"
-                android:hint="请输入联系人"
+                android:hint="请输入公司名称"
                 android:paddingStart="@dimen/dp_5"
                 android:paddingLeft="@dimen/dp_2"
                 android:textColor="@color/colorHint"

+ 42 - 0
app/src/main/res/layout/header.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:gravity="center"
+    android:layout_gravity="center"
+    android:background="#011f4b">
+
+
+    <LinearLayout
+        android:layout_marginTop="@dimen/dp_100"
+        android:layout_width="@dimen/dp_80"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+        <ImageView
+            android:id="@+id/iv_Checkcode"
+            android:layout_width="@dimen/dp_80"
+            android:layout_height="@dimen/dp_80"
+            android:src="@drawable/icon_no_gongzonghao"/>
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="@dimen/dp_6"
+            android:gravity="center"
+            android:textColor="@color/white"
+            android:layout_marginTop="@dimen/dp_6"
+            android:text="扫一扫上面的签到码图案,进行签到"/>
+    </LinearLayout>
+
+
+    <TextView
+        android:id="@+id/tv_flushCheckcode"
+        android:layout_marginTop="@dimen/dp_14"
+        android:layout_width="@dimen/dp_80"
+        android:layout_height="@dimen/dp_16"
+        android:gravity="center"
+        android:textSize="@dimen/dp_8"
+        android:background="@drawable/shape_login_rounded_rectangle"
+        android:textColor="#FFF"
+        android:text="刷新签到码"/>
+</LinearLayout>

+ 18 - 0
app/src/main/res/layout/item_nobody_homepage.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content">
+    <TextView
+        android:id="@+id/tv_toiletdiagram2"
+        android:layout_width="@dimen/dp_104"
+        android:layout_height="@dimen/dp_148"
+        android:layout_marginLeft="@dimen/dp_2"
+        android:background="@drawable/icon9"
+        android:gravity="center"
+        android:text="无人"
+        android:textColor="@color/state_green"
+        android:textSize="@dimen/sp_14" />
+
+
+</LinearLayout>

+ 31 - 0
app/src/main/res/layout/sidebar_layout.xml

@@ -0,0 +1,31 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:orientation="vertical">
+    <android.support.v7.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="?actionBarSize"
+        android:background="@color/colorPrimary"
+        app:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
+    </android.support.v7.widget.Toolbar>
+    <android.support.v4.widget.DrawerLayout
+        android:id="@+id/drawer_layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Hello World!" />
+        <android.support.design.widget.NavigationView
+            android:id="@+id/navigation_view"
+            android:layout_width="240dp"
+            android:layout_height="match_parent"
+            app:itemIconTint="@color/colorAccent"
+            android:layout_gravity="start"
+            app:headerLayout="@layout/header">
+        </android.support.design.widget.NavigationView>
+    </android.support.v4.widget.DrawerLayout>
+</LinearLayout>

+ 4 - 0
app/src/main/res/values-en/strings.xml

@@ -483,4 +483,8 @@
     <string name="jerk">急停</string>
     <string name="pointmove_speed">点动速度</string>
     <string name="equipment">设备编号:</string>
+
+
+
+    <string name="cleansignin">清洁人员签到</string>
 </resources>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -485,5 +485,6 @@
     <string name="pointmove_speed">点动速度</string>
     <string name="equipment">设备编号:</string>
 
+    <string name="cleansignin">清洁人员签到</string>
 
 </resources>

BIN
serialportlib/.cxx/cmake/debug/arm64-v8a/CMakeFiles/hboxs_serial_port.dir/src/main/cpp/SerialPort.c.o


BIN
serialportlib/.cxx/cmake/debug/x86_64/CMakeFiles/hboxs_serial_port.dir/src/main/cpp/SerialPort.c.o