version:2.6
fix: update:修改主页图标,布局
This commit is contained in:
@@ -9,6 +9,8 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -72,6 +74,7 @@ import com.uiuios.aios.network.URLAddress;
|
||||
import com.uiuios.aios.tpush.MessageReceiver;
|
||||
import com.uiuios.aios.utils.ApkUtils;
|
||||
import com.uiuios.aios.utils.AppUtil;
|
||||
import com.uiuios.aios.utils.BitmapUtils;
|
||||
import com.uiuios.aios.utils.NetStateUtils;
|
||||
import com.uiuios.aios.utils.SchemeUtils;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
@@ -153,18 +156,19 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
@BindView(R.id.rv_sos)
|
||||
RecyclerView rv_sos;
|
||||
@BindView(R.id.iv_note_nodata)
|
||||
TextView iv_note_nodata;
|
||||
ImageView iv_note_nodata;
|
||||
// @BindView(R.id.iv_head)
|
||||
// ImageView iv_head;
|
||||
@BindView(R.id.tv_name)
|
||||
TextView tv_name;
|
||||
@BindView(R.id.iv_app)
|
||||
ImageView iv_app;
|
||||
|
||||
@BindView(R.id.iv_battery)
|
||||
ImageView iv_battery;
|
||||
|
||||
private static final String TAG = CustomFragment.class.getSimpleName();
|
||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||
private int[] mShaderColors = new int[]{0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300};
|
||||
private int[] mShaderColors = new int[]{0xFF05d192, 0xFF05d192, 0xFF05d192, 0xFF05d192, 0xFF05d192, 0xFF05d192, 0xFF05d192};
|
||||
private int[] mShaderColorsRed = new int[]{0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
|
||||
private View rootView;
|
||||
private List<AlarmItem> alarmItemList;
|
||||
@@ -351,6 +355,10 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
||||
//你可以读到充电状态,如果在充电,可以读到是usb还是交流电
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
// 当前电量
|
||||
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
// 最大电量
|
||||
@@ -358,6 +366,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
int elec = (level * 100) / scale;
|
||||
Log.i(TAG, "electricity:=" + elec + "%");
|
||||
tv_battery.setText(elec + "%");
|
||||
notifyBattery(level, scale, status, isCharging);
|
||||
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|
||||
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|
||||
|| Intent.ACTION_BATTERY_LOW.equals(action)
|
||||
@@ -368,6 +377,11 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyBattery(int level, int scale, int status, boolean isCharging) {
|
||||
Bitmap bitmap = BitmapUtils.getbatteryIcon(mContext, BitmapFactory.decodeResource(getResources(), R.drawable.battery_icon), level, isCharging);
|
||||
iv_battery.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
private BroadcastReceiver mbatteryReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -828,19 +842,19 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
});
|
||||
}
|
||||
|
||||
private void getAlarmCache(){
|
||||
private void getAlarmCache() {
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_ALARM_CLOCK);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<AlarmClockData>>() {
|
||||
}.getType();
|
||||
List<AlarmClockData> list = gson.fromJson(jsonString, type);
|
||||
if (list == null || list.size() == 0) {
|
||||
rv_noti.setVisibility(View.GONE);
|
||||
iv_note_nodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
notificationAdapter.setDataList(list);
|
||||
rv_noti.setVisibility(View.VISIBLE);
|
||||
iv_note_nodata.setVisibility(View.GONE);
|
||||
} else {
|
||||
rv_noti.setVisibility(View.GONE);
|
||||
iv_note_nodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user