mCalorie = pedometerPresenter.getCalorie();
//注冊广播,监听时间变化
registerTimeDateReceiver();
+ updateTime();
}
@Override
String action = intent.getAction();
if (TextUtils.isEmpty(action)) return;
//更新时间
- String format = LocalDateTime.now().format(HH_MM);
- IcLog.d(TAG, "format time == > " + format);
- timeValue.postValue(format);
+ updateTime();
}
};
+ private void updateTime() {
+ String format = LocalDateTime.now().format(HH_MM);
+ IcLog.d(TAG, "format time == > " + format);
+ timeValue.postValue(format);
+ }
+
public void registerTimeDateReceiver() {
IntentFilter filter = new IntentFilter();
getApplication().registerReceiver(mIntentReceiver, filter);
}
-
public LiveData<Float> getCalorie() {
return mCalorie;
}
tools:context=".PedometerActivity">
<TextView
+ android:id="@+id/top_left_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
- android:id="@+id/top_left_title_tv"
android:text="@string/app_name"
android:textColor="@color/green1"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
+ android:id="@+id/top_time_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:padding="5dp"
android:text="12:12"
- android:id="@+id/top_time_tv"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold" />