From: TrillGates Date: Wed, 30 Jun 2021 03:55:43 +0000 (+0800) Subject: update aidl and return calorie to ui. X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=197e05fd85a8e75fc95bc306613fd41412f251e2;p=icworkservice.git update aidl and return calorie to ui. --- diff --git a/app/IcL02WorkService/release/IcL02WorkService_V59_202106201614_release.apk b/app/IcL02WorkService/release/IcL02WorkService_V59_202106201614_release.apk deleted file mode 100644 index 3382ea7..0000000 Binary files a/app/IcL02WorkService/release/IcL02WorkService_V59_202106201614_release.apk and /dev/null differ diff --git a/app/IcL02WorkService/release/IcL02WorkService_V59_202106301150_release.apk b/app/IcL02WorkService/release/IcL02WorkService_V59_202106301150_release.apk new file mode 100644 index 0000000..22b6403 Binary files /dev/null and b/app/IcL02WorkService/release/IcL02WorkService_V59_202106301150_release.apk differ diff --git a/app/IcL02WorkService/release/output.json b/app/IcL02WorkService/release/output.json index 44fe6a3..6d243c9 100644 --- a/app/IcL02WorkService/release/output.json +++ b/app/IcL02WorkService/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"IcL02WorkService_V59_202106201614_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V59_202106201614_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"IcL02WorkService_V59_202106301150_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V59_202106301150_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/aidl/com/ic/aidl/ped/IPedAidlInterface.aidl b/app/src/main/aidl/com/ic/aidl/ped/IPedAidlInterface.aidl index 547e996..ba08675 100644 --- a/app/src/main/aidl/com/ic/aidl/ped/IPedAidlInterface.aidl +++ b/app/src/main/aidl/com/ic/aidl/ped/IPedAidlInterface.aidl @@ -10,6 +10,7 @@ interface IPedAidlInterface { * and return values in AIDL. */ void updatePedCount(int count); + void updateCalorie(float count); void updatePedRecord(in List record); } diff --git a/app/src/main/java/com/ic/work/WorkService.java b/app/src/main/java/com/ic/work/WorkService.java index 4005260..18a172a 100644 --- a/app/src/main/java/com/ic/work/WorkService.java +++ b/app/src/main/java/com/ic/work/WorkService.java @@ -184,7 +184,7 @@ public class WorkService extends Service { @Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(PedCountEvent event) { if (pedProcess != null) { - pedProcess.sendPedCount(event.getPedCount()); + pedProcess.sendPedCount(event.getPedCount(),event.getCalorie()); } if (akProcess != null) { diff --git a/app/src/main/java/com/ic/work/event/PedCountEvent.java b/app/src/main/java/com/ic/work/event/PedCountEvent.java index bae08de..557ec0d 100644 --- a/app/src/main/java/com/ic/work/event/PedCountEvent.java +++ b/app/src/main/java/com/ic/work/event/PedCountEvent.java @@ -2,9 +2,19 @@ package com.ic.work.event; public class PedCountEvent { private int pedCount; + private float calorie; - public PedCountEvent(int count) { + public float getCalorie() { + return calorie; + } + + public void setCalorie(float calorie) { + this.calorie = calorie; + } + + public PedCountEvent(int count, float calorie) { this.pedCount = count; + this.calorie = calorie; } public int getPedCount() { diff --git a/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java b/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java index e687303..933fdd2 100644 --- a/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java +++ b/app/src/main/java/com/ic/work/hardware/PedBaseRunnable.java @@ -103,7 +103,7 @@ public class PedBaseRunnable { return entity; } - private String getCalorieValue(int number) { + protected String getCalorieValue(int number) { BigDecimal bg = new BigDecimal(PedUtil.calcConsumeEnergy(mHeight, mWeight, number)); String value = String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue()); //保存一份到数据库中 diff --git a/app/src/main/java/com/ic/work/hardware/PedRunnable.java b/app/src/main/java/com/ic/work/hardware/PedRunnable.java index a745f30..df5db66 100644 --- a/app/src/main/java/com/ic/work/hardware/PedRunnable.java +++ b/app/src/main/java/com/ic/work/hardware/PedRunnable.java @@ -6,6 +6,7 @@ import com.ic.work.db.PedInjection; import com.ic.work.event.PedCountEvent; import com.ic.work.event.TaskFinishedEvent; import com.ic.work.utils.HardwareUtils; +import com.ic.work.utils.ICLogger; import com.ic.work.utils.IcLog; import org.greenrobot.eventbus.EventBus; @@ -23,7 +24,14 @@ public class PedRunnable extends PedBaseRunnable implements Runnable { int ped = HardwareUtils.getNdkStepCountValue(); IcLog.i(TAG, "Get Ped Count" + ped); //发送给主线程。主线更新数据UI - EventBus.getDefault().post(new PedCountEvent(ped)); + String calorieValue = getCalorieValue(ped); + try { + ICLogger.d("calorieValue == > " + calorieValue); + float calorie = Float.parseFloat(calorieValue); + EventBus.getDefault().post(new PedCountEvent(ped, calorie)); + } catch (Exception e) { + e.printStackTrace(); + } updateCountDB(ped, getOffsetDateTime()); //add by TrillGates notify task finished. EventBus.getDefault().post(new TaskFinishedEvent()); diff --git a/app/src/main/java/com/ic/work/process/PedProcess.java b/app/src/main/java/com/ic/work/process/PedProcess.java index c1aa908..7605608 100644 --- a/app/src/main/java/com/ic/work/process/PedProcess.java +++ b/app/src/main/java/com/ic/work/process/PedProcess.java @@ -9,6 +9,7 @@ import com.ic.aidl.ped.IPedRemoteService; import com.ic.aidl.ped.RecordParcelable; import com.ic.work.event.PedSettingEvent; import com.ic.work.event.ThreadPoolEvent; +import com.ic.work.utils.ICLogger; import com.ic.work.utils.IcLog; import org.greenrobot.eventbus.EventBus; @@ -64,12 +65,16 @@ public class PedProcess { } }; - public void sendPedCount(int count) { + public void sendPedCount(int count, float calorie) { int N = 0; try { N = mCallbacks.beginBroadcast(); for (int i = 0; i < N; i++) { mCallbacks.getBroadcastItem(i).updatePedCount(count); + //卡路里分发一下 + //换算一下 + ICLogger.d(count + " calorie == > " + calorie); + mCallbacks.getBroadcastItem(i).updateCalorie(calorie); } } catch (NullPointerException e) { IcLog.e(TAG, "", e); @@ -84,6 +89,7 @@ public class PedProcess { IcLog.e(TAG, "", ll); } } + } public void sendPedRecord(List record) {