1.添加广播。修改计步不在去清零,优化线程池
authorkfl_614 <kfl_614@163.com>
Thu, 2 Apr 2020 11:17:23 +0000 (19:17 +0800)
committerkfl_614 <kfl_614@163.com>
Thu, 2 Apr 2020 11:17:23 +0000 (19:17 +0800)
2.添加日期改变广播。零点开始获取定位与获取数据。

12 files changed:
app/src/main/AndroidManifest.xml
app/src/main/java/com/ic/work/MainActivity.java
app/src/main/java/com/ic/work/ThreadPoolManager.java
app/src/main/java/com/ic/work/WorkService.java
app/src/main/java/com/ic/work/event/ThreadPoolEvent.java [new file with mode: 0644]
app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java [new file with mode: 0644]
app/src/main/java/com/ic/work/hardware/PedRunnable.java
app/src/main/java/com/ic/work/hardware/WritePedTotalRunnable.java [new file with mode: 0644]
app/src/main/java/com/ic/work/process/BloodProcess.java
app/src/main/java/com/ic/work/process/PedProcess.java
app/src/main/java/com/ic/work/process/WeatherProcess.java
app/version_code.properties

index d52c6fa..41cf9f9 100644 (file)
             android:name="com.amap.api.v2.apikey"
             android:value="80c129088f7bbe251a846d645ee8360a" />
 
-        <!--android:process=":remote"-->
         <service
             android:name=".WorkService"
             android:enabled="true"
             android:exported="true"
-            >
+            android:process=":remote">
             <intent-filter>
                 <action android:name="com.ic.action.WORK_SERVICE" />
             </intent-filter>
index 62511d2..1635e79 100644 (file)
@@ -2,18 +2,24 @@ package com.ic.work;
 
 import androidx.appcompat.app.AppCompatActivity;
 
+import android.content.Context;
 import android.nfc.Tag;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.SystemClock;
 import android.widget.Button;
 
+import com.ic.work.hardware.WritePedTotalRunnable;
 import com.ic.work.utils.IcLog;
 import com.ic.work.utils.PedUtil;
 import com.ic.work.utils.ServiceUtil;
 
+import org.threeten.bp.Instant;
 import org.threeten.bp.LocalDate;
 import org.threeten.bp.LocalDateTime;
 import org.threeten.bp.LocalTime;
 import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneId;
 import org.threeten.bp.format.DateTimeFormatter;
 
 import java.math.BigDecimal;
@@ -23,6 +29,9 @@ public class MainActivity extends AppCompatActivity {
 
     private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
 
+    private Context context;
+    private WorkServiceApp app;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -35,12 +44,27 @@ public class MainActivity extends AppCompatActivity {
                     getPackageName());
         });
 
-        OffsetDateTime today = OffsetDateTime.now();
-        IcLog.i(TAG,today.format(formatter));
+        context = this;
+        app =(WorkServiceApp) getApplication();
+
+        OffsetDateTime time = OffsetDateTime.now(ZoneId.systemDefault()).plusDays(1);
+
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                int count=0;
+                while (count<5){
+                    ThreadPoolManager.getInstance().execute(new WritePedTotalRunnable(
+                            context,
+                            app.getRepository(),
+                            3000+count));
 
-        BigDecimal bg = new BigDecimal(PedUtil.calcDistanceBySteps(170, 3600));
-        IcLog.i(TAG,""+bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
+                    count++;
+                }
 
-        IcLog.i(TAG,""+ LocalDateTime.of(LocalDate.now(), LocalTime.MIN).getHour());
+            }
+        },1000);
     }
+
+
 }
index 8a5486e..23f4f68 100644 (file)
@@ -1,6 +1,8 @@
 package com.ic.work;
 
+import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -10,7 +12,7 @@ public class ThreadPoolManager {
 
     private static ThreadPoolManager mInstance;
 
-    private ThreadPoolExecutor mTheadPool;
+    private ExecutorService mTheadPool;
 
     public static final synchronized ThreadPoolManager getInstance() {
         if (mInstance == null) {
@@ -20,11 +22,7 @@ public class ThreadPoolManager {
     }
 
     private ThreadPoolManager() {
-        mTheadPool = new ThreadPoolExecutor(
-                0,
-                CPU_COUNT * 2 + 1,
-                120L, TimeUnit.SECONDS,
-                new SynchronousQueue<Runnable>());
+        mTheadPool = Executors.newSingleThreadExecutor();
     }
 
     public void execute(Runnable runnable) {
@@ -41,6 +39,6 @@ public class ThreadPoolManager {
         if (runnable == null)
             return;
 
-        mTheadPool.remove(runnable);
+       // mTheadPool.remove(runnable);
     }
 }
index 04fb72d..1aae415 100644 (file)
@@ -5,11 +5,6 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.net.ConnectivityManager;
-import android.net.LinkProperties;
-import android.net.Network;
-import android.net.NetworkCapabilities;
-import android.net.NetworkInfo;
 import android.os.Build;
 import android.os.IBinder;
 import android.text.TextUtils;
@@ -22,22 +17,25 @@ import com.ic.work.event.LocationResultEvent;
 import com.ic.work.event.PedCountEvent;
 import com.ic.work.event.PedRecordResultEvent;
 import com.ic.work.event.PedSettingEvent;
+import com.ic.work.event.ThreadPoolEvent;
 import com.ic.work.event.WeatherAgainEvent;
 import com.ic.work.event.WeatherResultEvent;
+import com.ic.work.hardware.BloodRunnable;
 import com.ic.work.hardware.MessengerCoreService;
+import com.ic.work.hardware.PedRecordRunnable;
+import com.ic.work.hardware.PedRunnable;
+import com.ic.work.hardware.WritePedTotalRunnable;
 import com.ic.work.process.BloodProcess;
 import com.ic.work.process.PedProcess;
 import com.ic.work.process.WeatherProcess;
 import com.ic.work.utils.IcLog;
 import com.ic.work.utils.SPUtils;
-import com.ic.work.weather.LocationState;
+import com.ic.work.weather.WeatherDBRun;
 import com.ic.work.weather.WeatherHelper;
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
-import org.threeten.bp.LocalDateTime;
-import org.threeten.bp.ZoneId;
 
 public class WorkService extends Service {
 
@@ -48,6 +46,9 @@ public class WorkService extends Service {
 
     private static final String GET_PED_ACTION = "com.ic.action.GET_PED_COUNT";
 
+    private static final String PED_TOTAL_KEY = "PED_TOTAL";
+    private static final String PED_FINISH_ACTION = "com.ic.action.PED_FINISH";
+
     private WeatherProcess weatherProcess;
     private BloodProcess bloodProcess;
     private PedProcess pedProcess;
@@ -58,6 +59,8 @@ public class WorkService extends Service {
 
     private MessengerCoreService coreService;
 
+    private BloodRunnable mBloodRun;
+
     @Override
     public IBinder onBind(Intent intent) {
         if (intent != null) {
@@ -85,13 +88,9 @@ public class WorkService extends Service {
         super.onCreate();
         mApp = (WorkServiceApp) getApplication();
 
-        weatherProcess = new WeatherProcess(mApp);
+        weatherProcess = new WeatherProcess();
         bloodProcess = new BloodProcess();
-
-        pedProcess = new PedProcess(
-                (WorkServiceApp) getApplication(),
-                SPUtils.getPedHeightSP(getApplicationContext()),
-                SPUtils.getPedWighttSP(getApplicationContext()));
+        pedProcess = new PedProcess();
 
         mWeatherHelper = new WeatherHelper();
 
@@ -102,8 +101,6 @@ public class WorkService extends Service {
         coreService = new MessengerCoreService();
         coreService.bindCoreService(getApplicationContext());
 
-        mWeatherHelper.startLocation(getApplicationContext(),false);
-
         IcLog.i(TAG, "work service is start");
     }
 
@@ -160,21 +157,14 @@ public class WorkService extends Service {
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMessageEvent(PedSettingEvent event) {
-
-        if (pedProcess != null) {
-            return;
-        }
-
         switch (event.getType()) {
             case 1:
                 int height = event.getValue();
                 SPUtils.setPedHeightSP(getApplicationContext(), height);
-                pedProcess.updateHeight(height);
                 break;
             case 2:
                 int weight = event.getValue();
                 SPUtils.setPedWighttSP(getApplicationContext(), weight);
-                pedProcess.updateWeight(weight);
                 break;
         }
     }
@@ -206,16 +196,43 @@ public class WorkService extends Service {
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMessageEvent(WeatherAgainEvent event) {
         if (mWeatherHelper != null) {
-            mWeatherHelper.startLocation(getApplicationContext(),false);
+            mWeatherHelper.startLocation(getApplicationContext(), false);
+        }
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(ThreadPoolEvent event) {
+        switch (event.getEventType()) {
+            case 1:
+                postPedThread();
+                break;
+            case 2:
+                ThreadPoolManager.getInstance().execute(new PedRecordRunnable(mApp.getRepository()));
+                break;
+            case 3:
+                if (mBloodRun == null) {
+                    mBloodRun = new BloodRunnable();
+                }
+                ThreadPoolManager.getInstance().execute(mBloodRun);
+                break;
+            case 4:
+                if (mBloodRun != null) {
+                    ThreadPoolManager.getInstance().remove(mBloodRun);
+                    mBloodRun = null;
+                }
+                break;
+            case 5:
+                ThreadPoolManager.getInstance().execute(new WeatherDBRun(mApp.getWeatherRepository()));
+                break;
         }
     }
 
     public void registerBroadcast() {
         IntentFilter filter = new IntentFilter();
         filter.addAction(GET_PED_ACTION);
-        filter.addAction(Intent.ACTION_TIME_TICK);
+        filter.addAction(PED_FINISH_ACTION);
+        filter.addAction(Intent.ACTION_DATE_CHANGED);
         filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
-        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
         registerReceiver(mIntentReceiver, filter);
     }
 
@@ -243,20 +260,31 @@ public class WorkService extends Service {
                 }
                 switch (acyion) {
                     case GET_PED_ACTION:
-                        pedProcess.startPedRunGetCount();
+                        postPedThread();
                         break;
                     case Intent.ACTION_TIMEZONE_CHANGED:
-                        mWeatherHelper.startLocation(getApplicationContext(),true);
+                        mWeatherHelper.startLocation(getApplicationContext(), true);
                         break;
-                    case Intent.ACTION_TIME_TICK:
-                        mWeatherHelper.startLocation(getApplicationContext(),false);
-                        LocalDateTime currTime = LocalDateTime.now(ZoneId.systemDefault());
-                        if(currTime.getHour() == 0){
-                            pedProcess.startPedRunGetCount();
-                        }
+                    case PED_FINISH_ACTION:
+                        IcLog.i(TAG,"PED_FINISH_ACTION");
+                        //完成,需要把所有的今天的数据全部写入到数据中
+                        int count = intent.getIntExtra(PED_TOTAL_KEY, 0);
+                        ThreadPoolManager.getInstance().execute(new WritePedTotalRunnable(
+                                mApp.getApplicationContext(),
+                                mApp.getRepository(),
+                                count));
+                        break;
+                    case Intent.ACTION_DATE_CHANGED:
+                        IcLog.i(TAG,"ACTION_DATE_CHANGED");
+                        mWeatherHelper.startLocation(getApplicationContext(), true);
+                        postPedThread();
                         break;
                 }
             }
         }
     };
+
+    private void postPedThread() {
+        ThreadPoolManager.getInstance().execute(new PedRunnable(mApp.getApplicationContext(), mApp.getRepository()));
+    }
 }
diff --git a/app/src/main/java/com/ic/work/event/ThreadPoolEvent.java b/app/src/main/java/com/ic/work/event/ThreadPoolEvent.java
new file mode 100644 (file)
index 0000000..5d45950
--- /dev/null
@@ -0,0 +1,13 @@
+package com.ic.work.event;
+
+public class ThreadPoolEvent {
+    private int eventType;
+
+    public ThreadPoolEvent(int eventType) {
+        this.eventType = eventType;
+    }
+
+    public int getEventType() {
+        return eventType;
+    }
+}
diff --git a/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java b/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java
new file mode 100644 (file)
index 0000000..f4e177c
--- /dev/null
@@ -0,0 +1,114 @@
+package com.ic.work.hardware;
+
+import android.content.Context;
+
+import com.ic.work.db.PedInjection;
+import com.ic.work.db.entity.PedEntity;
+import com.ic.work.utils.PedUtil;
+import com.ic.work.utils.SPUtils;
+
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneId;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class PedBaseRunnable {
+
+    private PedInjection mPedInjection;
+    private int mHeight;
+    private int mWeight;
+
+    protected PedBaseRunnable(Context context, PedInjection pedInjection) {
+        mPedInjection = pedInjection;
+        mHeight = SPUtils.getPedHeightSP(context);
+        mWeight = SPUtils.getPedWighttSP(context);
+    }
+
+    protected boolean isCheckPedInjection() {
+        return mPedInjection == null;
+    }
+
+    protected int queryDBPedCount() {
+        return mPedInjection.queryDBPedCount();
+    }
+
+    protected List<PedEntity>  queryTodayPedEntity(){
+        return mPedInjection.queryDBPedDate(getOffsetDateTime());
+    }
+
+    protected void insertDBPedEntity(int number, OffsetDateTime date, int size) {
+        //判断 size 超过
+        if (size >= 60) {
+            //删除一条最早的数据
+            List<PedEntity> entities = mPedInjection.queryDBPedOldestList();
+            if (entities != null && entities.size() == 1) {
+                mPedInjection.deletePedEntity(entities.get(0).getId());
+            }
+        }
+        mPedInjection.insertDBPedDate(createEntity(number, date));
+    }
+
+    protected void updateDBPedEntity(PedEntity entity) {
+        int number = entity.getPedNumber();
+        entity.setPedDistance(getDistanceValue(number));
+        entity.setPedCalorie(getCalorieValue(number));
+        mPedInjection.updateDBPedDate(entity);
+    }
+
+    protected void processPedCountDB(int pedCount){
+        if (isCheckPedInjection()) {
+            return;
+        }
+
+        int size = queryDBPedCount();
+
+        if (size == 0) {
+            //如果数据库中无记录,把当前数据插入到数据库中
+            insertDBPedEntity(pedCount, getOffsetDateTime(), size);
+        } else {
+            //2.去查询数据中是否有当天的记录。
+            List<PedEntity> todayPed = queryTodayPedEntity();
+            if (todayPed != null && todayPed.size() > 0) {
+                //3.如果数据中有当天的数据,并更新数据
+                if (pedCount > 0 && pedCount > todayPed.get(0).getPedNumber()) {
+                    todayPed.get(0).setPedNumber(pedCount);
+                    updateDBPedEntity(todayPed.get(0));
+                }
+            } else {
+                //直接 插入今天的数据
+                insertDBPedEntity(pedCount, getOffsetDateTime(), size);
+            }
+        }
+    }
+
+    private PedEntity createEntity(int number, OffsetDateTime date) {
+
+        PedEntity entity = new PedEntity();
+        entity.setPedNumber(number);
+        entity.setPedDistance(getDistanceValue(number));
+        entity.setPedCalorie(getCalorieValue(number));
+        entity.setPedDate(date);
+
+        return entity;
+    }
+
+    private String getCalorieValue(int number) {
+        BigDecimal bg = new BigDecimal(PedUtil.calcConsumeEnergy(mHeight, mWeight, number));
+        return String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
+    }
+
+    private String getDistanceValue(int number) {
+        BigDecimal bg = new BigDecimal(PedUtil.calcDistanceBySteps(mHeight, number));
+        return String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
+    }
+
+    protected OffsetDateTime getOffsetDateTime() {
+        return OffsetDateTime.now(ZoneId.systemDefault());
+    }
+
+    private OffsetDateTime getFrontOffsetDateTime() {
+        return getOffsetDateTime().minusDays(1);
+    }
+
+}
index 0b8ea4e..1703dba 100644 (file)
@@ -1,5 +1,7 @@
 package com.ic.work.hardware;
 
+import android.content.Context;
+
 import com.ic.work.db.PedInjection;
 import com.ic.work.db.entity.PedEntity;
 import com.ic.work.event.PedCountEvent;
@@ -14,131 +16,32 @@ import org.threeten.bp.ZoneId;
 import java.math.BigDecimal;
 import java.util.List;
 
-public class PedRunnable implements Runnable {
+public class PedRunnable extends PedBaseRunnable implements Runnable {
 
     private static final String TAG = "PedRunnable";
 
-    private PedInjection mPedDb;
-
-    private int mHeight;
-    private int mWeight;
-
     private boolean isRuning = false;
 
-    public PedRunnable(PedInjection pedDB, int height, int weight) {
-        mPedDb = pedDB;
-        mHeight = height;
-        mWeight = weight;
-    }
-
-    public void setHeight(int mHeight) {
-        this.mHeight = mHeight;
-    }
-
-    public void setWeight(int mWeight) {
-        this.mWeight = mWeight;
+    public PedRunnable(Context context,PedInjection pedDB) {
+       super(context,pedDB);
     }
 
     @Override
     public void run() {
-        //1.先获取一次当前的计步数
+
         if (isRuning) {
             return;
         }
 
         isRuning = true;
 
+        //1.先获取一次当前的计步数
         int currCount = HardwareUtils.getNdkStepCountValue();
         IcLog.i(TAG, "Ped Count" + currCount);
-
-        int size = mPedDb.queryDBPedCount();
-        if (size == 0) {
-            //如果数据库中无记录,把当前数据插入到数据库中
-            insertDBPedEntity(currCount, getOffsetDateTime(), size);
-        } else {
-            //2.去查询数据中是否有当天的记录。
-            List<PedEntity> todayPed = mPedDb.queryDBPedDate(getOffsetDateTime());
-            if (todayPed != null && todayPed.size() > 0) {
-                //3.如果数据中有当天的数据,并更新数据
-                if (currCount > 0 && currCount > todayPed.get(0).getPedNumber()) {
-                    todayPed.get(0).setPedNumber(currCount);
-                    updateDBPedEntity(todayPed.get(0));
-                }
-            } else {
-                //4.如果数据库中没有当天的数据,则把当前的数据更新前一天的数据中
-                //  并且重置计步,并在数据库中新建一条数据
-
-                //获取前一天的数据
-                List<PedEntity> beforePed = mPedDb.queryDBPedDate(getFrontOffsetDateTime());
-                if (beforePed != null && beforePed.size() > 0) {
-
-                    beforePed.get(0).setPedNumber(currCount);
-                    updateDBPedEntity(beforePed.get(0));
-
-                    insertDBPedEntity(0, getOffsetDateTime(), size);
-                    //发送给主线程。主线更新数据UI
-                    EventBus.getDefault().post(new PedCountEvent(0));
-                    return;
-                } else {
-                    //如果没有前一天没有数据。则直接 插入今天的数据
-                    insertDBPedEntity(currCount, getOffsetDateTime(), size);
-                }
-
-                //重置计步
-                HardwareUtils.resetNdkStepCountValue();
-            }
-        }
-
         //发送给主线程。主线更新数据UI
         EventBus.getDefault().post(new PedCountEvent(currCount));
-        isRuning = false;
-    }
-
-    private PedEntity createEntity(int number, OffsetDateTime date) {
-
-        PedEntity entity = new PedEntity();
-        entity.setPedNumber(number);
-        entity.setPedDistance(getDistanceValue(number));
-        entity.setPedCalorie(getCalorieValue(number));
-        entity.setPedDate(date);
-
-        return entity;
-    }
+        processPedCountDB(currCount);
 
-    private void insertDBPedEntity(int number, OffsetDateTime date, int size) {
-        //判断 size 超过
-        if (size >= 60) {
-            //删除一条最早的数据
-            List<PedEntity> entities = mPedDb.queryDBPedOldestList();
-            if (entities != null && entities.size() == 1) {
-                mPedDb.deletePedEntity(entities.get(0).getId());
-            }
-        }
-        mPedDb.insertDBPedDate(createEntity(number, date));
-    }
-
-    private void updateDBPedEntity(PedEntity entity) {
-        int number = entity.getPedNumber();
-        entity.setPedDistance(getDistanceValue(number));
-        entity.setPedCalorie(getCalorieValue(number));
-        mPedDb.updateDBPedDate(entity);
-    }
-
-    private String getCalorieValue(int number) {
-        BigDecimal bg = new BigDecimal(PedUtil.calcConsumeEnergy(mHeight, mWeight, number));
-        return String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
-    }
-
-    private String getDistanceValue(int number) {
-        BigDecimal bg = new BigDecimal(PedUtil.calcDistanceBySteps(mHeight, number));
-        return String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
-    }
-
-    private OffsetDateTime getOffsetDateTime() {
-        return OffsetDateTime.now(ZoneId.systemDefault());
-    }
-
-    private OffsetDateTime getFrontOffsetDateTime() {
-        return getOffsetDateTime().minusDays(1);
+        isRuning = false;
     }
 }
diff --git a/app/src/main/java/com/ic/work/hardware/WritePedTotalRunnable.java b/app/src/main/java/com/ic/work/hardware/WritePedTotalRunnable.java
new file mode 100644 (file)
index 0000000..541931c
--- /dev/null
@@ -0,0 +1,19 @@
+package com.ic.work.hardware;
+
+import android.content.Context;
+import com.ic.work.db.PedInjection;
+
+public class WritePedTotalRunnable extends PedBaseRunnable implements Runnable {
+
+    private int mTotalPed;
+
+    public WritePedTotalRunnable(Context context, PedInjection pedDB, int totalPed) {
+        super(context, pedDB);
+        mTotalPed = totalPed;
+    }
+
+    @Override
+    public void run() {
+        processPedCountDB(mTotalPed);
+    }
+}
index d51088d..87e5b1c 100644 (file)
@@ -7,21 +7,17 @@ import android.os.RemoteException;
 import com.ic.aidl.blood.IBloodAidlInterface;
 import com.ic.aidl.blood.IBloodRemoteService;
 import com.ic.work.ThreadPoolManager;
-import com.ic.work.hardware.BloodRunnable;
+import com.ic.work.event.ThreadPoolEvent;
 import com.ic.work.utils.IcLog;
 
+import org.greenrobot.eventbus.EventBus;
+
 
 public class BloodProcess {
     private static final String TAG = "BloodProcess";
 
     private RemoteCallbackList<IBloodAidlInterface> mCallbacks = new RemoteCallbackList<>();
 
-    private BloodRunnable mBloodRun;
-
-    public BloodProcess() {
-        mBloodRun = new BloodRunnable();
-    }
-
     public IBinder getBloodBinder() {
         return bloodBinder;
     }
@@ -43,12 +39,12 @@ public class BloodProcess {
 
         @Override
         public void startCheckBlood() throws RemoteException {
-            ThreadPoolManager.getInstance().execute(mBloodRun);
+            EventBus.getDefault().post(new ThreadPoolEvent(3));
         }
 
         @Override
         public void stopCheckBlood() throws RemoteException {
-            ThreadPoolManager.getInstance().remove(mBloodRun);
+            EventBus.getDefault().post(new ThreadPoolEvent(4));
         }
     };
 
index 5ea82ad..fc843ae 100644 (file)
@@ -1,6 +1,5 @@
 package com.ic.work.process;
 
-import android.os.Binder;
 import android.os.IBinder;
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
@@ -8,11 +7,8 @@ import android.os.RemoteException;
 import com.ic.aidl.ped.IPedAidlInterface;
 import com.ic.aidl.ped.IPedRemoteService;
 import com.ic.aidl.ped.RecordParcelable;
-import com.ic.work.ThreadPoolManager;
-import com.ic.work.WorkServiceApp;
 import com.ic.work.event.PedSettingEvent;
-import com.ic.work.hardware.PedRecordRunnable;
-import com.ic.work.hardware.PedRunnable;
+import com.ic.work.event.ThreadPoolEvent;
 import com.ic.work.utils.IcLog;
 
 import org.greenrobot.eventbus.EventBus;
@@ -24,17 +20,6 @@ public class PedProcess {
 
     private RemoteCallbackList<IPedAidlInterface> mCallbacks = new RemoteCallbackList<>();
 
-    private PedRunnable mPedRun;
-    private PedRecordRunnable mRecordRun;
-
-    public PedProcess(WorkServiceApp app, int height, int weight) {
-        mPedRun = new PedRunnable(app.getRepository(), height, weight);
-        mRecordRun = new PedRecordRunnable(app.getRepository());
-    }
-
-    public void startPedRunGetCount(){
-        ThreadPoolManager.getInstance().execute(mPedRun);
-    }
 
     public IBinder getPedBinder() {
         return pedBinder;
@@ -57,12 +42,12 @@ public class PedProcess {
 
         @Override
         public void queryPedCount() throws RemoteException {
-            startPedRunGetCount();
+            EventBus.getDefault().post(new ThreadPoolEvent(1));
         }
 
         @Override
         public void queryPedRecord() throws RemoteException {
-            ThreadPoolManager.getInstance().execute(mRecordRun);
+            EventBus.getDefault().post(new ThreadPoolEvent(2));
         }
 
         @Override
@@ -76,14 +61,6 @@ public class PedProcess {
         }
     };
 
-    public void updateHeight(int height){
-        mPedRun.setHeight(height);
-    }
-
-    public void updateWeight(int weight){
-        mPedRun.setWeight(weight);
-    }
-
     public void sendPedCount(int count) {
         int N = 0;
         try {
index 3931720..6ef4e25 100644 (file)
@@ -7,10 +7,10 @@ import android.os.RemoteException;
 import com.ic.aidl.weather.IWeatherAidlInterface;
 import com.ic.aidl.weather.IWeatherRemoteService;
 import com.ic.aidl.weather.WeatherParcelable;
-import com.ic.work.ThreadPoolManager;
-import com.ic.work.WorkServiceApp;
+import com.ic.work.event.ThreadPoolEvent;
 import com.ic.work.utils.IcLog;
-import com.ic.work.weather.WeatherDBRun;
+
+import org.greenrobot.eventbus.EventBus;
 
 import java.util.List;
 
@@ -20,12 +20,6 @@ public class WeatherProcess {
 
     private RemoteCallbackList<IWeatherAidlInterface> mCallbacks = new RemoteCallbackList<>();
 
-    private WeatherDBRun weatherRun;
-
-    public WeatherProcess(WorkServiceApp app) {
-        weatherRun = new WeatherDBRun(app.getWeatherRepository());
-    }
-
     public IBinder getWeatherBinder(){
         return weatherBinder;
     }
@@ -47,7 +41,7 @@ public class WeatherProcess {
 
         @Override
         public void queryWeatherInfo() throws RemoteException {
-            ThreadPoolManager.getInstance().execute(weatherRun);
+            EventBus.getDefault().post(new ThreadPoolEvent(5));
         }
     };
 
index 17a1daf..ec13f8d 100644 (file)
@@ -1,2 +1,2 @@
-#Tue Mar 31 16:59:40 CST 2020
-VERSION_CODE=18
+#Tue Mar 31 18:36:21 CST 2020
+VERSION_CODE=19