version:4.2
fix: update:优化联系人列表
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package com.uiui.aios.activity.contact;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
@@ -11,10 +18,25 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class ContactActivity extends BaseActivity implements ContactContact.ContactView {
|
||||
@BindView(R.id.rv_contact)
|
||||
RecyclerView rv_contact;
|
||||
@BindView(R.id.tv_people)
|
||||
TextView tv_people;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
@OnClick({R.id.iv_back})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private ContactPresenter mContactPresenter;
|
||||
private ContactAdapter mContactAdapter;
|
||||
@@ -31,6 +53,11 @@ public class ContactActivity extends BaseActivity implements ContactContact.Cont
|
||||
mContactPresenter.attachView(this);
|
||||
mContactPresenter.setLifecycle(lifecycleSubject);
|
||||
mContactAdapter = new ContactAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
rv_contact.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
} else {
|
||||
rv_contact.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
}
|
||||
rv_contact.setAdapter(mContactAdapter);
|
||||
}
|
||||
|
||||
@@ -41,6 +68,10 @@ public class ContactActivity extends BaseActivity implements ContactContact.Cont
|
||||
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
mContactAdapter.setContactList(contactList);
|
||||
if (contactList != null) {
|
||||
mContactAdapter.setContactList(contactList);
|
||||
tv_people.setText(contactList.size() + "人");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.EmergencyContact;
|
||||
import com.uiui.aios.bean.NetDesktopIcon;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
@@ -59,7 +60,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
NetInterfaceManager.getInstance().getSystemSettings(true, getLifecycle(), new NetInterfaceManager.SosNumberCallback() {
|
||||
|
||||
@Override
|
||||
public void setSosNumber(List<Contact> setting_sos) {
|
||||
public void setSosNumber(List<EmergencyContact> setting_sos) {
|
||||
Intent intent = new Intent("setting_sos");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
|
||||
@@ -35,9 +37,23 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ContactHolder contactHolder, int position) {
|
||||
Contact contact = mContactList.get(position);
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).into(contactHolder.iv_head);
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).error(R.drawable.default_head).into(contactHolder.iv_head);
|
||||
contactHolder.tv_name.setText(contact.getName());
|
||||
contactHolder.tv_phone.setText(contact.getMobile());
|
||||
int index = position % 3;
|
||||
switch (index) {
|
||||
case 0:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
break;
|
||||
case 1:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sun));
|
||||
break;
|
||||
case 2:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sunny));
|
||||
break;
|
||||
default:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,12 +62,14 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
}
|
||||
|
||||
static class ContactHolder extends RecyclerView.ViewHolder {
|
||||
ImageView iv_head;
|
||||
ConstraintLayout root;
|
||||
NiceImageView iv_head;
|
||||
TextView tv_name;
|
||||
TextView tv_phone;
|
||||
|
||||
public ContactHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_head = itemView.findViewById(R.id.iv_head);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_phone = itemView.findViewById(R.id.tv_phone);
|
||||
|
||||
53
app/src/main/java/com/uiui/aios/bean/EmergencyContact.java
Normal file
53
app/src/main/java/com/uiui/aios/bean/EmergencyContact.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.uiui.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class EmergencyContact implements Serializable {
|
||||
private static final long serialVersionUID = 3368451934517980000L;
|
||||
|
||||
String avatar;
|
||||
String name;
|
||||
String mobile;
|
||||
int is_urgent;
|
||||
boolean show;
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public int getIs_urgent() {
|
||||
return is_urgent;
|
||||
}
|
||||
|
||||
public void setIs_urgent(int is_urgent) {
|
||||
this.is_urgent = is_urgent;
|
||||
}
|
||||
|
||||
public boolean isShow() {
|
||||
return show;
|
||||
}
|
||||
|
||||
public void setShow(boolean show) {
|
||||
this.show = show;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class SystemSettings implements Serializable {
|
||||
int qch_restore;
|
||||
int setting_browserInput;
|
||||
int dev_mode;
|
||||
List<Contact> setting_sos;
|
||||
List<EmergencyContact> setting_sos;
|
||||
String setting_volume;
|
||||
String setting_luminance;
|
||||
String setting_typeface;
|
||||
@@ -262,11 +262,11 @@ public class SystemSettings implements Serializable {
|
||||
this.setting_hotspot = setting_hotspot;
|
||||
}
|
||||
|
||||
public List<Contact> getSetting_sos() {
|
||||
public List<EmergencyContact> getSetting_sos() {
|
||||
return setting_sos;
|
||||
}
|
||||
|
||||
public void setSetting_sos(List<Contact> setting_sos) {
|
||||
public void setSetting_sos(List<EmergencyContact> setting_sos) {
|
||||
this.setting_sos = setting_sos;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,6 @@ import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -28,6 +22,11 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
@@ -39,28 +38,28 @@ import com.qweather.sdk.bean.base.Unit;
|
||||
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
|
||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||
import com.qweather.sdk.view.QWeather;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiui.aios.activity.EmergencyActivity;
|
||||
import com.uiui.aios.activity.alarm.AlarmClockActivity;
|
||||
import com.uiui.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiui.aios.activity.contact.ContactActivity;
|
||||
import com.uiui.aios.activity.weather.WeatherActivity;
|
||||
import com.uiui.aios.adapter.NotificationAdapter;
|
||||
import com.uiui.aios.adapter.SOSNnmberAdapter;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.AlarmItem;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.bean.EmergencyContact;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.bean.UserAvatarInfo;
|
||||
import com.uiui.aios.dialog.SingleDialog;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
import com.uiui.aios.tpush.MessageReceiver;
|
||||
@@ -136,7 +135,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
@BindView(R.id.iv_note_nodata)
|
||||
ImageView iv_note_nodata;
|
||||
@BindView(R.id.iv_head)
|
||||
NiceImageView iv_head;
|
||||
ImageView iv_head;
|
||||
@BindView(R.id.tv_name)
|
||||
TextView tv_name;
|
||||
|
||||
@@ -398,7 +397,20 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
cl_shared_space.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToastUtil.show("此功能暂未上线");
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setTitle("温馨提示")
|
||||
.setMessage("此功能暂未上线")
|
||||
.setPositive("确定")
|
||||
// .setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
|
||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
cl_health.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -425,7 +437,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
private void checkSosNumber() {
|
||||
NetInterfaceManager.getInstance().getSystemSettings(new NetInterfaceManager.SosNumberCallback() {
|
||||
@Override
|
||||
public void setSosNumber(List<Contact> setting_sos) {
|
||||
public void setSosNumber(List<EmergencyContact> setting_sos) {
|
||||
Intent intent = new Intent(mContext, EmergencyActivity.class);
|
||||
// intent.putExtra("setting_sos", phone);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
@@ -15,11 +15,12 @@ import com.uiui.aios.bean.ActivityBean;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.ArticleInfo;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.bean.DemandBean;
|
||||
import com.uiui.aios.bean.EmergencyContact;
|
||||
import com.uiui.aios.bean.GoodsInfo;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.bean.NetDesktopIcon;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.bean.SystemSettings;
|
||||
import com.uiui.aios.bean.UserAvatarInfo;
|
||||
@@ -54,6 +55,7 @@ import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
@@ -795,7 +797,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public interface SosNumberCallback {
|
||||
void setSosNumber(List<Contact> setting_sos);
|
||||
void setSosNumber(List<EmergencyContact> setting_sos);
|
||||
|
||||
void setEmpty();
|
||||
|
||||
@@ -816,9 +818,9 @@ public class NetInterfaceManager {
|
||||
getSystemSettings(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
Type type = new TypeToken<List<EmergencyContact>>() {
|
||||
}.getType();
|
||||
List<Contact> setting_sos = gson.fromJson(jsonString, type);
|
||||
List<EmergencyContact> setting_sos = gson.fromJson(jsonString, type);
|
||||
if (setting_sos == null || setting_sos.size() == 0) {
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
@@ -860,12 +862,13 @@ public class NetInterfaceManager {
|
||||
mMMKV.encode("is_health", systemSettings.getIs_health());
|
||||
mMMKV.encode("is_shopping", systemSettings.getIs_shopping());
|
||||
mMMKV.encode("is_info", systemSettings.getIs_info());
|
||||
List<Contact> setting_sos = systemSettings.getSetting_sos();
|
||||
List<EmergencyContact> setting_sos = systemSettings.getSetting_sos();
|
||||
if (setting_sos == null || setting_sos.size() == 0) {
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, "");
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, GsonUtils.toJsonString(setting_sos));
|
||||
List<EmergencyContact> contactList = setting_sos.stream().filter(contact -> contact.getIs_urgent() == 1).collect(Collectors.toList());
|
||||
mCacheHelper.put(URLAddress.GET_SETTINGS, GsonUtils.toJsonString(contactList));
|
||||
if (callback != null) callback.setSosNumber(setting_sos);
|
||||
}
|
||||
} else {
|
||||
@@ -883,9 +886,9 @@ public class NetInterfaceManager {
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
Type type = new TypeToken<List<EmergencyContact>>() {
|
||||
}.getType();
|
||||
List<Contact> setting_sos = gson.fromJson(jsonString, type);
|
||||
List<EmergencyContact> setting_sos = gson.fromJson(jsonString, type);
|
||||
if (setting_sos == null || setting_sos.size() == 0) {
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user