version:6.1

fix:
update:修改联系人,修复联系人上传失败
This commit is contained in:
2024-07-04 09:48:12 +08:00
parent a466c70784
commit f06f51c5a7
109 changed files with 2700 additions and 995 deletions

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
@@ -28,6 +29,7 @@ import com.uiuios.aios.receiver.BootReceiver;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -42,23 +44,29 @@ import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
public class EmergencyActivity extends AppCompatActivity {
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
@BindView(R.id.tv_countdown)
TextView tv_countdown;
@BindView(R.id.iv_finish)
ImageView iv_finish;
private Disposable subscribe;
private String TAG = EmergencyActivity.class.getSimpleName();
private boolean needDial = false;
private boolean isCalling = false;
private List<Contact> phoneListSet;
private CacheHelper mCacheHelper;
// private List<Contact> phoneListSet;
// private CacheHelper mCacheHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e(TAG, "onCreate: ");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emergency);
mCacheHelper = new CacheHelper(this);
// mCacheHelper = new CacheHelper(this);
ButterKnife.bind(this);
//发送紧急广播
@@ -75,20 +83,22 @@ public class EmergencyActivity extends AppCompatActivity {
// return;
// }
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_MAIL_LIST);
//为 "" 是已经请求成功的
if (jsonString == null) {
return;
}
Gson gson = new Gson();
Type type = new TypeToken<List<Contact>>() {
}.getType();
List<Contact> contactList = gson.fromJson(jsonString, type);
if (contactList == null || contactList.size() == 0) {
return;
}
phoneListSet = contactList.stream().filter(contact -> contact.getIs_urgent() == 1).collect(Collectors.toList());
Log.e(TAG, "onCreate: " + phoneListSet);
// String jsonString = mCacheHelper.getAsString(UrlAddress.GET_MAIL_LIST);
// //为 "" 是已经请求成功的
// if (jsonString == null) {
// return;
// }
// Gson gson = new Gson();
// Type type = new TypeToken<List<Contact>>() {
// }.getType();
// List<Contact> contactList = gson.fromJson(jsonString, type);
// if (contactList == null || contactList.size() == 0) {
// return;
// }
String phone = mMMKV.decodeString(CommonConfig.EMERGENCY_CONTACT_KEY, "");
// phoneListSet = new ArrayList<String>();
// Log.e(TAG, "onCreate: " + phoneListSet);
final Long time = 3L;
subscribe = Observable.interval(1, TimeUnit.SECONDS)
@@ -100,10 +110,9 @@ public class EmergencyActivity extends AppCompatActivity {
tv_countdown.setText("倒计时(" + (time - aLong - 1) + ")秒");
Log.e(TAG, "accept: " + (time - aLong - 1));
} else {
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
String longitude = mCacheHelper.getAsString(CommonConfig.MAP_LONGITUDE_KEY);
String latitude = mCacheHelper.getAsString(CommonConfig.MAP_LATITUDE_KEY);
String address = mCacheHelper.getAsString(CommonConfig.MAP_ADDRESS_KEY);
String longitude = mMMKV.decodeString(CommonConfig.MAP_LONGITUDE_KEY, "");
String latitude = mMMKV.decodeString(CommonConfig.MAP_LATITUDE_KEY, "");
String address = mMMKV.decodeString(CommonConfig.MAP_ADDRESS_KEY, "");
NetInterfaceManager.getInstance()
.getSOSRecordObservable(longitude, latitude, address)
.subscribe(new Observer<BaseResponse>() {
@@ -128,15 +137,21 @@ public class EmergencyActivity extends AppCompatActivity {
Log.e("SosRecordApi", "onComplete: ");
}
});
needDial = true;
if (TextUtils.isEmpty(phone)) {
Toaster.show("没有设置紧急联系人");
finish();
}
Intent intent1 = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phoneListSet.get(0).getMobile());
Uri data = Uri.parse("tel:" + phone);
intent1.setData(data);
startActivity(intent1);
isCalling = true;
phoneListSet.remove(0);
// finish();
// phoneListSet.remove(0);
subscribe.dispose();
finish();
}
});
iv_finish.setOnClickListener(new View.OnClickListener() {
@@ -166,36 +181,36 @@ public class EmergencyActivity extends AppCompatActivity {
protected void onStart() {
super.onStart();
Log.e(TAG, "onResume: ");
Log.e(TAG, "onResume: " + phoneListSet);
if (needDial) {
if (phoneListSet == null || phoneListSet.size() == 0) {
return;
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent1 = new Intent(Intent.ACTION_CALL);
String phone = phoneListSet.get(0).getMobile();
Uri data = Uri.parse("tel:" + phone);
intent1.setData(data);
startActivity(intent1);
isCalling = true;
phoneListSet.remove(0);
}
}, 2000);
} else {
if (phoneListSet == null) {
Toaster.show("没有设置紧急联系人");
finish();
}
}
// Log.e(TAG, "onResume: " + phoneListSet);
// if (needDial) {
// if (phoneListSet == null || phoneListSet.size() == 0) {
// return;
// }
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// Intent intent1 = new Intent(Intent.ACTION_CALL);
// String phone = phoneListSet.get(0).getMobile();
// Uri data = Uri.parse("tel:" + phone);
// intent1.setData(data);
// startActivity(intent1);
// isCalling = true;
// phoneListSet.remove(0);
// }
// }, 2000);
// } else {
// if (phoneListSet == null) {
// Toaster.show("没有设置紧急联系人");
// finish();
// }
// }
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.e(TAG, "onDestroy: ");
if (subscribe != null) {
if (subscribe != null && !subscribe.isDisposed()) {
subscribe.dispose();
subscribe = null;
}