version:2.2
fix: update:接口优化
This commit is contained in:
@@ -177,7 +177,7 @@ dependencies {
|
|||||||
// implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
|
// implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
|
||||||
// implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
// implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||||
//
|
//
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||||
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
|
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
mFragments.add(mCustomFragment);
|
mFragments.add(mCustomFragment);
|
||||||
|
|
||||||
mMainPresenter.getSystemSettings();
|
mMainPresenter.getSystemSettings();
|
||||||
mMainPresenter.getAdminSnSetting();
|
// mMainPresenter.getAdminSnSetting();
|
||||||
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
|
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i <= desktopIcons.size(); i++) {
|
for (int i = 0; i <= desktopIcons.size(); i++) {
|
||||||
@@ -317,7 +317,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
gotoNotificationAccessSetting(this);
|
gotoNotificationAccessSetting(this);
|
||||||
}
|
}
|
||||||
addData();
|
addData();
|
||||||
mMainPresenter.sendRunningInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
|
private static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
|
||||||
@@ -369,6 +368,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
protected void onRestart() {
|
protected void onRestart() {
|
||||||
super.onRestart();
|
super.onRestart();
|
||||||
mMainPresenter.sendAPPUsage();
|
mMainPresenter.sendAPPUsage();
|
||||||
|
mMainPresenter.sendRunningInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -445,7 +445,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSystemSettings() {
|
public void setSystemSettings() {
|
||||||
mMainPresenter.getDesktopLayout();
|
// mMainPresenter.getDesktopLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -56,29 +56,28 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSystemSettings() {
|
public void getSystemSettings() {
|
||||||
NetInterfaceManager.getInstance().getSystemSettings(true, getLifecycle(), new NetInterfaceManager.ContactCallback() {
|
// NetInterfaceManager.getInstance().getSystemSettings(true, getLifecycle(), new NetInterfaceManager.ContactCallback() {
|
||||||
@Override
|
// @Override
|
||||||
public void setContact(List<Contact> contactList) {
|
// public void setContact(List<Contact> contactList) {
|
||||||
Intent intent = new Intent("setting_sos");
|
// Intent intent = new Intent("setting_sos");
|
||||||
mContext.sendBroadcast(intent);
|
// mContext.sendBroadcast(intent);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void setEmergencyContact(List<Contact> emergencyContact) {
|
// public void setEmergencyContact(List<Contact> emergencyContact) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void setEmpty() {
|
// public void setEmpty() {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onComplete() {
|
// public void onComplete() {
|
||||||
mView.setSystemSettings();
|
// }
|
||||||
}
|
// });
|
||||||
});
|
mView.setSystemSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
|||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
public class BaseFragment extends Fragment implements LifecycleProvider<FragmentEvent> {
|
public abstract class BaseFragment extends Fragment implements LifecycleProvider<FragmentEvent> {
|
||||||
public final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
|
public final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
|
||||||
|
|
||||||
|
protected boolean isViewInitiated;
|
||||||
|
protected boolean isVisibleToUser;
|
||||||
|
protected boolean isDataInitiated;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
@CheckResult
|
@CheckResult
|
||||||
@@ -56,6 +60,35 @@ public class BaseFragment extends Fragment implements LifecycleProvider<Fragment
|
|||||||
lifecycleSubject.onNext(FragmentEvent.CREATE);
|
lifecycleSubject.onNext(FragmentEvent.CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
isViewInitiated = true;
|
||||||
|
prepareFetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
|
this.isVisibleToUser = isVisibleToUser;
|
||||||
|
prepareFetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void fetchData();
|
||||||
|
|
||||||
|
public boolean prepareFetchData() {
|
||||||
|
return prepareFetchData(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean prepareFetchData(boolean forceUpdate) {
|
||||||
|
if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
|
||||||
|
fetchData();
|
||||||
|
isDataInitiated = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ public class AppListFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private View rootView;
|
private View rootView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
ImageView iv_app;
|
ImageView iv_app;
|
||||||
|
|
||||||
|
|
||||||
private String TAG = CustomFragment.class.getSimpleName();
|
private static final String TAG = CustomFragment.class.getSimpleName();
|
||||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||||
private int[] mShaderColors = new int[]{0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300};
|
private int[] mShaderColors = new int[]{0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300, 0xFFff9300};
|
||||||
private int[] mShaderColorsRed = new int[]{0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
|
private int[] mShaderColorsRed = new int[]{0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
|
||||||
@@ -232,6 +232,10 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
mMMKV = MMKV.defaultMMKV();
|
mMMKV = MMKV.defaultMMKV();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchData() {
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
@@ -330,7 +334,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
private BatteryReceiver batteryReceiver;
|
private BatteryReceiver batteryReceiver;
|
||||||
|
|
||||||
private class BatteryReceiver extends BroadcastReceiver {
|
private class BatteryReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
@@ -385,7 +388,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
mCRv = mContext.getContentResolver();
|
mCRv = mContext.getContentResolver();
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
initView();
|
initView();
|
||||||
initData();
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +551,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
startActivity(new Intent(mContext, ControlActivity.class));
|
startActivity(new Intent(mContext, ControlActivity.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
refreshMemory();
|
refreshMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,36 +629,36 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
mCustomPresenter.getSnInfo();
|
// NetInterfaceManager.getInstance().getUserAvatarInfoControl()
|
||||||
NetInterfaceManager.getInstance().getUserAvatarInfoControl()
|
// .subscribe(new Observer<BaseResponse<UserAvatarInfo>>() {
|
||||||
.subscribe(new Observer<BaseResponse<UserAvatarInfo>>() {
|
// @Override
|
||||||
@Override
|
// public void onSubscribe(@NonNull Disposable d) {
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
// Log.e("getUserAvatarInfoControl", "onSubscribe: ");
|
||||||
Log.e("getUserAvatarInfoControl", "onSubscribe: ");
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// public void onNext(@NonNull BaseResponse<UserAvatarInfo> userAvatarInfoBaseResponse) {
|
||||||
public void onNext(@NonNull BaseResponse<UserAvatarInfo> userAvatarInfoBaseResponse) {
|
// Log.e("getUserAvatarInfoControl", "onNext: " + userAvatarInfoBaseResponse);
|
||||||
Log.e("getUserAvatarInfoControl", "onNext: " + userAvatarInfoBaseResponse);
|
// if (userAvatarInfoBaseResponse.code == 200) {
|
||||||
if (userAvatarInfoBaseResponse.code == 200) {
|
// if (!mContext.isDestroyed()) {
|
||||||
if (!mContext.isDestroyed()) {
|
//// Glide.with(iv_head).load(userAvatarInfoBaseResponse.data.getAvatar()).into(iv_head);
|
||||||
// Glide.with(iv_head).load(userAvatarInfoBaseResponse.data.getAvatar()).into(iv_head);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// public void onError(@NonNull Throwable e) {
|
||||||
public void onError(@NonNull Throwable e) {
|
// Log.e("getUserAvatarInfoControl", "onError: " + e.getMessage());
|
||||||
Log.e("getUserAvatarInfoControl", "onError: " + e.getMessage());
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
@Override
|
// public void onComplete() {
|
||||||
public void onComplete() {
|
// Log.e("getUserAvatarInfoControl", "onComplete: ");
|
||||||
Log.e("getUserAvatarInfoControl", "onComplete: ");
|
// }
|
||||||
}
|
// });
|
||||||
});
|
// mCustomPresenter.getSnInfo();
|
||||||
initAmap();
|
initAmap();
|
||||||
getAlarmClock();
|
getAlarmCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -824,6 +825,22 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getAlarmCache(){
|
||||||
|
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) {
|
||||||
|
notificationAdapter.setDataList(list);
|
||||||
|
rv_noti.setVisibility(View.VISIBLE);
|
||||||
|
iv_note_nodata.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
rv_noti.setVisibility(View.GONE);
|
||||||
|
iv_note_nodata.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void getAlarmClock() {
|
private void getAlarmClock() {
|
||||||
NetInterfaceManager.getInstance().getAlarmClock(new NetInterfaceManager.AlarmClockCallback() {
|
NetInterfaceManager.getInstance().getAlarmClock(new NetInterfaceManager.AlarmClockCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ public class CustomPresenter implements CustomContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSnInfo() {
|
public void getSnInfo() {
|
||||||
NetInterfaceManager.getInstance().getSnInfo(new NetInterfaceManager.SnInfoCallback() {
|
// NetInterfaceManager.getInstance().getSnInfo(new NetInterfaceManager.SnInfoCallback() {
|
||||||
@Override
|
// @Override
|
||||||
public void setSnInfo(SnInfo snInfo) {
|
// public void setSnInfo(SnInfo snInfo) {
|
||||||
mView.setSnInfo(snInfo);
|
// mView.setSnInfo(snInfo);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,11 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
|||||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case BOOT_COMPLETED:
|
case BOOT_COMPLETED:
|
||||||
MainService.mPresenter.getAlarmClock();
|
// MainService.mPresenter.getAlarmClock();
|
||||||
case Intent.ACTION_BOOT_COMPLETED:
|
case Intent.ACTION_BOOT_COMPLETED:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
*/
|
*/
|
||||||
public class MainSPresenter implements MainSContact.Presenter {
|
public class MainSPresenter implements MainSContact.Presenter {
|
||||||
private static final String TAG = MainSPresenter.class.getSimpleName();
|
private static final String TAG = MainSPresenter.class.getSimpleName();
|
||||||
|
|
||||||
private static final int OK = 200;
|
private static final int OK = 200;
|
||||||
private MainSContact.MainSView mView;
|
private MainSContact.MainSView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user