-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":25,"versionName":"202106030958","enabled":true,"outputFile":"ICL02Sport_V25_202106030958_release.apk","fullName":"release","baseName":"release"},"path":"ICL02Sport_V25_202106030958_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":26,"versionName":"202106201445","enabled":true,"outputFile":"ICL02Sport_V26_202106201445_release.apk","fullName":"release","baseName":"release"},"path":"ICL02Sport_V26_202106201445_release.apk","properties":{}}]
\ No newline at end of file
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
+import android.os.Handler;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
*/
public class PedMainFragment extends Fragment {
+ private static final String TAG = "PedMainFragment";
+ private final Handler mHandler;
+
public interface QueryPedometerCountListener {
void onQueryCount();
}
+ private PedMainFragment() {
+ mHandler = new Handler();
+ }
+
private Context mContext;
private App mApp;
private int targetValue;
- private boolean isFirstLoad = false;
-
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
try {
queryListener = (QueryPedometerCountListener) context;
} catch (ClassCastException e) {
+ e.printStackTrace();
}
}
@Override
public void onResume() {
super.onResume();
- if (!isFirstLoad) {
+ //活跃的时候,每2秒种获取一次
+ mHandler.post(getPetTask);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mHandler.removeCallbacks(getPetTask);
+ }
+
+ private final Runnable getPetTask = new Runnable() {
+ @Override
+ public void run() {
queryListener.onQueryCount();
- isFirstLoad = true;
+ mHandler.postDelayed(this, 2 * 1000);
}
- }
+ };
+
+ private int mLastNum = 0;
public void updatePedNumber(int number) {
+ Log.d(TAG, "number == > " + number);
int value = (int) (number * 0.01);
if (value < 1) {
value = 1;
}
setupRingProgress(value);
- setupRingProgressNumberTv(number);
+ setupRingProgressNumberTv(mLastNum, number);
+ this.mLastNum = number;
}
private void setupRingProgress(int number) {
mRingProgress.setProgress(number);
}
- private void setupRingProgressNumberTv(int number) {
+ private void setupRingProgressNumberTv(int lastNumber, int number) {
TextView pedNumber = pedMainBinding.pedNumberTv;
Typeface typeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/Baloo2-SemiBold.ttf");
pedNumber.setTypeface(typeFace);
- ValueAnimator animator = ValueAnimator.ofInt(0, number);
+ ValueAnimator animator = ValueAnimator.ofInt(lastNumber, number);
animator.setDuration(500);
animator.addUpdateListener(animation -> pedMainBinding.setPedNumber(animation.getAnimatedValue().toString()));
animator.start();
public void onAttach(Context context) {
super.onAttach(context);
this.mContext = context;
-
try {
queryListener = (QueryPedometerRecordListener) context;
} catch (ClassCastException e) {
+ e.printStackTrace();
}
}
mSetupRv = view.findViewById(R.id.ped_record_rv);
mSetupRv.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
- public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
+ @NonNull RecyclerView parent,
+ @NonNull RecyclerView.State state) {
outRect.bottom = 10;
}
});
import com.ic.sport.util.IcLog;
import com.ic.sport.util.ServiceUtil;
+import java.net.FileNameMap;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
public class PedometerPresenter {
private static final String TAG = "PedometerPresenter";
private IPedRemoteService mService;
private MutableLiveData<Integer> mObsPedCount;
private MutableLiveData<List<RecordParcelable>> mObsPedRecord;
+ private final ExecutorService executorService;
public PedometerPresenter(Context context) {
mContext = context;
mObsPedCount = new MutableLiveData<>();
mObsPedRecord = new MutableLiveData<>();
+ executorService = Executors.newSingleThreadExecutor();
}
public MutableLiveData<Integer> getObsPedCount() {
return mObsPedRecord;
}
+ private final Object mLock = new Object();
+
+ private final Runnable getPedTask = new Runnable() {
+ @Override
+ public void run() {
+ synchronized (mLock) {
+ if (mService != null) {
+ try {
+ mService.queryPedCount();
+ } catch (Exception e) {
+ IcLog.e(TAG, e.getMessage());
+ }
+ }
+ }
+ }
+ };
+
public void bindService() {
ServiceUtil.bindServiceUtil(mContext, "com.ic.action.WORK_SERVICE",
connection, mContext.getPackageName(), 103);
}
public void queryPedCount() {
- if (mService != null) {
- try {
- mService.queryPedCount();
- } catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
- }
- }
+ executorService.execute(getPedTask);
}
public void queryPedRecord() {
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="90dp"
+ android:layout_marginTop="130dp"
android:includeFontPadding="false"
android:text="@{pedNumber}"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="60dp"
+ android:layout_marginTop="80dp"
android:text="@string/ped_main_today"
android:textColor="#FFFFFF"
- android:textSize="36sp" />
+ android:textSize="36sp"
+ android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:includeFontPadding="false"
android:text="@string/ped_main_step"
android:textColor="@color/white"
- android:textSize="36sp" />
+ android:textSize="36sp"
+ android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginBottom="32dp"
android:drawablePadding="1dp"
android:text="@{pedTarget}"
+
android:textColor="@color/white"
android:textSize="28sp"
android:textStyle="bold" />
-#Thu Jun 03 09:58:00 CST 2021\r
-VERSION_CODE=25\r
+#Sun Jun 20 14:45:55 CST 2021\r
+VERSION_CODE=26\r