version:1.2
fix:优化卡顿 update:基本对接完成,增加指示器放大
This commit is contained in:
@@ -2,11 +2,20 @@ package com.uiui.zyos.service.main;
|
||||
|
||||
import com.uiui.zyos.base.BasePresenter;
|
||||
import com.uiui.zyos.base.BaseView;
|
||||
import com.uiui.zyos.bean.AlarmClockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MainSContact {
|
||||
public interface Presenter extends BasePresenter<MainSView> {
|
||||
/*获取网课模式*/
|
||||
void getCloudLessonSettings();
|
||||
/*获取闹钟*/
|
||||
void getAlarmClock();
|
||||
}
|
||||
|
||||
public interface MainSView extends BaseView {
|
||||
void setCloudLessonSettings();
|
||||
void setAlarmClock(List<AlarmClockData> dataList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ import android.util.Log;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.zyos.bean.AlarmClockData;
|
||||
import com.uiui.zyos.config.CommonConfig;
|
||||
import com.uiui.zyos.network.NetInterfaceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
@@ -19,7 +24,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
private static final int OK = 200;
|
||||
private MainSContact.MainSView mView;
|
||||
private Context mContext;
|
||||
MMKV mMMKV = MMKV.defaultMMKV();
|
||||
MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
@@ -45,4 +50,34 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCloudLessonSettings() {
|
||||
NetInterfaceManager.getInstance().getCloudLessonSettings(lifecycle, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setCloudLessonSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAlarmClock() {
|
||||
NetInterfaceManager.getInstance().getAlarmClock(true, getLifecycle(), new NetInterfaceManager.AlarmClockCallback() {
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
||||
Log.e(TAG, "setAlarmClock: " + alarmClockList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
Log.e(TAG, "setAlarmClock: setAlarmClockEmpty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Log.e(TAG, "setAlarmClock: onError");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
package com.uiui.zyos.service.main;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.uiui.zyos.activity.NoticeActivity;
|
||||
import com.uiui.zyos.alarm.AlarmUtils;
|
||||
import com.uiui.zyos.base.BaseService;
|
||||
import com.uiui.zyos.bean.AlarmClockData;
|
||||
import com.uiui.zyos.jxw.JxwPackageConfig;
|
||||
import com.uiui.zyos.utils.Utils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MainService extends BaseService implements MainSContact.MainSView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
|
||||
|
||||
public MainSPresenter mPresenter;
|
||||
|
||||
public MainService() {
|
||||
@@ -17,12 +34,15 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
Log.e(TAG, "onDisconnected: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
|
||||
Log.e(TAG, "onConnected: ");
|
||||
if (Utils.isScreenOn(MainService.this)) {
|
||||
mPresenter.getCloudLessonSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +58,10 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.getCloudLessonSettings();
|
||||
registerAlarmReceiver();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
startJxwLauncher();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,8 +75,94 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
super.onDestroy();
|
||||
mPresenter.detachView();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
unregisterReceiver();
|
||||
}
|
||||
|
||||
private void startJxwLauncher() {
|
||||
ComponentName cn = new ComponentName(JxwPackageConfig.JXW_LAUNCHER_PACKAGE_NAME, JxwPackageConfig.JXW_LAUNCHER_CLASS_NAME);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterReceiver() {
|
||||
if (alarmReceiver != null) {
|
||||
unregisterReceiver(alarmReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ALARMWAKEUP = "ALARM_WAKEUP";
|
||||
|
||||
private void registerAlarmReceiver() {
|
||||
if (alarmReceiver == null) {
|
||||
alarmReceiver = new AlarmReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(ALARMWAKEUP);
|
||||
registerReceiver(alarmReceiver, filter);
|
||||
}
|
||||
|
||||
private AlarmReceiver alarmReceiver = new AlarmReceiver();
|
||||
|
||||
private class AlarmReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + System.currentTimeMillis());
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
String title = intent.getStringExtra("title");
|
||||
int code = intent.getIntExtra("id", -1);
|
||||
Log.e(TAG, "onReceive: title = " + title);
|
||||
setNextAlarm(code);
|
||||
if (ALARMWAKEUP.equals(action)) {
|
||||
Intent noticeIntent = new Intent();
|
||||
noticeIntent.putExtra("id", code);
|
||||
noticeIntent.setClass(MainService.this, NoticeActivity.class);
|
||||
noticeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(noticeIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextAlarm(int code) {
|
||||
HashMap<Integer, AlarmClockData> clockDataHashMap = AlarmUtils.getInstance().getOldData();
|
||||
AlarmClockData alarmClockData = clockDataHashMap.get(code);
|
||||
Log.e(TAG, "setNextAlarm: " + alarmClockData);
|
||||
if (alarmClockData != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
Log.e(TAG, "setNextAlarm: " + day_of_week);
|
||||
switch (alarmClockData.getType()) {
|
||||
case AlarmUtils.ONCE:
|
||||
break;
|
||||
case AlarmUtils.LOOP:
|
||||
AlarmUtils.getInstance().setDayLoopAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
break;
|
||||
case AlarmUtils.WORKING_DAY:
|
||||
if (day_of_week < 5 || day_of_week == 7) {
|
||||
AlarmUtils.getInstance().setWorkDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
}
|
||||
break;
|
||||
case AlarmUtils.OFF_DAY:
|
||||
AlarmUtils.getInstance().setOffDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCloudLessonSettings() {
|
||||
mPresenter.getAlarmClock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> dataList) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user