version:
fix: update:主页缓存
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
package com.uiui.aios.activity.alarm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.AlarmAdapter;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,8 +15,6 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import cn.jzvd.Jzvd;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class AlarmClockActivity extends BaseActivity implements AlarmClockContact.ClockView {
|
||||
|
||||
|
||||
@@ -109,8 +109,5 @@ public class HealthCodeActivity extends BaseActivity implements HealthCodeContac
|
||||
@Override
|
||||
public void onError() {
|
||||
ToastUtil.show("连接服务器失败,请检查网络连接");
|
||||
// mViewPager.setVisibility(View.GONE);
|
||||
// mMagicIndicator.setVisibility(View.GONE);
|
||||
// iv_nodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +248,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
mBaseFragmentPagerAdapter.notifyItemChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
@@ -293,6 +295,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
||||
gotoNotificationAccessSetting(this);
|
||||
}
|
||||
addData();
|
||||
mMainPresenter.sendRunningInfo();
|
||||
}
|
||||
|
||||
|
||||
191
app/src/main/java/com/uiui/aios/bean/SnInfo.java
Normal file
191
app/src/main/java/com/uiui/aios/bean/SnInfo.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.uiui.aios.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SnInfo implements Serializable {
|
||||
private static final long serialVersionUID = -5268233433601073239L;
|
||||
|
||||
int id;
|
||||
String sn_value;
|
||||
int is_log;
|
||||
int is_log_type;
|
||||
int sex;
|
||||
int age;
|
||||
String height;
|
||||
String weight;
|
||||
String devices_version;
|
||||
String sn_name;
|
||||
String school;
|
||||
String is_lock;
|
||||
String is_reset;
|
||||
String grade;
|
||||
String name;
|
||||
int admin_id;
|
||||
String mobile;
|
||||
|
||||
/*
|
||||
*3 商用——企业用户
|
||||
4 C端——老人用户
|
||||
5 教育——机构用户
|
||||
6 C端——学生用户
|
||||
7 C端——DIY用户
|
||||
8 C端——经销商
|
||||
*
|
||||
* */
|
||||
int type_id;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSn_value() {
|
||||
return sn_value;
|
||||
}
|
||||
|
||||
public void setSn_value(String sn_value) {
|
||||
this.sn_value = sn_value;
|
||||
}
|
||||
|
||||
public int getIs_log() {
|
||||
return is_log;
|
||||
}
|
||||
|
||||
public void setIs_log(int is_log) {
|
||||
this.is_log = is_log;
|
||||
}
|
||||
|
||||
public int getIs_log_type() {
|
||||
return is_log_type;
|
||||
}
|
||||
|
||||
public void setIs_log_type(int is_log_type) {
|
||||
this.is_log_type = is_log_type;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(String height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(String weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getDevices_version() {
|
||||
return devices_version;
|
||||
}
|
||||
|
||||
public void setDevices_version(String devices_version) {
|
||||
this.devices_version = devices_version;
|
||||
}
|
||||
|
||||
public String getSn_name() {
|
||||
return sn_name;
|
||||
}
|
||||
|
||||
public void setSn_name(String sn_name) {
|
||||
this.sn_name = sn_name;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getIs_lock() {
|
||||
return is_lock;
|
||||
}
|
||||
|
||||
public void setIs_lock(String is_lock) {
|
||||
this.is_lock = is_lock;
|
||||
}
|
||||
|
||||
public String getIs_reset() {
|
||||
return is_reset;
|
||||
}
|
||||
|
||||
public void setIs_reset(String is_reset) {
|
||||
this.is_reset = is_reset;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAdmin_id() {
|
||||
return admin_id;
|
||||
}
|
||||
|
||||
public void setAdmin_id(int admin_id) {
|
||||
this.admin_id = admin_id;
|
||||
}
|
||||
|
||||
public String getGrade() {
|
||||
return grade;
|
||||
}
|
||||
|
||||
public void setGrade(String grade) {
|
||||
this.grade = grade;
|
||||
}
|
||||
|
||||
public int getType_id() {
|
||||
return type_id;
|
||||
}
|
||||
|
||||
public void setType_id(int type_id) {
|
||||
this.type_id = type_id;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
251
app/src/main/java/com/uiui/aios/dialog/SingleDialog.java
Normal file
251
app/src/main/java/com/uiui/aios/dialog/SingleDialog.java
Normal file
@@ -0,0 +1,251 @@
|
||||
package com.uiui.aios.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
|
||||
|
||||
/**
|
||||
* description:自定义dialog
|
||||
*/
|
||||
|
||||
public class SingleDialog extends AlertDialog {
|
||||
/**
|
||||
* 显示的图片
|
||||
*/
|
||||
private ImageView imageIv;
|
||||
|
||||
/**
|
||||
* 显示的标题
|
||||
*/
|
||||
private TextView titleTv;
|
||||
|
||||
/**
|
||||
* 显示的消息
|
||||
*/
|
||||
private TextView messageTv;
|
||||
|
||||
/**
|
||||
* 确认和取消按钮
|
||||
*/
|
||||
private TextView positiveBn;
|
||||
// private TextView negtiveBn;
|
||||
|
||||
/**
|
||||
* 按钮之间的分割线
|
||||
*/
|
||||
// private View columnLineView;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public SingleDialog(Context context) {
|
||||
super(context, R.style.CustomDialog);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 都是内容数据
|
||||
*/
|
||||
private String message;
|
||||
private String title;
|
||||
private String positive, negtive;
|
||||
private int imageResId = -1;
|
||||
|
||||
/**
|
||||
* 底部是否只有一个按钮
|
||||
*/
|
||||
private boolean isSingle = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.single_dialog);
|
||||
//按空白处不能取消动画
|
||||
setCanceledOnTouchOutside(false);
|
||||
//初始化界面控件
|
||||
initView();
|
||||
//初始化界面数据
|
||||
refreshView();
|
||||
//初始化界面控件的事件
|
||||
initEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化界面的确定和取消监听器
|
||||
*/
|
||||
private void initEvent() {
|
||||
//设置确定按钮被点击后,向外界提供监听
|
||||
positiveBn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onClickBottomListener != null) {
|
||||
onClickBottomListener.onPositiveClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
//设置取消按钮被点击后,向外界提供监听
|
||||
// negtiveBn.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (onClickBottomListener != null) {
|
||||
// onClickBottomListener.onNegtiveClick();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化界面控件的显示数据
|
||||
*/
|
||||
private void refreshView() {
|
||||
//如果用户自定了title和message
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
titleTv.setText(title);
|
||||
titleTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
titleTv.setVisibility(View.GONE);
|
||||
}
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
messageTv.setText(message);
|
||||
}
|
||||
//如果设置按钮的文字
|
||||
if (!TextUtils.isEmpty(positive)) {
|
||||
positiveBn.setText(positive);
|
||||
} else {
|
||||
positiveBn.setText("确定");
|
||||
}
|
||||
// if (!TextUtils.isEmpty(negtive)) {
|
||||
// negtiveBn.setText(negtive);
|
||||
// } else {
|
||||
// negtiveBn.setText("取消");
|
||||
// }
|
||||
|
||||
if (imageResId != -1) {
|
||||
imageIv.setImageResource(imageResId);
|
||||
imageIv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
imageIv.setVisibility(View.GONE);
|
||||
}
|
||||
/**
|
||||
* 只显示一个按钮的时候隐藏取消按钮,回掉只执行确定的事件
|
||||
*/
|
||||
// if (isSingle) {
|
||||
//// columnLineView.setVisibility(View.GONE);
|
||||
// negtiveBn.setVisibility(View.GONE);
|
||||
// } else {
|
||||
// negtiveBn.setVisibility(View.VISIBLE);
|
||||
//// columnLineView.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
refreshView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化界面控件
|
||||
*/
|
||||
private void initView() {
|
||||
// negtiveBn = findViewById(R.id.negtive);
|
||||
positiveBn = findViewById(R.id.positive);
|
||||
titleTv = findViewById(R.id.title);
|
||||
messageTv = findViewById(R.id.message);
|
||||
imageIv = findViewById(R.id.image);
|
||||
// columnLineView = findViewById(R.id.column_line);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置确定取消按钮的回调
|
||||
*/
|
||||
private OnClickBottomListener onClickBottomListener;
|
||||
|
||||
public void setOnClickBottomListener(OnClickBottomListener onClickBottomListener) {
|
||||
this.onClickBottomListener = onClickBottomListener;
|
||||
}
|
||||
|
||||
public interface OnClickBottomListener {
|
||||
/**
|
||||
* 点击确定按钮事件
|
||||
*/
|
||||
void onPositiveClick();
|
||||
|
||||
/**
|
||||
* 点击取消按钮事件
|
||||
*/
|
||||
// void onNegtiveClick();
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public SingleDialog setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public SingleDialog setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPositive() {
|
||||
return positive;
|
||||
}
|
||||
|
||||
public SingleDialog setPositive(String positive) {
|
||||
this.positive = positive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNegtive() {
|
||||
return negtive;
|
||||
}
|
||||
|
||||
public SingleDialog setNegtive(String negtive) {
|
||||
this.negtive = negtive;
|
||||
return this;
|
||||
}
|
||||
|
||||
// public SingleDialog setNegtiveText(String negtive) {
|
||||
// negtiveBn.setText(negtive);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public int getImageResId() {
|
||||
return imageResId;
|
||||
}
|
||||
|
||||
public boolean isSingle() {
|
||||
return isSingle;
|
||||
}
|
||||
|
||||
public SingleDialog setSingle(boolean single) {
|
||||
isSingle = single;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SingleDialog setImageResId(int imageResId) {
|
||||
this.imageResId = imageResId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,15 @@ import com.uiui.aios.adapter.NotificationAdapter;
|
||||
import com.uiui.aios.adapter.SOSNnmberAdapter;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.AlarmItem;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.dialog.SingleDialog;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.AppUtil;
|
||||
import com.uiui.aios.utils.NetStateUtils;
|
||||
import com.uiui.aios.utils.SchemeUtils;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
|
||||
@@ -302,14 +307,14 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
cl_note.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(mContext, AlarmClockActivity.class));
|
||||
getAlarm();
|
||||
}
|
||||
});
|
||||
notificationAdapter = new NotificationAdapter();
|
||||
rv_noti.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(mContext, AlarmClockActivity.class));
|
||||
getAlarm();
|
||||
}
|
||||
});
|
||||
rv_noti.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
@@ -354,7 +359,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
mClHealth.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getActivity(), HealthCodeActivity.class));
|
||||
getHealthCode();
|
||||
// SchemeUtils.openScheme(getActivity(), SchemeUtils.SCHEME_TONGUE);
|
||||
}
|
||||
});
|
||||
@@ -363,14 +368,14 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
public void onClick(View v) {
|
||||
// startActivity(new Intent(getActivity(), CodeActivity.class));
|
||||
// startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); //直接进入手机中的wifi网络设置界面
|
||||
SchemeUtils.openScheme(getActivity(), SchemeUtils.SCHEME_TONGUE);
|
||||
openScheme(SchemeUtils.SCHEME_TONGUE);
|
||||
}
|
||||
});
|
||||
mClFace.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// startActivity(new Intent(getActivity(), CodeActivity.class));
|
||||
SchemeUtils.openScheme(getActivity(), SchemeUtils.SCHEME_FACE);
|
||||
openScheme(SchemeUtils.SCHEME_FACE);
|
||||
}
|
||||
});
|
||||
mClHand.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -378,7 +383,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
public void onClick(View v) {
|
||||
// startActivity(new Intent(getActivity(), CodeActivity.class));
|
||||
// getActivity().startActivity(new Intent(getActivity(), APPListActivity.class));
|
||||
SchemeUtils.openScheme(getActivity(), SchemeUtils.SCHEME_HAND);
|
||||
openScheme(SchemeUtils.SCHEME_HAND);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -386,6 +391,11 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
refreshMemory();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
initAmap();
|
||||
getAlarmClock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -393,6 +403,39 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
setSosNumber();
|
||||
}
|
||||
|
||||
private void openScheme(String uri) {
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setMessage("网络不可用")
|
||||
.setTitle("温馨提示")
|
||||
.setPositive("确定")
|
||||
// .setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
|
||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
// dialog.setCancelable(false);
|
||||
if (!NetStateUtils.isNetworkConnected(mContext)) {
|
||||
dialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
NetInterfaceManager.getInstance().getSnInfo(new NetInterfaceManager.SnInfoCallback() {
|
||||
@Override
|
||||
public void setSnInfo(SnInfo snInfo) {
|
||||
if (snInfo == null || TextUtils.isEmpty(snInfo.getMobile())) {
|
||||
dialog.setMessage("绑定手机才能使用");
|
||||
dialog.show();
|
||||
} else {
|
||||
SchemeUtils.openScheme(getActivity(), uri);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setSosNumber() {
|
||||
String setting_sos = Settings.System.getString(mCRv, "setting_sos");
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
@@ -418,11 +461,6 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
initAmap();
|
||||
getAlarmClock();
|
||||
}
|
||||
|
||||
private void initAmap() {
|
||||
AmapManager.getInstance().startLocation(new AMapLocationListener() {
|
||||
@Override
|
||||
@@ -438,14 +476,30 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
});
|
||||
}
|
||||
|
||||
private void getAlarmClock() {
|
||||
String jsonString = mmkv.decodeString("AlarmClock", "");
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
List<AlarmClockData> data = new ArrayList<>();
|
||||
AlarmClockData alarmClockData = AlarmUtils.getInstance().getRecentAlarmClock();
|
||||
if (alarmClockData!=null){
|
||||
data.add(alarmClockData);
|
||||
private void getAlarm() {
|
||||
NetInterfaceManager.getInstance().getAlarmClock(new NetInterfaceManager.AlarmClockCallback() {
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
||||
startActivity(new Intent(mContext, AlarmClockActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
showNoData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getAlarmClock() {
|
||||
AlarmClockData alarmClockData = AlarmUtils.getInstance().getRecentAlarmClock();
|
||||
List<AlarmClockData> data = new ArrayList<>();
|
||||
if (alarmClockData != null) {
|
||||
data.add(alarmClockData);
|
||||
notificationAdapter.setDataList(data);
|
||||
rv_noti.setVisibility(View.VISIBLE);
|
||||
iv_note_nodata.setVisibility(View.GONE);
|
||||
@@ -455,6 +509,43 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
}
|
||||
}
|
||||
|
||||
private void showNoData() {
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setMessage("当前没有数据")
|
||||
.setTitle("温馨提示")
|
||||
.setPositive("确定")
|
||||
// .setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
|
||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
// dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void getHealthCode() {
|
||||
NetInterfaceManager.getInstance().getHealthCode(new NetInterfaceManager.HealthCodeCallback() {
|
||||
@Override
|
||||
public void setHealthCode(List<HealthCode> healthCode) {
|
||||
startActivity(new Intent(mContext, HealthCodeActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
showNoData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getweather(double longitude, double latitude) {
|
||||
String location = longitude + "," + latitude;
|
||||
Log.e(TAG, "getweather: " + location);
|
||||
@@ -525,7 +616,6 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void killBackgroundApp() {
|
||||
List<String> pkgList = ApkUtils.queryFilterAppList(mContext);
|
||||
for (String pkg : pkgList) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
@@ -44,7 +45,7 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
* Use the {@link SecondFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SecondFragment extends BaseFragment {
|
||||
public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = SecondFragment.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.iv_img)
|
||||
@@ -126,6 +127,16 @@ public class SecondFragment extends BaseFragment {
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
initData();
|
||||
}
|
||||
|
||||
public SecondFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@@ -155,6 +166,7 @@ public class SecondFragment extends BaseFragment {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,43 +189,38 @@ public class SecondFragment extends BaseFragment {
|
||||
getDemandList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
private void getDemandList() {
|
||||
NetInterfaceManager.getInstance().getDemandListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<DemandBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getDemandList", "onSubscribe: ");
|
||||
}
|
||||
NetInterfaceManager.getInstance().getDemandList(true, lifecycleSubject, new NetInterfaceManager.DemandListCallback() {
|
||||
@Override
|
||||
public void setDemandList(List<DemandBean> demandBeans) {
|
||||
cl4.setVisibility(View.VISIBLE);
|
||||
iv4.setVisibility(View.GONE);
|
||||
DemandBean demandBean = demandBeans.get(0);
|
||||
setDemand(demandBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<DemandBean>> listBaseResponse) {
|
||||
Log.e("getDemandList", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl4.setVisibility(View.VISIBLE);
|
||||
iv4.setVisibility(View.GONE);
|
||||
List<DemandBean> demandBeans = listBaseResponse.data;
|
||||
if (demandBeans != null && demandBeans.size() != 0) {
|
||||
DemandBean demandBean = demandBeans.get(0);
|
||||
setDemand(demandBean);
|
||||
}
|
||||
} else {
|
||||
cl4.setVisibility(View.GONE);
|
||||
iv4.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void noData() {
|
||||
cl4.setVisibility(View.GONE);
|
||||
iv4.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getDemandList", "onError: " + e.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getDemandList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDemand(DemandBean demandBean) {
|
||||
@@ -226,41 +233,31 @@ public class SecondFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
private void getActivityList() {
|
||||
NetInterfaceManager.getInstance().getActivityListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ActivityBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getActivityList", "onSubscribe: ");
|
||||
}
|
||||
NetInterfaceManager.getInstance().getActivityList(true, lifecycleSubject, new NetInterfaceManager.ActivitiesListCallback() {
|
||||
@Override
|
||||
public void setActivitiesList(List<ActivityBean> activityBeans) {
|
||||
cl3.setVisibility(View.VISIBLE);
|
||||
iv3.setVisibility(View.GONE);
|
||||
ActivityBean activityBean = activityBeans.get(0);
|
||||
setActivity(activityBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ActivityBean>> listBaseResponse) {
|
||||
Log.e("getActivityList", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl3.setVisibility(View.VISIBLE);
|
||||
iv3.setVisibility(View.GONE);
|
||||
List<ActivityBean> activityBeans = listBaseResponse.data;
|
||||
if (activityBeans != null && activityBeans.size() != 0) {
|
||||
ActivityBean activityBean = activityBeans.get(0);
|
||||
setActivity(activityBean);
|
||||
}
|
||||
} else {
|
||||
cl3.setVisibility(View.GONE);
|
||||
iv3.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void noData() {
|
||||
cl3.setVisibility(View.GONE);
|
||||
iv3.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getActivityList", "onError: " + e.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getActivityList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setActivity(ActivityBean activity) {
|
||||
@@ -395,4 +392,6 @@ public class SecondFragment extends BaseFragment {
|
||||
tv_title.setText(articleInfo.getTitle());
|
||||
tv_content.setText(articleInfo.getContent());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.aios.bean.ActivityBean;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.ArticleInfo;
|
||||
@@ -18,6 +19,7 @@ import com.uiui.aios.bean.DemandBean;
|
||||
import com.uiui.aios.bean.GoodsInfo;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.bean.NetDesktopIcon;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.bean.UserId;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.ConnectManager;
|
||||
@@ -32,6 +34,7 @@ import com.uiui.aios.network.api.GetUserIDApi;
|
||||
import com.uiui.aios.network.api.GoodsListApi;
|
||||
import com.uiui.aios.network.api.HealthCodeApi;
|
||||
import com.uiui.aios.network.api.RunNewApp;
|
||||
import com.uiui.aios.network.api.SNInfoApi;
|
||||
import com.uiui.aios.network.api.SOSRecordApi;
|
||||
import com.uiui.aios.network.api.SendScreenshotApi;
|
||||
import com.uiui.aios.network.api.UpdateAlarmClockApi;
|
||||
@@ -159,6 +162,13 @@ public class NetInterfaceManager {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Observable<BaseResponse<SnInfo>> getsnInfoControl() {
|
||||
return mRetrofit.create(SNInfoApi.class)
|
||||
.getsninfo(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AlarmClockData>>> getAlarmClockObservable() {
|
||||
return mRetrofit
|
||||
.create(AlarmClockApi.class)
|
||||
@@ -294,6 +304,109 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public interface ActivitiesListCallback {
|
||||
void setActivitiesList(List<ActivityBean> activityBeans);
|
||||
|
||||
void noData();
|
||||
|
||||
void onError();
|
||||
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
public void getActivityList(boolean refresh, BehaviorSubject<FragmentEvent> lifecycle, ActivitiesListCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLAddress.GET_ACTIVITY_LIST, connectMode)) {
|
||||
getActivityList(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_ACTIVITY_LIST);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getActivityList(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<ActivityBean>>() {
|
||||
}.getType();
|
||||
List<ActivityBean> activityBeans = gson.fromJson(jsonString, type);
|
||||
if (activityBeans == null || activityBeans.size() == 0) {
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
if (callback != null) callback.setActivitiesList(activityBeans);
|
||||
}
|
||||
if (callback != null) callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getActivityList(BehaviorSubject<FragmentEvent> lifecycle, ActivitiesListCallback callback) {
|
||||
getActivityListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getActivityListObserver(callback));
|
||||
}
|
||||
|
||||
public void getActivityList(ActivitiesListCallback callback) {
|
||||
getActivityListObservable()
|
||||
.subscribe(getActivityListObserver(callback));
|
||||
}
|
||||
|
||||
public void getActivityList() {
|
||||
getActivityListObservable()
|
||||
.subscribe(getActivityListObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<List<ActivityBean>>> getActivityListObserver(ActivitiesListCallback callback) {
|
||||
return new Observer<BaseResponse<List<ActivityBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getActivityListObserver", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ActivityBean>> listBaseResponse) {
|
||||
Log.e("getActivityListObserver", "onNext: ");
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<ActivityBean> activityBeans = listBaseResponse.data;
|
||||
if (activityBeans == null || activityBeans.size() == 0) {
|
||||
mCacheHelper.put(URLAddress.GET_ACTIVITY_LIST, "");
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_ACTIVITY_LIST, GsonUtils.toJsonString(activityBeans));
|
||||
if (callback != null) callback.setActivitiesList(activityBeans);
|
||||
}
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_ACTIVITY_LIST, "");
|
||||
if (callback != null) callback.noData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getActivityListObserver", "onError: " + e.getMessage());
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_ACTIVITY_LIST);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<ActivityBean>>() {
|
||||
}.getType();
|
||||
List<ActivityBean> activityBeans = gson.fromJson(jsonString, type);
|
||||
if (activityBeans == null || activityBeans.size() == 0) {
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
if (callback != null) callback.setActivitiesList(activityBeans);
|
||||
}
|
||||
if (callback != null) callback.onError();
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getActivityListObserver", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public Observable<BaseResponse<List<DemandBean>>> getDemandListObservable() {
|
||||
return mRetrofit.create(DemandListApi.class)
|
||||
.getDemandList(Utils.getSerial(), 1, 1, getUserId())
|
||||
@@ -301,6 +414,110 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public interface DemandListCallback {
|
||||
void setDemandList(List<DemandBean> demandBeans);
|
||||
|
||||
void noData();
|
||||
|
||||
void onError();
|
||||
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
public void getDemandList(boolean refresh, BehaviorSubject<FragmentEvent> lifecycle, DemandListCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLAddress.GET_DEMAND_LIST, connectMode)) {
|
||||
getDemandList(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_DEMAND_LIST);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getDemandList(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<DemandBean>>() {
|
||||
}.getType();
|
||||
List<DemandBean> demandBeans = gson.fromJson(jsonString, type);
|
||||
if (demandBeans == null || demandBeans.size() == 0) {
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
if (callback != null) callback.setDemandList(demandBeans);
|
||||
}
|
||||
if (callback != null) callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getDemandList(BehaviorSubject<FragmentEvent> lifecycle, DemandListCallback callback) {
|
||||
getDemandListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getDemandListObserver(callback));
|
||||
}
|
||||
|
||||
public void getDemandList(DemandListCallback callback) {
|
||||
getDemandListObservable()
|
||||
.subscribe(getDemandListObserver(callback));
|
||||
}
|
||||
|
||||
public void getDemandList() {
|
||||
getDemandListObservable()
|
||||
.subscribe(getDemandListObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<List<DemandBean>>> getDemandListObserver(DemandListCallback callback) {
|
||||
return new Observer<BaseResponse<List<DemandBean>>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getDemandListObserver", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<DemandBean>> listBaseResponse) {
|
||||
Log.e("getDemandListObserver", "onNext: ");
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<DemandBean> demandBeans = listBaseResponse.data;
|
||||
if (demandBeans == null || demandBeans.size() == 0) {
|
||||
mCacheHelper.put(URLAddress.GET_DEMAND_LIST, "");
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_DEMAND_LIST, GsonUtils.toJsonString(demandBeans));
|
||||
if (callback != null) callback.setDemandList(demandBeans);
|
||||
}
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_DEMAND_LIST, "");
|
||||
if (callback != null) callback.noData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getDemandListObserver", "onError: " + e.getMessage());
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_DEMAND_LIST);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<DemandBean>>() {
|
||||
}.getType();
|
||||
List<DemandBean> demandBeans = gson.fromJson(jsonString, type);
|
||||
if (demandBeans == null || demandBeans.size() == 0) {
|
||||
if (callback != null) callback.noData();
|
||||
} else {
|
||||
if (callback != null) callback.setDemandList(demandBeans);
|
||||
}
|
||||
if (callback != null) callback.onError();
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getDemandListObserver", "onComplete: ");
|
||||
if (callback != null) callback.onComplete();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public AppUsageRecordApi getAppUsageRecordControl() {
|
||||
return mRetrofit.create(AppUsageRecordApi.class);
|
||||
@@ -333,63 +550,88 @@ public class NetInterfaceManager {
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLAddress.GET_HEALTH_CODE, connectMode)) {
|
||||
getHealthCode(lifecycle, callback);
|
||||
} else {
|
||||
getHealthCodeCache(lifecycle, callback);
|
||||
}
|
||||
}
|
||||
|
||||
private void getHealthCodeCache(BehaviorSubject<ActivityEvent> lifecycle, HealthCodeCallback callback) {
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_HEALTH_CODE);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getHealthCode(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<HealthCode>>() {
|
||||
}.getType();
|
||||
List<HealthCode> healthCodeList = gson.fromJson(jsonString, type);
|
||||
if (healthCodeList == null || healthCodeList.size() == 0) {
|
||||
callback.noData();
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_HEALTH_CODE);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getHealthCode(lifecycle, callback);
|
||||
} else {
|
||||
callback.setHealthCode(healthCodeList);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<HealthCode>>() {
|
||||
}.getType();
|
||||
List<HealthCode> healthCodeList = gson.fromJson(jsonString, type);
|
||||
if (healthCodeList == null || healthCodeList.size() == 0) {
|
||||
callback.noData();
|
||||
} else {
|
||||
callback.setHealthCode(healthCodeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getHealthCodeCache(HealthCodeCallback callback) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void getHealthCode(BehaviorSubject<ActivityEvent> lifecycle, HealthCodeCallback callback) {
|
||||
getHealthCodeObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<HealthCode>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getHealthCode", "onSubscribe: ");
|
||||
}
|
||||
.subscribe(getHealthCodeObserver(callback));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<HealthCode>> listBaseResponse) {
|
||||
Log.e("getHealthCode", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<HealthCode> healthCodeList = listBaseResponse.data;
|
||||
mCacheHelper.put(URLAddress.GET_HEALTH_CODE, GsonUtils.toJsonString(healthCodeList));
|
||||
callback.setHealthCode(healthCodeList);
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_HEALTH_CODE, "");
|
||||
callback.noData();
|
||||
}
|
||||
}
|
||||
public void getHealthCode(HealthCodeCallback callback) {
|
||||
getHealthCodeObservable()
|
||||
.subscribe(getHealthCodeObserver(callback));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getHealthCode", "onError: ");
|
||||
getHealthCodeCache(lifecycle, callback);
|
||||
callback.onError();
|
||||
onComplete();
|
||||
}
|
||||
public void getHealthCode() {
|
||||
getHealthCodeObservable()
|
||||
.subscribe(getHealthCodeObserver(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getHealthCode", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
public Observer<BaseResponse<List<HealthCode>>> getHealthCodeObserver(HealthCodeCallback callback) {
|
||||
return new Observer<BaseResponse<List<HealthCode>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getHealthCode", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<HealthCode>> listBaseResponse) {
|
||||
Log.e("getHealthCode", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<HealthCode> healthCodeList = listBaseResponse.data;
|
||||
mCacheHelper.put(URLAddress.GET_HEALTH_CODE, GsonUtils.toJsonString(healthCodeList));
|
||||
callback.setHealthCode(healthCodeList);
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_HEALTH_CODE, "");
|
||||
callback.noData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getHealthCode", "onError: ");
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_HEALTH_CODE);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<HealthCode>>() {
|
||||
}.getType();
|
||||
List<HealthCode> healthCodeList = gson.fromJson(jsonString, type);
|
||||
if (healthCodeList == null || healthCodeList.size() == 0) {
|
||||
callback.noData();
|
||||
} else {
|
||||
callback.setHealthCode(healthCodeList);
|
||||
}
|
||||
callback.onError();
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getHealthCode", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -474,6 +716,16 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAlarmClockObserver", "onError: " + e.getMessage());
|
||||
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) {
|
||||
if (callback != null) callback.setAlarmClockEmpty();
|
||||
} else {
|
||||
if (callback != null) callback.setAlarmClock(list);
|
||||
}
|
||||
if (callback != null) callback.onError();
|
||||
onComplete();
|
||||
}
|
||||
@@ -484,4 +736,38 @@ public class NetInterfaceManager {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface SnInfoCallback {
|
||||
void setSnInfo(SnInfo snInfo);
|
||||
}
|
||||
|
||||
public void getSnInfo(SnInfoCallback callback) {
|
||||
getsnInfoControl()
|
||||
.subscribe(new Observer<BaseResponse<SnInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getSnInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SnInfo> snInfoBaseResponse) {
|
||||
Log.e("getSnInfo", "onNext: ");
|
||||
callback.setSnInfo(snInfoBaseResponse.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getSnInfo", "onError: ");
|
||||
callback.setSnInfo(null);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSnInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.uiui.aios.network;
|
||||
|
||||
public class URLAddress {
|
||||
public static final String ROOT_URL = "https://led.zuoyepad.com/android/";
|
||||
/*设备信息接口*/
|
||||
public static final String SNINFO = "sn/getSnInfo";
|
||||
/*获取闹钟*/
|
||||
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
||||
/*应用使用记录*/
|
||||
|
||||
16
app/src/main/java/com/uiui/aios/network/api/SNInfoApi.java
Normal file
16
app/src/main/java/com/uiui/aios/network/api/SNInfoApi.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SNInfoApi {
|
||||
@GET(URLAddress.SNINFO)
|
||||
Observable<BaseResponse<SnInfo>> getsninfo(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
84
app/src/main/java/com/uiui/aios/utils/NetStateUtils.java
Normal file
84
app/src/main/java/com/uiui/aios/utils/NetStateUtils.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.uiui.aios.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
public class NetStateUtils {
|
||||
|
||||
/**
|
||||
* 判断网络连接状态
|
||||
*
|
||||
* @param context
|
||||
* @return true:网络已链接, false:网络已断开连接
|
||||
*/
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断wifi状态
|
||||
*
|
||||
* @param context
|
||||
* @return true:是wifi情况 ,false:非wifi情况
|
||||
*/
|
||||
public static boolean isWifiConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mWiFiNetworkInfo = mConnectivityManager
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if (mWiFiNetworkInfo != null) {
|
||||
return mWiFiNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断移动网络
|
||||
*
|
||||
* @param context
|
||||
* @return true:是移动网络情况, false:非移动网络情况
|
||||
*/
|
||||
public static boolean isMobileConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mMobileNetworkInfo = mConnectivityManager
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
if (mMobileNetworkInfo != null) {
|
||||
return mMobileNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连接类型
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getConnectedType(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null && mNetworkInfo.isAvailable()) {
|
||||
return mNetworkInfo.getType();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user