Browse Source

1.增加蹲位清洗,点击某蹲位就可以清洗某蹲位
2.后台推送蹲位清洗,后台点击某蹲位就可以清洗某蹲位
3.

Tony 5 years ago
parent
commit
7a729d52cb
37 changed files with 1481 additions and 75 deletions
  1. 7 1
      app/build.gradle
  2. 13 6
      app/proguard-rules.pro
  3. 18 0
      app/src/main/AndroidManifest.xml
  4. 85 0
      app/src/main/java/com/sunzee/base/BaseApplication.java
  5. 14 0
      app/src/main/java/com/sunzee/model/domain/Name.java
  6. 36 6
      app/src/main/java/com/sunzee/mvp/advertising/AdvertisingPresenter.java
  7. 10 5
      app/src/main/java/com/sunzee/mvp/home/HomePresenter.java
  8. 2 0
      app/src/main/java/com/sunzee/mvp/home/HomeView.java
  9. 99 0
      app/src/main/java/com/sunzee/mvp/homepage/HomePagePresenter.java
  10. 9 0
      app/src/main/java/com/sunzee/mvp/homepage/HomePageView.java
  11. 2 1
      app/src/main/java/com/sunzee/receiver/TimedCleaningTaskAlarmReceiver.java
  12. 5 1
      app/src/main/java/com/sunzee/retrofit/ApiStores.java
  13. 16 2
      app/src/main/java/com/sunzee/service/MyIntentService.java
  14. 30 7
      app/src/main/java/com/sunzee/service/MyService.java
  15. 14 3
      app/src/main/java/com/sunzee/thread/advanceparameter/AdvanceParameterTask.java
  16. 1 0
      app/src/main/java/com/sunzee/thread/advanceparameter/AdvanceParameterThreadType.java
  17. 22 15
      app/src/main/java/com/sunzee/thread/advanceparameter/ThreadPoolAdvanceParameter.java
  18. 158 0
      app/src/main/java/com/sunzee/thread/homepage/HomepageTask.java
  19. 10 0
      app/src/main/java/com/sunzee/thread/homepage/HomepageThreadType.java
  20. 92 0
      app/src/main/java/com/sunzee/thread/homepage/ThreadPoolHomepage.java
  21. 11 0
      app/src/main/java/com/sunzee/thread/myservice/MyserviceTask.java
  22. 1 0
      app/src/main/java/com/sunzee/thread/myservice/MyserviceThreadType.java
  23. 18 3
      app/src/main/java/com/sunzee/thread/myservice/ThreadPoolMyservice.java
  24. 21 4
      app/src/main/java/com/sunzee/ui/activity/AdvertisingActivity.java
  25. 9 9
      app/src/main/java/com/sunzee/ui/activity/HomeActivity.java
  26. 2 2
      app/src/main/java/com/sunzee/ui/dialog/NormalDialog.java
  27. 86 0
      app/src/main/java/com/sunzee/ui/dialog/StartCleaningDialog.java
  28. 1 0
      app/src/main/java/com/sunzee/ui/fragment/AdvanceParameterFragment.java
  29. 188 10
      app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java
  30. 105 0
      app/src/main/java/com/sunzee/ui/view/CustomView.java
  31. 255 0
      app/src/main/java/com/sunzee/ui/view/CustomViewGrounp.java
  32. 11 0
      app/src/main/java/com/sunzee/utils/PreventSpeedClickUtil.java
  33. 73 0
      app/src/main/res/layout/dialog_startclean.xml
  34. 30 0
      app/src/main/res/layout/fragment_home2.xml
  35. 25 0
      app/src/main/res/values/ids.xml
  36. 1 0
      app/src/main/res/values/strings.xml
  37. 1 0
      gradle.properties

+ 7 - 1
app/build.gradle

@@ -40,7 +40,7 @@ ext {
     eventbusversion = "3.2.0"
     filedownloader = '1.7.6'
     hawkVersion = '2.0.1'
-    greendaoVersion='3.2.2'
+    greendaoVersion = '3.2.2'
 }
 
 dependencies {
@@ -48,6 +48,10 @@ dependencies {
     implementation "com.wuxiaolong.androidutils:androidutils:$androidutilsVersion"
     //noinspection GradleCompatible,GradleDependency
     implementation "com.android.support:appcompat-v7:$appcompatVersion"
+    implementation 'com.tencent.bugly:crashreport:latest.release'
+    //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.1.9
+    implementation 'com.tencent.bugly:nativecrashreport:latest.release'
+    //其中latest.release指代最新Bugly NDK版本号,也可以指定明确的版本号,例如3.0
     //黄油刀
     implementation 'com.android.support:appcompat-v7:28.0.0'
     implementation 'com.android.support.constraint:constraint-layout:1.1.3'
@@ -77,4 +81,6 @@ dependencies {
 
     implementation "com.liulishuo.filedownloader:library:$filedownloader"
     implementation "org.greenrobot:greendao:$greendaoVersion"
+
+
 }

+ 13 - 6
app/proguard-rules.pro

@@ -1,17 +1,24 @@
 # Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in C:\Users\WuXiaolong\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
 #
 # For more details, see
 #   http://developer.android.com/guide/developing/tools/proguard.html
 
-# Add any project specific keep options here:
-
 # If your project uses WebView with JS, uncomment the following
 # and specify the fully qualified class name to the JavaScript interface
 # class:
 #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
 #   public *;
 #}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
+#bugly
+-dontwarn com.tencent.bugly.**
+-keep public class com.tencent.bugly.**{*;}

+ 18 - 0
app/src/main/AndroidManifest.xml

@@ -16,6 +16,13 @@
         tools:ignore="ProtectedPermissions" />
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
 
+
+    <!--bugly所需权限-->
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.READ_LOGS" />
+
     <application
         android:name=".base.BaseApplication"
         android:allowBackup="true"
@@ -94,6 +101,17 @@
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
             </intent-filter>
         </receiver>
+
+        <meta-data
+            android:name="PUSH_APPID"
+            android:value="n4vsaIAi0eAbAkfBfqsUL7" />
+        <meta-data
+            android:name="PUSH_APPKEY"
+            android:value="iUQlj7YC4c5Zb7CSuwQTP4" />
+        <meta-data
+            android:name="PUSH_APPSECRET"
+            android:value="fLvPjR8hni7VFMkgjh8lx2" /> <!-- 配置SDK核⼼服务 -->
+        <!-- android:permission在2.13.1.0版本后必须配置 -->
     </application>
 
 </manifest>

+ 85 - 0
app/src/main/java/com/sunzee/base/BaseApplication.java

@@ -4,7 +4,13 @@ import android.app.Application;
 import android.content.Context;
 import android.content.Intent;
 import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Point;
+import android.os.Build;
 import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Display;
+import android.view.WindowManager;
 
 import com.hboxs.serialport.SerialPortDevice;
 import com.hboxs.serialport.SerialPortManager;
@@ -15,7 +21,13 @@ import com.sunzee.model.Heartbeat;
 import com.sunzee.model.domain.Name;
 import com.sunzee.service.MyService;
 import com.sunzee.utils.FileUtil;
+import com.sunzee.utils.GeTuiUtil;
 import com.sunzee.utils.SharedPreferencesUtils;
+import com.tencent.bugly.crashreport.CrashReport;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
 
 /**
  * Created by MinKin.
@@ -29,9 +41,14 @@ public class BaseApplication extends Application {
     private DaoMaster mDaoMaster;
     private DaoSession mDaoSession;
 
+    public static int mRealSizeWidth;//手机屏幕真实宽度
+    public static int mRealSizeHeight;//手机屏幕真实高度
+    private static final String TAG = "BaseApplication";
     @Override
     public void onCreate() {
         super.onCreate();
+        //初始化bugly
+        initBugly();
         mContext = this;
         instances = this;
         Hawk.init(this).build();
@@ -42,7 +59,75 @@ public class BaseApplication extends Application {
         startMyService();
         firstHeartbeat();
         setDatabase();
+        getScreenWidthHeight();
+    }
+
+    //获取屏幕高和宽:不包含虚拟按键部分的高和宽。
+    public void getScreenWidthHeight() {
+        WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
+        Display display = windowManager.getDefaultDisplay();
+        Point outPoint = new Point();
+        if (Build.VERSION.SDK_INT >= 19) {
+            // 可能有虚拟按键的情况
+            display.getRealSize(outPoint);
+        } else {
+            // 不可能有虚拟按键
+            display.getSize(outPoint);
+        }
+        mRealSizeHeight = outPoint.y;
+        mRealSizeWidth = outPoint.x;
+        Log.d(TAG, "GTgetScreenHeight: "+mRealSizeHeight);
+        Log.d(TAG, "GTgetScreenWidth: "+mRealSizeWidth);
+    }
+
+
+    /**
+     * 初始化bugly
+     */
+    private void initBugly() {
+        Context context = getApplicationContext();
+        // 获取当前包名
+        String packageName = context.getPackageName();
+        // 获取当前进程名
+        String processName = getProcessName(android.os.Process.myPid());
+        // 设置是否为上报进程
+        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
+        strategy.setUploadProcess(processName == null || processName.equals(packageName));
+        // 初始化Bugly
+        CrashReport.initCrashReport(context, "b764cadec8", true, strategy);
+        // 如果通过“AndroidManifest.xml”来配置APP信息,初始化方法如下
+        // CrashReport.initCrashReport(context, strategy);
+    }
+
+    /**
+     * 获取进程号对应的进程名
+     *
+     * @param pid 进程号
+     * @return 进程名
+     */
+    private static String getProcessName(int pid) {
+        BufferedReader reader = null;
+        try {
+            reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline"));
+            String processName = reader.readLine();
+            if (!TextUtils.isEmpty(processName)) {
+                processName = processName.trim();
+            }
+            return processName;
+        } catch (Throwable throwable) {
+            throwable.printStackTrace();
+        } finally {
+            try {
+                if (reader != null) {
+                    reader.close();
+                }
+            } catch (IOException exception) {
+                exception.printStackTrace();
+            }
+        }
+        return null;
     }
+    //-------------------------------------------------------------------------------------bugly end -------------------------------------------
 
     /**
      * 首次心跳

+ 14 - 0
app/src/main/java/com/sunzee/model/domain/Name.java

@@ -28,4 +28,18 @@ public interface Name {
 
     //网络状态
     String NET_TYPE = "net_type";
+
+
+    /**
+     * 清洗的过期时间
+     */
+    String OVERDUE_DATE = "overdueDate";
+    /**
+     * 清洗的次数
+     */
+    String REMAINING = "remaining";
+    /**
+     * 开始清洗
+     */
+    String STARTCLEAN = "startClean";
 }

+ 36 - 6
app/src/main/java/com/sunzee/mvp/advertising/AdvertisingPresenter.java

@@ -14,7 +14,9 @@ import com.sunzee.model.Heartbeat;
 import com.sunzee.model.HttpResult;
 import com.sunzee.model.HttpResult2;
 import com.sunzee.model.domain.GetAdBean;
+import com.sunzee.model.domain.Name;
 import com.sunzee.model.domain.ParameterBean;
+import com.sunzee.model.message.ApiMessageEvent;
 import com.sunzee.retrofit.ApiCallback;
 import com.sunzee.thread.advanceparameter.ThreadPoolAdvanceParameter;
 import com.sunzee.utils.AlarmManagerUtil;
@@ -23,6 +25,7 @@ import com.sunzee.utils.HexadecimalUtil;
 import com.sunzee.utils.ToastUtil;
 import com.wuxiaolong.androidutils.library.LogUtil;
 
+import org.greenrobot.eventbus.EventBus;
 import org.w3c.dom.Text;
 
 import java.io.File;
@@ -43,6 +46,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
 
     private static final String TAG = "AdvertisingPresenter";
 
+
     public AdvertisingPresenter(AdvertisingView view) {
         attachView(view);
     }
@@ -248,7 +252,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             @Override
             public void onSuccess(HttpResult<String> model) {
                 String times = model.getData().trim();
-                Log.d(TAG, "onSuccess: "+times);
+                Log.d(TAG, "onSuccess: " + times);
                 if ("尚未设定清洗规则".equals(times)) {
                     return;
                 }
@@ -293,21 +297,21 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
                 String remaining = model.getRemaining();
                 if (TextUtils.isEmpty(overdueDate)) {
                     //如果为空
-                    Hawk.put("overdueDate", null);
+                    Hawk.put(Name.OVERDUE_DATE, null);
                 } else {
                     try {
                         Calendar calendar = Calendar.getInstance();
                         calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(overdueDate));
-                        Hawk.put("overdueDate", calendar.getTimeInMillis());
+                        Hawk.put(Name.OVERDUE_DATE, calendar.getTimeInMillis());
                     } catch (Exception e) {
                         e.printStackTrace();
-                        Hawk.put("overdueDate", null);
+                        Hawk.put(Name.OVERDUE_DATE, null);
                     }
                 }
                 if (TextUtils.isEmpty(remaining)) {
-                    Hawk.put("remaining", null);
+                    Hawk.put(Name.REMAINING, null);
                 } else {
-                    Hawk.put("remaining", remaining);
+                    Hawk.put(Name.REMAINING, remaining);
                 }
 
             }
@@ -398,4 +402,30 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             }
         });
     }
+
+    /**
+     * 上次局部清洗的蹲位有多少个
+     * @param num 数量
+     */
+    public void sendPositionNum(int num) {
+        Map<String, String> params = new HashMap<>();
+        params.put("clientId", Heartbeat.deviceId + "");
+        params.put("num", num + "");
+        Log.d(TAG, "sendPositionNum: "+num);
+        addSubscription(apiStores.sendPositionNum(params), new ApiCallback<HttpResult<String>>() {
+
+            @Override
+            public void onSuccess(HttpResult<String> model) {
+            }
+
+            @Override
+            public void onFailure(String msg) {
+            }
+
+            @Override
+            public void onFinish() {
+
+            }
+        });
+    }
 }

+ 10 - 5
app/src/main/java/com/sunzee/mvp/home/HomePresenter.java

@@ -77,15 +77,20 @@ public class HomePresenter extends BasePresenter<HomeView> {
      * 获取下载连接
      */
     public void updataapk() {
+        Log.d(TAG, "updataapk: ");
         Map<String, String> map = new HashMap<>();
-        map.put("model", "301ch");
+        map.put("model", "A");
         addSubscription(apiStores.updataAPK(map), new ApiCallback<HttpResult<String>>() {
             @Override
             public void onSuccess(HttpResult<String> model) {
-                Log.d(TAG, "onFailure: "+model);
-                Gson gson=new Gson();
-                ApkInfoBean apkInfoBean = gson.fromJson(model.getData(), ApkInfoBean.class);
-                mvpView.updataSuccess(apkInfoBean);
+                Log.d(TAG, "onSuccess: "+model);
+                if (model.getData()!=null) {
+                    Gson gson=new Gson();
+                    ApkInfoBean apkInfoBean = gson.fromJson(model.getData(), ApkInfoBean.class);
+                    mvpView.updataSuccess(apkInfoBean);
+                }else if(model.getErrorMsg()!=null){
+                    mvpView.updataFailure(model.getErrorMsg());
+                }
             }
 
             @Override

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

@@ -10,4 +10,6 @@ public interface HomeView extends BaseView {
     void initSuccess(String data);
 
     void updataSuccess(ApkInfoBean apkInfoBean);
+
+    void updataFailure(String name);
 }

+ 99 - 0
app/src/main/java/com/sunzee/mvp/homepage/HomePagePresenter.java

@@ -1,12 +1,111 @@
 package com.sunzee.mvp.homepage;
 
+import android.util.Log;
+
+import com.hboxs.serialport.util.HexUtils;
+import com.orhanobut.hawk.Hawk;
 import com.sunzee.base.BasePresenter;
+import com.sunzee.model.Heartbeat;
+import com.sunzee.model.HttpResult;
+import com.sunzee.model.domain.Name;
+import com.sunzee.retrofit.ApiCallback;
+import com.sunzee.thread.homepage.ThreadPoolHomepage;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 首页界面 presenter
  */
 public class HomePagePresenter extends BasePresenter<HomePageView> {
+    private static final String TAG = "HomePagePresenter";
+
     public HomePagePresenter(HomePageView view) {
         attachView(view);
     }
+
+    /**
+     * 是否可以清洗
+     *
+     * @return
+     */
+    public void isCanWrite() {
+        isCleaned();
+    }
+
+    private 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: 没有过期");
+                        //发送开始清洗的订单。
+                        getCleanReport(1);
+                        //如果还有次那么就开始购买。
+                    } else if (remaining > 0) {
+                        Log.d(TAG, "onSuccess: 时间过期,按次数计算");
+                        Hawk.put(Name.REMAINING, String.valueOf(remaining - 1));
+                        //发送开始清洗的订单。
+                        getCleanReport(1);
+                    } else {
+                        Log.d(TAG, "onSuccess: 全部过期,全部不能清洗");
+                    }
+                } 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() {
+
+            }
+        });
+    }
 }

+ 9 - 0
app/src/main/java/com/sunzee/mvp/homepage/HomePageView.java

@@ -6,4 +6,13 @@ import com.sunzee.base.BaseView;
  * 首页界面 view
  */
 public interface HomePageView extends BaseView {
+    /**
+     * 可以清洗,账户没有过期
+     */
+    void startClean();
+
+    /**
+     * 不可以清洗,账户已经过期
+     */
+    void haveExpired();
 }

+ 2 - 1
app/src/main/java/com/sunzee/receiver/TimedCleaningTaskAlarmReceiver.java

@@ -5,6 +5,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.util.Log;
 
+import com.sunzee.model.domain.Name;
 import com.sunzee.model.message.ApiMessageEvent;
 import com.sunzee.utils.AlarmManagerUtil;
 
@@ -22,7 +23,7 @@ public class TimedCleaningTaskAlarmReceiver extends BroadcastReceiver {
                     intent);
         }
         //推送myservice开始清洗
-        EventBus.getDefault().post(new ApiMessageEvent("startClean", "闹钟响了26"));
+        EventBus.getDefault().post(new ApiMessageEvent(Name.STARTCLEAN, "闹钟响了26"));
     }
 
 

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

@@ -88,7 +88,11 @@ public interface ApiStores {
     Observable<HttpResult<String>> getBackgroundTime();
 
 
-    //机器开始清洗了,向上面报告
+    //可以清洗机器开始清洗了,向上面报告
     @GET("api/app_alarmRecord/clean/cleanReport.htm")
     Observable<HttpResult<String>> getCleanReport(@QueryMap Map<String, String> params);
+
+    //上次机器有多少个蹲位
+    @GET("api/app_alarmRecord/clean/sendPositionNum.htm")
+    Observable<HttpResult<String>> sendPositionNum(@QueryMap Map<String, String> params);
 }

+ 16 - 2
app/src/main/java/com/sunzee/service/MyIntentService.java

@@ -1,6 +1,8 @@
 package com.sunzee.service;
 
 import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -88,6 +90,7 @@ public class MyIntentService extends GTIntentService {
     public void onReceiveClientId(Context context, String clientid) {
         LogUtil.e(TAG, "onReceiveClientId -> " + "clientid = " + clientid);
         Heartbeat.clientId = clientid;
+        EventBus.getDefault().post(new ApiMessageEvent("clientid", clientid));
     }
 
     /**
@@ -138,10 +141,21 @@ public class MyIntentService extends GTIntentService {
                 // todo
                 Log.d(TAG, "onReceiveMessageData: " + gson + ":" + geTuiBean + ":" + kind);
                 break;
+            case "cleanPositionNum":
+                //局部清洗
+                cleanPositionNum(gson, geTuiBean, kind);
+                break;
         }
 
     }
 
+    private void cleanPositionNum(Gson gson, GeTuiBean geTuiBean, String kind) {
+        //todo
+
+        EventBus.getDefault().post(new ApiMessageEvent("cleanPositionNum",geTuiBean.getKind_data()));
+    }
+
+
     private void updataCleanRule(Gson gson, GeTuiBean geTuiBean, String kind) {
         String times = geTuiBean.getKind_data();
         Log.d(TAG, "闹钟响了26onSuccess: " + times);
@@ -181,7 +195,7 @@ public class MyIntentService extends GTIntentService {
                 case "M317":
                 case "M318":
                 case "M17":
-                    Log.d(TAG, "updataParam: "+address);
+                    Log.d(TAG, "updataParam: " + address);
                     if ("0".equals(data)) {
                         EventBus.getDefault().post(new ApiMessageEvent("updataParamSet", address));
                     } else {
@@ -285,7 +299,7 @@ public class MyIntentService extends GTIntentService {
 
             @Override
             public void onFailure(String msg) {
-                Log.d(TAG, "onFailure: "+msg);
+                Log.d(TAG, "onFailure: " + msg);
             }
 
             @Override

+ 30 - 7
app/src/main/java/com/sunzee/service/MyService.java

@@ -328,12 +328,30 @@ public class MyService extends Service {
                     return;
                 }
                 startWrite(messageEvent.getData());
+            case "clientid":
+                stopHeartbeat();
+                startHeartbeat();
+                Log.d(TAG, "GTevent clientid:" + messageEvent.getData());
+                break;
+
+            case "cleanPositionNum":
+                if (!PreventSpeedClickUtil.isFastClick()) {
+                    return;
+                }
+                //开始清洗 随机清洗,会给要清洗的蹲位是
+                cleanPositionNum(messageEvent.getData());
+                break;
             default:
                 break;
 
         }
     }
 
+    private void cleanPositionNum(Object data) {
+        mThreadPoolMyservice.stopWriteD120();
+        mThreadPoolMyservice.startWriteD120("D120", "000" + data);
+    }
+
     private void startWrite(Object kindData) {
         String[] split = (String[]) kindData;
         String address = split[0];
@@ -362,11 +380,11 @@ public class MyService extends Service {
                     Calendar calendar = Calendar.getInstance();
                     calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(timedata));
                     //第一次就会出现报错。
-                    Long overdueDate = (Long) Hawk.get("overdueDate");//购买的到期的时间
+                    Long overdueDate = (Long) Hawk.get(Name.OVERDUE_DATE);//购买的到期的时间
                     Long timeInMillis = calendar.getTimeInMillis();//当前时间
-                    String data = (String) Hawk.get("remaining");
+                    String data = (String) Hawk.get(Name.REMAINING);
                     long remaining = Long.valueOf(data);
-                    Log.d(TAG, "onSuccess: 时间过期remaining"+remaining);
+                    Log.d(TAG, "onSuccess: 时间过期remaining" + remaining);
                     //如果时间没过期,那么可以继续制作
                     if (overdueDate > timeInMillis) {
                         Log.d(TAG, "onSuccess: 没有过期");
@@ -375,10 +393,10 @@ public class MyService extends Service {
                         //如果还有次那么就开始购买。
                     } else if (remaining > 0) {
                         Log.d(TAG, "onSuccess: 时间过期,按次数计算");
-                        Hawk.put("remaining", String.valueOf(remaining - 1));
+                        Hawk.put(Name.REMAINING, String.valueOf(remaining - 1));
                         //发送开始清洗的订单。
                         getCleanReport(0);
-                    }else{
+                    } else {
                         Log.d(TAG, "onSuccess: 全部过期,全部不能清洗");
                     }
                 } catch (Exception e) {
@@ -924,7 +942,11 @@ public class MyService extends Service {
                 mThreadPoolMyservice.stopSet();
                 mThreadPoolMyservice.stopRst();
                 mThreadPoolMyservice.stopWrite();
-                if (messageEvent.getName().equals("M17")) {
+                if (messageEvent.getName().equals("D120")) {
+                    mThreadPoolMyservice.stopWriteD120();
+                    mThreadPoolMyservice.stopSetM8();
+                    mThreadPoolMyservice.startSetM8();
+                } else if (messageEvent.getName().equals("M17")) {
                     mThreadPoolMyservice.stopSetM17();
                     if (isRegularCleaning) {
                         isRegularCleaning = false;
@@ -974,7 +996,7 @@ public class MyService extends Service {
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                    }else{
+                    } else {
                         //通过校验
                         Log.d(TAG, "event: " + name);
                         String result = AsciiUtils.asciiByteArray2HexStr(responseFrame.getData());
@@ -1175,6 +1197,7 @@ public class MyService extends Service {
             Log.d(TAG + "22", "setError: 不上传");
         }
     }
+
     //-----------------------------------------------------------------------报警 end---------------------------------
     public void setAdvanced(String name, ArrayList<String> results, ThreadPoolAdvanceParameter threadGetParameter1) {
         if (name.equals("D426")) {

+ 14 - 3
app/src/main/java/com/sunzee/thread/advanceparameter/AdvanceParameterTask.java

@@ -16,7 +16,6 @@ public class AdvanceParameterTask implements Runnable {
     private volatile String address;
 
 
-
     public String getAddress() {
         return address;
     }
@@ -34,12 +33,14 @@ public class AdvanceParameterTask implements Runnable {
         clearPlcQuee();
         this.type = type;
     }
+
     public AdvanceParameterTask(int type, String address, String data) {
         clearPlcQuee();
         this.type = type;
-        this.address=address;
+        this.address = address;
         this.data = data;
     }
+
     public AdvanceParameterTask(int type, String address, int id) {
         clearPlcQuee();
         this.type = type;
@@ -94,13 +95,23 @@ public class AdvanceParameterTask implements Runnable {
             case AdvanceParameterThreadType.runWrite:
                 runWrite();
                 break;
+            case AdvanceParameterThreadType.runD403:
+                runReadD403();
+                break;
 
         }
     }
 
+    private void runReadD403() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new ReadCommandFrame("D403", 2), 403, "D403");
+        }
+    }
+
     private static final String TAG = "AdvanceParameterTask";
+
     private void runWrite() {
-        if (getIsRun()){
+        if (getIsRun()) {
             Log.d(TAG, "runWrite: ");
             SerialPortManager.getInstance().sendCommandFrame(new WriteCommandFrame(address, data), address);
         }

+ 1 - 0
app/src/main/java/com/sunzee/thread/advanceparameter/AdvanceParameterThreadType.java

@@ -9,4 +9,5 @@ public interface AdvanceParameterThreadType {
     int runD431 = 431;
 
     int runWrite = 2;
+    int runD403 = 403;
 }

+ 22 - 15
app/src/main/java/com/sunzee/thread/advanceparameter/ThreadPoolAdvanceParameter.java

@@ -1,11 +1,5 @@
 package com.sunzee.thread.advanceparameter;
 
-import android.util.Log;
-
-import com.hboxs.serialport.SerialPortManager;
-import com.hboxs.serialport.frame.WriteCommandFrame;
-import com.hboxs.serialport.util.HexUtils;
-
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -20,16 +14,17 @@ public class ThreadPoolAdvanceParameter {
     public String[] getValues() {
         return values;
     }
+
     private String[] values = new String[6];
 
     private ScheduledFuture<?>
             mScheduledFutureD426, mScheduledFutureD427, mScheduledFutureD428,
             mScheduledFutureD429, mScheduledFutureD430, mScheduledFutureD431,
-            mScheduledFutureWrite;
+            mScheduledFutureWrite, mScheduledFutureD403;
 
     private AdvanceParameterTask
             mTaskRunD426, mTaskRunD427, mTaskRunD428, mTaskRunD429,
-            mTaskRunD430, mTaskRunD431, mTaskRunWrite;
+            mTaskRunD430, mTaskRunD431, mTaskRunWrite, mTaskRunD403;
 
     public ThreadPoolAdvanceParameter() {
         scheduled = new ScheduledThreadPoolExecutor(6);
@@ -111,16 +106,25 @@ public class ThreadPoolAdvanceParameter {
 
         mTaskRunD431 = new AdvanceParameterTask(AdvanceParameterThreadType.runD431);
         mScheduledFutureD431 = scheduled.scheduleAtFixedRate(mTaskRunD431, 10, 1000, TimeUnit.MILLISECONDS);
+
+
+
+    }
+
+    public void startReadD403(){
+        mTaskRunD403 = new AdvanceParameterTask(AdvanceParameterThreadType.runD403);
+        mScheduledFutureD403 = scheduled.scheduleAtFixedRate(mTaskRunD403, 10, 1000, TimeUnit.MILLISECONDS);
     }
 
     public void stopAll() {
-        stopRead(mTaskRunD426, mScheduledFutureD426);
-        stopRead(mTaskRunD427, mScheduledFutureD427);
-        stopRead(mTaskRunD428, mScheduledFutureD428);
-        stopRead(mTaskRunD429, mScheduledFutureD429);
-        stopRead(mTaskRunD430, mScheduledFutureD430);
-        stopRead(mTaskRunD431, mScheduledFutureD431);
-        stopRead(mTaskRunWrite, mScheduledFutureWrite);
+        stopReadD426();
+        stopReadD427();
+        stopReadD428();
+        stopReadD429();
+        stopReadD430();
+        stopReadD431();
+        stopWrite();
+        stopReadD403();
     }
 
     public void stopReadD426() {
@@ -147,6 +151,9 @@ public class ThreadPoolAdvanceParameter {
         stopRead(mTaskRunD431, mScheduledFutureD431);
     }
 
+    public void stopReadD403() {
+        stopRead(mTaskRunD403, mScheduledFutureD403);
+    }
 
     public static void stopRead(AdvanceParameterTask threadTask, ScheduledFuture<?> scheduledFuture1) {
         if (threadTask != null) {

+ 158 - 0
app/src/main/java/com/sunzee/thread/homepage/HomepageTask.java

@@ -0,0 +1,158 @@
+package com.sunzee.thread.homepage;
+
+import com.hboxs.serialport.SerialPortManager;
+import com.hboxs.serialport.SerialPortSendQueue;
+import com.hboxs.serialport.frame.RstCommandFrame;
+import com.hboxs.serialport.frame.SetCommandFrame;
+import com.hboxs.serialport.frame.WriteCommandFrame;
+import com.hboxs.serialport.util.HexUtils;
+
+/**
+ * 长时间或者推送要执行的任务
+ */
+public class HomepageTask implements Runnable {
+
+    private int type;
+    private volatile String address;
+
+    public String getAddress() {
+        return address;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    private volatile int id;
+    private volatile boolean isRun;
+    private String name;
+    private String data;
+
+    public HomepageTask(int type) {
+        clearPlcQuee();
+        this.type = type;
+    }
+
+    public HomepageTask(int type, String address) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+    }
+
+    public HomepageTask(int type, String address, int id) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+        this.id = id;
+    }
+
+    public HomepageTask(int type, String address, String data) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+        this.data = data;
+    }
+
+    public HomepageTask(int type, String address, String data, int id, String name) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+        this.data = data;
+        this.id = id;
+        this.name = name;
+    }
+
+    private void clearPlcQuee() {
+        setIsRun(true);
+        SerialPortSendQueue.clear();
+    }
+
+    public void setIsRun(boolean isRun) {
+        this.isRun = isRun;
+    }
+
+    public boolean getIsRun() {
+        return isRun;
+    }
+
+    @Override
+    public void run() {
+        switch (type) {
+            case HomepageThreadType.runD120:
+                runWriteD120();
+                break;
+            case HomepageThreadType.runM8:
+                runSetM8();
+                break;
+            case HomepageThreadType.runRst:
+                runRst();
+                break;
+            case HomepageThreadType.runSet:
+                runSet();
+                break;
+            case HomepageThreadType.runWrite:
+                runWrite();
+                break;
+
+        }
+    }
+
+    private void runWrite() {
+        if (getIsRun()) {
+            SerialPortManager.getInstance().sendCommandFrame(new WriteCommandFrame(address, data), address);
+        }
+    }
+
+    private void runSet() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new SetCommandFrame(address), 18, address);
+        }
+    }
+
+    private void runRst() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new RstCommandFrame(address), 18, address);
+        }
+    }
+
+    private void runSetM8() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new SetCommandFrame("M8"), 8, "M8");
+        }
+    }
+
+    private void runWriteD120() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new WriteCommandFrame(address, HexUtils.hexStr2BinStr(data)), 120, address);
+        }
+    }
+
+    public void setAddressAndId(String address, int id) {
+        this.address = address;
+        this.id = id;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+}

+ 10 - 0
app/src/main/java/com/sunzee/thread/homepage/HomepageThreadType.java

@@ -0,0 +1,10 @@
+package com.sunzee.thread.homepage;
+
+public interface HomepageThreadType {
+    int runM8 = 8;
+    int runD120=120;
+
+    int runRst = 0;
+    int runSet = 1;
+    int runWrite = 2;
+}

+ 92 - 0
app/src/main/java/com/sunzee/thread/homepage/ThreadPoolHomepage.java

@@ -0,0 +1,92 @@
+package com.sunzee.thread.homepage;
+
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 长时间或者推送要执行的线程池
+ */
+public class ThreadPoolHomepage {
+    private ScheduledThreadPoolExecutor scheduled;
+
+    private ScheduledFuture<?>
+            mScheduledFutureM8,
+            mScheduledFutureSet, mScheduledFutureRst, mScheduledFutureWrite, mScheduledFutureD120;
+    private HomepageTask
+            MTaskRunM8, mTaskRunD120,
+            mTaskRunMRst, mTaskRunMSet, mTaskRunWrite;
+
+    public ThreadPoolHomepage() {
+        scheduled = new ScheduledThreadPoolExecutor(6);
+        //设置线程池的策略  抛弃旧的任务
+        scheduled.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
+    }
+
+    public void startSetM8() {
+        MTaskRunM8 = new HomepageTask(HomepageThreadType.runM8);
+        mScheduledFutureM8 = scheduled.scheduleAtFixedRate(MTaskRunM8, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+
+    public void startRst(String address) {
+        mTaskRunMRst = new HomepageTask(HomepageThreadType.runRst, address);
+        mScheduledFutureRst = scheduled.scheduleAtFixedRate(mTaskRunMRst, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+
+    public void startSet(String address) {
+        mTaskRunMSet = new HomepageTask(HomepageThreadType.runSet, address);
+        mScheduledFutureSet = scheduled.scheduleAtFixedRate(mTaskRunMSet, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+    public void startWrite(String paraAddress, String data) {
+        mTaskRunWrite = new HomepageTask(HomepageThreadType.runWrite, paraAddress, data);
+        mScheduledFutureWrite = scheduled.scheduleAtFixedRate(mTaskRunWrite, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+    public void startWriteD120(String paraAddress, String data) {
+        mTaskRunD120 = new HomepageTask(HomepageThreadType.runD120, paraAddress, data);
+        mScheduledFutureD120 = scheduled.scheduleAtFixedRate(mTaskRunD120, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+    public void stopWriteD120() {
+        stopRead(mTaskRunD120, mScheduledFutureD120);
+    }
+
+    public void stopWrite() {
+        stopRead(mTaskRunWrite, mScheduledFutureWrite);
+    }
+
+    public void stopRst() {
+        stopRead(mTaskRunMRst, mScheduledFutureRst);
+    }
+
+    public void stopSet() {
+        stopRead(mTaskRunMSet, mScheduledFutureSet);
+    }
+
+
+    public static void stopRead(HomepageTask threadTask, ScheduledFuture<?> scheduledFuture1) {
+        if (threadTask != null) {
+            threadTask.setIsRun(false);
+        }
+        if (scheduledFuture1 != null) {
+            scheduledFuture1.cancel(true);
+        }
+    }
+
+    public void stopSetM8() {
+        stopRead(MTaskRunM8, mScheduledFutureM8);
+    }
+
+    public void stopALLRead() {
+        stopWrite();
+        stopRst();
+        stopSet();
+        stopSetM8();
+        stopWriteD120();
+    }
+
+}

+ 11 - 0
app/src/main/java/com/sunzee/thread/myservice/MyserviceTask.java

@@ -8,6 +8,7 @@ import com.hboxs.serialport.frame.ReadCommandFrame;
 import com.hboxs.serialport.frame.RstCommandFrame;
 import com.hboxs.serialport.frame.SetCommandFrame;
 import com.hboxs.serialport.frame.WriteCommandFrame;
+import com.hboxs.serialport.util.HexUtils;
 
 /**
  * 长时间或者推送要执行的任务
@@ -98,6 +99,10 @@ public class MyserviceTask implements Runnable {
             case MyserviceThreadType.runWrite:
                 runWrite();
                 break;
+            case MyserviceThreadType.runD120:
+                runWriteD120();
+                break;
+
 
         }
     }
@@ -126,6 +131,12 @@ public class MyserviceTask implements Runnable {
         }
     }
 
+    private void runWriteD120() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new WriteCommandFrame(address, HexUtils.hexStr2BinStr(data)), 120, address);
+        }
+    }
+
     private void runSetM8() {
         if (getIsRun()) {
             SerialPortSendQueue.sendCommand(new SetCommandFrame("M8"), 8, "M8");

+ 1 - 0
app/src/main/java/com/sunzee/thread/myservice/MyserviceThreadType.java

@@ -8,4 +8,5 @@ public interface MyserviceThreadType {
     int runRst = 0;
     int runSet = 1;
     int runWrite = 2;
+    int runD120 = 120;
 }

+ 18 - 3
app/src/main/java/com/sunzee/thread/myservice/ThreadPoolMyservice.java

@@ -1,5 +1,8 @@
 package com.sunzee.thread.myservice;
 
+import com.sunzee.thread.homepage.HomepageTask;
+import com.sunzee.thread.homepage.HomepageThreadType;
+
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -13,10 +16,12 @@ public class ThreadPoolMyservice {
 
     private ScheduledFuture<?>
             mScheduledFutureM600, mScheduledFutureM8, mScheduledFutureM17,
-            mScheduledFutureSet, mScheduledFutureRst, mScheduledFutureWrite;
+            mScheduledFutureSet, mScheduledFutureRst, mScheduledFutureWrite,
+            mScheduledFutureD120;
     private MyserviceTask
             mTaskRunM600, MTaskRunM8, MTaskRunM17,
-            mTaskRunMRst, mTaskRunMSet, mTaskRunWrite;
+            mTaskRunMRst, mTaskRunMSet, mTaskRunWrite,
+            mTaskRunD120;
 
     public ThreadPoolMyservice() {
         scheduled = new ScheduledThreadPoolExecutor(6);
@@ -44,6 +49,15 @@ public class ThreadPoolMyservice {
         mScheduledFutureRst = scheduled.scheduleAtFixedRate(mTaskRunMRst, 0, 1000, TimeUnit.MILLISECONDS);
     }
 
+    public void startWriteD120(String paraAddress, String data) {
+        mTaskRunD120 = new MyserviceTask(MyserviceThreadType.runD120, paraAddress, data);
+        mScheduledFutureD120 = scheduled.scheduleAtFixedRate(mTaskRunD120, 0, 1000, TimeUnit.MILLISECONDS);
+    }
+
+    public void stopWriteD120() {
+        stopRead(mTaskRunD120, mScheduledFutureD120);
+    }
+
 
     public void startSet(String address) {
         mTaskRunMSet = new MyserviceTask(MyserviceThreadType.runSet, address);
@@ -90,13 +104,14 @@ public class ThreadPoolMyservice {
         stopRead(MTaskRunM8, mScheduledFutureM8);
     }
 
-    public void stopALLRead(){
+    public void stopALLRead() {
         stopWrite();
         stopRst();
         stopSet();
         stopReadM600();
         stopSetM8();
         stopSetM17();
+        stopWriteD120();
     }
 
 }

+ 21 - 4
app/src/main/java/com/sunzee/ui/activity/AdvertisingActivity.java

@@ -5,6 +5,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.support.annotation.Nullable;
 import android.text.format.DateFormat;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.SurfaceView;
@@ -34,6 +35,7 @@ import com.sunzee.utils.LongClickUtils;
 import com.sunzee.utils.SimplePlayerUtils;
 import com.sunzee.utils.ToastUtil;
 import com.sunzee.utils.UiUtil;
+import com.tencent.bugly.crashreport.CrashReport;
 import com.wuxiaolong.androidutils.library.LogUtil;
 
 import org.greenrobot.eventbus.EventBus;
@@ -75,7 +77,12 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
         mGeTuiUtil.geTui();
         initView();
         initEvent();
-        AlarmManagerUtil.setAlarm(this, 1, 12, 16, 0, 6, 0, "闹钟响了32");
+        WindowManager manager = this.getWindowManager();
+        DisplayMetrics outMetrics = new DisplayMetrics();
+        manager.getDefaultDisplay().getMetrics(outMetrics);
+        int width = outMetrics.widthPixels;
+        int height = outMetrics.heightPixels;
+        Log.d(TAG, "onCreate: width:" + width + "height:" + height);
     }
 
     private void initEvent() {
@@ -114,7 +121,10 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
         LogUtil.d(TAG, "setup: " + mLeftsimplePlayer);
         play();
         startRefreshime();
+        mPoolAdvanceParameter.stopAll();
         mPoolAdvanceParameter.startALLRead();
+        mPoolAdvanceParameter.stopReadD403();
+        mPoolAdvanceParameter.startReadD403();
     }
 
     private void play() {
@@ -153,7 +163,7 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
     public void getDataSuccess() {
         String[] values = mPoolAdvanceParameter.getValues();
         ArrayList<ParameterBean> parameterBeans = new ArrayList<>();
-       String[] paraAddress = {
+        String[] paraAddress = {
                 "D426", "D427", "D428", "D429",
                 "D430", "D431"};
         for (int i = 0; i < values.length; i++) {
@@ -173,6 +183,7 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
     @Override
     protected void onDestroy() {
         super.onDestroy();
+        mPoolAdvanceParameter.stopAll();
         EventBus.getDefault().unregister(this);
         myHandler.removeCallbacksAndMessages(null);
         myHandler = null;
@@ -246,10 +257,16 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
                 }
                 if (responseFrame.isValidSum()) {
                     //通过校验
-                    Log.d(TAG, "event: " + name);
+                    Log.d(TAG, "11event: " + name);
                     String result = AsciiUtils.asciiByteArray2HexStr(responseFrame.getData());
                     ArrayList<String> results = HexadecimalUtil.flipString(result);
-                    mvpPresenter.setAdvanced(name, results, mPoolAdvanceParameter);
+                    if ("D403".equals(name)) {
+                        mPoolAdvanceParameter.stopReadD403();
+                        Log.d(TAG, "11event: " + (int) HexadecimalUtil.hex2dec(results.get(0)));
+                        mvpPresenter.sendPositionNum((int) HexadecimalUtil.hex2dec(results.get(0)));
+                    } else {
+                        mvpPresenter.setAdvanced(name, results, mPoolAdvanceParameter);
+                    }
                 }
                 break;
         }

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

@@ -21,10 +21,8 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.hboxs.serialport.SerialPortSendQueue;
-import com.hboxs.serialport.frame.ResponseFrame;
 import com.hboxs.serialport.frame.SetCommandFrame;
 import com.hboxs.serialport.message.Message;
-import com.hboxs.serialport.util.AsciiUtils;
 import com.sunzee.R;
 import com.sunzee.base.BaseFragment;
 import com.sunzee.base.MvpActivity;
@@ -38,7 +36,7 @@ import com.sunzee.mvp.home.HomeView;
 import com.sunzee.service.DownPresenter;
 import com.sunzee.service.MyService;
 import com.sunzee.ui.dialog.ManagementSystemDialog;
-import com.sunzee.ui.dialog.NormalDialog;
+import com.sunzee.ui.dialog.CheckUpdatesDialog;
 import com.sunzee.ui.dialog.ShutdownDialog;
 import com.sunzee.utils.FileUtil;
 import com.sunzee.utils.HomePagerSimpleFactory;
@@ -52,9 +50,6 @@ import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -329,6 +324,11 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         }
     }
 
+    @Override
+    public void updataFailure(String name) {
+        ToastUtil.showToast(name);
+    }
+
     /*
      * 获取当前程序的版本号
      */
@@ -346,7 +346,7 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
     }
 
     //检查更新
-    private NormalDialog updateDialog;
+    private CheckUpdatesDialog updateDialog;
 
     /**
      * 检查更新弹窗
@@ -359,9 +359,9 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
      */
     private void showUpdateDialog(String versionName, final boolean isUpdate, final int version, final String url, String versionInfo) {
         if (updateDialog == null) {
-            updateDialog = new NormalDialog(HomeActivity.this);
+            updateDialog = new CheckUpdatesDialog(HomeActivity.this);
         }
-        updateDialog.setListener(new NormalDialog.DialogClickListener() {
+        updateDialog.setListener(new CheckUpdatesDialog.DialogClickListener() {
             @Override
             public void onClickListener(int type) {
                 switch (type) {

+ 2 - 2
app/src/main/java/com/sunzee/ui/dialog/NormalDialog.java

@@ -18,7 +18,7 @@ import com.sunzee.utils.UiUtil;
 /**
  * 通用对话框 dialog[检查更新]
  */
-public class NormalDialog extends Dialog implements View.OnClickListener {
+public class CheckUpdatesDialog extends Dialog implements View.OnClickListener {
 
     public static final int OK = 2;
     public static final int NO = 3;
@@ -40,7 +40,7 @@ public class NormalDialog extends Dialog implements View.OnClickListener {
     private DialogClickListener listener;
 
 
-    public NormalDialog(Context context) {
+    public CheckUpdatesDialog(Context context) {
         super(context, R.style.DialogBgD);//加载样式
         setContentView(R.layout.dialog_normal);
         initView();

+ 86 - 0
app/src/main/java/com/sunzee/ui/dialog/StartCleaningDialog.java

@@ -0,0 +1,86 @@
+package com.sunzee.ui.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Build;
+import android.support.annotation.RequiresApi;
+import android.support.v4.widget.TextViewCompat;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.sunzee.model.domain.Name;
+import com.sunzee.utils.SharedPreferencesUtils;
+import com.sunzee.utils.UiUtil;
+
+/**
+ * 通用对话框 dialog[检查更新]
+ */
+public class StartCleaningDialog extends Dialog implements View.OnClickListener {
+
+    private TextView tvTitle;
+    private TextView tvContent;
+    private Button btnConfirm;
+    private Button btnCancel;
+
+    public void setListener(DialogClickListener listener) {
+        this.listener = listener;
+    }
+
+    private DialogClickListener listener;
+
+
+    public StartCleaningDialog(Context context) {
+        super(context, R.style.DialogBgD);//加载样式
+        setContentView(R.layout.dialog_startclean);
+        initView();
+    }
+
+    protected void initView() {
+        tvTitle = findViewById(R.id.tv_title);
+        tvContent = findViewById(R.id.tv_content);
+        btnConfirm = findViewById(R.id.btn_confirm);
+        btnCancel = findViewById(R.id.btn_cancel);
+        btnConfirm.setOnClickListener(this);
+        btnCancel.setOnClickListener(this);
+    }
+    /**
+     * set button text
+     *
+     * @param strIdTitle title text
+     * @param strId      shutdown text
+     * @param strid1     open text
+     */
+    public void setBtnText(int strIdTitle, int content, int strId, int strid1) {
+        tvTitle.setText(strIdTitle);
+        tvContent.setText(content);
+        btnConfirm.setText(strId);
+        btnCancel.setText(strid1);
+        btnCancel.setTextColor(UiUtil.getColorRes(R.color.white));
+    }
+    /**
+     * 设置文字
+     *
+     * @param text
+     */
+    public void setContent(String text) {
+        tvContent.setText(text);
+    }
+
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.btn_cancel:
+                dismiss();
+                break;
+        }
+        listener.onClickListener(v.getId());
+    }
+
+    public interface DialogClickListener {
+        void onClickListener(int type);
+    }
+}

+ 1 - 0
app/src/main/java/com/sunzee/ui/fragment/AdvanceParameterFragment.java

@@ -162,6 +162,7 @@ public class AdvanceParameterFragment extends MvpFragment<AdvanceParameterPresen
             case sendError:
                 break;
             case ack:
+                Log.d(TAG, "event: 吸入成功");
                 ToastUtil.showToast("更新成功");
                 Log.d(TAG, "event: 写入成功");
                 mPoolAdvanceParameter.stopWrite();

+ 188 - 10
app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java

@@ -3,46 +3,167 @@ package com.sunzee.ui.fragment;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.LinearLayout;
+import android.widget.TextView;
 
+import com.hboxs.serialport.SerialPortDevice;
+import com.hboxs.serialport.SerialPortManager;
 import com.hboxs.serialport.SerialPortSendQueue;
+import com.hboxs.serialport.frame.ResponseFrame;
 import com.hboxs.serialport.frame.WriteCommandFrame;
+import com.hboxs.serialport.message.Message;
 import com.hboxs.serialport.util.HexUtils;
+import com.orhanobut.hawk.Hawk;
 import com.sunzee.R;
 import com.sunzee.base.MvpFragment;
 import com.sunzee.mvp.homepage.HomePagePresenter;
 import com.sunzee.mvp.homepage.HomePageView;
+import com.sunzee.thread.homepage.ThreadPoolHomepage;
+import com.sunzee.ui.dialog.StartCleaningDialog;
+import com.sunzee.ui.view.CustomViewGrounp;
+import com.sunzee.utils.PreventSpeedClickUtil;
+import com.sunzee.utils.ToastUtil;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
- * 首页界面 fragment
+ * 后台首页界面 fragment
  */
-public class HomepageFragment extends MvpFragment<HomePagePresenter> implements HomePageView {
+public class HomepageFragment extends MvpFragment<HomePagePresenter> implements HomePageView, CustomViewGrounp.onClickCleaning {
+
+    private CustomViewGrounp mCustomViewGrounp;
+    private TextView mTvCommit;
+    private StartCleaningDialog mStartCleaningDialog;
+    private PreventSpeedClickUtil mPreventSpeedClickUtil;
+    private ThreadPoolHomepage mThreadPoolHomepage = new ThreadPoolHomepage();
+    private int cleaningLocation = 1;
 
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        View inflate = inflater.inflate(R.layout.fragment_home, container, false);
+        View inflate = inflater.inflate(R.layout.fragment_home2, container, false);
+        EventBus.getDefault().register(this);
         initView(inflate);
+        initEvent();
         return inflate;
     }
 
-    private void initView(View inflate) {
-        LinearLayout startNumberClean = inflate.findViewById(R.id.start_number_clean);
-        startNumberClean.setOnClickListener(new View.OnClickListener() {
+    private void initEvent() {
+        mTvCommit.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                //可以写入成功。
-                SerialPortSendQueue.sendCommand(new WriteCommandFrame("D120", HexUtils.hexStr2BinStr("0002")), 120, "D120");
+                //保存位置
+                Map<String, List<Float>> integerMap = mCustomViewGrounp.getIntegerMap1();
+                if (integerMap.size() == 0) {
+                    return;
+                }
+                Map<String, List<Float>> location = Hawk.get("location", null);
+                if (location != null) {
+                    for (String s : location.keySet()) {
+                        if (integerMap.containsKey(s)) {
+                            location.put(s, integerMap.get(s));
+                        }
+                    }
+                    Hawk.put("location", location);
+                } else {
+                    Hawk.put("location", integerMap);
+                }
+                ToastUtil.showToast("保存成功");
             }
         });
+
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+        mThreadPoolHomepage.stopALLRead();
+        EventBus.getDefault().unregister(this);
+    }
+
+    private static final String TAG = "HomepageFragment";
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void event(Message messageEvent) {
+        switch (messageEvent.getType()) {
+            case connected:
+                Log.d(TAG, "event: connected");
+                break;
+            case sendError:
+                Log.d(TAG, "event: sendError");
+                break;
+            case ack:
+                Log.d(TAG, "event: 写入成功" + messageEvent.getName());
+                if (messageEvent.getName().equals("D120")) {
+                    mThreadPoolHomepage.stopWriteD120();
+                    mThreadPoolHomepage.stopSetM8();
+                    mThreadPoolHomepage.startSetM8();
+                } else if (messageEvent.getName().equals("M8")) {
+                    mThreadPoolHomepage.stopSetM8();
+                }
+                break;
+            case nak:
+                Log.d(TAG, "event: nak");
+                break;
+            case disconnected:
+                SerialPortDevice device = new SerialPortDevice("/dev/ttyS2", "9600");
+                SerialPortManager.getInstance().open(device);
+                Log.d(TAG, "event: disconnected");
+                break;
+            case response:
+                ResponseFrame responseFrame = (ResponseFrame) messageEvent.getContent();
+                String name = messageEvent.getName();
+                if ("M600".equals(name)) {
+                    return;
+                }
+                break;
+        }
+    }
+
+    private void initView(View inflate) {
+        //为控件设置数据
+        mCustomViewGrounp = inflate.findViewById(R.id.cv_custom);
+        List<String> list = new ArrayList<>();
+        for (int i = 0; i < 8; i++) {
+            if (i == 6) {
+                list.add("走廊");
+                continue;
+            } else if (i == 7) {
+                list.add("洗手台");
+                continue;
+            }
+            list.add(i + 1 + "号厕所");
+        }
+        mCustomViewGrounp.setTextList(list);
+        Map<String, List<Float>> location = Hawk.get("location", null);
+        if (location != null) {
+            for (int i = 0; i < mCustomViewGrounp.getChildCount(); i++) {
+                List list1 = location.get(i + "");
+                if (list1 == null) {
+                    continue;
+                }
+                View childAt = mCustomViewGrounp.getChildAt(i);
+                childAt.setX(Float.valueOf(String.valueOf(list1.get(0))));
+                childAt.setY(Float.valueOf(String.valueOf(list1.get(1))));
+            }
+        }
+        mCustomViewGrounp.setOnClickCleaning(this);
+        mTvCommit = inflate.findViewById(R.id.tv_commit);
+        mPreventSpeedClickUtil = new PreventSpeedClickUtil();
     }
 
     @Override
     protected HomePagePresenter createPresenter() {
-        return null;
+        return new HomePagePresenter(this);
     }
 
     @Override
@@ -54,4 +175,61 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
     public void hideLoading() {
 
     }
+
+    //弹出对话框,是否要开始清洗。
+    @Override
+    public void setOnCLickCleaning(final int cleaningLocation) {
+        //防止快速点击
+        if (!mPreventSpeedClickUtil.isFastClick()) {
+            return;
+        }
+        this.cleaningLocation = cleaningLocation;
+
+        if (mStartCleaningDialog == null) {
+            mStartCleaningDialog = new StartCleaningDialog(this.getContext());
+        }
+        mStartCleaningDialog.setListener(new StartCleaningDialog.DialogClickListener() {
+            @Override
+            public void onClickListener(int type) {
+                switch (type) {
+                    case R.id.btn_confirm:
+                        //防止快速点击
+                        if (!mPreventSpeedClickUtil.isFastClick500()) {
+                            return;
+                        }
+                        //判断是否过期,或者是否次数以到。
+                        showLoading();
+                        mvpPresenter.isCanWrite();
+                        mStartCleaningDialog.dismiss();
+                        break;
+                    case R.id.btn_cancel:
+                        ToastUtil.showToast("取消");
+                        mStartCleaningDialog.dismiss();
+                        break;
+                }
+            }
+        });
+        mStartCleaningDialog.setBtnText(R.string.start_cleaning, R.string.start_cleaning_content, R.string.confirm, R.string.cancel);
+        mStartCleaningDialog.show();
+
+    }
+
+
+    //开始写入清洗那个位置。
+    private void startClean(int i) {
+        //todo 判断是否过期和是否有次数。
+        mThreadPoolHomepage.stopWriteD120();
+        mThreadPoolHomepage.startWriteD120("D120", "000" + i);
+    }
+
+    @Override
+    public void startClean() {
+        hideLoading();
+        startClean(cleaningLocation);
+    }
+
+    @Override
+    public void haveExpired() {
+        ToastUtil.showToast("已过期,请充值后使用哦。");
+    }
 }

+ 105 - 0
app/src/main/java/com/sunzee/ui/view/CustomView.java

@@ -0,0 +1,105 @@
+package com.sunzee.ui.view;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 可拖动控件
+ */
+@SuppressLint("AppCompatCustomView")
+public class CustomView extends TextView {
+    private int moveX;
+    private int moveY;
+    private InformationLocation informationLocation;
+    private List<Float> arr = new ArrayList<>();
+
+
+    public boolean isIsmove() {
+        return ismove;
+    }
+
+    private boolean ismove;
+
+    public CustomView(Context context) {
+        this(context, null);
+    }
+
+    public CustomView(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public CustomView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    private static final String TAG = "CustomView";
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent event) {
+        return super.dispatchTouchEvent(event);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        super.onTouchEvent(event);
+        int x = (int) event.getX();
+        int y = (int) event.getY();
+        switch (event.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+                moveX = x;
+                moveY = y;
+                ismove = false;
+                Log.d(TAG, "ACTION_DOWN: "+ismove);
+                break;
+            case MotionEvent.ACTION_MOVE:
+                //计算移动的距离
+                int mOffsetX = x - moveX;
+                int mOffsetY = y - moveY;
+                Log.d(TAG, "mOffsetX: "+mOffsetX);
+                Log.d(TAG, "mOffsetY: "+mOffsetY);
+                if (mOffsetX>5||mOffsetY>5||mOffsetX<-5||mOffsetY<-5){
+                    ismove = true;
+                    Log.d(TAG, "ACTION_MOVE: "+ismove);
+                }
+                offsetLeftAndRight(mOffsetX);
+                offsetTopAndBottom(mOffsetY);
+                break;
+            case MotionEvent.ACTION_UP:
+                arr.add(getX());
+                arr.add(getY());
+                informationLocation.setInformationLocationListener(this, arr,ismove);
+                break;
+        }
+
+        //调用layout方法来重新放置它的位置
+        if (getX() >= 1422) {
+            setX(1400);
+        } else if (getX() <= 0) {
+            setX(10);
+        }
+        if (getY() >= 770) {
+            setY(760);
+        } else if (getY() <= -1) {
+            setY(10);
+        }
+        return true;
+    }
+
+
+    public void setInformationLocation(InformationLocation informationLocation) {
+        this.informationLocation = informationLocation;
+    }
+
+    //提供控件的位置和id
+    public interface InformationLocation {
+        void setInformationLocationListener(View view, List<Float> list, boolean ismove);
+    }
+}

+ 255 - 0
app/src/main/java/com/sunzee/ui/view/CustomViewGrounp.java

@@ -0,0 +1,255 @@
+package com.sunzee.ui.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.orhanobut.hawk.Hawk;
+import com.sunzee.R;
+import com.sunzee.utils.UiUtil;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+/**
+ * 写代码看视频,看完一个视频,先写代码,不要拖,而不是全部看完再写
+ */
+
+/**
+ * 1.继承viewGroup
+ * 2.声明属性,,,getDimension使用float接收
+ */
+public class CustomViewGrounp extends ViewGroup implements CustomView.InformationLocation, View.OnClickListener {
+    //存储数据
+    private List<String> mData = new ArrayList<>();
+    private Map<String, List<Float>> mIntegerMap = new LinkedHashMap<>();
+    private Map<String, List<Float>> mIntegerMap1 = Hawk.get("location", mIntegerMap);
+    private boolean ismove;
+    private onClickCleaning onClickCleaning;
+
+    public Map<String, List<Float>> getIntegerMap1() {
+        return mIntegerMap1;
+    }
+
+    public void setTextList(List<String> data) {
+        this.mData.clear();
+        this.mData.addAll(data);
+        setUpChildren();
+    }
+
+    private static final String TAG = "CustomViewGrounp";
+
+    private void setUpChildren() {
+        //先清空布局的子元素
+        removeAllViews();
+        //添加子view进来
+        Log.d(TAG, "setUpChildren: " + mData.size());
+        for (int i = 0; i < mData.size(); i++) {
+            CustomView customView = new CustomView(getContext());
+            customView.setId(UiUtil.getResId("cv_" + i, R.id.class));
+            customView.setWidth(170);
+            customView.setHeight(170);
+            customView.setBackgroundResource(R.drawable.selector_language_bg);
+            customView.setGravity(Gravity.CENTER);
+            customView.setTextSize(20);
+            customView.setText(mData.get(i));
+            customView.setOnClickListener(this);
+            //设置TextView的相关属性,编剧,位置,颜色等等。
+            addView(customView);
+            Log.d(TAG, "setUpChildren: ");
+        }
+
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        measureChildren(widthMeasureSpec, heightMeasureSpec);
+
+        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+        int width = MeasureSpec.getSize(widthMeasureSpec);
+        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+        int height = MeasureSpec.getSize(heightMeasureSpec);
+
+        if (widthMode == MeasureSpec.AT_MOST && heightMode == MeasureSpec.AT_MOST) {
+            int groupWidth = getMaxWidth();
+            int groupHeight = getTotalHeight();
+            setMeasuredDimension(groupWidth, groupHeight);
+        } else if (widthMode == MeasureSpec.AT_MOST) {
+            setMeasuredDimension(getMaxWidth(), height);
+        } else if (heightMode == MeasureSpec.AT_MOST) {
+            setMeasuredDimension(width, getTotalHeight());
+        }
+
+    }
+
+    public CustomViewGrounp(Context context) {
+        this(context, null);
+    }
+
+    public CustomViewGrounp(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public CustomViewGrounp(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+
+    @Override
+    protected void onLayout(boolean changed, int l, int t, int r, int b) {
+        int childCount = getChildCount();
+        for (int i = 0; i < childCount; i++) {
+            CustomView childAt = (CustomView) getChildAt(i);
+            childAt.setInformationLocation(this);
+            childAt.layout(i, i, childAt.getMeasuredWidth(), childAt.getMeasuredHeight());
+        }
+    }
+
+    private int getMaxWidth() {
+        int count = getChildCount();
+        int maxWidth = 0;
+        for (int i = 0; i < count; i++) {
+            int currentWidth = getChildAt(i).getMeasuredWidth();
+            if (maxWidth < currentWidth) {
+                maxWidth = currentWidth;
+            }
+        }
+        return maxWidth;
+    }
+
+    private int getTotalHeight() {
+        int count = getChildCount();
+        int totalHeight = 0;
+        for (int i = 0; i < count; i++) {
+            totalHeight += getChildAt(i).getMeasuredHeight();
+        }
+        return totalHeight;
+    }
+
+
+    @Override
+    public void setInformationLocationListener(View view, List<Float> list, boolean ismove) {
+        this.ismove = ismove;
+        switch (view.getId()) {
+            case R.id.cv_0:
+                mIntegerMap1.put("0", list);
+                break;
+            case R.id.cv_1:
+                mIntegerMap1.put("1", list);
+                break;
+            case R.id.cv_2:
+                mIntegerMap1.put("2", list);
+                break;
+            case R.id.cv_3:
+                mIntegerMap1.put("3", list);
+                break;
+            case R.id.cv_4:
+                mIntegerMap1.put("4", list);
+                break;
+            case R.id.cv_5:
+                mIntegerMap1.put("5", list);
+                break;
+            case R.id.cv_6:
+                mIntegerMap1.put("6", list);
+                break;
+            case R.id.cv_7:
+                mIntegerMap1.put("7", list);
+                break;
+            case R.id.cv_8:
+                mIntegerMap1.put("8", list);
+                break;
+            case R.id.cv_9:
+                mIntegerMap1.put("9", list);
+                break;
+            case R.id.cv_10:
+                mIntegerMap1.put("10", list);
+                break;
+            case R.id.cv_11:
+                mIntegerMap1.put("11", list);
+                break;
+            case R.id.cv_12:
+                mIntegerMap1.put("12", list);
+                break;
+            case R.id.cv_13:
+                mIntegerMap1.put("13", list);
+                break;
+            case R.id.cv_14:
+                mIntegerMap1.put("14", list);
+                break;
+            case R.id.cv_15:
+                mIntegerMap1.put("15", list);
+                break;
+        }
+    }
+
+    @Override
+    public void onClick(View v) {
+        Log.d(TAG, "onClick: "+ismove);
+        if (!ismove) {
+            switch (v.getId()) {
+                case R.id.cv_0:
+                    onClickCleaning.setOnCLickCleaning(1);
+                    break;
+                case R.id.cv_1:
+                    onClickCleaning.setOnCLickCleaning(2);
+                    break;
+                case R.id.cv_2:
+                    onClickCleaning.setOnCLickCleaning(3);
+                    break;
+                case R.id.cv_3:
+                    onClickCleaning.setOnCLickCleaning(4);
+                    break;
+                case R.id.cv_4:
+                    onClickCleaning.setOnCLickCleaning(5);
+                    break;
+                case R.id.cv_5:
+                    onClickCleaning.setOnCLickCleaning(6);
+                    break;
+                case R.id.cv_6:
+                    onClickCleaning.setOnCLickCleaning(7);
+                    break;
+                case R.id.cv_7:
+                    onClickCleaning.setOnCLickCleaning(8);
+                    break;
+                case R.id.cv_8:
+                    onClickCleaning.setOnCLickCleaning(9);
+                    break;
+                case R.id.cv_9:
+                    onClickCleaning.setOnCLickCleaning(10);
+                    break;
+                case R.id.cv_10:
+                    onClickCleaning.setOnCLickCleaning(11);
+                    break;
+                case R.id.cv_11:
+                    onClickCleaning.setOnCLickCleaning(12);
+                    break;
+                case R.id.cv_12:
+                    onClickCleaning.setOnCLickCleaning(13);
+                    break;
+                case R.id.cv_13:
+                    onClickCleaning.setOnCLickCleaning(14);
+                    break;
+                case R.id.cv_14:
+                    onClickCleaning.setOnCLickCleaning(15);
+                    break;
+                case R.id.cv_15:
+                    onClickCleaning.setOnCLickCleaning(16);
+                    break;
+            }
+        }
+    }
+
+    public void setOnClickCleaning(onClickCleaning onClickCleaning) {
+        this.onClickCleaning = onClickCleaning;
+    }
+
+    //客户点击了,那么我们需要进行清洗
+    public interface onClickCleaning {
+        void setOnCLickCleaning(int i);
+    }
+}

+ 11 - 0
app/src/main/java/com/sunzee/utils/PreventSpeedClickUtil.java

@@ -6,6 +6,7 @@ package com.sunzee.utils;
 public class PreventSpeedClickUtil {
     // 两次点击按钮之间的点击间隔不能少于1000毫秒
     private static final int MIN_CLICK_DELAY_TIME = 1000;
+    private static final int MIN_CLICK_DELAY_TIME2 = 300;
     private static long lastClickTime;
 
     public static boolean isFastClick() {
@@ -17,4 +18,14 @@ public class PreventSpeedClickUtil {
         lastClickTime = curClickTime;
         return flag;
     }
+
+    public static boolean isFastClick500() {
+        boolean flag = false;
+        long curClickTime = System.currentTimeMillis();
+        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME2) {
+            flag = true;
+        }
+        lastClickTime = curClickTime;
+        return flag;
+    }
 }

+ 73 - 0
app/src/main/res/layout/dialog_startclean.xml

@@ -0,0 +1,73 @@
+<?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">
+
+    <LinearLayout
+        android:layout_width="@dimen/dp_200"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:background="@drawable/shape_btn_back"
+        android:gravity="center_horizontal"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/dp_20"
+            android:text="@string/confirm_reminder"
+            android:textColor="#014DA1"
+            android:textSize="@dimen/dp_10" />
+
+        <ImageView
+            android:id="@+id/iv_qr_code"
+            android:layout_width="@dimen/dp_86"
+            android:layout_height="@dimen/dp_86"
+            android:layout_gravity="center_horizontal"
+            android:src="@drawable/shape_btn_back"
+            android:visibility="gone" />
+
+        <TextView
+            android:id="@+id/tv_content"
+            android:layout_width="@dimen/dp_160"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="@dimen/dp_20"
+            android:gravity="center_horizontal"
+            android:text="@string/confirm_content"
+            android:textColor="@color/colorGray"
+            android:textSize="@dimen/dp_10" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+
+            android:layout_height="wrap_content"
+            android:layout_margin="@dimen/dp_20"
+            android:orientation="horizontal">
+
+            <Button
+                android:id="@+id/btn_confirm"
+                android:layout_width="@dimen/dp_70"
+                android:layout_height="@dimen/dp_22"
+                android:layout_marginRight="@dimen/dp_10"
+                android:background="@drawable/shape_system_btn_rounded_rectangle"
+                android:text="@string/confirm"
+                android:textColor="@color/white"
+                android:textSize="@dimen/dp_10" />
+
+            <Button
+                android:id="@+id/btn_cancel"
+                android:layout_width="@dimen/dp_70"
+                android:layout_height="@dimen/dp_22"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:background="@drawable/shape_system_btn_rounded_rectangle"
+                android:text="@string/cancel"
+                android:textColor="@color/white"
+                android:textSize="@dimen/dp_10" />
+
+        </LinearLayout>
+
+
+    </LinearLayout>
+</RelativeLayout>

+ 30 - 0
app/src/main/res/layout/fragment_home2.xml

@@ -0,0 +1,30 @@
+<?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:background="@color/shallowblue"
+    android:orientation="vertical"
+    android:paddingLeft="@dimen/dp_10"
+    android:paddingRight="@dimen/dp_10">
+
+    <com.sunzee.ui.view.CustomViewGrounp
+        android:id="@+id/cv_custom"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+
+    <TextView
+        android:id="@+id/tv_commit"
+        android:layout_width="@dimen/dp_50"
+        android:layout_height="@dimen/dp_20"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:layout_gravity="right"
+        android:layout_marginRight="@dimen/dp_10"
+        android:layout_marginBottom="@dimen/dp_10"
+        android:background="@drawable/shape_login_rounded_rectangle"
+        android:gravity="center"
+        android:text="保存位置修改"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_6" />
+</RelativeLayout>

+ 25 - 0
app/src/main/res/values/ids.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <item name="cv_0" type="id" />
+    <item name="cv_1" type="id" />
+    <item name="cv_2" type="id" />
+    <item name="cv_3" type="id" />
+    <item name="cv_4" type="id" />
+    <item name="cv_5" type="id" />
+    <item name="cv_6" type="id" />
+    <item name="cv_7" type="id" />
+    <item name="cv_8" type="id" />
+    <item name="cv_9" type="id" />
+    <item name="cv_10" type="id" />
+    <item name="cv_11" type="id" />
+    <item name="cv_12" type="id" />
+    <item name="cv_13" type="id" />
+    <item name="cv_14" type="id" />
+    <item name="cv_15" type="id" />
+    <item name="cv_16" type="id" />
+    <item name="cv_17" type="id" />
+    <item name="cv_18" type="id" />
+    <item name="cv_19" type="id" />
+    <item name="cv_20" type="id" />
+
+</resources>

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

@@ -729,5 +729,6 @@
     <string name="debug_5">清洁消毒喷水泵</string>
     <string name="debug_6">清洗洁厕灵+水</string>
     <string name="debug_7">消毒消毒液+水</string>
+    <string name="start_cleaning_content">是否开始清洗?</string>
 
 </resources>

+ 1 - 0
gradle.properties

@@ -12,3 +12,4 @@ org.gradle.jvmargs=-Xmx1536m
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
 android.useDeprecatedNdk=true
+