165 lines
4.4 KiB
Java
165 lines
4.4 KiB
Java
package com.handuan.os.bean;
|
||
|
||
import android.text.TextUtils;
|
||
import android.util.Log;
|
||
|
||
import androidx.annotation.NonNull;
|
||
import androidx.annotation.Nullable;
|
||
|
||
import com.google.gson.Gson;
|
||
import com.google.gson.JsonParser;
|
||
import com.handuan.os.alarm.AlarmUtils;
|
||
|
||
import java.io.Serializable;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.Calendar;
|
||
import java.util.Date;
|
||
|
||
public class AlarmClockData implements Serializable {
|
||
private static final long serialVersionUID = -5856502480745183157L;
|
||
|
||
int id;
|
||
int type;//类型 1一次 2循环 3周一到周五 4 周六周日
|
||
String time;//"2021-11-15 18:33:23",//时间格式化字符串,循环类型是18:33:23
|
||
String title;//标题
|
||
String voice;//语音文件地址
|
||
String voice_md5;
|
||
String file;//图片或视频文件地址
|
||
int remind_type;
|
||
int is_onoff;//0关闭 1开启
|
||
|
||
boolean finished = false;
|
||
|
||
public int getId() {
|
||
return id;
|
||
}
|
||
|
||
public void setId(int id) {
|
||
this.id = id;
|
||
}
|
||
|
||
public int getType() {
|
||
return type;
|
||
}
|
||
|
||
public void setType(int type) {
|
||
this.type = type;
|
||
}
|
||
|
||
public String getTime() {
|
||
return time;
|
||
}
|
||
|
||
public void setTime(String time) {
|
||
this.time = time;
|
||
}
|
||
|
||
public String getTitle() {
|
||
return title;
|
||
}
|
||
|
||
public void setTitle(String title) {
|
||
this.title = title;
|
||
}
|
||
|
||
public String getVoice() {
|
||
return voice;
|
||
}
|
||
|
||
public void setVoice(String voice) {
|
||
this.voice = voice;
|
||
}
|
||
|
||
public String getVoice_md5() {
|
||
return voice_md5;
|
||
}
|
||
|
||
public void setVoice_md5(String voice_md5) {
|
||
this.voice_md5 = voice_md5;
|
||
}
|
||
|
||
public String getFile() {
|
||
return file;
|
||
}
|
||
|
||
public void setFile(String file) {
|
||
this.file = file;
|
||
}
|
||
|
||
public boolean isFinished() {
|
||
return finished;
|
||
}
|
||
|
||
public void setFinished(boolean finished) {
|
||
this.finished = finished;
|
||
}
|
||
|
||
public int getRemind_type() {
|
||
return remind_type;
|
||
}
|
||
|
||
public void setRemind_type(int remind_type) {
|
||
this.remind_type = remind_type;
|
||
}
|
||
|
||
public int getIs_onoff() {
|
||
return is_onoff;
|
||
}
|
||
|
||
public void setIs_onoff(int is_onoff) {
|
||
this.is_onoff = is_onoff;
|
||
}
|
||
|
||
public long getTimeStamp() {
|
||
if (TextUtils.isEmpty(time)) {
|
||
return 0L;
|
||
}
|
||
if (time.length() == 5) {
|
||
String[] timeSplit = time.split(":");
|
||
int hour = Integer.parseInt(timeSplit[0]);
|
||
int minute = Integer.parseInt(timeSplit[1]);
|
||
Calendar c = Calendar.getInstance();
|
||
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH),
|
||
c.get(Calendar.DAY_OF_MONTH), hour, minute, 0);
|
||
long mTimeInfo = c.getTimeInMillis();
|
||
Log.e("AlarmClockData", "getTimeStamp: " + mTimeInfo);
|
||
long actualTime = mTimeInfo > System.currentTimeMillis() ? mTimeInfo : mTimeInfo + AlarmUtils.ONE_DAY_TIME;
|
||
return actualTime;
|
||
} else {
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
try {
|
||
Date date = simpleDateFormat.parse(time);
|
||
long timestamp = date.getTime();
|
||
return timestamp;
|
||
} catch (ParseException e) {
|
||
return System.currentTimeMillis();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
@NonNull
|
||
@Override
|
||
public String toString() {
|
||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||
}
|
||
|
||
@Override
|
||
public boolean equals(@Nullable Object obj) {
|
||
if (obj == null) return false;
|
||
if (!(obj instanceof AlarmClockData)) return false;
|
||
if (id != ((AlarmClockData) obj).id) return false;
|
||
if (type != ((AlarmClockData) obj).type) return false;
|
||
if (!time.equals(((AlarmClockData) obj).time)) return false;
|
||
if (!title.equals(((AlarmClockData) obj).title)) return false;
|
||
if (!voice.equals(((AlarmClockData) obj).voice)) return false;
|
||
if (!voice_md5.equals(((AlarmClockData) obj).voice_md5)) return false;
|
||
if (!file.equals(((AlarmClockData) obj).file)) return false;
|
||
if (remind_type != ((AlarmClockData) obj).remind_type) return false;
|
||
if (is_onoff != ((AlarmClockData) obj).is_onoff) return false;
|
||
|
||
return true;
|
||
}
|
||
}
|