version:3.1
fix: update:更改主页样式,完善闹钟
This commit is contained in:
@@ -57,34 +57,23 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getAlarmClock() {
|
||||
NetInterfaceManager.getInstance().getAlarmClockObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AlarmClockData>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getAlarmClock", "onSubscribe: ");
|
||||
}
|
||||
NetInterfaceManager.getInstance().getAlarmClock(true, getLifecycle(), new NetInterfaceManager.AlarmClockCallback() {
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
||||
AlarmUtils.getInstance().setAlarmClockData(alarmClockList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<List<AlarmClockData>> listBaseResponse) {
|
||||
Log.e("getAlarmClock", "onNext: "+listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AlarmClockData> data = listBaseResponse.data;
|
||||
AlarmUtils.getInstance().setAlarmClockData(data);
|
||||
} else {
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
AlarmUtils.getInstance().deleteAllAlarmClock();
|
||||
AlarmUtils.getInstance().setAlarmClockData(null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getAlarmClock", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAlarmClock", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.activity.NoticeActivity;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.base.BaseService;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
@@ -30,6 +31,8 @@ import com.uiui.aios.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
@@ -131,12 +134,14 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
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);
|
||||
@@ -147,6 +152,32 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
}
|
||||
}
|
||||
|
||||
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().setDayLoopAlarm(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:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听时间和日期变化
|
||||
public void registerTimeReceiver() {
|
||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||
@@ -173,7 +204,7 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "timezone changed");
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "time tick");
|
||||
isScreenshot();
|
||||
// isScreenshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +220,7 @@ public class MainService extends BaseService implements MainSContact.MainSView,
|
||||
String topPackageName = ForegroundAppUtil.getForegroundPackageName(MainService.this);
|
||||
Log.e(TAG, "isScreenshot: " + topPackageName);
|
||||
String pkg = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
if (TextUtils.isEmpty(pkg)|| BuildConfig.APPLICATION_ID.equals(pkg)) {
|
||||
if (TextUtils.isEmpty(pkg) || BuildConfig.APPLICATION_ID.equals(pkg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user