version:3.0
fix: update:紧急呼叫增加定位,进入紧急呼叫页面之前判断紧急联系人是否存在
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
||||
applicationId "com.uiui.aios"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 20
|
||||
versionName "2.9"
|
||||
versionCode 21
|
||||
versionName "3.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.receiver.BootReceiver;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
@@ -79,8 +81,12 @@ public class EmergencyActivity extends AppCompatActivity {
|
||||
tv_countdown.setText("倒计时(" + (time - aLong - 1) + ")秒");
|
||||
Log.e(TAG, "accept: " + (time - aLong - 1));
|
||||
} else {
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
String longitude = mmkv.decodeString(AmapManager.LONGITUDE_KEY, "未知");
|
||||
String latitude = mmkv.decodeString(AmapManager.LATITUDE_KEY, "未知");
|
||||
String address = mmkv.decodeString(AmapManager.ADDRESS_KEY, "未知");
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSOSRecordObservable()
|
||||
.getSOSRecordObservable(longitude, latitude, address)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
400
app/src/main/java/com/uiui/aios/bean/SystemSettings.java
Normal file
400
app/src/main/java/com/uiui/aios/bean/SystemSettings.java
Normal file
@@ -0,0 +1,400 @@
|
||||
package com.uiui.aios.bean;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SystemSettings implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7763589370400496883L;
|
||||
|
||||
int setting_call;
|
||||
int setting_memory;
|
||||
String setting_usb;
|
||||
int setting_bluetooth;
|
||||
int setting_navigation;
|
||||
int setting_statusbar;
|
||||
int setting_tfmedia;
|
||||
String setting_phones;
|
||||
int setting_phone;
|
||||
int setting_camera;
|
||||
String setting_tfmedia_format;
|
||||
int setting_clock;
|
||||
int setting_recording;
|
||||
int setting_music;
|
||||
int setting_picture;
|
||||
int setting_wallpaper;
|
||||
int setting_file;
|
||||
int setting_browser;
|
||||
int setting_bhtvideo;
|
||||
String setting_context;
|
||||
|
||||
int setting_bht;
|
||||
int setting_hotspot;
|
||||
int qch_restore;
|
||||
int setting_browserInput;
|
||||
int dev_mode;
|
||||
String setting_sos;
|
||||
String setting_volume;
|
||||
String setting_luminance;
|
||||
String setting_typeface;
|
||||
int setting_admin_app;
|
||||
int projection_screen;
|
||||
int hot_point;
|
||||
String desktop_app;
|
||||
String browser_app;
|
||||
String typewriting_app;
|
||||
int is_control;
|
||||
|
||||
int setting_rotation;
|
||||
int setting_airplane;
|
||||
int setting_disturbance;
|
||||
int setting_location;
|
||||
int setting_charge;
|
||||
int setting_other_appInstaller;
|
||||
|
||||
|
||||
public int getQch_restore() {
|
||||
return qch_restore;
|
||||
}
|
||||
|
||||
public void setQch_restore(int qch_restore) {
|
||||
this.qch_restore = qch_restore;
|
||||
}
|
||||
|
||||
public int getSetting_browserInput() {
|
||||
return setting_browserInput;
|
||||
}
|
||||
|
||||
public void setSetting_browserInput(int setting_browserInput) {
|
||||
this.setting_browserInput = setting_browserInput;
|
||||
}
|
||||
|
||||
public int getDev_mode() {
|
||||
return dev_mode;
|
||||
}
|
||||
|
||||
public void setDev_mode(int dev_mode) {
|
||||
this.dev_mode = dev_mode;
|
||||
}
|
||||
|
||||
|
||||
public int getSetting_call() {
|
||||
return setting_call;
|
||||
}
|
||||
|
||||
public void setSetting_call(int setting_call) {
|
||||
this.setting_call = setting_call;
|
||||
}
|
||||
|
||||
public int getSetting_memory() {
|
||||
return setting_memory;
|
||||
}
|
||||
|
||||
public void setSetting_memory(int setting_memory) {
|
||||
this.setting_memory = setting_memory;
|
||||
}
|
||||
|
||||
public String getSetting_usb() {
|
||||
return setting_usb;
|
||||
}
|
||||
|
||||
public void setSetting_usb(String setting_usb) {
|
||||
this.setting_usb = setting_usb;
|
||||
}
|
||||
|
||||
public int getSetting_bluetooth() {
|
||||
return setting_bluetooth;
|
||||
}
|
||||
|
||||
public void setSetting_bluetooth(int setting_bluetooth) {
|
||||
this.setting_bluetooth = setting_bluetooth;
|
||||
}
|
||||
|
||||
public int getSetting_navigation() {
|
||||
return setting_navigation;
|
||||
}
|
||||
|
||||
public void setSetting_navigation(int setting_navigation) {
|
||||
this.setting_navigation = setting_navigation;
|
||||
}
|
||||
|
||||
public int getSetting_statusbar() {
|
||||
return setting_statusbar;
|
||||
}
|
||||
|
||||
public void setSetting_statusbar(int setting_statusbar) {
|
||||
this.setting_statusbar = setting_statusbar;
|
||||
}
|
||||
|
||||
public int getSetting_tfmedia() {
|
||||
return setting_tfmedia;
|
||||
}
|
||||
|
||||
public void setSetting_tfmedia(int setting_tfmedia) {
|
||||
this.setting_tfmedia = setting_tfmedia;
|
||||
}
|
||||
|
||||
public String getSetting_phones() {
|
||||
return setting_phones;
|
||||
}
|
||||
|
||||
public void setSetting_phones(String setting_phones) {
|
||||
this.setting_phones = setting_phones;
|
||||
}
|
||||
|
||||
public int getSetting_phone() {
|
||||
return setting_phone;
|
||||
}
|
||||
|
||||
public void setSetting_phone(int setting_phone) {
|
||||
this.setting_phone = setting_phone;
|
||||
}
|
||||
|
||||
public int getSetting_camera() {
|
||||
return setting_camera;
|
||||
}
|
||||
|
||||
public void setSetting_camera(int setting_camera) {
|
||||
this.setting_camera = setting_camera;
|
||||
}
|
||||
|
||||
public String getSetting_tfmedia_format() {
|
||||
return setting_tfmedia_format;
|
||||
}
|
||||
|
||||
public void setSetting_tfmedia_format(String setting_tfmedia_format) {
|
||||
this.setting_tfmedia_format = setting_tfmedia_format;
|
||||
}
|
||||
|
||||
public int getSetting_clock() {
|
||||
return setting_clock;
|
||||
}
|
||||
|
||||
public void setSetting_clock(int setting_clock) {
|
||||
this.setting_clock = setting_clock;
|
||||
}
|
||||
|
||||
public int getSetting_recording() {
|
||||
return setting_recording;
|
||||
}
|
||||
|
||||
public void setSetting_recording(int setting_recording) {
|
||||
this.setting_recording = setting_recording;
|
||||
}
|
||||
|
||||
public int getSetting_music() {
|
||||
return setting_music;
|
||||
}
|
||||
|
||||
public void setSetting_music(int setting_music) {
|
||||
this.setting_music = setting_music;
|
||||
}
|
||||
|
||||
public int getSetting_picture() {
|
||||
return setting_picture;
|
||||
}
|
||||
|
||||
public void setSetting_picture(int setting_picture) {
|
||||
this.setting_picture = setting_picture;
|
||||
}
|
||||
|
||||
public int getSetting_wallpaper() {
|
||||
return setting_wallpaper;
|
||||
}
|
||||
|
||||
public void setSetting_wallpaper(int setting_wallpaper) {
|
||||
this.setting_wallpaper = setting_wallpaper;
|
||||
}
|
||||
|
||||
public int getSetting_file() {
|
||||
return setting_file;
|
||||
}
|
||||
|
||||
public void setSetting_file(int setting_file) {
|
||||
this.setting_file = setting_file;
|
||||
}
|
||||
|
||||
public int getSetting_browser() {
|
||||
return setting_browser;
|
||||
}
|
||||
|
||||
public void setSetting_browser(int setting_browser) {
|
||||
this.setting_browser = setting_browser;
|
||||
}
|
||||
|
||||
public int getSetting_bhtvideo() {
|
||||
return setting_bhtvideo;
|
||||
}
|
||||
|
||||
public void setSetting_bhtvideo(int setting_bhtvideo) {
|
||||
this.setting_bhtvideo = setting_bhtvideo;
|
||||
}
|
||||
|
||||
public String getSetting_context() {
|
||||
return setting_context;
|
||||
}
|
||||
|
||||
public void setSetting_context(String setting_context) {
|
||||
this.setting_context = setting_context;
|
||||
}
|
||||
|
||||
public int getSetting_bht() {
|
||||
return setting_bht;
|
||||
}
|
||||
|
||||
public void setSetting_bht(int setting_bht) {
|
||||
this.setting_bht = setting_bht;
|
||||
}
|
||||
|
||||
public int getSetting_hotspot() {
|
||||
return setting_hotspot;
|
||||
}
|
||||
|
||||
public void setSetting_hotspot(int setting_hotspot) {
|
||||
this.setting_hotspot = setting_hotspot;
|
||||
}
|
||||
|
||||
public String getSetting_sos() {
|
||||
return setting_sos;
|
||||
}
|
||||
|
||||
public void setSetting_sos(String setting_sos) {
|
||||
this.setting_sos = setting_sos;
|
||||
}
|
||||
|
||||
public String getSetting_volume() {
|
||||
return setting_volume;
|
||||
}
|
||||
|
||||
public void setSetting_volume(String setting_volume) {
|
||||
this.setting_volume = setting_volume;
|
||||
}
|
||||
|
||||
public String getSetting_luminance() {
|
||||
return setting_luminance;
|
||||
}
|
||||
|
||||
public void setSetting_luminance(String setting_luminance) {
|
||||
this.setting_luminance = setting_luminance;
|
||||
}
|
||||
|
||||
public String getSetting_typeface() {
|
||||
return setting_typeface;
|
||||
}
|
||||
|
||||
public void setSetting_typeface(String setting_typeface) {
|
||||
this.setting_typeface = setting_typeface;
|
||||
}
|
||||
|
||||
public int getSetting_admin_app() {
|
||||
return setting_admin_app;
|
||||
}
|
||||
|
||||
public void setSetting_admin_app(int setting_admin_app) {
|
||||
this.setting_admin_app = setting_admin_app;
|
||||
}
|
||||
|
||||
public int getProjection_screen() {
|
||||
return projection_screen;
|
||||
}
|
||||
|
||||
public void setProjection_screen(int projection_screen) {
|
||||
this.projection_screen = projection_screen;
|
||||
}
|
||||
|
||||
public int getHot_point() {
|
||||
return hot_point;
|
||||
}
|
||||
|
||||
public void setHot_point(int hot_point) {
|
||||
this.hot_point = hot_point;
|
||||
}
|
||||
|
||||
public String getDesktop_app() {
|
||||
return desktop_app;
|
||||
}
|
||||
|
||||
public void setDesktop_app(String desktop_app) {
|
||||
this.desktop_app = desktop_app;
|
||||
}
|
||||
|
||||
public String getBrowser_app() {
|
||||
return browser_app;
|
||||
}
|
||||
|
||||
public void setBrowser_app(String browser_app) {
|
||||
this.browser_app = browser_app;
|
||||
}
|
||||
|
||||
public String getTypewriting_app() {
|
||||
return typewriting_app;
|
||||
}
|
||||
|
||||
public void setTypewriting_app(String typewriting_app) {
|
||||
this.typewriting_app = typewriting_app;
|
||||
}
|
||||
|
||||
public int getIs_control() {
|
||||
return is_control;
|
||||
}
|
||||
|
||||
public void setIs_control(int is_control) {
|
||||
this.is_control = is_control;
|
||||
}
|
||||
|
||||
public int getSetting_rotation() {
|
||||
return setting_rotation;
|
||||
}
|
||||
|
||||
public void setSetting_rotation(int setting_rotation) {
|
||||
this.setting_rotation = setting_rotation;
|
||||
}
|
||||
|
||||
public int getSetting_airplane() {
|
||||
return setting_airplane;
|
||||
}
|
||||
|
||||
public void setSetting_airplane(int setting_airplane) {
|
||||
this.setting_airplane = setting_airplane;
|
||||
}
|
||||
|
||||
public int getSetting_disturbance() {
|
||||
return setting_disturbance;
|
||||
}
|
||||
|
||||
public void setSetting_disturbance(int setting_disturbance) {
|
||||
this.setting_disturbance = setting_disturbance;
|
||||
}
|
||||
|
||||
public int getSetting_location() {
|
||||
return setting_location;
|
||||
}
|
||||
|
||||
public void setSetting_location(int setting_location) {
|
||||
this.setting_location = setting_location;
|
||||
}
|
||||
|
||||
public int getSetting_charge() {
|
||||
return setting_charge;
|
||||
}
|
||||
|
||||
public void setSetting_charge(int setting_charge) {
|
||||
this.setting_charge = setting_charge;
|
||||
}
|
||||
|
||||
public int getSetting_other_appInstaller() {
|
||||
return setting_other_appInstaller;
|
||||
}
|
||||
|
||||
public void setSetting_other_appInstaller(int setting_other_appInstaller) {
|
||||
this.setting_other_appInstaller = setting_other_appInstaller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
@@ -333,10 +333,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
cl_soso.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), EmergencyActivity.class);
|
||||
// intent.putExtra("setting_sos", phone);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getActivity().startActivity(intent);
|
||||
checkSosNumber();
|
||||
}
|
||||
});
|
||||
cl_weather.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -391,6 +388,29 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
refreshMemory();
|
||||
}
|
||||
|
||||
private void checkSosNumber() {
|
||||
NetInterfaceManager.getInstance().getSystemSettings(new NetInterfaceManager.SosNumberCallback() {
|
||||
@Override
|
||||
public void setSosNumber(String json) {
|
||||
Intent intent = new Intent(getActivity(), EmergencyActivity.class);
|
||||
// intent.putExtra("setting_sos", phone);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmpty() {
|
||||
showNoData("温馨提示", "没有设置紧急联系人");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
initAmap();
|
||||
getAlarmClock();
|
||||
@@ -405,8 +425,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
|
||||
private void openScheme(String uri) {
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setMessage("网络不可用")
|
||||
.setTitle("温馨提示")
|
||||
dialog.setTitle("温馨提示")
|
||||
.setMessage("网络不可用")
|
||||
.setPositive("确定")
|
||||
// .setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
@@ -485,7 +505,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
showNoData();
|
||||
showNoData("温馨提示", "当前没有数据");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -509,14 +529,13 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
}
|
||||
}
|
||||
|
||||
private void showNoData() {
|
||||
private void showNoData(String title, String msg) {
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setMessage("当前没有数据")
|
||||
.setTitle("温馨提示")
|
||||
dialog.setTitle(title)
|
||||
.setMessage(msg)
|
||||
.setPositive("确定")
|
||||
// .setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
|
||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
@@ -536,7 +555,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
showNoData();
|
||||
showNoData("温馨提示", "当前没有数据");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,9 @@ import java.lang.reflect.Type;
|
||||
public class AmapManager {
|
||||
private String TAG = AmapManager.class.getSimpleName();
|
||||
private static final String AMAPLOCATION_JSON_KEY = "AMAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "amap_longitude_key";
|
||||
public static final String LATITUDE_KEY = "amap_latitude_key";
|
||||
public static final String ADDRESS_KEY = "amap_address_key";
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static AmapManager sInstance;
|
||||
private Context mContext;
|
||||
@@ -73,6 +76,9 @@ public class AmapManager {
|
||||
if (aMapLocation.getErrorCode() == 0) {
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: " + aMapLocation.getAddress());
|
||||
mMMKV.encode(LONGITUDE_KEY, aMapLocation.getLongitude());
|
||||
mMMKV.encode(LATITUDE_KEY, aMapLocation.getLatitude());
|
||||
mMMKV.encode(ADDRESS_KEY, aMapLocation.getAddress());
|
||||
} else {
|
||||
//定位失败
|
||||
Log.e(TAG, "onLocationChanged: " + "定位失败");
|
||||
@@ -108,6 +114,9 @@ public class AmapManager {
|
||||
if (aMapLocation.getErrorCode() == 0) {
|
||||
nowAMapLocation = aMapLocation;
|
||||
mMMKV.encode(AMAPLOCATION_JSON_KEY, aMapLocation.toStr());
|
||||
mMMKV.encode(LONGITUDE_KEY, aMapLocation.getLongitude());
|
||||
mMMKV.encode(LATITUDE_KEY, aMapLocation.getLatitude());
|
||||
mMMKV.encode(ADDRESS_KEY, aMapLocation.getAddress());
|
||||
} else {
|
||||
mMMKV.encode(AMAPLOCATION_JSON_KEY, "");
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.uiui.aios.network;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@@ -20,6 +20,7 @@ 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.SystemSettings;
|
||||
import com.uiui.aios.bean.UserId;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.ConnectManager;
|
||||
@@ -37,17 +38,14 @@ 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.Setting;
|
||||
import com.uiui.aios.network.api.UpdateAlarmClockApi;
|
||||
import com.uiui.aios.network.api.UpdateDesktopApi;
|
||||
import com.uiui.aios.network.interceptor.RepeatRequestInterceptor;
|
||||
import com.uiui.aios.utils.GsonUtils;
|
||||
import com.uiui.aios.utils.MD5Util;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -62,11 +60,8 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@@ -184,9 +179,16 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getSOSRecordObservable() {
|
||||
public Observable<BaseResponse<SystemSettings>> getsettingControl() {
|
||||
return mRetrofit.create(Setting.class)
|
||||
.getSetting(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getSOSRecordObservable(String longitude, String latitude, String address) {
|
||||
return mRetrofit.create(SOSRecordApi.class)
|
||||
.sendSOSRecord(Utils.getSerial())
|
||||
.sendSOSRecord(Utils.getSerial(), longitude, latitude, address)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
@@ -769,5 +771,100 @@ public class NetInterfaceManager {
|
||||
});
|
||||
}
|
||||
|
||||
public interface SosNumberCallback {
|
||||
void setSosNumber(String json);
|
||||
|
||||
void setEmpty();
|
||||
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
public void getSystemSettings(boolean refresh, BehaviorSubject<FragmentEvent> lifecycle, SosNumberCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(URLAddress.GET_SETTINGS, connectMode)) {
|
||||
getSystemSettings(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_SETTINGS);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getSystemSettings(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<String>() {
|
||||
}.getType();
|
||||
String setting_sos = gson.fromJson(jsonString, type);
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
if (callback != null) callback.setSosNumber(setting_sos);
|
||||
}
|
||||
if (callback != null) callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getSystemSettings(BehaviorSubject<FragmentEvent> lifecycle, SosNumberCallback callback) {
|
||||
getsettingControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getSystemSettingsObserver(callback));
|
||||
}
|
||||
|
||||
public void getSystemSettings(SosNumberCallback callback) {
|
||||
getsettingControl()
|
||||
.subscribe(getSystemSettingsObserver(callback));
|
||||
}
|
||||
|
||||
public void getSystemSettings() {
|
||||
getsettingControl()
|
||||
.subscribe(getSystemSettingsObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<SystemSettings>> getSystemSettingsObserver(SosNumberCallback callback) {
|
||||
return new Observer<BaseResponse<SystemSettings>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getSystemSettings", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SystemSettings> settingsBaseResponse) {
|
||||
Log.e("getSystemSettings", "onNext: " + settingsBaseResponse);
|
||||
if (settingsBaseResponse.code == 200) {
|
||||
SystemSettings systemSettings = settingsBaseResponse.data;
|
||||
String setting_sos = systemSettings.getSetting_sos();
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, "");
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, setting_sos);
|
||||
if (callback != null) callback.setSosNumber(setting_sos);
|
||||
}
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, "");
|
||||
if (callback != null) callback.setEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||
String setting_sos = mCacheHelper.getAsString(URLAddress.GET_SETTINGS);
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
if (callback != null) callback.setSosNumber(setting_sos);
|
||||
}
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSystemSettings", "onComplete: ");
|
||||
if (callback != null) callback.onComplete();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ public class URLAddress {
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
/*上传截图*/
|
||||
public static final String SEND_SCREENSHOT = "sn/uploadScreenshot";
|
||||
/*获取系统设置*/
|
||||
public final static String GET_SETTINGS = "control/getSetting";
|
||||
/*sos记录*/
|
||||
public static final String SOS_RECORD = "sosRecord";
|
||||
/*爱心提醒通知成功*/
|
||||
|
||||
@@ -12,6 +12,9 @@ public interface SOSRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.SOS_RECORD)
|
||||
Observable<BaseResponse> sendSOSRecord(
|
||||
@Field("sn") String sn
|
||||
@Field("sn") String sn,
|
||||
@Field("longitude") String longitude,
|
||||
@Field("latitude") String latitude,
|
||||
@Field("address") String address
|
||||
);
|
||||
}
|
||||
|
||||
16
app/src/main/java/com/uiui/aios/network/api/Setting.java
Normal file
16
app/src/main/java/com/uiui/aios/network/api/Setting.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.SystemSettings;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface Setting {
|
||||
@GET(URLAddress.GET_SETTINGS)
|
||||
Observable<BaseResponse<SystemSettings>> getSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -5,5 +5,5 @@
|
||||
android:width="0.8dp"
|
||||
android:color="#ffffff" />
|
||||
<!-- 圆角 -->
|
||||
<corners android:radius="6dp" />
|
||||
<corners android:radius="@dimen/dp_12" />
|
||||
</shape>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
android:minWidth="30dp"
|
||||
android:text="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv" />
|
||||
|
||||
Reference in New Issue
Block a user