|
@@ -54,8 +54,10 @@ import com.app.http.BaseBean;
|
|
import com.app.http.Http;
|
|
import com.app.http.Http;
|
|
import com.blankj.utilcode.util.ActivityUtils;
|
|
import com.blankj.utilcode.util.ActivityUtils;
|
|
import com.blankj.utilcode.util.AppUtils;
|
|
import com.blankj.utilcode.util.AppUtils;
|
|
|
|
+import com.blankj.utilcode.util.ColorUtils;
|
|
import com.blankj.utilcode.util.GsonUtils;
|
|
import com.blankj.utilcode.util.GsonUtils;
|
|
import com.blankj.utilcode.util.LanguageUtils;
|
|
import com.blankj.utilcode.util.LanguageUtils;
|
|
|
|
+import com.blankj.utilcode.util.NetworkUtils;
|
|
import com.blankj.utilcode.util.ObjectUtils;
|
|
import com.blankj.utilcode.util.ObjectUtils;
|
|
import com.blankj.utilcode.util.PermissionUtils;
|
|
import com.blankj.utilcode.util.PermissionUtils;
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
@@ -306,6 +308,7 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
SimCardStateListener();
|
|
SimCardStateListener();
|
|
checkBoxListener();
|
|
checkBoxListener();
|
|
|
|
+ networkListen();
|
|
subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|
|
|
@SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
|
|
@SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
|
|
@@ -484,6 +487,7 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
@Override
|
|
@Override
|
|
public String doInBackground() {
|
|
public String doInBackground() {
|
|
try {
|
|
try {
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务");
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1); // 向前推一天
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1); // 向前推一天
|
|
long tenDaysAgo = calendar.getTimeInMillis();
|
|
long tenDaysAgo = calendar.getTimeInMillis();
|
|
@@ -510,10 +514,12 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
cursor.close();
|
|
cursor.close();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务," + list.size());
|
|
|
|
|
|
for (Integer id : list) {
|
|
for (Integer id : list) {
|
|
DBHelper dbHelper = new DBHelper(Utils.getApp());
|
|
DBHelper dbHelper = new DBHelper(Utils.getApp());
|
|
int success = dbHelper.checkSuccessById(id);
|
|
int success = dbHelper.checkSuccessById(id);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务,success=" + success);
|
|
if (success != 1) {
|
|
if (success != 1) {
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, String> dataMap = HxUtils.queryInboxMessage(id);
|
|
HashMap<String, String> dataMap = HxUtils.queryInboxMessage(id);
|
|
@@ -532,18 +538,21 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
.post(new Http.HttpCallBack<String>() {
|
|
.post(new Http.HttpCallBack<String>() {
|
|
@Override
|
|
@Override
|
|
public void onNext(String model) {
|
|
public void onNext(String model) {
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onNext: ");
|
|
dbHelper.insertOrUpdateData(id, isHavaNumber ? 1 : 2);
|
|
dbHelper.insertOrUpdateData(id, isHavaNumber ? 1 : 2);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onError(Throwable ex) {
|
|
public void onError(Throwable ex) {
|
|
super.onError(ex);
|
|
super.onError(ex);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onError: ");
|
|
XLog.e(StringUtils.getString(R.string.log_tip_4, id), ex);
|
|
XLog.e(StringUtils.getString(R.string.log_tip_4, id), ex);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onFail(BaseBean t) {
|
|
public void onFail(BaseBean t) {
|
|
super.onFail(t);
|
|
super.onFail(t);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onFail: ");
|
|
XLog.i(StringUtils.getString(R.string.log_tip_4, id));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_4, id));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -577,6 +586,48 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
}, 2000, 30000, TimeUnit.MILLISECONDS);
|
|
}, 2000, 30000, TimeUnit.MILLISECONDS);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void networkListen() {
|
|
|
|
+ ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<List<Boolean>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public List<Boolean> doInBackground() {
|
|
|
|
+ boolean b1 = NetworkUtils.isConnected();
|
|
|
|
+ boolean b2 = NetworkUtils.isAvailable();
|
|
|
|
+ List<Boolean> mList = new ArrayList<>();
|
|
|
|
+ mList.add(b1);
|
|
|
|
+ mList.add(b2);
|
|
|
|
+ return mList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(List<Boolean> result) {
|
|
|
|
+ ThreadUtils.runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setText(
|
|
|
|
+ StringUtils.getString(R.string.connected_b_available_b, result.get(0), result.get(1))
|
|
|
|
+ );
|
|
|
|
+ if (!(result.get(0) && result.get(1))) {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setBackgroundColor(ColorUtils.getColor(R.color.red));
|
|
|
|
+ } else {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setBackgroundColor(ColorUtils.getColor(R.color.green));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(Throwable t) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCancel() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }, 2000, 2000, TimeUnit.MILLISECONDS);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private String getSimCardState() {
|
|
private String getSimCardState() {
|
|
int simState = telephonyManager.getSimState();
|
|
int simState = telephonyManager.getSimState();
|
|
switch (simState) {
|
|
switch (simState) {
|