version:6.8
fix: update:增加时间,更换提示
This commit is contained in:
@@ -69,6 +69,7 @@ import com.uiui.aios.network.URLAddress;
|
|||||||
import com.uiui.aios.tpush.MessageReceiver;
|
import com.uiui.aios.tpush.MessageReceiver;
|
||||||
import com.uiui.aios.utils.ApkUtils;
|
import com.uiui.aios.utils.ApkUtils;
|
||||||
import com.uiui.aios.utils.AppUtil;
|
import com.uiui.aios.utils.AppUtil;
|
||||||
|
import com.uiui.aios.utils.DataUtil;
|
||||||
import com.uiui.aios.utils.NetStateUtils;
|
import com.uiui.aios.utils.NetStateUtils;
|
||||||
import com.uiui.aios.utils.SchemeUtils;
|
import com.uiui.aios.utils.SchemeUtils;
|
||||||
import com.uiui.aios.utils.ToastUtil;
|
import com.uiui.aios.utils.ToastUtil;
|
||||||
@@ -76,6 +77,8 @@ import com.uiui.aios.utils.Utils;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@@ -148,6 +151,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
// TextView tv_name;
|
// TextView tv_name;
|
||||||
@BindView(R.id.iv_app)
|
@BindView(R.id.iv_app)
|
||||||
ImageView iv_app;
|
ImageView iv_app;
|
||||||
|
@BindView(R.id.tv_time)
|
||||||
|
TextView tv_time;
|
||||||
|
|
||||||
private String TAG = CustomFragment.class.getSimpleName();
|
private String TAG = CustomFragment.class.getSimpleName();
|
||||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||||
@@ -353,6 +358,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
||||||
registerBatteryReceiver();
|
registerBatteryReceiver();
|
||||||
registerAlarmClockReceiver();
|
registerAlarmClockReceiver();
|
||||||
|
registTimeReceiver();
|
||||||
|
tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
|
||||||
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) {
|
if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) {
|
||||||
cl_appstore.setVisibility(View.GONE);
|
cl_appstore.setVisibility(View.GONE);
|
||||||
@@ -911,6 +918,56 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private void registTimeReceiver() {
|
||||||
|
if (null == mTimeReceiver) {
|
||||||
|
mTimeReceiver = new TimeReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||||
|
mContext.registerReceiver(mTimeReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unRegistTimeReceiver() {
|
||||||
|
if (null != mTimeReceiver) {
|
||||||
|
mContext.unregisterReceiver(mTimeReceiver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeReceiver mTimeReceiver;
|
||||||
|
|
||||||
|
class TimeReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (action.equals(Intent.ACTION_DATE_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIMEZONE_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIME_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIME_TICK)
|
||||||
|
) {
|
||||||
|
tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据日期取得星期几
|
||||||
|
public static String getWeek() {
|
||||||
|
Date date = new Date();
|
||||||
|
String[] weeks = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(date);
|
||||||
|
int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
if (weekIndex < 0) {
|
||||||
|
weekIndex = 0;
|
||||||
|
}
|
||||||
|
return weeks[weekIndex];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -925,5 +982,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
if (mAlarmClockReceiver != null) {
|
if (mAlarmClockReceiver != null) {
|
||||||
mContext.unregisterReceiver(mAlarmClockReceiver);
|
mContext.unregisterReceiver(mAlarmClockReceiver);
|
||||||
}
|
}
|
||||||
|
unRegistTimeReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
app/src/main/java/com/uiui/aios/utils/DataUtil.java
Normal file
38
app/src/main/java/com/uiui/aios/utils/DataUtil.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package com.uiui.aios.utils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者 mjsheng
|
||||||
|
* 日期 2018/8/31 09:50
|
||||||
|
* 邮箱 501802639@qq.com
|
||||||
|
* 来自:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DataUtil {
|
||||||
|
private static SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
private static SimpleDateFormat hour = new SimpleDateFormat("HH:mm");
|
||||||
|
private static SimpleDateFormat minute = new SimpleDateFormat("mm");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化日期(精确到天)
|
||||||
|
*/
|
||||||
|
public static String formatDateDay() {
|
||||||
|
return day.format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化日期(hour)
|
||||||
|
*/
|
||||||
|
public static String formatDateHour() {
|
||||||
|
return hour.format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化日期(minute)
|
||||||
|
*/
|
||||||
|
public static String formatDateMinute() {
|
||||||
|
return minute.format(new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user