version:6.8
fix: update:修改主页健康码为应用,拨号增加系统拨号
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package com.uiui.aios.activity;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.AppSelectedAdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.AppSelectBean;
|
||||
import com.uiui.aios.view.GridSpaceItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class QuickAppActivity extends BaseActivity {
|
||||
public static final String QUICK_APP_KEY = "QuickAppKey";
|
||||
private AppSelectedAdapter mAppSelectedAdapter;
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_quick_app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mAppSelectedAdapter = new AppSelectedAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(3, 50, 50));
|
||||
} else {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(2, 50, 50));
|
||||
}
|
||||
recyclerView.setAdapter(mAppSelectedAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mAppSelectedAdapter.setAppSelectBeans(getPackageList());
|
||||
}
|
||||
|
||||
boolean listThirdParty = true;
|
||||
|
||||
private List<AppSelectBean> getPackageList() {
|
||||
PackageManager pm = getPackageManager();
|
||||
List<AppSelectBean> appSelectBeanList = new ArrayList<>();
|
||||
List<PackageInfo> applicationInfos = pm.getInstalledPackages(0);
|
||||
for (PackageInfo packageInfo : applicationInfos) {
|
||||
if (BuildConfig.APPLICATION_ID.equals(packageInfo.applicationInfo.packageName)) {
|
||||
continue;
|
||||
}
|
||||
final boolean isSystem = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||
if (!listThirdParty || !isSystem) {
|
||||
AppSelectBean appSelectBean = new AppSelectBean(packageInfo.applicationInfo.loadLabel(pm).toString(), packageInfo.applicationInfo.packageName, packageInfo.applicationInfo.loadIcon(pm));
|
||||
appSelectBeanList.add(appSelectBean);
|
||||
}
|
||||
}
|
||||
return appSelectBeanList;
|
||||
}
|
||||
}
|
||||
@@ -74,10 +74,11 @@ public class ContactActivity extends BaseActivity implements ContactContact.Cont
|
||||
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
if (contactList != null) {
|
||||
mContactAdapter.setContactList(contactList);
|
||||
tv_people.setText(contactList.size() + "人");
|
||||
}
|
||||
|
||||
tv_people.setText(contactList.size() + "人");
|
||||
Contact contact = new Contact();
|
||||
contact.setName("拨号");
|
||||
contact.setMobile(ContactAdapter.DIALER_PACKAGE);
|
||||
contactList.add(0, contact);
|
||||
mContactAdapter.setContactList(contactList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,19 @@ package com.uiui.aios.activity.contact;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
import com.uiui.aios.utils.GsonUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
@@ -19,6 +26,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
public class ContactPresenter implements ContactContact.Presenter {
|
||||
private Context mContext;
|
||||
private ContactContact.ContactView mView;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
@@ -58,12 +66,28 @@ public class ContactPresenter implements ContactContact.Presenter {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<Contact>> listBaseResponse) {
|
||||
Log.e("getContactList", "onNext: " + listBaseResponse);
|
||||
mView.setContact(listBaseResponse.data);
|
||||
if (listBaseResponse.code == 200) {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, GsonUtils.toJsonString(listBaseResponse.data));
|
||||
mView.setContact(listBaseResponse.data);
|
||||
} else {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, "");
|
||||
mView.setContact(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getContactList", "onError: " + e.getMessage());
|
||||
String jsonString = mMMKV.getString(URLAddress.GET_MAIL_LIST, null);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
}.getType();
|
||||
List<Contact> contacts = gson.fromJson(jsonString, type);
|
||||
if (contacts == null) {
|
||||
mView.setContact(new ArrayList<>());
|
||||
} else {
|
||||
mView.setContact(contacts);
|
||||
}
|
||||
onComplete();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.QuickAppActivity;
|
||||
import com.uiui.aios.bean.AppSelectBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.Holder> {
|
||||
private static final String TAG = AppSelectedAdapter.class.getSimpleName();
|
||||
private Context mContext;
|
||||
private List<AppSelectBean> mAppSelectBeans;
|
||||
private int unselectedStatus = -1;
|
||||
private int selecedPosition = unselectedStatus;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
public void setAppSelectBeans(List<AppSelectBean> appSelectBeanList) {
|
||||
this.mAppSelectBeans = appSelectBeanList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_app_select, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
AppSelectBean appSelectBean = mAppSelectBeans.get(position);
|
||||
holder.iv_icon.setImageDrawable(appSelectBean.getIcon());
|
||||
holder.tv_name.setText(appSelectBean.getAppName());
|
||||
if (selecedPosition == position) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
}
|
||||
holder.iv_select.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (position != selecedPosition) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
selecedPosition = position;
|
||||
mMMKV.encode(QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
Log.e(TAG, "setQuickApp: " + appSelectBean.getPackageName());
|
||||
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
selecedPosition = -1;
|
||||
mMMKV.encode(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Log.e(TAG, "setQuickApp: empty");
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAppSelectBeans == null ? 0 : mAppSelectBeans.size();
|
||||
}
|
||||
|
||||
static class Holder extends RecyclerView.ViewHolder {
|
||||
ImageView iv_select, iv_icon;
|
||||
TextView tv_name;
|
||||
|
||||
Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
iv_select = itemView.findViewById(R.id.iv_select);
|
||||
iv_icon = itemView.findViewById(R.id.iv_icon);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
private List<Contact> mContactList;
|
||||
private Context mContext;
|
||||
|
||||
public static final String DIALER_PACKAGE = "com.android.dialer";
|
||||
|
||||
public void setContactList(List<Contact> contactList) {
|
||||
this.mContactList = contactList;
|
||||
notifyDataSetChanged();
|
||||
@@ -45,7 +47,9 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
public void onClick(View view) {
|
||||
Intent intent1 = new Intent(Intent.ACTION_CALL);
|
||||
String phone = contact.getMobile();
|
||||
if (!TextUtils.isEmpty(phone)) {
|
||||
if (DIALER_PACKAGE.equals(phone)) {
|
||||
mContext.startActivity(new Intent(Intent.ACTION_DIAL));
|
||||
} else if (!TextUtils.isEmpty(phone)) {
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
intent1.setData(data);
|
||||
mContext.startActivity(intent1);
|
||||
@@ -53,9 +57,14 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
|
||||
|
||||
}
|
||||
});
|
||||
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());
|
||||
if (DIALER_PACKAGE.equals(contact.getMobile())) {
|
||||
contactHolder.tv_phone.setText("");
|
||||
Glide.with(contactHolder.iv_head).load(R.drawable.dialer_icon).error(R.drawable.dialer_icon).into(contactHolder.iv_head);
|
||||
} else {
|
||||
contactHolder.tv_phone.setText(contact.getMobile());
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).error(R.drawable.default_head).into(contactHolder.iv_head);
|
||||
}
|
||||
int index = position % 3;
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.uiui.aios.base;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -15,12 +13,13 @@ import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.manager.ConnectManager;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.service.main.MainService;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.SystemUtils;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,45 +29,33 @@ import java.util.List;
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static Context context;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static BaseApplication instance;
|
||||
|
||||
public static Context getAppContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
// 单例模式中获取唯一的ExitApplication实例
|
||||
public static BaseApplication getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new BaseApplication();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = this;
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
}
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
Aria.init(this);
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
||||
tpushInit();
|
||||
AppUsedTimeUtils.init(this);
|
||||
AlarmUtils.init(this);
|
||||
HeConfig.init("HE2206151627491952", "03125bfee8934cf4b640af48e8187c9d");
|
||||
//切换至开发版服务
|
||||
HeConfig.switchToDevService();
|
||||
AmapManager.init(this);
|
||||
ConnectManager.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
startService(new Intent(this, MainService.class));
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (SystemUtils.isMainProcessName(this, android.os.Process.myPid())) {
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
Aria.init(this);
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
||||
AppUsedTimeUtils.init(this);
|
||||
AlarmUtils.init(this);
|
||||
tpushInit();
|
||||
HeConfig.init("HE2206151627491952", "03125bfee8934cf4b640af48e8187c9d");
|
||||
//切换至开发版服务
|
||||
HeConfig.switchToDevService();
|
||||
AmapManager.init(this);
|
||||
ConnectManager.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
startService(new Intent(this, MainService.class));
|
||||
}
|
||||
}
|
||||
|
||||
private void tpushInit() {
|
||||
|
||||
43
app/src/main/java/com/uiui/aios/bean/AppSelectBean.java
Normal file
43
app/src/main/java/com/uiui/aios/bean/AppSelectBean.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.uiui.aios.bean;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppSelectBean implements Serializable {
|
||||
private static final long serialVersionUID = 5054284058523960678L;
|
||||
|
||||
String appName;
|
||||
String packageName;
|
||||
Drawable icon;
|
||||
|
||||
public AppSelectBean(String appName, String packageName, Drawable icon) {
|
||||
this.appName = appName;
|
||||
this.packageName = packageName;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(Drawable icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
@@ -45,6 +47,7 @@ import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.EmergencyActivity;
|
||||
import com.uiui.aios.activity.QuickAppActivity;
|
||||
import com.uiui.aios.activity.alarm.AlarmClockActivity;
|
||||
import com.uiui.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiui.aios.activity.contact.ContactActivity;
|
||||
@@ -104,6 +107,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
ConstraintLayout cl_contact;
|
||||
@BindView(R.id.cl_ai)
|
||||
ConstraintLayout cl_ai;
|
||||
@BindView(R.id.cl_app)
|
||||
ConstraintLayout cl_app;
|
||||
@BindView(R.id.cl_appstore)
|
||||
ConstraintLayout cl_appstore;
|
||||
|
||||
@@ -141,6 +146,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
// ImageView iv_head;
|
||||
// @BindView(R.id.tv_name)
|
||||
// TextView tv_name;
|
||||
@BindView(R.id.iv_app)
|
||||
ImageView iv_app;
|
||||
|
||||
private String TAG = CustomFragment.class.getSimpleName();
|
||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||
@@ -452,6 +459,23 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
openScheme(SchemeUtils.SCHEME_HAND);
|
||||
}
|
||||
});
|
||||
cl_app.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
} else {
|
||||
ApkUtils.openPackage(mContext, quickAppPackagesName);
|
||||
}
|
||||
}
|
||||
});
|
||||
cl_app.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
cl_appstore.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -496,11 +520,11 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
NetInterfaceManager.getInstance().getContactList(new NetInterfaceManager.ContactCallback() {
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
if (contactList == null || contactList.size() == 0) {
|
||||
showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
} else {
|
||||
startActivity(new Intent(getActivity(), ContactActivity.class));
|
||||
}
|
||||
// if (contactList == null || contactList.size() == 0) {
|
||||
// showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
// } else {
|
||||
// startActivity(new Intent(mContext, ContactActivity.class));
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -510,12 +534,12 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
@Override
|
||||
public void setEmpty() {
|
||||
showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
// showNoData("温馨提示", "请在小程序上设置通讯录");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
startActivity(new Intent(mContext, ContactActivity.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -591,9 +615,29 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
// setAlarm();
|
||||
getAlarmClock();
|
||||
setSosNumber();
|
||||
setQuickApp();
|
||||
mCustomPresenter.getSnIsActivation();
|
||||
}
|
||||
|
||||
private String quickAppPackagesName;
|
||||
|
||||
private void setQuickApp() {
|
||||
quickAppPackagesName = mMMKV.decodeString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Log.e(TAG, "setQuickApp: " + quickAppPackagesName);
|
||||
if (!TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
ApplicationInfo applicationInfo = null;
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
try {
|
||||
applicationInfo = pm.getApplicationInfo(quickAppPackagesName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (applicationInfo != null) {
|
||||
iv_app.setImageDrawable(applicationInfo.loadIcon(pm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openScheme(String uri) {
|
||||
int is_health = mMMKV.decodeInt("is_health", 0);
|
||||
if (is_health == 0) {
|
||||
|
||||
@@ -13,9 +13,14 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okio.Buffer;
|
||||
|
||||
/**
|
||||
* v1.0 2022-07-15 16:16:52
|
||||
*/
|
||||
public class RepeatRequestInterceptor implements Interceptor {
|
||||
private static final String TAG = RepeatRequestInterceptor.class.getSimpleName();
|
||||
|
||||
@@ -26,13 +31,18 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Response response = chain.proceed(request);
|
||||
ResponseBody responseBody = response.body();
|
||||
|
||||
Response response = chain.proceed(chain.request());
|
||||
String content = response.body().string();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.e(TAG, "请求体返回:| Response:" + content);
|
||||
//会消费请求,导致请求多次
|
||||
String content = responseBody.string();
|
||||
// Response copy = response.newBuilder().body(responseBody).build();
|
||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||
if (BuildConfig.DEBUG) {
|
||||
// Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + request.body());
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
long time = System.currentTimeMillis();//请求时间
|
||||
try {
|
||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||
@@ -48,7 +58,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
log("注册请求:", requestKey, request);
|
||||
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return chain.proceed(request);
|
||||
return response.newBuilder().body(copy).build();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
@@ -78,8 +88,20 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-" + e.getMessage();
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
private static String requestBodyToString(RequestBody body) {
|
||||
try {
|
||||
final Buffer buffer = new Buffer();
|
||||
body.writeTo(buffer);
|
||||
if (buffer.size() > 4096) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,12 +65,12 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
Log.e(TAG, "setAlarmClock: ");
|
||||
Log.e(TAG, "setAlarmClock: setAlarmClockEmpty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e(TAG, "setAlarmClock: ");
|
||||
Log.e(TAG, "setAlarmClock: onError");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
24
app/src/main/java/com/uiui/aios/utils/SystemUtils.java
Normal file
24
app/src/main/java/com/uiui/aios/utils/SystemUtils.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.uiui.aios.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SystemUtils {
|
||||
|
||||
public static boolean isMainProcessName(Context cxt, int pid) {
|
||||
String packageName = cxt.getPackageName();
|
||||
ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
|
||||
if (runningApps == null) {
|
||||
return false;
|
||||
}
|
||||
for (ActivityManager.RunningAppProcessInfo procInfo : runningApps) {
|
||||
if (procInfo.pid == pid) {
|
||||
return procInfo.processName.equals(packageName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.uiui.aios.view;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* 描述 : RecyclerView GridLayoutManager 等间距。
|
||||
* <p>
|
||||
* 等间距需满足两个条件:
|
||||
* 1.各个模块的大小相等,即 各列的left+right 值相等;
|
||||
* 2.各列的间距相等,即 前列的right + 后列的left = 列间距;
|
||||
* <p>
|
||||
* 在{@link #getItemOffsets(Rect, View, RecyclerView, RecyclerView.State)} 中针对 outRect 的left 和right 满足这两个条件即可
|
||||
* <p>
|
||||
* 作者 : shiguotao
|
||||
* 版本 : V1
|
||||
* 创建时间 : 2020/3/19 4:54 PM
|
||||
*/
|
||||
public class GridSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final String TAG = "GridSpaceItemDecoration";
|
||||
|
||||
private int mSpanCount;//横条目数量
|
||||
private int mRowSpacing;//行间距
|
||||
private int mColumnSpacing;// 列间距
|
||||
|
||||
/**
|
||||
* @param spanCount 列数
|
||||
* @param rowSpacing 行间距
|
||||
* @param columnSpacing 列间距
|
||||
*/
|
||||
public GridSpaceItemDecoration(int spanCount, int rowSpacing, int columnSpacing) {
|
||||
this.mSpanCount = spanCount;
|
||||
this.mRowSpacing = rowSpacing;
|
||||
this.mColumnSpacing = columnSpacing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view); // 获取view 在adapter中的位置。
|
||||
int column = position % mSpanCount; // view 所在的列
|
||||
|
||||
outRect.left = column * mColumnSpacing / mSpanCount; // column * (列间距 * (1f / 列数))
|
||||
outRect.right = mColumnSpacing - (column + 1) * mColumnSpacing / mSpanCount; // 列间距 - (column + 1) * (列间距 * (1f /列数))
|
||||
|
||||
Log.e(TAG, "position:" + position
|
||||
+ " columnIndex: " + column
|
||||
+ " left,right ->" + outRect.left + "," + outRect.right);
|
||||
|
||||
// 如果position > 行数,说明不是在第一行,则不指定行高,其他行的上间距为 top=mRowSpacing
|
||||
if (position >= mSpanCount) {
|
||||
outRect.top = mRowSpacing; // item top
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user