Files
Xuewang365OSNeutral/app/src/main/java/com/xwad/os/push/PushManager.java
tongtongstudio 7e16ba8813 version
fix:
update:修改包名
2025-11-28 20:50:52 +08:00

94 lines
2.9 KiB
Java

package com.xwad.os.push;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import com.xwad.os.disklrucache.CacheHelper;
import com.xwad.os.fragment.user.UserFragment;
import com.xwad.os.network.NetInterfaceManager;
import com.hjq.toast.Toaster;
public class PushManager {
private static final String TAG = "PushManager";
public static final String SET_ALARMCLOCK = "zuoyeos.action.change.alarmclaock";
@SuppressLint("StaticFieldLeak")
private static PushManager sInstance;
private Context mContext;
private ContentResolver mResolver;
private CacheHelper mCacheHelper;
private PushManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.mResolver = context.getContentResolver();
this.mCacheHelper = new CacheHelper(context);
}
public static void init(Context context) {
if (sInstance == null) {
sInstance = new PushManager(context);
}
}
public static PushManager getInstance() {
if (sInstance == null) {
throw new IllegalStateException("You must be init PushManager first");
}
return sInstance;
}
//闹钟
private static final String JIGUANG_ALARM_CLOCK = "57";
/*网课模式*/
private static final String ONLINE_COURSE_MODE = "71";
/*作业提醒*/
private static final String HOMEWORK_REMINDERS = "115";
/*爱的鼓励*/
private static final String LOVE_ENCOURAGEMENT = "121";
public void setPushContent(String title, String extras) {
switch (title) {
case JIGUANG_ALARM_CLOCK:
Toaster.debugShow("收到推送消息: 设置闹钟");
sendAlarmClock(extras);
break;
case ONLINE_COURSE_MODE:
Toaster.debugShow("收到推送消息: 网课模式");
NetInterfaceManager.getInstance().getCloudLessonSettings();
break;
case HOMEWORK_REMINDERS:
sendHomework(extras);
break;
case LOVE_ENCOURAGEMENT:
Toaster.debugShow("收到推送消息: 爱的鼓励");
sendEncouragement(extras);
default:
}
}
private void sendAlarmClock(String extras) {
NetInterfaceManager.getInstance().getAlarmClock();
Intent intent = new Intent(SET_ALARMCLOCK);
mContext.sendBroadcast(intent);
}
private void sendHomework(String extras) {
Intent intent = new Intent(UserFragment.ACTION_REFRESH_HOMEWORK_REMINDERS);
mContext.sendBroadcast(intent);
}
private void sendEncouragement(String extras) {
Intent intent = new Intent(UserFragment.ACTION_REFRESH_LOVE_ENCOURAGEMENT);
mContext.sendBroadcast(intent);
}
}