version:
fix: update:优化类名,准备修复闹钟问题
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,4 +16,3 @@
|
|||||||
/app/src/test/java/com/uiui/os/
|
/app/src/test/java/com/uiui/os/
|
||||||
/.idea/
|
/.idea/
|
||||||
/app/proguardbuild/
|
/app/proguardbuild/
|
||||||
/dependencies.txt
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId "com.xxpatx.os"
|
applicationId "com.xxpatx.os"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1016
|
versionCode 1017
|
||||||
versionName "1.1.5"
|
versionName "1.1.6"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -199,22 +199,18 @@
|
|||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/activity_styles" />
|
android:theme="@style/FloatingWindow" />
|
||||||
<activity android:name=".activity.APPListActivity" />
|
<activity android:name=".activity.APPListActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.alarm.port.PortAlarmActivity"
|
android:name=".activity.alarm.list.AlarmListActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.alarmclock.main.AlarmClockActivity"
|
android:name=".activity.alarm.add.AlarmAddActivity"
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppWhiteTheme" />
|
|
||||||
<activity
|
|
||||||
android:name=".activity.alarmclock.add.port.PortAlarmClockAddActivity"
|
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.alarmclock.edit.AlarmClockEditActivity"
|
android:name=".activity.alarm.edit.AlarmEditActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
package com.uiui.video.bean;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public class VideoInfo implements Serializable, Parcelable {
|
|
||||||
private static final long serialVersionUID = -6934564449880301237L;
|
|
||||||
|
|
||||||
int id;
|
|
||||||
@SerializedName(value = "type_name", alternate = {"liven_type_name", "knowledge_type_name"})
|
|
||||||
String type_name;//分类名
|
|
||||||
String name;//视频名称
|
|
||||||
String remarks;//简介
|
|
||||||
String video_file;
|
|
||||||
String video_cover;
|
|
||||||
double video_duration; //时长 单位秒
|
|
||||||
long video_size;//大小 单位字节
|
|
||||||
@SerializedName("weigh")
|
|
||||||
int weight;//权重
|
|
||||||
int play_count;//播放次数
|
|
||||||
|
|
||||||
protected VideoInfo(Parcel in) {
|
|
||||||
id = in.readInt();
|
|
||||||
type_name = in.readString();
|
|
||||||
name = in.readString();
|
|
||||||
remarks = in.readString();
|
|
||||||
video_file = in.readString();
|
|
||||||
video_cover = in.readString();
|
|
||||||
video_duration = in.readDouble();
|
|
||||||
video_size = in.readLong();
|
|
||||||
weight = in.readInt();
|
|
||||||
play_count = in.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeInt(id);
|
|
||||||
dest.writeString(type_name);
|
|
||||||
dest.writeString(name);
|
|
||||||
dest.writeString(remarks);
|
|
||||||
dest.writeString(video_file);
|
|
||||||
dest.writeString(video_cover);
|
|
||||||
dest.writeDouble(video_duration);
|
|
||||||
dest.writeLong(video_size);
|
|
||||||
dest.writeInt(weight);
|
|
||||||
dest.writeInt(play_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<VideoInfo> CREATOR = new Creator<VideoInfo>() {
|
|
||||||
@Override
|
|
||||||
public VideoInfo createFromParcel(Parcel in) {
|
|
||||||
return new VideoInfo(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VideoInfo[] newArray(int size) {
|
|
||||||
return new VideoInfo[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType_name() {
|
|
||||||
return type_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType_name(String type_name) {
|
|
||||||
this.type_name = type_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemarks() {
|
|
||||||
return remarks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemarks(String remarks) {
|
|
||||||
this.remarks = remarks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVideo_file() {
|
|
||||||
return video_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideo_file(String video_file) {
|
|
||||||
this.video_file = video_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVideo_cover() {
|
|
||||||
return video_cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideo_cover(String video_cover) {
|
|
||||||
this.video_cover = video_cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getVideo_duration() {
|
|
||||||
return video_duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideo_duration(double video_duration) {
|
|
||||||
this.video_duration = video_duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getVideo_size() {
|
|
||||||
return video_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideo_size(long video_size) {
|
|
||||||
this.video_size = video_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWeight() {
|
|
||||||
return weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWeight(int weight) {
|
|
||||||
this.weight = weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlay_count() {
|
|
||||||
return play_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlay_count(int play_count) {
|
|
||||||
this.play_count = play_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.add.port;
|
package com.xxpatx.os.activity.alarm.add;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
@@ -25,15 +24,13 @@ import com.xxpatx.os.alarm.AlarmClockData;
|
|||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
import com.xxpatx.os.alarm.AlarmUtils;
|
||||||
import com.xxpatx.os.base.GlideEngine;
|
import com.xxpatx.os.base.GlideEngine;
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.xxpatx.os.databinding.ActivityAddAlarmPortBinding;
|
import com.xxpatx.os.databinding.ActivityAlarmAddBinding;
|
||||||
import com.xxpatx.os.service.main.MainService;
|
import com.xxpatx.os.service.main.MainService;
|
||||||
import com.xxpatx.os.utils.FFmpegUtils;
|
import com.xxpatx.os.utils.FFmpegUtils;
|
||||||
import com.xxpatx.os.utils.FileUtil;
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
import com.xxpatx.os.utils.ScreenUtil;
|
import com.xxpatx.os.utils.ScreenUtil;
|
||||||
import com.xxpatx.os.utils.TimeUtils;
|
import com.xxpatx.os.utils.TimeUtils;
|
||||||
|
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -45,8 +42,8 @@ import io.reactivex.rxjava3.annotations.NonNull;
|
|||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAddViewModel, ActivityAddAlarmPortBinding> {
|
public class AlarmAddActivity extends BaseMvvmActivity<AlarmAddViewModel, ActivityAlarmAddBinding> {
|
||||||
private static final String TAG = "PortAlarmClockAddActivity";
|
private static final String TAG = "AlarmAddActivity";
|
||||||
|
|
||||||
private TimePickerView pvTime;
|
private TimePickerView pvTime;
|
||||||
|
|
||||||
@@ -68,7 +65,7 @@ public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return R.layout.activity_add_alarm_port;
|
return R.layout.activity_alarm_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,41 +108,6 @@ public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAd
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mViewDataBinding.rbAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 1;
|
|
||||||
mViewDataBinding.etActivation.setText("用药闹钟");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rbLook.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 2;
|
|
||||||
mViewDataBinding.etActivation.setText("接送闹钟");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rbReserve.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 3;
|
|
||||||
mViewDataBinding.etActivation.setText("预约闹钟");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -190,7 +152,7 @@ public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openSelector() {
|
private void openSelector() {
|
||||||
PictureSelector.create(PortAlarmClockAddActivity.this)
|
PictureSelector.create(AlarmAddActivity.this)
|
||||||
.openGallery(SelectMimeType.ofAll())
|
.openGallery(SelectMimeType.ofAll())
|
||||||
.setSelectionMode(1)
|
.setSelectionMode(1)
|
||||||
.setImageEngine(GlideEngine.createGlideEngine())
|
.setImageEngine(GlideEngine.createGlideEngine())
|
||||||
@@ -200,7 +162,7 @@ public class PortAlarmClockAddActivity extends BaseMvvmActivity<PortAlarmClockAd
|
|||||||
mPictrueFilePath = result.get(0).getRealPath();
|
mPictrueFilePath = result.get(0).getRealPath();
|
||||||
File file = new File(mPictrueFilePath);
|
File file = new File(mPictrueFilePath);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtil.dip2px(PortAlarmClockAddActivity.this, 8F)));
|
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtil.dip2px(AlarmAddActivity.this, 8F)));
|
||||||
Glide.with(mViewDataBinding.nvPic).load(file).apply(options).into(mViewDataBinding.nvPic);
|
Glide.with(mViewDataBinding.nvPic).load(file).apply(options).into(mViewDataBinding.nvPic);
|
||||||
mViewDataBinding.nvPic.setVisibility(View.VISIBLE);
|
mViewDataBinding.nvPic.setVisibility(View.VISIBLE);
|
||||||
mViewDataBinding.clPic.setVisibility(View.GONE);
|
mViewDataBinding.clPic.setVisibility(View.GONE);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xxpatx.os.activity.alarm.add;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||||
|
import com.xxpatx.os.databinding.ActivityAlarmAddBinding;
|
||||||
|
|
||||||
|
public class AlarmAddViewModel extends BaseViewModel<ActivityAlarmAddBinding, ActivityEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityAlarmAddBinding getVDBinding() {
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.edit;
|
package com.xxpatx.os.activity.alarm.edit;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
@@ -26,13 +26,14 @@ import com.luck.picture.lib.entity.LocalMedia;
|
|||||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
import com.xxpatx.os.alarm.AlarmClockData;
|
||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
import com.xxpatx.os.alarm.AlarmUtils;
|
||||||
import com.xxpatx.os.base.GlideEngine;
|
import com.xxpatx.os.base.GlideEngine;
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.databinding.ActivityAddAlarmBinding;
|
import com.xxpatx.os.databinding.ActivityAlarmEditBinding;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
import com.xxpatx.os.utils.FFmpegUtils;
|
import com.xxpatx.os.utils.FFmpegUtils;
|
||||||
import com.xxpatx.os.utils.FileUtil;
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
@@ -40,7 +41,6 @@ import com.xxpatx.os.utils.GlideLoadUtils;
|
|||||||
import com.xxpatx.os.utils.ScreenUtil;
|
import com.xxpatx.os.utils.ScreenUtil;
|
||||||
import com.xxpatx.os.utils.TimeUtils;
|
import com.xxpatx.os.utils.TimeUtils;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -57,8 +57,8 @@ import okhttp3.MediaType;
|
|||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewModel, ActivityAddAlarmBinding> {
|
public class AlarmEditActivity extends BaseMvvmActivity<AlarmEditViewModel, ActivityAlarmEditBinding> {
|
||||||
private static final String TAG = "AlarmClockEditActivity";
|
private static final String TAG = "AlarmEditActivity";
|
||||||
|
|
||||||
private LoadingDialog mLoadingDialog;
|
private LoadingDialog mLoadingDialog;
|
||||||
private PopupWindow mMenuPopupWindow;
|
private PopupWindow mMenuPopupWindow;
|
||||||
@@ -74,9 +74,19 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
private AlarmClockData mAlarmClockData;
|
private AlarmClockData mAlarmClockData;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setNightMode() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setfitWindow() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
return R.layout.activity_add_alarm;
|
return R.layout.activity_alarm_edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,38 +94,13 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
mViewModel.setCtx(this);
|
mViewModel.setCtx(this);
|
||||||
mViewModel.setVDBinding(mViewDataBinding);
|
mViewModel.setVDBinding(mViewDataBinding);
|
||||||
mViewModel.setLifecycle(getLifecycleSubject());
|
mViewModel.setLifecycle(getLifecycleSubject());
|
||||||
// mViewDataBinding.setClick(new BtnClick());
|
mViewDataBinding.setClick(new Click());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initView() {
|
public void initView() {
|
||||||
// tv_title.setText("编辑闹钟");
|
|
||||||
initTimePicker();
|
initTimePicker();
|
||||||
|
|
||||||
mViewDataBinding.clPic.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
openSelector();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.clType.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
// showTimeFilterWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.nvPic.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
openSelector();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.ivBack.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
mViewDataBinding.rb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
@@ -142,43 +127,6 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mViewDataBinding.rbAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 1;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rbLook.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 2;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rbReserve.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
mClockType = 3;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.ivAdd.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
checkContent();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,7 +234,7 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
String fileUrl = alarmClockData.getFile();
|
String fileUrl = alarmClockData.getFile();
|
||||||
mPictrueFilePath = fileUrl;
|
mPictrueFilePath = fileUrl;
|
||||||
String fileName = Utils.getFileNamefromURL(fileUrl);
|
String fileName = Utils.getFileNamefromURL(fileUrl);
|
||||||
File file = new File(Utils.getDownLoadPath(AlarmClockEditActivity.this) + fileName);
|
File file = new File(Utils.getDownLoadPath(AlarmEditActivity.this) + fileName);
|
||||||
if (TextUtils.isEmpty(fileUrl)) {
|
if (TextUtils.isEmpty(fileUrl)) {
|
||||||
mViewDataBinding.clPic.setVisibility(View.VISIBLE);
|
mViewDataBinding.clPic.setVisibility(View.VISIBLE);
|
||||||
mViewDataBinding.nvPic.setVisibility(View.GONE);
|
mViewDataBinding.nvPic.setVisibility(View.GONE);
|
||||||
@@ -376,7 +324,7 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e("checkContent", "onSubscribe: ");
|
Log.e("checkContent", "onSubscribe: ");
|
||||||
Toaster.show("正在上传");
|
Toaster.show("正在上传");
|
||||||
mViewDataBinding.ivAdd.setEnabled(false);
|
mViewDataBinding.tvAdd.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -406,7 +354,7 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("checkContent", "onComplete: ");
|
Log.e("checkContent", "onComplete: ");
|
||||||
mViewDataBinding.ivAdd.setEnabled(true);
|
mViewDataBinding.tvAdd.setEnabled(true);
|
||||||
finish();
|
finish();
|
||||||
mLoadingDialog.close();
|
mLoadingDialog.close();
|
||||||
}
|
}
|
||||||
@@ -469,7 +417,7 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openSelector() {
|
private void openSelector() {
|
||||||
PictureSelector.create(AlarmClockEditActivity.this)
|
PictureSelector.create(AlarmEditActivity.this)
|
||||||
.openGallery(SelectMimeType.ofAll())
|
.openGallery(SelectMimeType.ofAll())
|
||||||
.setSelectionMode(1)
|
.setSelectionMode(1)
|
||||||
.setImageEngine(GlideEngine.createGlideEngine())
|
.setImageEngine(GlideEngine.createGlideEngine())
|
||||||
@@ -479,7 +427,7 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
mPictrueFilePath = result.get(0).getRealPath();
|
mPictrueFilePath = result.get(0).getRealPath();
|
||||||
File file = new File(mPictrueFilePath);
|
File file = new File(mPictrueFilePath);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtil.dip2px(AlarmClockEditActivity.this, 8F)));
|
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtil.dip2px(AlarmEditActivity.this, 8F)));
|
||||||
Glide.with(mViewDataBinding.nvPic).load(file).apply(options).into(mViewDataBinding.nvPic);
|
Glide.with(mViewDataBinding.nvPic).load(file).apply(options).into(mViewDataBinding.nvPic);
|
||||||
mViewDataBinding.nvPic.setVisibility(View.VISIBLE);
|
mViewDataBinding.nvPic.setVisibility(View.VISIBLE);
|
||||||
mViewDataBinding.clPic.setVisibility(View.GONE);
|
mViewDataBinding.clPic.setVisibility(View.GONE);
|
||||||
@@ -593,4 +541,19 @@ public class AlarmClockEditActivity extends BaseMvvmActivity<AlarmClockEditViewM
|
|||||||
return calendar;
|
return calendar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Click {
|
||||||
|
public void exit(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openGallery(View view) {
|
||||||
|
openSelector();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submit(View view) {
|
||||||
|
checkContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xxpatx.os.activity.alarm.edit;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||||
|
import com.xxpatx.os.databinding.ActivityAlarmEditBinding;
|
||||||
|
|
||||||
|
public class AlarmEditViewModel extends BaseViewModel<ActivityAlarmEditBinding, ActivityEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityAlarmEditBinding getVDBinding() {
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.xxpatx.os.activity.alarm.port;
|
package com.xxpatx.os.activity.alarm.list;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -13,29 +13,28 @@ import com.tencent.mmkv.MMKV;
|
|||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.activity.alarmclock.add.port.PortAlarmClockAddActivity;
|
import com.xxpatx.os.activity.alarm.add.AlarmAddActivity;
|
||||||
|
import com.xxpatx.os.alarm.AlarmAdapter;
|
||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
import com.xxpatx.os.alarm.AlarmClockData;
|
||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
import com.xxpatx.os.alarm.AlarmUtils;
|
||||||
import com.xxpatx.os.alarm.PortAlarmAdapter;
|
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
import com.xxpatx.os.databinding.ActivityAlarmPortBinding;
|
import com.xxpatx.os.databinding.ActivityAlarmListBinding;
|
||||||
import com.xxpatx.os.dialog.DeleteDialog;
|
import com.xxpatx.os.dialog.DeleteDialog;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, ActivityAlarmPortBinding> {
|
public class AlarmListActivity extends BaseMvvmActivity<AlarmListViewModel, ActivityAlarmListBinding> {
|
||||||
private static final String TAG = "PortAlarmActivity";
|
private static final String TAG = "AlarmListActivity";
|
||||||
|
|
||||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||||
|
|
||||||
private PortAlarmAdapter mAlarmAdapter;
|
private AlarmAdapter mAlarmAdapter;
|
||||||
private int mType = 0;
|
private int mType = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,7 +52,7 @@ public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, Acti
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return R.layout.activity_alarm_port;
|
return R.layout.activity_alarm_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,8 +69,8 @@ public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, Acti
|
|||||||
@Override
|
@Override
|
||||||
public void initView() {
|
public void initView() {
|
||||||
|
|
||||||
mAlarmAdapter = new PortAlarmAdapter();
|
mAlarmAdapter = new AlarmAdapter();
|
||||||
mAlarmAdapter.setOnLongClickListener(new PortAlarmAdapter.OnLongClickListener() {
|
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLongClick(AlarmClockData alarmClockData) {
|
public void onLongClick(AlarmClockData alarmClockData) {
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
||||||
@@ -82,7 +81,7 @@ public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, Acti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mViewDataBinding.rvData.setLayoutManager(new LinearLayoutManager(PortAlarmActivity.this));
|
mViewDataBinding.rvData.setLayoutManager(new LinearLayoutManager(AlarmListActivity.this));
|
||||||
mViewDataBinding.rvData.setAdapter(mAlarmAdapter);
|
mViewDataBinding.rvData.setAdapter(mAlarmAdapter);
|
||||||
mViewDataBinding.rvData.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
mViewDataBinding.rvData.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -225,7 +224,7 @@ public class PortAlarmActivity extends BaseMvvmActivity<PortAlarmViewModel, Acti
|
|||||||
if (clockModify) {
|
if (clockModify) {
|
||||||
Toaster.showLong("已禁用闹钟修改");
|
Toaster.showLong("已禁用闹钟修改");
|
||||||
} else {
|
} else {
|
||||||
startActivity(new Intent(PortAlarmActivity.this, PortAlarmClockAddActivity.class));
|
startActivity(new Intent(AlarmListActivity.this, AlarmAddActivity.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.xxpatx.os.activity.alarm.port;
|
package com.xxpatx.os.activity.alarm.list;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import com.trello.rxlifecycle4.android.ActivityEvent;
|
|||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
import com.xxpatx.os.alarm.AlarmClockData;
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.databinding.ActivityAlarmPortBinding;
|
import com.xxpatx.os.databinding.ActivityAlarmListBinding;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,12 +18,12 @@ import io.reactivex.rxjava3.annotations.NonNull;
|
|||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
public class PortAlarmViewModel extends BaseViewModel<ActivityAlarmPortBinding, ActivityEvent> {
|
public class AlarmListViewModel extends BaseViewModel<ActivityAlarmListBinding, ActivityEvent> {
|
||||||
|
|
||||||
private static final String TAG = "PortAlarmViewModel";
|
private static final String TAG = "AlarmListViewModel";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityAlarmPortBinding getVDBinding() {
|
public ActivityAlarmListBinding getVDBinding() {
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.add.port;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
|
||||||
import com.xxpatx.os.databinding.ActivityAddAlarmPortBinding;
|
|
||||||
|
|
||||||
public class PortAlarmClockAddViewModel extends BaseViewModel<ActivityAddAlarmPortBinding, ActivityEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityAddAlarmPortBinding getVDBinding() {
|
|
||||||
return binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.edit;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
|
||||||
import com.xxpatx.os.databinding.ActivityAddAlarmBinding;
|
|
||||||
|
|
||||||
public class AlarmClockEditViewModel extends BaseViewModel<ActivityAddAlarmBinding, ActivityEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityAddAlarmBinding getVDBinding() {
|
|
||||||
return binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.main;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
|
|
||||||
import com.hjq.toast.Toaster;
|
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
|
||||||
import com.xxpatx.os.R;
|
|
||||||
import com.xxpatx.os.alarm.AlarmAdapter;
|
|
||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
|
||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
|
||||||
import com.xxpatx.os.databinding.ActivityAlarmBinding;
|
|
||||||
import com.xxpatx.os.dialog.DeleteDialog;
|
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
|
||||||
import com.xxpatx.os.push.PushManager;
|
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
||||||
|
|
||||||
import cn.jzvd.Jzvd;
|
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
|
||||||
|
|
||||||
public class AlarmClockActivity extends BaseMvvmActivity<AlarmClockViewModel, ActivityAlarmBinding> {
|
|
||||||
private static final String TAG = "AlarmClockActivity";
|
|
||||||
|
|
||||||
private AlarmAdapter mAlarmAdapter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutId() {
|
|
||||||
return R.layout.activity_alarm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initDataBinding() {
|
|
||||||
mViewModel.setCtx(this);
|
|
||||||
mViewModel.setVDBinding(mViewDataBinding);
|
|
||||||
mViewModel.setLifecycle(getLifecycleSubject());
|
|
||||||
mViewDataBinding.setClick(new BtnClick());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initView() {
|
|
||||||
UltimateBarX.statusBarOnly(this)
|
|
||||||
.colorRes(R.color.default_blue)
|
|
||||||
.fitWindow(true)
|
|
||||||
.apply();
|
|
||||||
|
|
||||||
mAlarmAdapter = new AlarmAdapter();
|
|
||||||
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onLongClick(AlarmClockData alarmClockData) {
|
|
||||||
showDialog(alarmClockData);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mViewDataBinding.rvData.setLayoutManager(new LinearLayoutManager(AlarmClockActivity.this));
|
|
||||||
mViewDataBinding.rvData.setAdapter(mAlarmAdapter);
|
|
||||||
mViewDataBinding.ivBack.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// mViewDataBinding.swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onRefresh() {
|
|
||||||
// mViewModel.getAlarmClock();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// mViewDataBinding.fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View view) {
|
|
||||||
// startActivity(new Intent(AlarmClockActivity.this, AlarmClockAddActivity.class));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showDialog(AlarmClockData alarmClockData) {
|
|
||||||
DeleteDialog dialog = new DeleteDialog(this);
|
|
||||||
dialog.setTitle("提醒")
|
|
||||||
.setMessage("是否要删除本次闹钟")
|
|
||||||
.setPositive("确定")
|
|
||||||
.setNegtive("取消")
|
|
||||||
.setOnClickBottomListener(new DeleteDialog.OnClickBottomListener() {
|
|
||||||
@Override
|
|
||||||
public void onPositiveClick() {
|
|
||||||
deleteAlarm(alarmClockData);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNegtiveClick() {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteAlarm(AlarmClockData alarmClockData) {
|
|
||||||
if (alarmClockData.isIs_local()) {
|
|
||||||
alarmClockData.setDeleted(true);
|
|
||||||
AlarmUtils.getInstance().deleteAlarmClock(alarmClockData);
|
|
||||||
} else {
|
|
||||||
NetInterfaceManager.getInstance().deleteAlarmClockObservable(alarmClockData.getId())
|
|
||||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
Log.e("deleteAlarm", "onSubscribe: ");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
|
||||||
Log.e("deleteAlarm", "onNext: " + baseResponse);
|
|
||||||
if (baseResponse.code == 200) {
|
|
||||||
AlarmUtils.getInstance().deleteAlarmClock(alarmClockData);
|
|
||||||
Toaster.show("删除成功");
|
|
||||||
} else {
|
|
||||||
Toaster.show("删除失败:" + baseResponse.msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
Log.e("deleteAlarm", "onError: " + e.getMessage());
|
|
||||||
alarmClockData.setDeleted(true);
|
|
||||||
AlarmUtils.getInstance().updateAlarmClock(alarmClockData);
|
|
||||||
onComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("deleteAlarm", "onComplete: ");
|
|
||||||
mViewModel.getAlarmClock();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData() {
|
|
||||||
registerAlarmClockReceiver();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void showAlarmClock(List<AlarmClockData> alarmClockData) {
|
|
||||||
// mAlarmAdapter.setAlarmClockData(alarmClockData);
|
|
||||||
//// mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
|
||||||
// mViewDataBinding.clNodata.setVisibility(View.GONE);
|
|
||||||
// mViewDataBinding.rvData.setVisibility(View.VISIBLE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setAlarmClockEmpty() {
|
|
||||||
// mAlarmAdapter.setAlarmClockData(null);
|
|
||||||
//// mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
|
||||||
// mViewDataBinding.clNodata.setVisibility(View.VISIBLE);
|
|
||||||
// mViewDataBinding.rvData.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError() {
|
|
||||||
//// mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
Jzvd.releaseAllVideos();
|
|
||||||
if (mAlarmClockReceiver != null) {
|
|
||||||
unregisterReceiver(mAlarmClockReceiver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mViewModel.getAlarmClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerAlarmClockReceiver() {
|
|
||||||
if (null == mAlarmClockReceiver) {
|
|
||||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
|
||||||
}
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
|
||||||
filter.addAction(PushManager.SET_ALARMCLOCK);
|
|
||||||
registerReceiver(mAlarmClockReceiver, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AlarmClockReceiver mAlarmClockReceiver;
|
|
||||||
|
|
||||||
private class AlarmClockReceiver extends BroadcastReceiver {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
Log.e(TAG, "onReceive: " + action);
|
|
||||||
if (PushManager.SET_ALARMCLOCK.equals(action)) {
|
|
||||||
mViewModel.getAlarmClock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BtnClick {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.xxpatx.os.activity.alarmclock.main;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
|
||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
|
||||||
import com.xxpatx.os.databinding.ActivityAlarmBinding;
|
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AlarmClockViewModel extends BaseViewModel<ActivityAlarmBinding, ActivityEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityAlarmBinding getVDBinding() {
|
|
||||||
return binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void getAlarmClock() {
|
|
||||||
NetInterfaceManager.getInstance().getAlarmClock(true, getLifecycle(), new NetInterfaceManager.AlarmClockCallback() {
|
|
||||||
@Override
|
|
||||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
|
||||||
// mView.showAlarmClock(alarmClockList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAlarmClockEmpty() {
|
|
||||||
// mView.setAlarmClockEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError() {
|
|
||||||
// mView.onError();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,6 +24,7 @@ import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
|||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.databinding.ActivityAddContactBinding;
|
import com.xxpatx.os.databinding.ActivityAddContactBinding;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
import com.xxpatx.os.utils.GlideLoadUtils;
|
import com.xxpatx.os.utils.GlideLoadUtils;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
|
|
||||||
@@ -40,6 +41,8 @@ import okhttp3.MediaType;
|
|||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
import static com.xxpatx.os.utils.FileUtil.uriToFile;
|
||||||
|
|
||||||
public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, ActivityAddContactBinding> {
|
public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, ActivityAddContactBinding> {
|
||||||
private static final String TAG = "AddContactActivity";
|
private static final String TAG = "AddContactActivity";
|
||||||
|
|
||||||
@@ -108,7 +111,7 @@ public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, Ac
|
|||||||
File avatarFile;
|
File avatarFile;
|
||||||
Log.e("checkContact", "avatarFilePath: " + avatarFilePath);
|
Log.e("checkContact", "avatarFilePath: " + avatarFilePath);
|
||||||
if (TextUtils.isEmpty(avatarFilePath)) {
|
if (TextUtils.isEmpty(avatarFilePath)) {
|
||||||
avatarFile = drawableToFile(R.drawable.default_avatar, "avatar");
|
avatarFile = FileUtil.drawableToFile(AddContactActivity.this, R.drawable.default_avatar, "avatar");
|
||||||
} else {
|
} else {
|
||||||
Uri uri = Uri.parse(avatarFilePath);
|
Uri uri = Uri.parse(avatarFilePath);
|
||||||
avatarFile = uriToFile(uri, AddContactActivity.this);
|
avatarFile = uriToFile(uri, AddContactActivity.this);
|
||||||
@@ -154,83 +157,6 @@ public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, Ac
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* drawable转为file
|
|
||||||
*
|
|
||||||
* @param drawableId drawable的ID
|
|
||||||
* @param fileName 转换后的文件名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public File drawableToFile(int drawableId, String fileName) {
|
|
||||||
// InputStream is = view.getContext().getResources().openRawResource(R.drawable.logo);
|
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
||||||
// Bitmap bitmap = BitmapFactory.decodeStream(is);
|
|
||||||
String defaultPath = getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
|
||||||
File file = new File(defaultPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
String defaultImgPath = defaultPath + "/" + fileName;
|
|
||||||
file = new File(defaultImgPath);
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
FileOutputStream fOut = new FileOutputStream(file);
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 20, fOut);
|
|
||||||
// is.close();
|
|
||||||
fOut.flush();
|
|
||||||
fOut.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File uriToFile(Uri uri, Context context) {
|
|
||||||
String path = null;
|
|
||||||
if ("file".equals(uri.getScheme())) {
|
|
||||||
path = uri.getEncodedPath();
|
|
||||||
if (path != null) {
|
|
||||||
path = Uri.decode(path);
|
|
||||||
ContentResolver cr = context.getContentResolver();
|
|
||||||
StringBuffer buff = new StringBuffer();
|
|
||||||
buff.append("(").append(MediaStore.Images.ImageColumns.DATA).append("=").append("'" + path + "'").append(")");
|
|
||||||
Cursor cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA}, buff.toString(), null, null);
|
|
||||||
int index = 0;
|
|
||||||
int dataIdx = 0;
|
|
||||||
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
|
||||||
index = cur.getColumnIndex(MediaStore.Images.ImageColumns._ID);
|
|
||||||
index = cur.getInt(index);
|
|
||||||
dataIdx = cur.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
|
|
||||||
path = cur.getString(dataIdx);
|
|
||||||
}
|
|
||||||
cur.close();
|
|
||||||
if (index == 0) {
|
|
||||||
} else {
|
|
||||||
Uri u = Uri.parse("content://media/external/images/media/" + index);
|
|
||||||
System.out.println("temp uri is :" + u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (path != null) {
|
|
||||||
return new File(path);
|
|
||||||
}
|
|
||||||
} else if ("content".equals(uri.getScheme())) {
|
|
||||||
// 4.2.2以后
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
path = cursor.getString(columnIndex);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
return new File(path);
|
|
||||||
} else {
|
|
||||||
//Log.i(TAG, "Uri Scheme:" + uri.getScheme());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class BtnClick {
|
public class BtnClick {
|
||||||
public void exit(View view) {
|
public void exit(View view) {
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -3,13 +3,8 @@ package com.xxpatx.os.activity.contact;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -28,20 +23,13 @@ import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
|||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.base.GlideEngine;
|
import com.xxpatx.os.base.GlideEngine;
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.databinding.ActivityAddWechatContactBinding;
|
import com.xxpatx.os.databinding.ActivityAddWechatContactBinding;
|
||||||
|
import com.xxpatx.os.db.ContactCacheUtils;
|
||||||
import com.xxpatx.os.utils.ScreenUtil;
|
import com.xxpatx.os.utils.ScreenUtil;
|
||||||
import com.xxpatx.os.utils.Utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.MultipartBody;
|
|
||||||
import okhttp3.RequestBody;
|
|
||||||
|
|
||||||
public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactViewModel, ActivityAddWechatContactBinding> {
|
public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactViewModel, ActivityAddWechatContactBinding> {
|
||||||
private static final String TAG = "AddWechatContactActivity";
|
private static final String TAG = "AddWechatContactActivity";
|
||||||
@@ -86,22 +74,38 @@ public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactV
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
mViewModel.getBaseResponseMutableLiveData().observe(this, new Observer<BaseResponse>() {
|
mViewModel.getAddData().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(BaseResponse baseResponse) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
if (baseResponse.code == 200) {
|
if (aBoolean) {
|
||||||
mLoadingDialog.loadSuccess();
|
mLoadingDialog.loadSuccess();
|
||||||
mLoadingDialog.close();
|
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
mLoadingDialog.setFailedText(baseResponse.msg);
|
|
||||||
mLoadingDialog.loadFailed();
|
mLoadingDialog.loadFailed();
|
||||||
mLoadingDialog.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mViewModel.getContactData().observe(this, new Observer<Contact>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Contact contact) {
|
||||||
|
ContactCacheUtils.getInstance().addContact(contact);
|
||||||
|
Toaster.showLong("已保存至本地");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mLoadingDialog.close();
|
||||||
|
mLoadingDialog = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
private void openSelector() {
|
private void openSelector() {
|
||||||
PictureSelector.create(AddWechatContactActivity.this)
|
PictureSelector.create(AddWechatContactActivity.this)
|
||||||
@@ -128,125 +132,6 @@ public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactV
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkContact() {
|
|
||||||
String name = mViewDataBinding.etName.getText().toString();
|
|
||||||
if (TextUtils.isEmpty(name)) {
|
|
||||||
Toaster.show("请输入联系人姓名");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String phone = mViewDataBinding.etPhone.getText().toString();
|
|
||||||
if (TextUtils.isEmpty(phone)) {
|
|
||||||
Toaster.show("请输入手机号码");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String groupTag = mViewDataBinding.etGroup.getText().toString();
|
|
||||||
if (TextUtils.isEmpty(groupTag)) {
|
|
||||||
Toaster.show("请输入微信群组标签");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mViewDataBinding.tbSim.isToggleOn() == 1) {
|
|
||||||
createContact(name, phone);
|
|
||||||
} else {
|
|
||||||
File avatarFile;
|
|
||||||
Log.e("checkContact", "mPictrueFilePath: " + mPictrueFilePath);
|
|
||||||
if (TextUtils.isEmpty(mPictrueFilePath)) {
|
|
||||||
avatarFile = drawableToFile(R.drawable.default_avatar, "avatar");
|
|
||||||
} else {
|
|
||||||
Uri uri = Uri.parse(mPictrueFilePath);
|
|
||||||
avatarFile = uriToFile(uri, AddWechatContactActivity.this);
|
|
||||||
}
|
|
||||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
|
||||||
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
|
||||||
MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody);
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("sn", Utils.getSerial());
|
|
||||||
params.put("name", name);
|
|
||||||
params.put("mobile", phone);
|
|
||||||
params.put("tag", groupTag);
|
|
||||||
params.put("is_urgent", String.valueOf(mViewDataBinding.toggleButton.isToggleOn()));
|
|
||||||
mViewModel.addContact(params, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLoadingDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* drawable转为file
|
|
||||||
*
|
|
||||||
* @param drawableId drawable的ID
|
|
||||||
* @param fileName 转换后的文件名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public File drawableToFile(int drawableId, String fileName) {
|
|
||||||
// InputStream is = view.getContext().getResources().openRawResource(R.drawable.logo);
|
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
||||||
// Bitmap bitmap = BitmapFactory.decodeStream(is);
|
|
||||||
String defaultPath = getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
|
||||||
File file = new File(defaultPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
String defaultImgPath = defaultPath + "/" + fileName;
|
|
||||||
file = new File(defaultImgPath);
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
FileOutputStream fOut = new FileOutputStream(file);
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
|
||||||
// is.close();
|
|
||||||
fOut.flush();
|
|
||||||
fOut.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File uriToFile(Uri uri, Context context) {
|
|
||||||
String path = null;
|
|
||||||
if ("file".equals(uri.getScheme())) {
|
|
||||||
path = uri.getEncodedPath();
|
|
||||||
if (path != null) {
|
|
||||||
path = Uri.decode(path);
|
|
||||||
ContentResolver cr = context.getContentResolver();
|
|
||||||
StringBuffer buff = new StringBuffer();
|
|
||||||
buff.append("(").append(MediaStore.Images.ImageColumns.DATA).append("=").append("'" + path + "'").append(")");
|
|
||||||
Cursor cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA}, buff.toString(), null, null);
|
|
||||||
int index = 0;
|
|
||||||
int dataIdx = 0;
|
|
||||||
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
|
||||||
index = cur.getColumnIndex(MediaStore.Images.ImageColumns._ID);
|
|
||||||
index = cur.getInt(index);
|
|
||||||
dataIdx = cur.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
|
|
||||||
path = cur.getString(dataIdx);
|
|
||||||
}
|
|
||||||
cur.close();
|
|
||||||
if (index == 0) {
|
|
||||||
} else {
|
|
||||||
Uri u = Uri.parse("content://media/external/images/media/" + index);
|
|
||||||
System.out.println("temp uri is :" + u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (path != null) {
|
|
||||||
return new File(path);
|
|
||||||
}
|
|
||||||
} else if ("content".equals(uri.getScheme())) {
|
|
||||||
// 4.2.2以后
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
path = cursor.getString(columnIndex);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
return new File(path);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "uriToFile uriString:" + uri.toString());
|
|
||||||
return new File(uri.toString());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAddContacts() {
|
public void testAddContacts() {
|
||||||
//插入raw_contacts表,并获取_id属性
|
//插入raw_contacts表,并获取_id属性
|
||||||
Uri uri = Uri.parse("content://icc/adn");
|
Uri uri = Uri.parse("content://icc/adn");
|
||||||
@@ -283,7 +168,6 @@ public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactV
|
|||||||
values.put("tag", name);
|
values.put("tag", name);
|
||||||
values.put("number", phoneNumber);
|
values.put("number", phoneNumber);
|
||||||
getContentResolver().insert(simUri, values);
|
getContentResolver().insert(simUri, values);
|
||||||
mLoadingDialog.close();
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +182,20 @@ public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactV
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addContact(View view) {
|
public void addContact(View view) {
|
||||||
checkContact();
|
String name = mViewDataBinding.etName.getText().toString();
|
||||||
|
if (TextUtils.isEmpty(name)) {
|
||||||
|
Toaster.show("请输入联系人姓名");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String phone = mViewDataBinding.etPhone.getText().toString();
|
||||||
|
if (TextUtils.isEmpty(phone)) {
|
||||||
|
Toaster.show("请输入手机号码");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.e("checkContact", "avatarFilePath: " + mViewModel.avatarFilePath);
|
||||||
|
mLoadingDialog.setLoadingText("正在上传");
|
||||||
|
mLoadingDialog.show();
|
||||||
|
mViewModel.checkContact();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,41 @@
|
|||||||
package com.xxpatx.os.activity.contact;
|
package com.xxpatx.os.activity.contact;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import com.hjq.toast.Toaster;
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.databinding.ActivityAddWechatContactBinding;
|
import com.xxpatx.os.databinding.ActivityAddWechatContactBinding;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
|
import com.xxpatx.os.utils.Utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
import io.reactivex.rxjava3.annotations.NonNull;
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
import okhttp3.MediaType;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
public class AddWechatContactViewModel extends BaseViewModel<ActivityAddWechatContactBinding, ActivityEvent> {
|
public class AddWechatContactViewModel extends BaseViewModel<ActivityAddWechatContactBinding, ActivityEvent> {
|
||||||
|
private static final String TAG = "AddWechatContactViewModel";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityAddWechatContactBinding getVDBinding() {
|
public ActivityAddWechatContactBinding getVDBinding() {
|
||||||
return binding;
|
return binding;
|
||||||
@@ -29,41 +46,99 @@ public class AddWechatContactViewModel extends BaseViewModel<ActivityAddWechatCo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MutableLiveData<BaseResponse> mBaseResponseMutableLiveData = new MutableLiveData<>();
|
public String avatarFilePath = "";
|
||||||
|
|
||||||
public MutableLiveData<BaseResponse> getBaseResponseMutableLiveData() {
|
private MutableLiveData<Boolean> mAddData = new MutableLiveData<>();
|
||||||
return mBaseResponseMutableLiveData;
|
|
||||||
|
public MutableLiveData<Boolean> getAddData() {
|
||||||
|
return mAddData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addContact(Map<String, String> params, MultipartBody.Part body) {
|
private MutableLiveData<Contact> mContactData = new MutableLiveData<>();
|
||||||
|
|
||||||
|
public MutableLiveData<Contact> getContactData() {
|
||||||
|
return mContactData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkContact() {
|
||||||
|
String name = binding.etName.getText().toString();
|
||||||
|
String phone = binding.etPhone.getText().toString();
|
||||||
|
String tag = binding.etTag.getText().toString();
|
||||||
|
File avatarFile;
|
||||||
|
Log.e("checkContact", "avatarFilePath: " + avatarFilePath);
|
||||||
|
if (TextUtils.isEmpty(avatarFilePath)) {
|
||||||
|
avatarFile = FileUtil.drawableToFile(getCtx(), R.drawable.default_avatar, "avatar");
|
||||||
|
} else {
|
||||||
|
Uri uri = Uri.parse(avatarFilePath);
|
||||||
|
avatarFile = FileUtil.uriToFile(uri, getCtx());
|
||||||
|
}
|
||||||
|
if (avatarFile == null) {
|
||||||
|
Toaster.showShort("图片加载失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
|
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
||||||
|
MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody);
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("sn", Utils.getSerial());
|
||||||
|
params.put("name", name);
|
||||||
|
params.put("mobile", phone);
|
||||||
|
params.put("tag", tag);
|
||||||
|
params.put("is_urgent", String.valueOf(binding.toggleButton.isToggleOn()));
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getMailListAddObservable(params, body)
|
.getMailListAddObservable(params, body)
|
||||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e("addContact", "onSubscribe: ");
|
Log.e("checkContact", "onSubscribe: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||||
Log.e("addContact", "onNext: " + baseResponse);
|
Log.e("checkContact", "onNext: " + baseResponse);
|
||||||
mBaseResponseMutableLiveData.setValue(baseResponse);
|
if (baseResponse.code == 200) {
|
||||||
|
Toaster.show("已添加");
|
||||||
|
mAddData.setValue(true);
|
||||||
|
} else {
|
||||||
|
Contact contact = new Contact();
|
||||||
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
|
int fakeId = random.nextInt(Integer.MAX_VALUE);
|
||||||
|
Log.e(TAG, "checkContent: fakeId = " + fakeId);
|
||||||
|
contact.setId(fakeId);
|
||||||
|
contact.setMobile(phone);
|
||||||
|
contact.setName(name);
|
||||||
|
contact.setTag(tag);
|
||||||
|
contact.setIs_urgent(binding.toggleButton.isToggleOn());
|
||||||
|
contact.setAvatar(avatarFilePath);
|
||||||
|
mContactData.setValue(contact);
|
||||||
|
Toaster.show(baseResponse.msg);
|
||||||
|
mAddData.setValue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
Log.e("addContact", "onError: " + e.getMessage());
|
Log.e("checkContact", "onError: " + e.getMessage());
|
||||||
BaseResponse baseResponse = new BaseResponse();
|
Contact contact = new Contact();
|
||||||
baseResponse.code = 404;
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
baseResponse.msg = "网络连接失败";
|
int fakeId = random.nextInt(Integer.MAX_VALUE);
|
||||||
mBaseResponseMutableLiveData.setValue(baseResponse);
|
Log.e(TAG, "checkContent: fakeId = " + fakeId);
|
||||||
|
contact.setId(fakeId);
|
||||||
|
contact.setMobile(phone);
|
||||||
|
contact.setName(name);
|
||||||
|
contact.setTag(tag);
|
||||||
|
contact.setIs_urgent(binding.toggleButton.isToggleOn());
|
||||||
|
contact.setAvatar(avatarFilePath);
|
||||||
|
mContactData.setValue(contact);
|
||||||
|
mAddData.setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("addContact", "onComplete: ");
|
Log.e("checkContact", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
package com.xxpatx.os.activity.contact;
|
package com.xxpatx.os.activity.contact;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -26,18 +21,18 @@ import com.luck.picture.lib.basic.PictureSelector;
|
|||||||
import com.luck.picture.lib.config.SelectMimeType;
|
import com.luck.picture.lib.config.SelectMimeType;
|
||||||
import com.luck.picture.lib.entity.LocalMedia;
|
import com.luck.picture.lib.entity.LocalMedia;
|
||||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||||
|
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.base.GlideEngine;
|
import com.xxpatx.os.base.GlideEngine;
|
||||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.bean.Contact;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.databinding.ActivityEditContactBinding;
|
import com.xxpatx.os.databinding.ActivityEditContactBinding;
|
||||||
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
import com.xxpatx.os.utils.ScreenUtil;
|
import com.xxpatx.os.utils.ScreenUtil;
|
||||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -120,42 +115,13 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
Glide.with(this).asBitmap().load(mContact.getAvatar()).error(R.drawable.default_avatar).into(new SimpleTarget<Bitmap>() {
|
Glide.with(this).asBitmap().load(mContact.getAvatar()).error(R.drawable.default_avatar).into(new SimpleTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
mPictrueFilePath = bitmapToFile(resource, "avatar").getAbsolutePath();
|
mPictrueFilePath = FileUtil.bitmapToFile(EditContactActivity.this, resource, "avatar").getAbsolutePath();
|
||||||
Log.e(TAG, "onResourceReady: " + mPictrueFilePath);
|
Log.e(TAG, "onResourceReady: " + mPictrueFilePath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mViewDataBinding.setContact(mContact);
|
mViewDataBinding.setContact(mContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* bitmap
|
|
||||||
*
|
|
||||||
* @param bitmap bitmap
|
|
||||||
* @param fileName 转换后的文件名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public File bitmapToFile(Bitmap bitmap, String fileName) {
|
|
||||||
String defaultPath = getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
|
||||||
File file = new File(defaultPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
String defaultImgPath = defaultPath + "/" + fileName;
|
|
||||||
file = new File(defaultImgPath);
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
FileOutputStream fOut = new FileOutputStream(file);
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
|
||||||
// is.close();
|
|
||||||
fOut.flush();
|
|
||||||
fOut.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void openSelector() {
|
private void openSelector() {
|
||||||
PictureSelector.create(EditContactActivity.this)
|
PictureSelector.create(EditContactActivity.this)
|
||||||
.openGallery(SelectMimeType.ofAll())
|
.openGallery(SelectMimeType.ofAll())
|
||||||
@@ -200,17 +166,17 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
File avatarFile;
|
File avatarFile;
|
||||||
Log.e("checkContact", "mPictrueFilePath: " + mPictrueFilePath);
|
Log.e("checkContact", "mPictrueFilePath: " + mPictrueFilePath);
|
||||||
if (TextUtils.isEmpty(mPictrueFilePath)) {
|
if (TextUtils.isEmpty(mPictrueFilePath)) {
|
||||||
avatarFile = drawableToFile(R.drawable.default_avatar, "avatar");
|
avatarFile = FileUtil.drawableToFile(EditContactActivity.this, R.drawable.default_avatar, "avatar");
|
||||||
} else {
|
} else {
|
||||||
Uri uri = Uri.parse(mPictrueFilePath);
|
Uri uri = Uri.parse(mPictrueFilePath);
|
||||||
avatarFile = uriToFile(uri, EditContactActivity.this);
|
avatarFile = FileUtil.uriToFile(uri, EditContactActivity.this);
|
||||||
}
|
}
|
||||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
||||||
MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody);
|
MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody);
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("sn", Utils.getSerial());
|
params.put("sn", Utils.getSerial());
|
||||||
params.put("id", mContact.getId());
|
params.put("id", String.valueOf(mContact.getId()));
|
||||||
params.put("name", name);
|
params.put("name", name);
|
||||||
params.put("mobile", phone);
|
params.put("mobile", phone);
|
||||||
params.put("tag", groupTag);
|
params.put("tag", groupTag);
|
||||||
@@ -219,83 +185,6 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
mLoadingDialog.show();
|
mLoadingDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* drawable转为file
|
|
||||||
*
|
|
||||||
* @param drawableId drawable的ID
|
|
||||||
* @param fileName 转换后的文件名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public File drawableToFile(int drawableId, String fileName) {
|
|
||||||
// InputStream is = view.getContext().getResources().openRawResource(R.drawable.logo);
|
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
||||||
// Bitmap bitmap = BitmapFactory.decodeStream(is);
|
|
||||||
String defaultPath = getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
|
||||||
File file = new File(defaultPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
String defaultImgPath = defaultPath + "/" + fileName;
|
|
||||||
file = new File(defaultImgPath);
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
FileOutputStream fOut = new FileOutputStream(file);
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
|
||||||
// is.close();
|
|
||||||
fOut.flush();
|
|
||||||
fOut.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File uriToFile(Uri uri, Context context) {
|
|
||||||
String path = null;
|
|
||||||
if ("file".equals(uri.getScheme())) {
|
|
||||||
path = uri.getEncodedPath();
|
|
||||||
if (path != null) {
|
|
||||||
path = Uri.decode(path);
|
|
||||||
ContentResolver cr = context.getContentResolver();
|
|
||||||
StringBuffer buff = new StringBuffer();
|
|
||||||
buff.append("(").append(MediaStore.Images.ImageColumns.DATA).append("=").append("'" + path + "'").append(")");
|
|
||||||
Cursor cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA}, buff.toString(), null, null);
|
|
||||||
int index = 0;
|
|
||||||
int dataIdx = 0;
|
|
||||||
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
|
||||||
index = cur.getColumnIndex(MediaStore.Images.ImageColumns._ID);
|
|
||||||
index = cur.getInt(index);
|
|
||||||
dataIdx = cur.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
|
|
||||||
path = cur.getString(dataIdx);
|
|
||||||
}
|
|
||||||
cur.close();
|
|
||||||
if (index == 0) {
|
|
||||||
} else {
|
|
||||||
Uri u = Uri.parse("content://media/external/images/media/" + index);
|
|
||||||
System.out.println("temp uri is :" + u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (path != null) {
|
|
||||||
return new File(path);
|
|
||||||
}
|
|
||||||
} else if ("content".equals(uri.getScheme())) {
|
|
||||||
// 4.2.2以后
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
path = cursor.getString(columnIndex);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
return new File(path);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "uriToFile uriString:" + uri.toString());
|
|
||||||
return new File(uri.toString());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BtnClick {
|
public class BtnClick {
|
||||||
public void exit(View view) {
|
public void exit(View view) {
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
@Override
|
@Override
|
||||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||||
Log.e(TAG, "onConnected: " + networkType);
|
Log.e(TAG, "onConnected: " + networkType);
|
||||||
|
mViewModel.uploadContacts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -130,6 +131,9 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initView() {
|
public void initView() {
|
||||||
|
Log.e(TAG, "initView: ");
|
||||||
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
|
|
||||||
// UltimateBarX.addNavigationBarBottomPadding(mViewDataBinding.clBottom);
|
// UltimateBarX.addNavigationBarBottomPadding(mViewDataBinding.clBottom);
|
||||||
toggleNotificationListenerService(this);
|
toggleNotificationListenerService(this);
|
||||||
|
|
||||||
@@ -638,6 +642,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
unregisterAllReceiver();
|
unregisterAllReceiver();
|
||||||
|
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xxpatx.os.activity.main;
|
package com.xxpatx.os.activity.main;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -21,26 +22,33 @@ import com.tencent.mmkv.MMKV;
|
|||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
import com.xxpatx.os.BuildConfig;
|
import com.xxpatx.os.BuildConfig;
|
||||||
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||||
import com.xxpatx.os.bean.ActivationBean;
|
import com.xxpatx.os.bean.ActivationBean;
|
||||||
import com.xxpatx.os.bean.AppInfo;
|
import com.xxpatx.os.bean.AppInfo;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.bean.DesktopIcon;
|
import com.xxpatx.os.bean.DesktopIcon;
|
||||||
import com.xxpatx.os.bean.NetDesktopIcon;
|
import com.xxpatx.os.bean.NetDesktopIcon;
|
||||||
import com.xxpatx.os.bean.SnInfo;
|
import com.xxpatx.os.bean.SnInfo;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
import com.xxpatx.os.databinding.ActivityMainBinding;
|
import com.xxpatx.os.databinding.ActivityMainBinding;
|
||||||
|
import com.xxpatx.os.db.ContactCacheUtils;
|
||||||
import com.xxpatx.os.gson.GsonUtils;
|
import com.xxpatx.os.gson.GsonUtils;
|
||||||
import com.xxpatx.os.manager.AppManager;
|
import com.xxpatx.os.manager.AppManager;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
import com.xxpatx.os.utils.ActivationUtil;
|
import com.xxpatx.os.utils.ActivationUtil;
|
||||||
import com.xxpatx.os.utils.ApkUtils;
|
import com.xxpatx.os.utils.ApkUtils;
|
||||||
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
||||||
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
import com.xxpatx.os.utils.WiFiUtils;
|
import com.xxpatx.os.utils.WiFiUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
import io.reactivex.rxjava3.annotations.NonNull;
|
||||||
@@ -50,6 +58,9 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
|||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEvent> {
|
public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEvent> {
|
||||||
private static final String TAG = "MainViewModel";
|
private static final String TAG = "MainViewModel";
|
||||||
@@ -382,6 +393,63 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void uploadContacts() {
|
||||||
|
List<Contact> contactList = ContactCacheUtils.getInstance().getDatabaseContact();
|
||||||
|
if (contactList == null || contactList.size() == 0) {
|
||||||
|
Log.e(TAG, "uploadContacts: not found local contacts");
|
||||||
|
} else {
|
||||||
|
for (Contact contact : contactList) {
|
||||||
|
addContact(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addContact(Contact contact) {
|
||||||
|
File avatarFile;
|
||||||
|
if (TextUtils.isEmpty(contact.getAvatar())) {
|
||||||
|
avatarFile = FileUtil.drawableToFile(getCtx(), R.drawable.default_avatar, "avatar");
|
||||||
|
} else {
|
||||||
|
Uri uri = Uri.parse(contact.getAvatar());
|
||||||
|
avatarFile = FileUtil.uriToFile(uri, getCtx());
|
||||||
|
}
|
||||||
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
|
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
||||||
|
MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody);
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("sn", Utils.getSerial());
|
||||||
|
params.put("name", contact.getName());
|
||||||
|
params.put("mobile", contact.getMobile());
|
||||||
|
params.put("tag", contact.getTag());
|
||||||
|
params.put("is_urgent", String.valueOf(contact.getIs_urgent()));
|
||||||
|
NetInterfaceManager.getInstance()
|
||||||
|
.getMailListAddObservable(params, body)
|
||||||
|
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||||
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
Log.e("addContact", "onSubscribe: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||||
|
Log.e("addContact", "onNext: " + baseResponse);
|
||||||
|
if (baseResponse.code == 200 || baseResponse.code == -200) {
|
||||||
|
ContactCacheUtils.getInstance().deleteContact(contact.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
Log.e("addContact", "onError: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e("addContact", "onComplete: ");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void sendAPPUsage() {
|
public void sendAPPUsage() {
|
||||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||||
|
|||||||
@@ -102,7 +102,11 @@ public class NoticeInfoActivity extends BaseMvvmActivity<NoticeInfoViewModel, Ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showPic(AlarmClockData alarmClockData) {
|
private void showPic(AlarmClockData alarmClockData) {
|
||||||
|
if (TextUtils.isEmpty(alarmClockData.getTitle())){
|
||||||
|
mViewDataBinding.tvTitle.setText("爱心提醒");
|
||||||
|
}else {
|
||||||
mViewDataBinding.tvTitle.setText(alarmClockData.getTitle());
|
mViewDataBinding.tvTitle.setText(alarmClockData.getTitle());
|
||||||
|
}
|
||||||
mViewDataBinding.btOk.setOnClickListener(new View.OnClickListener() {
|
mViewDataBinding.btOk.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -222,7 +226,7 @@ public class NoticeInfoActivity extends BaseMvvmActivity<NoticeInfoViewModel, Ac
|
|||||||
mViewDataBinding.jzVideo.startVideo();
|
mViewDataBinding.jzVideo.startVideo();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mViewDataBinding.clVp.setVisibility(View.GONE);
|
mViewDataBinding.clVp.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.activity.alarmclock.edit.AlarmClockEditActivity;
|
import com.xxpatx.os.activity.alarm.edit.AlarmEditActivity;
|
||||||
import com.xxpatx.os.utils.FFmpegUtils;
|
import com.xxpatx.os.utils.FFmpegUtils;
|
||||||
import com.xxpatx.os.utils.ScreenUtils;
|
import com.xxpatx.os.utils.ScreenUtils;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
import com.xxpatx.os.view.JzvdStdRound;
|
import com.xxpatx.os.view.JzvdStdRound;
|
||||||
|
import com.xxpatx.os.view.ToggleButton;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -61,7 +62,7 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
|||||||
@Override
|
@Override
|
||||||
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
mContext = (FragmentActivity) parent.getContext();
|
mContext = (FragmentActivity) parent.getContext();
|
||||||
return new AlarmAdapter.holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm_clock, parent, false));
|
return new AlarmAdapter.holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm_port, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,6 +105,28 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
|||||||
} else {
|
} else {
|
||||||
holder.tv_title.setText(title);
|
holder.tv_title.setText(title);
|
||||||
}
|
}
|
||||||
|
int is_onoff = alarmClockData.getIs_onoff();
|
||||||
|
holder.toggleButton2.setDisable(true);
|
||||||
|
if (is_onoff == 1) {
|
||||||
|
holder.tv_status.setText("已开启");
|
||||||
|
holder.toggleButton2.setToggleOn(false);
|
||||||
|
} else {
|
||||||
|
holder.tv_status.setText("已关闭");
|
||||||
|
holder.toggleButton2.setToggleOff(false);
|
||||||
|
}
|
||||||
|
int type = alarmClockData.getClazz();
|
||||||
|
switch (type){
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_medicine_pressed));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_look_pressed));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_reserve_pressed));
|
||||||
|
break;
|
||||||
|
}
|
||||||
String voice = alarmClockData.getVoice();
|
String voice = alarmClockData.getVoice();
|
||||||
if (TextUtils.isEmpty(voice)) {
|
if (TextUtils.isEmpty(voice)) {
|
||||||
holder.cl_voice.setVisibility(View.GONE);
|
holder.cl_voice.setVisibility(View.GONE);
|
||||||
@@ -218,7 +241,7 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
|||||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent intent = new Intent(mContext, AlarmClockEditActivity.class);
|
Intent intent = new Intent(mContext, AlarmEditActivity.class);
|
||||||
intent.putExtra("id", alarmClockData.getId());
|
intent.putExtra("id", alarmClockData.getId());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
@@ -241,10 +264,11 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class holder extends RecyclerView.ViewHolder {
|
class holder extends RecyclerView.ViewHolder {
|
||||||
TextView tv_time, tv_remind_type, tv_title, tv_voice;
|
TextView tv_time, tv_remind_type, tv_title, tv_voice, tv_status;
|
||||||
ConstraintLayout cl_voice, cl_vp, root;
|
ConstraintLayout cl_voice, cl_vp, root;
|
||||||
JzvdStdRound jz_video;
|
JzvdStdRound jz_video;
|
||||||
ImageView imageView;
|
ImageView imageView,iv_type;
|
||||||
|
ToggleButton toggleButton2;
|
||||||
|
|
||||||
public holder(@NonNull View itemView) {
|
public holder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -257,7 +281,9 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
|||||||
root = itemView.findViewById(R.id.root);
|
root = itemView.findViewById(R.id.root);
|
||||||
jz_video = itemView.findViewById(R.id.jz_video);
|
jz_video = itemView.findViewById(R.id.jz_video);
|
||||||
imageView = itemView.findViewById(R.id.imageView);
|
imageView = itemView.findViewById(R.id.imageView);
|
||||||
|
iv_type = itemView.findViewById(R.id.iv_type);
|
||||||
|
tv_status = itemView.findViewById(R.id.tv_status);
|
||||||
|
toggleButton2 = itemView.findViewById(R.id.toggleButton2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||||||
|
|
||||||
public class AlarmOpenHelper extends SQLiteOpenHelper {
|
public class AlarmOpenHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public static final int DATABASE_VERSION = 2;
|
public static final int DATABASE_VERSION = 3;
|
||||||
public static final String DATABASE_NAME = "AlarmDatabase.db";
|
public static final String DATABASE_NAME = "AlarmDatabase.db";
|
||||||
// public static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
|
||||||
public static final String DATABASE_FILE_NAME = DATABASE_NAME;
|
|
||||||
|
|
||||||
public static final String TABLE_ALARM = " AlarmTable";
|
public static final String TABLE_ALARM = " AlarmTable";
|
||||||
|
|
||||||
@@ -23,6 +21,7 @@ public class AlarmOpenHelper extends SQLiteOpenHelper {
|
|||||||
public static final String KEY_FILE_MD5 = "file_md5";
|
public static final String KEY_FILE_MD5 = "file_md5";
|
||||||
public static final String KEY_REMIND_TYPE = "remind_type";
|
public static final String KEY_REMIND_TYPE = "remind_type";
|
||||||
public static final String KEY_IS_ONOFF = "is_onoff";
|
public static final String KEY_IS_ONOFF = "is_onoff";
|
||||||
|
public static final String KEY_CLAZZ = "clazz";
|
||||||
|
|
||||||
public static final String KEY_FINISHED = "finished";
|
public static final String KEY_FINISHED = "finished";
|
||||||
public static final String KEY_IS_LOCAL = "is_local";
|
public static final String KEY_IS_LOCAL = "is_local";
|
||||||
@@ -42,6 +41,7 @@ public class AlarmOpenHelper extends SQLiteOpenHelper {
|
|||||||
+ KEY_FILE_MD5 + " TEXT,"
|
+ KEY_FILE_MD5 + " TEXT,"
|
||||||
+ KEY_REMIND_TYPE + " INTEGER,"
|
+ KEY_REMIND_TYPE + " INTEGER,"
|
||||||
+ KEY_IS_ONOFF + " INTEGER,"
|
+ KEY_IS_ONOFF + " INTEGER,"
|
||||||
|
+ KEY_CLAZZ + " INTEGER,"
|
||||||
|
|
||||||
+ KEY_FINISHED + " BOOLEAN DEFAULT 0,"
|
+ KEY_FINISHED + " BOOLEAN DEFAULT 0,"
|
||||||
+ KEY_IS_LOCAL + " BOOLEAN DEFAULT 0,"
|
+ KEY_IS_LOCAL + " BOOLEAN DEFAULT 0,"
|
||||||
@@ -70,6 +70,9 @@ public class AlarmOpenHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL(sql2);
|
db.execSQL(sql2);
|
||||||
String sql3 = "ALTER TABLE " + TABLE_ALARM + " ADD COLUMN " + KEY_FILE_MD5 + " TEXT";
|
String sql3 = "ALTER TABLE " + TABLE_ALARM + " ADD COLUMN " + KEY_FILE_MD5 + " TEXT";
|
||||||
db.execSQL(sql3);
|
db.execSQL(sql3);
|
||||||
|
case 3:
|
||||||
|
String sql4 = "ALTER TABLE " + TABLE_ALARM + " ADD COLUMN " + KEY_CLAZZ + " INTEGER";
|
||||||
|
db.execSQL(sql4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.blankj.utilcode.util.FileUtils;
|
import com.blankj.utilcode.util.FileUtils;
|
||||||
|
import com.xxpatx.os.BuildConfig;
|
||||||
import com.xxpatx.os.service.main.MainService;
|
import com.xxpatx.os.service.main.MainService;
|
||||||
import com.xxpatx.os.utils.FileUtil;
|
import com.xxpatx.os.utils.FileUtil;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
@@ -55,13 +57,20 @@ public class AlarmUtils {
|
|||||||
public static final int OFF_DAY = 4;
|
public static final int OFF_DAY = 4;
|
||||||
|
|
||||||
private AlarmUtils(Context context) {
|
private AlarmUtils(Context context) {
|
||||||
this.mContext = context;
|
this.mContext = context.getApplicationContext();
|
||||||
// this.mAlarmOpenHelper = new AlarmOpenHelper(context, AlarmOpenHelper.DATABASE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
// this.mAlarmOpenHelper = new AlarmOpenHelper(context, AlarmOpenHelper.DATABASE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
this.mAlarmOpenHelper = new AlarmOpenHelper(context,
|
this.mAlarmOpenHelper = new AlarmOpenHelper(context,
|
||||||
context.getExternalCacheDir() + File.separator + AlarmOpenHelper.DATABASE_FILE_NAME,
|
Environment.getExternalStorageDirectory() + File.separator + AlarmOpenHelper.DATABASE_NAME,
|
||||||
null, AlarmOpenHelper.DATABASE_VERSION);
|
null, AlarmOpenHelper.DATABASE_VERSION);
|
||||||
|
} else {
|
||||||
|
this.mAlarmOpenHelper = new AlarmOpenHelper(context,
|
||||||
|
context.getExternalCacheDir() + File.separator + AlarmOpenHelper.DATABASE_NAME,
|
||||||
|
null, AlarmOpenHelper.DATABASE_VERSION);
|
||||||
|
}
|
||||||
this.mDatabase = mAlarmOpenHelper.getWritableDatabase();
|
this.mDatabase = mAlarmOpenHelper.getWritableDatabase();
|
||||||
this.mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
this.mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
pendingIntents = getOldPendingIntentsSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
@@ -98,6 +107,7 @@ public class AlarmUtils {
|
|||||||
values.put(AlarmOpenHelper.KEY_FILE_MD5, alarmClockData.getFile_md5());
|
values.put(AlarmOpenHelper.KEY_FILE_MD5, alarmClockData.getFile_md5());
|
||||||
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
||||||
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
||||||
|
values.put(AlarmOpenHelper.KEY_CLAZZ, alarmClockData.getClazz());
|
||||||
|
|
||||||
values.put(AlarmOpenHelper.KEY_FINISHED, alarmClockData.isFinished());
|
values.put(AlarmOpenHelper.KEY_FINISHED, alarmClockData.isFinished());
|
||||||
values.put(AlarmOpenHelper.KEY_IS_LOCAL, alarmClockData.isIs_local());
|
values.put(AlarmOpenHelper.KEY_IS_LOCAL, alarmClockData.isIs_local());
|
||||||
@@ -113,7 +123,6 @@ public class AlarmUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean addAlarmClock(AlarmClockData alarmClockData) {
|
public boolean addAlarmClock(AlarmClockData alarmClockData) {
|
||||||
openDatabase();
|
|
||||||
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
||||||
long id = 0;
|
long id = 0;
|
||||||
mDatabase.beginTransaction();
|
mDatabase.beginTransaction();
|
||||||
@@ -129,6 +138,27 @@ public class AlarmUtils {
|
|||||||
return id > 0;
|
return id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加数据
|
||||||
|
*
|
||||||
|
* @param alarmClockData
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean addLocalAlarmClock(AlarmClockData alarmClockData) {
|
||||||
|
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
||||||
|
long id = 0;
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
id = mDatabase.insertWithOnConflict(AlarmOpenHelper.TABLE_ALARM, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "addLocalAlarmClock: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
return id > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新数据
|
* 更新数据
|
||||||
@@ -137,7 +167,6 @@ public class AlarmUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean updateAlarmClock(AlarmClockData alarmClockData) {
|
public boolean updateAlarmClock(AlarmClockData alarmClockData) {
|
||||||
openDatabase();
|
|
||||||
AlarmClockData old = getDatabaseSingleAlarm(alarmClockData);
|
AlarmClockData old = getDatabaseSingleAlarm(alarmClockData);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
PendingIntent pendingIntent = getPendingIntent(old);
|
PendingIntent pendingIntent = getPendingIntent(old);
|
||||||
@@ -161,7 +190,6 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateAlarmClock(AlarmClockData alarmClockData, int newId) {
|
public boolean updateAlarmClock(AlarmClockData alarmClockData, int newId) {
|
||||||
openDatabase();
|
|
||||||
int oldId = alarmClockData.getId();
|
int oldId = alarmClockData.getId();
|
||||||
AlarmClockData old = getDatabaseSingleAlarm(alarmClockData);
|
AlarmClockData old = getDatabaseSingleAlarm(alarmClockData);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
@@ -193,7 +221,6 @@ public class AlarmUtils {
|
|||||||
* @param list
|
* @param list
|
||||||
*/
|
*/
|
||||||
public void insertAlarmClockList(List<AlarmClockData> list) {
|
public void insertAlarmClockList(List<AlarmClockData> list) {
|
||||||
openDatabase();
|
|
||||||
List<ContentValues> contentValuesList = new ArrayList<>();
|
List<ContentValues> contentValuesList = new ArrayList<>();
|
||||||
for (AlarmClockData alarmClockData : list) {
|
for (AlarmClockData alarmClockData : list) {
|
||||||
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
||||||
@@ -230,7 +257,6 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteAlarmClock(int RowID) {
|
public boolean deleteAlarmClock(int RowID) {
|
||||||
openDatabase();
|
|
||||||
long id = 0;
|
long id = 0;
|
||||||
mDatabase.beginTransaction();
|
mDatabase.beginTransaction();
|
||||||
try {
|
try {
|
||||||
@@ -248,6 +274,7 @@ public class AlarmUtils {
|
|||||||
* 删除所有闹钟
|
* 删除所有闹钟
|
||||||
*/
|
*/
|
||||||
public void deleteAllAlarmClock() {
|
public void deleteAllAlarmClock() {
|
||||||
|
Log.e(TAG, "deleteAllAlarmClock: ");
|
||||||
HashSet<PendingIntent> pendingIntents = getOldPendingIntentsSet();
|
HashSet<PendingIntent> pendingIntents = getOldPendingIntentsSet();
|
||||||
Iterator<PendingIntent> pendingIntentIterator = pendingIntents.iterator();
|
Iterator<PendingIntent> pendingIntentIterator = pendingIntents.iterator();
|
||||||
while (pendingIntentIterator.hasNext()) {
|
while (pendingIntentIterator.hasNext()) {
|
||||||
@@ -257,6 +284,10 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
List<AlarmClockData> alarmClockData = getDatabaseAlarms();
|
List<AlarmClockData> alarmClockData = getDatabaseAlarms();
|
||||||
for (AlarmClockData data : alarmClockData) {
|
for (AlarmClockData data : alarmClockData) {
|
||||||
|
Log.e(TAG, "deleteAllAlarmClock: id = " + data);
|
||||||
|
if (data.isIs_local()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
deleteAlarmClock(data.getId());
|
deleteAlarmClock(data.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,27 +298,28 @@ public class AlarmUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<AlarmClockData> getDatabaseAlarms() {
|
public List<AlarmClockData> getDatabaseAlarms() {
|
||||||
openDatabase();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
List<AlarmClockData> list = new ArrayList<>();
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM;
|
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM;
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
AlarmClockData alarmClockData = new AlarmClockData();
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
alarmClockData.setId(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_ID)));
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
alarmClockData.setType(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_TYPE)));
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
alarmClockData.setTime(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TIME)));
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
alarmClockData.setTitle(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TITLE)));
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
alarmClockData.setVoice(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE)));
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
alarmClockData.setVoice_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE_MD5)));
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
alarmClockData.setFile(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE)));
|
||||||
alarmClockData.setFile_md5(cursor.getString(7));
|
alarmClockData.setFile_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE_MD5)));
|
||||||
alarmClockData.setRemind_type(cursor.getInt(8));
|
alarmClockData.setRemind_type(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_REMIND_TYPE)));
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(9));
|
alarmClockData.setIs_onoff(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_ONOFF)));
|
||||||
alarmClockData.setFinished(cursor.getInt(10) == 1);
|
alarmClockData.setClazz(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_CLAZZ)));
|
||||||
alarmClockData.setIs_local(cursor.getInt(11) == 1);
|
|
||||||
alarmClockData.setEdited(cursor.getInt(12) == 1);
|
alarmClockData.setFinished(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_FINISHED)) == 1);
|
||||||
alarmClockData.setDeleted(cursor.getInt(13) == 1);
|
alarmClockData.setIs_local(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_LOCAL)) == 1);
|
||||||
|
alarmClockData.setEdited(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_EDITED)) == 1);
|
||||||
|
alarmClockData.setDeleted(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_DELETED)) == 1);
|
||||||
list.add(alarmClockData);
|
list.add(alarmClockData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@@ -299,27 +331,28 @@ public class AlarmUtils {
|
|||||||
* @return 获取单个闹钟
|
* @return 获取单个闹钟
|
||||||
*/
|
*/
|
||||||
public AlarmClockData getDatabaseSingleAlarm(AlarmClockData data) {
|
public AlarmClockData getDatabaseSingleAlarm(AlarmClockData data) {
|
||||||
openDatabase();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
List<AlarmClockData> list = new ArrayList<>();
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where id =" + data.getId();
|
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where id =" + data.getId();
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
AlarmClockData alarmClockData = new AlarmClockData();
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
alarmClockData.setId(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_ID)));
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
alarmClockData.setType(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_TYPE)));
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
alarmClockData.setTime(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TIME)));
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
alarmClockData.setTitle(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TITLE)));
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
alarmClockData.setVoice(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE)));
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
alarmClockData.setVoice_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE_MD5)));
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
alarmClockData.setFile(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE)));
|
||||||
alarmClockData.setFile_md5(cursor.getString(7));
|
alarmClockData.setFile_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE_MD5)));
|
||||||
alarmClockData.setRemind_type(cursor.getInt(8));
|
alarmClockData.setRemind_type(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_REMIND_TYPE)));
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(9));
|
alarmClockData.setIs_onoff(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_ONOFF)));
|
||||||
alarmClockData.setFinished(cursor.getInt(10) == 1);
|
alarmClockData.setClazz(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_CLAZZ)));
|
||||||
alarmClockData.setIs_local(cursor.getInt(11) == 1);
|
|
||||||
alarmClockData.setEdited(cursor.getInt(12) == 1);
|
alarmClockData.setFinished(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_FINISHED)) == 1);
|
||||||
alarmClockData.setDeleted(cursor.getInt(13) == 1);
|
alarmClockData.setIs_local(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_LOCAL)) == 1);
|
||||||
|
alarmClockData.setEdited(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_EDITED)) == 1);
|
||||||
|
alarmClockData.setDeleted(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_DELETED)) == 1);
|
||||||
list.add(alarmClockData);
|
list.add(alarmClockData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@@ -328,27 +361,28 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AlarmClockData getDatabaseSingleAlarm(int id) {
|
public AlarmClockData getDatabaseSingleAlarm(int id) {
|
||||||
openDatabase();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
List<AlarmClockData> list = new ArrayList<>();
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where id =" + id;
|
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where id =" + id;
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
AlarmClockData alarmClockData = new AlarmClockData();
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
alarmClockData.setId(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_ID)));
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
alarmClockData.setType(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_TYPE)));
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
alarmClockData.setTime(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TIME)));
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
alarmClockData.setTitle(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TITLE)));
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
alarmClockData.setVoice(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE)));
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
alarmClockData.setVoice_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE_MD5)));
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
alarmClockData.setFile(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE)));
|
||||||
alarmClockData.setFile_md5(cursor.getString(7));
|
alarmClockData.setFile_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE_MD5)));
|
||||||
alarmClockData.setRemind_type(cursor.getInt(8));
|
alarmClockData.setRemind_type(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_REMIND_TYPE)));
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(9));
|
alarmClockData.setIs_onoff(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_ONOFF)));
|
||||||
alarmClockData.setFinished(cursor.getInt(10) == 1);
|
alarmClockData.setClazz(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_CLAZZ)));
|
||||||
alarmClockData.setIs_local(cursor.getInt(11) == 1);
|
|
||||||
alarmClockData.setEdited(cursor.getInt(12) == 1);
|
alarmClockData.setFinished(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_FINISHED)) == 1);
|
||||||
alarmClockData.setDeleted(cursor.getInt(13) == 1);
|
alarmClockData.setIs_local(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_LOCAL)) == 1);
|
||||||
|
alarmClockData.setEdited(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_EDITED)) == 1);
|
||||||
|
alarmClockData.setDeleted(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_DELETED)) == 1);
|
||||||
list.add(alarmClockData);
|
list.add(alarmClockData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@@ -357,27 +391,28 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AlarmClockData> getDeletedAlarm() {
|
public List<AlarmClockData> getDeletedAlarm() {
|
||||||
openDatabase();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
List<AlarmClockData> list = new ArrayList<>();
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where deleted = 1";
|
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where deleted = 1";
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
AlarmClockData alarmClockData = new AlarmClockData();
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
alarmClockData.setId(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_ID)));
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
alarmClockData.setType(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_TYPE)));
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
alarmClockData.setTime(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TIME)));
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
alarmClockData.setTitle(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TITLE)));
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
alarmClockData.setVoice(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE)));
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
alarmClockData.setVoice_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE_MD5)));
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
alarmClockData.setFile(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE)));
|
||||||
alarmClockData.setFile_md5(cursor.getString(7));
|
alarmClockData.setFile_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE_MD5)));
|
||||||
alarmClockData.setRemind_type(cursor.getInt(8));
|
alarmClockData.setRemind_type(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_REMIND_TYPE)));
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(9));
|
alarmClockData.setIs_onoff(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_ONOFF)));
|
||||||
alarmClockData.setFinished(cursor.getInt(10) == 1);
|
alarmClockData.setClazz(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_CLAZZ)));
|
||||||
alarmClockData.setIs_local(cursor.getInt(11) == 1);
|
|
||||||
alarmClockData.setEdited(cursor.getInt(12) == 1);
|
alarmClockData.setFinished(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_FINISHED)) == 1);
|
||||||
alarmClockData.setDeleted(cursor.getInt(13) == 1);
|
alarmClockData.setIs_local(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_LOCAL)) == 1);
|
||||||
|
alarmClockData.setEdited(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_EDITED)) == 1);
|
||||||
|
alarmClockData.setDeleted(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_DELETED)) == 1);
|
||||||
list.add(alarmClockData);
|
list.add(alarmClockData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@@ -386,27 +421,28 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AlarmClockData> getLocalAddAlarm() {
|
public List<AlarmClockData> getLocalAddAlarm() {
|
||||||
openDatabase();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
List<AlarmClockData> list = new ArrayList<>();
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where is_local = 1";
|
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM + " where is_local = 1";
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
AlarmClockData alarmClockData = new AlarmClockData();
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
alarmClockData.setId(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_ID)));
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
alarmClockData.setType(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_TYPE)));
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
alarmClockData.setTime(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TIME)));
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
alarmClockData.setTitle(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_TITLE)));
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
alarmClockData.setVoice(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE)));
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
alarmClockData.setVoice_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_VOICE_MD5)));
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
alarmClockData.setFile(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE)));
|
||||||
alarmClockData.setFile_md5(cursor.getString(7));
|
alarmClockData.setFile_md5(cursor.getString(cursor.getColumnIndex(AlarmOpenHelper.KEY_FILE_MD5)));
|
||||||
alarmClockData.setRemind_type(cursor.getInt(8));
|
alarmClockData.setRemind_type(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_REMIND_TYPE)));
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(9));
|
alarmClockData.setIs_onoff(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_ONOFF)));
|
||||||
alarmClockData.setFinished(cursor.getInt(10) == 1);
|
alarmClockData.setClazz(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_CLAZZ)));
|
||||||
alarmClockData.setIs_local(cursor.getInt(11) == 1);
|
|
||||||
alarmClockData.setEdited(cursor.getInt(12) == 1);
|
alarmClockData.setFinished(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_FINISHED)) == 1);
|
||||||
alarmClockData.setDeleted(cursor.getInt(13) == 1);
|
alarmClockData.setIs_local(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_IS_LOCAL)) == 1);
|
||||||
|
alarmClockData.setEdited(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_EDITED)) == 1);
|
||||||
|
alarmClockData.setDeleted(cursor.getInt(cursor.getColumnIndex(AlarmOpenHelper.KEY_DELETED)) == 1);
|
||||||
list.add(alarmClockData);
|
list.add(alarmClockData);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@@ -421,6 +457,7 @@ public class AlarmUtils {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
public void setAlarmClockData(List<AlarmClockData> data) {
|
public void setAlarmClockData(List<AlarmClockData> data) {
|
||||||
|
Log.e(TAG, "setAlarmClockData: ");
|
||||||
if (pendingIntents == null) {
|
if (pendingIntents == null) {
|
||||||
pendingIntents = getOldPendingIntentsSet();
|
pendingIntents = getOldPendingIntentsSet();
|
||||||
}
|
}
|
||||||
@@ -473,12 +510,15 @@ public class AlarmUtils {
|
|||||||
List<AlarmClockData> deleteData = new ArrayList<>();
|
List<AlarmClockData> deleteData = new ArrayList<>();
|
||||||
for (Map.Entry<Integer, AlarmClockData> entry : oldData.entrySet()) {
|
for (Map.Entry<Integer, AlarmClockData> entry : oldData.entrySet()) {
|
||||||
if (alarmClockDataMap.get(entry.getKey()) == null) {
|
if (alarmClockDataMap.get(entry.getKey()) == null) {
|
||||||
deleteData.add(entry.getValue());
|
AlarmClockData alarmClockData = entry.getValue();
|
||||||
|
if (!alarmClockData.isIs_local()) {
|
||||||
|
deleteData.add(alarmClockData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AlarmClockData alarmClockData : deleteData) {
|
for (AlarmClockData alarmClockData : deleteData) {
|
||||||
if (alarmClockData.isIs_local() || alarmClockData.deleted) {
|
if (alarmClockData.isIs_local() || alarmClockData.deleted) {
|
||||||
Log.e(TAG, "mergeData: skip " + alarmClockData.getId());
|
Log.e(TAG, "mergeData: skip id = " + alarmClockData.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
deleteAlarmClock(alarmClockData);
|
deleteAlarmClock(alarmClockData);
|
||||||
@@ -503,6 +543,18 @@ public class AlarmUtils {
|
|||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新完成状态
|
||||||
|
*
|
||||||
|
* @param mId 闹钟id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean updateAlarmFinished(int mId) {
|
||||||
|
AlarmClockData alarmClockData = getDatabaseSingleAlarm(mId);
|
||||||
|
alarmClockData.setFinished(true);
|
||||||
|
return updateAlarmFinished(alarmClockData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新完成状态
|
* 更新完成状态
|
||||||
*
|
*
|
||||||
@@ -510,7 +562,6 @@ public class AlarmUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean updateAlarmFinished(AlarmClockData alarmClockData) {
|
public boolean updateAlarmFinished(AlarmClockData alarmClockData) {
|
||||||
openDatabase();
|
|
||||||
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
||||||
long id = 0;
|
long id = 0;
|
||||||
mDatabase.beginTransaction();
|
mDatabase.beginTransaction();
|
||||||
@@ -531,6 +582,7 @@ public class AlarmUtils {
|
|||||||
if (dataBaseAlarms != null && dataBaseAlarms.size() != 0) {
|
if (dataBaseAlarms != null && dataBaseAlarms.size() != 0) {
|
||||||
alarmClockData.addAll(dataBaseAlarms);
|
alarmClockData.addAll(dataBaseAlarms);
|
||||||
}
|
}
|
||||||
|
Log.e(TAG, "getOldData: " + alarmClockData);
|
||||||
return alarmClockData;
|
return alarmClockData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,11 +622,14 @@ public class AlarmUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HashSet<PendingIntent> getOldPendingIntentsSet() {
|
private HashSet<PendingIntent> getOldPendingIntentsSet() {
|
||||||
|
Log.e(TAG, "getOldPendingIntentsSet: ");
|
||||||
HashSet<PendingIntent> pendingIntents = new HashSet<>();
|
HashSet<PendingIntent> pendingIntents = new HashSet<>();
|
||||||
HashMap<Integer, AlarmClockData> data = getOldDataMap();
|
HashMap<Integer, AlarmClockData> data = getOldDataMap();
|
||||||
for (AlarmClockData alarmClockData : data.values()) {
|
for (AlarmClockData alarmClockData : data.values()) {
|
||||||
|
if (!alarmClockData.isIs_local()) {
|
||||||
pendingIntents.add(getPendingIntent(alarmClockData));
|
pendingIntents.add(getPendingIntent(alarmClockData));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return pendingIntents;
|
return pendingIntents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,6 +640,7 @@ public class AlarmUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private PendingIntent getPendingIntent(AlarmClockData alarmClock) {
|
private PendingIntent getPendingIntent(AlarmClockData alarmClock) {
|
||||||
|
Log.e(TAG, "getPendingIntent: ");
|
||||||
Intent intent = new Intent(MainService.ALARMWAKEUP);
|
Intent intent = new Intent(MainService.ALARMWAKEUP);
|
||||||
intent.putExtra("title", alarmClock.getTitle());
|
intent.putExtra("title", alarmClock.getTitle());
|
||||||
intent.putExtra("id", alarmClock.getId());
|
intent.putExtra("id", alarmClock.getId());
|
||||||
@@ -647,22 +703,22 @@ public class AlarmUtils {
|
|||||||
int type = alarm.getType();
|
int type = alarm.getType();
|
||||||
String timeString = alarm.getTime();
|
String timeString = alarm.getTime();
|
||||||
String title = alarm.getTitle();
|
String title = alarm.getTitle();
|
||||||
Log.e(TAG, "setAlarm: " + title);
|
Log.e(TAG, "setAlarm: title = " + title);
|
||||||
|
Log.e(TAG, "setAlarm: id = " + id);
|
||||||
long timeStamp = getTimestamp(timeString);
|
long timeStamp = getTimestamp(timeString);
|
||||||
Log.e(TAG, "setAlarm: " + timeStamp);
|
Log.e(TAG, "setAlarm: timeStamp = " + timeStamp);
|
||||||
boolean finished = alarm.isFinished();
|
boolean finished = alarm.isFinished();
|
||||||
String voiceUrl = alarm.getVoice();
|
String voiceUrl = alarm.getVoice();
|
||||||
String voiceMd5 = alarm.getVoice_md5();
|
String voiceMd5 = alarm.getVoice_md5();
|
||||||
if (!TextUtils.isEmpty(voiceUrl)) {
|
if (!TextUtils.isEmpty(voiceUrl)) {
|
||||||
if (!FileUtil.isLocalPath(voiceUrl))
|
|
||||||
ariaDownload(voiceUrl, voiceMd5);
|
ariaDownload(voiceUrl, voiceMd5);
|
||||||
}
|
}
|
||||||
String fileUrl = alarm.getFile();
|
String fileUrl = alarm.getFile();
|
||||||
String fileMd5 = alarm.getFile_md5();
|
String fileMd5 = alarm.getFile_md5();
|
||||||
if (!TextUtils.isEmpty(fileUrl)) {
|
if (!TextUtils.isEmpty(fileUrl)) {
|
||||||
if (!FileUtil.isLocalPath(fileUrl))
|
|
||||||
ariaDownload(fileUrl, fileMd5);
|
ariaDownload(fileUrl, fileMd5);
|
||||||
}
|
}
|
||||||
|
boolean local = alarm.is_local;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ONCE:
|
case ONCE:
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
@@ -672,18 +728,18 @@ public class AlarmUtils {
|
|||||||
intent.putExtra("id", id);
|
intent.putExtra("id", id);
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
setOnceAlarm(MainService.ALARMWAKEUP, title, id, timeStamp);
|
setOnceAlarm(MainService.ALARMWAKEUP, title, id, timeStamp, local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOOP:
|
case LOOP:
|
||||||
setDayLoopAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
setDayLoopAlarm(MainService.ALARMWAKEUP, title, id, timeString, local);
|
||||||
break;
|
break;
|
||||||
case WORKING_DAY:
|
case WORKING_DAY:
|
||||||
setWorkDayAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
setWorkDayAlarm(MainService.ALARMWAKEUP, title, id, timeString, local);
|
||||||
break;
|
break;
|
||||||
case OFF_DAY:
|
case OFF_DAY:
|
||||||
setOffDayAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
setOffDayAlarm(MainService.ALARMWAKEUP, title, id, timeString, local);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -694,12 +750,14 @@ public class AlarmUtils {
|
|||||||
* @param requestCode
|
* @param requestCode
|
||||||
* @param timestamp 设置一次性闹钟
|
* @param timestamp 设置一次性闹钟
|
||||||
*/
|
*/
|
||||||
public void setOnceAlarm(String action, String extra, int requestCode, long timestamp) {
|
public void setOnceAlarm(String action, String extra, int requestCode, long timestamp, boolean local) {
|
||||||
Intent intent = new Intent(action);
|
Intent intent = new Intent(action);
|
||||||
intent.putExtra("title", extra);
|
intent.putExtra("title", extra);
|
||||||
intent.putExtra("id", requestCode);
|
intent.putExtra("id", requestCode);
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
if (!local) {
|
||||||
pendingIntents.add(startPendingIntent);
|
pendingIntents.add(startPendingIntent);
|
||||||
|
}
|
||||||
mAlarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
mAlarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
||||||
Log.e(TAG, "setOnceAlarm: " + "id: " + requestCode + " title: " + extra + " timeString: " + timestamp);
|
Log.e(TAG, "setOnceAlarm: " + "id: " + requestCode + " title: " + extra + " timeString: " + timestamp);
|
||||||
}
|
}
|
||||||
@@ -709,7 +767,7 @@ public class AlarmUtils {
|
|||||||
* @param requestCode
|
* @param requestCode
|
||||||
* @param timeString 设置循环周期为一天的闹钟
|
* @param timeString 设置循环周期为一天的闹钟
|
||||||
*/
|
*/
|
||||||
public void setDayLoopAlarm(String action, String extra, int requestCode, String timeString) {
|
public void setDayLoopAlarm(String action, String extra, int requestCode, String timeString, boolean local) {
|
||||||
long timestamp = getTimestamp(timeString);
|
long timestamp = getTimestamp(timeString);
|
||||||
if (System.currentTimeMillis() > timestamp) {
|
if (System.currentTimeMillis() > timestamp) {
|
||||||
timestamp += AlarmManager.INTERVAL_DAY;
|
timestamp += AlarmManager.INTERVAL_DAY;
|
||||||
@@ -718,7 +776,9 @@ public class AlarmUtils {
|
|||||||
intent.putExtra("title", extra);
|
intent.putExtra("title", extra);
|
||||||
intent.putExtra("id", requestCode);
|
intent.putExtra("id", requestCode);
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
if (!local) {
|
||||||
pendingIntents.add(startPendingIntent);
|
pendingIntents.add(startPendingIntent);
|
||||||
|
}
|
||||||
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
||||||
Log.e(TAG, "setDayLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
Log.e(TAG, "setDayLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
||||||
// setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_DAY, timestamp);
|
// setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_DAY, timestamp);
|
||||||
@@ -729,8 +789,8 @@ public class AlarmUtils {
|
|||||||
* @param requestCode
|
* @param requestCode
|
||||||
* @param timestamp 设置循环周期为一小时的闹钟
|
* @param timestamp 设置循环周期为一小时的闹钟
|
||||||
*/
|
*/
|
||||||
public void setHourLoopAlarm(String action, String extra, int requestCode, long timestamp) {
|
public void setHourLoopAlarm(String action, String extra, int requestCode, long timestamp, boolean local) {
|
||||||
setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_HOUR, timestamp);
|
setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_HOUR, timestamp, local);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -739,17 +799,19 @@ public class AlarmUtils {
|
|||||||
* @param intervalMillis
|
* @param intervalMillis
|
||||||
* @param timestamp 循环闹钟
|
* @param timestamp 循环闹钟
|
||||||
*/
|
*/
|
||||||
public void setLoopAlarm(String action, String extra, int requestCode, long intervalMillis, long timestamp) {
|
public void setLoopAlarm(String action, String extra, int requestCode, long intervalMillis, long timestamp, boolean local) {
|
||||||
Intent intent = new Intent(action);
|
Intent intent = new Intent(action);
|
||||||
intent.putExtra("title", extra);
|
intent.putExtra("title", extra);
|
||||||
intent.putExtra("id", requestCode);
|
intent.putExtra("id", requestCode);
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
if (!local) {
|
||||||
pendingIntents.add(startPendingIntent);
|
pendingIntents.add(startPendingIntent);
|
||||||
|
}
|
||||||
mAlarmManager.setWindow(AlarmManager.RTC_WAKEUP, timestamp, intervalMillis, startPendingIntent);
|
mAlarmManager.setWindow(AlarmManager.RTC_WAKEUP, timestamp, intervalMillis, startPendingIntent);
|
||||||
Log.e(TAG, "setLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
Log.e(TAG, "setLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorkDayAlarm(String action, String extra, int requestCode, String timeString) {
|
public void setWorkDayAlarm(String action, String extra, int requestCode, String timeString, boolean local) {
|
||||||
long timestamp = getTimestamp(timeString);
|
long timestamp = getTimestamp(timeString);
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
@@ -768,12 +830,14 @@ public class AlarmUtils {
|
|||||||
intent.putExtra("title", extra);
|
intent.putExtra("title", extra);
|
||||||
intent.putExtra("id", requestCode);
|
intent.putExtra("id", requestCode);
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
if (!local) {
|
||||||
pendingIntents.add(startPendingIntent);
|
pendingIntents.add(startPendingIntent);
|
||||||
|
}
|
||||||
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
||||||
Log.e(TAG, "setWorkDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
Log.e(TAG, "setWorkDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOffDayAlarm(String action, String extra, int requestCode, String timeString) {
|
public void setOffDayAlarm(String action, String extra, int requestCode, String timeString, boolean local) {
|
||||||
long timestamp = getTimestamp(timeString);
|
long timestamp = getTimestamp(timeString);
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
@@ -793,7 +857,9 @@ public class AlarmUtils {
|
|||||||
intent.putExtra("title", extra);
|
intent.putExtra("title", extra);
|
||||||
intent.putExtra("id", requestCode);
|
intent.putExtra("id", requestCode);
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
if (!local) {
|
||||||
pendingIntents.add(startPendingIntent);
|
pendingIntents.add(startPendingIntent);
|
||||||
|
}
|
||||||
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
mAlarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
||||||
Log.e(TAG, "setOffDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
Log.e(TAG, "setOffDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,287 +0,0 @@
|
|||||||
package com.xxpatx.os.alarm;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.media.AudioAttributes;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
|
||||||
import com.xxpatx.os.R;
|
|
||||||
import com.xxpatx.os.utils.FFmpegUtils;
|
|
||||||
import com.xxpatx.os.utils.ScreenUtils;
|
|
||||||
import com.xxpatx.os.utils.Utils;
|
|
||||||
import com.xxpatx.os.view.JzvdStdRound;
|
|
||||||
import com.xxpatx.os.view.ToggleButton;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
|
||||||
|
|
||||||
public class PortAlarmAdapter extends RecyclerView.Adapter<PortAlarmAdapter.holder> {
|
|
||||||
|
|
||||||
private FragmentActivity mContext;
|
|
||||||
private List<AlarmClockData> mAlarmClockData;
|
|
||||||
private OnLongClickListener mOnLongClickListener;
|
|
||||||
|
|
||||||
public void setAlarmClockData(List<AlarmClockData> alarmClockData) {
|
|
||||||
this.mAlarmClockData = alarmClockData;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnLongClickListener(OnLongClickListener onLongClickListener) {
|
|
||||||
this.mOnLongClickListener = onLongClickListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnLongClickListener {
|
|
||||||
void onLongClick(AlarmClockData alarmClockData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
mContext = (FragmentActivity) parent.getContext();
|
|
||||||
return new PortAlarmAdapter.holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm_port, parent, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull holder holder, int position) {
|
|
||||||
AlarmClockData alarmClockData = mAlarmClockData.get(position);
|
|
||||||
switch (alarmClockData.getType()) {
|
|
||||||
case AlarmUtils.ONCE:
|
|
||||||
try {
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
||||||
Date date = sdf.parse(alarmClockData.getTime());
|
|
||||||
SimpleDateFormat hours = new SimpleDateFormat("HH:mm");
|
|
||||||
String time = hours.format(date);
|
|
||||||
holder.tv_time.setText(time);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
holder.tv_remind_type.setText("一次");
|
|
||||||
holder.tv_remind_type.setBackgroundResource(R.drawable.tv_times_bg_once);
|
|
||||||
break;
|
|
||||||
case AlarmUtils.LOOP:
|
|
||||||
holder.tv_time.setText(alarmClockData.getTime());
|
|
||||||
holder.tv_remind_type.setText("每天");
|
|
||||||
holder.tv_remind_type.setBackgroundResource(R.drawable.tv_times_bg_loop);
|
|
||||||
break;
|
|
||||||
case AlarmUtils.WORKING_DAY:
|
|
||||||
holder.tv_time.setText(alarmClockData.getTime());
|
|
||||||
holder.tv_remind_type.setText("周一至周五");
|
|
||||||
holder.tv_remind_type.setBackgroundResource(R.drawable.tv_times_bg_work);
|
|
||||||
break;
|
|
||||||
case AlarmUtils.OFF_DAY:
|
|
||||||
holder.tv_time.setText(alarmClockData.getTime());
|
|
||||||
holder.tv_remind_type.setText("周六至周日");
|
|
||||||
holder.tv_remind_type.setBackgroundResource(R.drawable.tv_times_bg_offday);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
String title = alarmClockData.getTitle();
|
|
||||||
if (TextUtils.isEmpty(title)) {
|
|
||||||
holder.tv_title.setText("无标题");
|
|
||||||
} else {
|
|
||||||
holder.tv_title.setText(title);
|
|
||||||
}
|
|
||||||
int is_onoff = alarmClockData.getIs_onoff();
|
|
||||||
holder.toggleButton2.setDisable(true);
|
|
||||||
if (is_onoff == 1) {
|
|
||||||
holder.tv_status.setText("已开启");
|
|
||||||
holder.toggleButton2.setToggleOn(false);
|
|
||||||
} else {
|
|
||||||
holder.tv_status.setText("已关闭");
|
|
||||||
holder.toggleButton2.setToggleOff(false);
|
|
||||||
}
|
|
||||||
int type = alarmClockData.getClazz();
|
|
||||||
switch (type){
|
|
||||||
case 1:
|
|
||||||
default:
|
|
||||||
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_medicine_pressed));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_look_pressed));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
holder.iv_type.setImageDrawable(mContext.getDrawable(R.drawable.icon_alarm_reserve_pressed));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String voice = alarmClockData.getVoice();
|
|
||||||
if (TextUtils.isEmpty(voice)) {
|
|
||||||
holder.cl_voice.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
holder.cl_voice.setVisibility(View.VISIBLE);
|
|
||||||
MediaPlayer mMediaPlayer = new MediaPlayer();
|
|
||||||
mMediaPlayer.setAudioAttributes(
|
|
||||||
new AudioAttributes.Builder()
|
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
mMediaPlayer.setOnCompletionListener(mp -> Log.e("setOnCompletionListener", "onCompletion: "));
|
|
||||||
mMediaPlayer.setOnPreparedListener(mp -> Log.e("setOnPreparedListener", "onPrepared: "));
|
|
||||||
mMediaPlayer.setOnErrorListener((mp, what, extra) -> false);
|
|
||||||
//设置音频文件到MediaPlayer对象中
|
|
||||||
try {
|
|
||||||
mMediaPlayer.setDataSource(voice);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
//让MediaPlayer对象准备,用这个方法防止加载时耗时导致anr
|
|
||||||
mMediaPlayer.prepareAsync();
|
|
||||||
FFmpegUtils.getDurationInMilliseconds(voice, new Observer<Integer>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull Integer integer) {
|
|
||||||
holder.tv_voice.setText(integer + "秒");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
holder.cl_voice.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mMediaPlayer.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
String fileUrl = alarmClockData.getFile();
|
|
||||||
if (TextUtils.isEmpty(fileUrl)) {
|
|
||||||
holder.cl_vp.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
holder.cl_vp.setVisibility(View.VISIBLE);
|
|
||||||
if (isImgUrl(fileUrl)) {
|
|
||||||
holder.imageView.setVisibility(View.VISIBLE);
|
|
||||||
holder.jz_video.setVisibility(View.GONE);
|
|
||||||
if (!mContext.isDestroyed()) {
|
|
||||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtils.dip2px(mContext, 16F)));
|
|
||||||
Glide.with(mContext).load(fileUrl).apply(options).into(holder.imageView);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
holder.imageView.setVisibility(View.GONE);
|
|
||||||
holder.jz_video.setVisibility(View.VISIBLE);
|
|
||||||
String fileName = Utils.getFileNamefromURL(fileUrl);
|
|
||||||
File file = new File(Utils.getDownLoadPath(mContext) + fileName);
|
|
||||||
String path;
|
|
||||||
if (file.exists() && !file.isDirectory()) {
|
|
||||||
path = file.getAbsolutePath();
|
|
||||||
} else {
|
|
||||||
path = fileUrl;
|
|
||||||
}
|
|
||||||
holder.jz_video.setUp(path, "");
|
|
||||||
holder.jz_video.startButton.setImageDrawable(mContext.getDrawable(R.drawable.play));
|
|
||||||
FFmpegUtils.loadVideoScreenshot(path, new Observer<Bitmap>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull Bitmap bitmap) {
|
|
||||||
if (!mContext.isDestroyed()) {
|
|
||||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtils.dip2px(mContext, 16F)));
|
|
||||||
Glide.with(mContext).load(bitmap).apply(options).into(holder.jz_video.posterImageView);
|
|
||||||
// Glide.with(mContext).load(bitmap).into(holder.imageView);
|
|
||||||
}
|
|
||||||
holder.jz_video.startButton.setImageDrawable(mContext.getDrawable(R.drawable.play));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
holder.root.setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View view) {
|
|
||||||
mOnLongClickListener.onLongClick(alarmClockData);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
// Intent intent = new Intent(mContext, AlarmClockEditActivity.class);
|
|
||||||
// intent.putExtra("id", alarmClockData.getId());
|
|
||||||
// mContext.startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pattern mCompile = Pattern.compile(".*?(gif|jpeg|png|jpg|bmp|webp)");
|
|
||||||
|
|
||||||
private boolean isImgUrl(String url) {
|
|
||||||
if (TextUtils.isEmpty(url) || url.trim().length() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mCompile.matcher(url).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return mAlarmClockData == null ? 0 : mAlarmClockData.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class holder extends RecyclerView.ViewHolder {
|
|
||||||
TextView tv_time, tv_remind_type, tv_title, tv_voice, tv_status;
|
|
||||||
ConstraintLayout cl_voice, cl_vp, root;
|
|
||||||
JzvdStdRound jz_video;
|
|
||||||
ImageView imageView,iv_type;
|
|
||||||
ToggleButton toggleButton2;
|
|
||||||
|
|
||||||
public holder(@NonNull View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
tv_time = itemView.findViewById(R.id.tv_time);
|
|
||||||
tv_remind_type = itemView.findViewById(R.id.tv_remind_type);
|
|
||||||
tv_title = itemView.findViewById(R.id.tv_title);
|
|
||||||
tv_voice = itemView.findViewById(R.id.tv_voice);
|
|
||||||
cl_voice = itemView.findViewById(R.id.cl_voice);
|
|
||||||
cl_vp = itemView.findViewById(R.id.cl_vp);
|
|
||||||
root = itemView.findViewById(R.id.root);
|
|
||||||
jz_video = itemView.findViewById(R.id.jz_video);
|
|
||||||
imageView = itemView.findViewById(R.id.imageView);
|
|
||||||
iv_type = itemView.findViewById(R.id.iv_type);
|
|
||||||
tv_status = itemView.findViewById(R.id.tv_status);
|
|
||||||
toggleButton2 = itemView.findViewById(R.id.toggleButton2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,7 @@ import com.tencent.bugly.crashreport.CrashReport;
|
|||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.xxpatx.os.BuildConfig;
|
import com.xxpatx.os.BuildConfig;
|
||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
import com.xxpatx.os.alarm.AlarmUtils;
|
||||||
|
import com.xxpatx.os.db.ContactCacheUtils;
|
||||||
import com.xxpatx.os.db.WechatContactManager;
|
import com.xxpatx.os.db.WechatContactManager;
|
||||||
import com.xxpatx.os.manager.AmapManager;
|
import com.xxpatx.os.manager.AmapManager;
|
||||||
import com.xxpatx.os.manager.AppManager;
|
import com.xxpatx.os.manager.AppManager;
|
||||||
@@ -46,8 +47,9 @@ public class BaseApplication extends Application {
|
|||||||
// 初始化 Toast 框架
|
// 初始化 Toast 框架
|
||||||
Toaster.init(this);
|
Toaster.init(this);
|
||||||
|
|
||||||
CrashReport.initCrashReport(getApplicationContext(), "f65d7a4361", false);
|
CrashReport.initCrashReport(getApplicationContext(), "09fec11058", false);
|
||||||
CrashReport.setDeviceModel(getApplicationContext(), Build.MODEL);
|
CrashReport.setDeviceModel(getApplicationContext(), Build.MODEL);
|
||||||
|
CrashReport.setDeviceId(this, Utils.getSerial());
|
||||||
xcrash.XCrash.init(this);
|
xcrash.XCrash.init(this);
|
||||||
|
|
||||||
aliyunPushInit();
|
aliyunPushInit();
|
||||||
@@ -77,6 +79,7 @@ public class BaseApplication extends Application {
|
|||||||
Log.e(TAG, "onCreate: " + e.getMessage());
|
Log.e(TAG, "onCreate: " + e.getMessage());
|
||||||
}
|
}
|
||||||
WechatContactManager.init(this);
|
WechatContactManager.init(this);
|
||||||
|
ContactCacheUtils.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void aliyunPushInit() {
|
private void aliyunPushInit() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||||||
public class Contact implements Serializable {
|
public class Contact implements Serializable {
|
||||||
private static final long serialVersionUID = 8814155739557674021L;
|
private static final long serialVersionUID = 8814155739557674021L;
|
||||||
|
|
||||||
String id;
|
int id;
|
||||||
String name;//名称
|
String name;//名称
|
||||||
int is_urgent;//是否紧急联系人 0否1是
|
int is_urgent;//是否紧急联系人 0否1是
|
||||||
String mobile;//手机号
|
String mobile;//手机号
|
||||||
@@ -32,11 +32,11 @@ public class Contact implements Serializable {
|
|||||||
this.simContact = sim;
|
this.simContact = sim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
47
app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java
Normal file
47
app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package com.xxpatx.os.db;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class ContactCacheHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
public static final int DATABASE_VERSION = 1;
|
||||||
|
public static final String DATABASE_NAME = "ContactDatabase.db";
|
||||||
|
// public static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
||||||
|
public static final String DATABASE_FILE_NAME = DATABASE_NAME;
|
||||||
|
|
||||||
|
public static final String TABLE_ALARM = "ContactTable";
|
||||||
|
|
||||||
|
public static final String KEY_ID = "id";
|
||||||
|
public static final String KEY_NAME = "name";
|
||||||
|
public static final String KEY_URGENT = "urgent";
|
||||||
|
public static final String KEY_MOBILE = "mobile";
|
||||||
|
public static final String KEY_AVATAR = "avatar";
|
||||||
|
public static final String KEY_TAG = "tag";
|
||||||
|
|
||||||
|
|
||||||
|
private static final String CREATE_CONTACT_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_ALARM +
|
||||||
|
"("
|
||||||
|
+ KEY_ID + " INTEGER,"
|
||||||
|
+ KEY_NAME + " TEXT,"
|
||||||
|
+ KEY_URGENT + " INTEGER DEFAULT 0,"
|
||||||
|
+ KEY_MOBILE + " TEXT PRIMARY KEY,"
|
||||||
|
+ KEY_AVATAR + " TEXT,"
|
||||||
|
+ KEY_TAG + " TEXT"
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
public ContactCacheHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
|
||||||
|
super(context, name, factory, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||||
|
sqLiteDatabase.execSQL(CREATE_CONTACT_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
162
app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java
Normal file
162
app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
package com.xxpatx.os.db;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.xxpatx.os.bean.Contact;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ContactCacheUtils {
|
||||||
|
private static final String TAG = "ContactCacheUtils";
|
||||||
|
|
||||||
|
private static ContactCacheUtils sInstance;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private SQLiteDatabase mDatabase;
|
||||||
|
private ContactCacheHelper mContactHelper;
|
||||||
|
|
||||||
|
public ContactCacheUtils(Context context) {
|
||||||
|
this.mContext = context.getApplicationContext();
|
||||||
|
// this.mContactHelper = new ContactCacheHelper(context, ContactCacheHelper.DATABASE_NAME, null, ContactCacheHelper.DATABASE_VERSION);
|
||||||
|
// this.mContactHelper = new ContactCacheHelper(context,
|
||||||
|
// context.getExternalCacheDir() + File.separator + ContactCacheHelper.DATABASE_NAME,
|
||||||
|
// null, ContactCacheHelper.DATABASE_VERSION);
|
||||||
|
this.mContactHelper = new ContactCacheHelper(context,
|
||||||
|
Environment.getExternalStorageDirectory() + File.separator + ContactCacheHelper.DATABASE_NAME,
|
||||||
|
null, ContactCacheHelper.DATABASE_VERSION);
|
||||||
|
this.mDatabase = mContactHelper.getWritableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(Context context) {
|
||||||
|
if (context == null) {
|
||||||
|
throw new RuntimeException("context is NULL");
|
||||||
|
}
|
||||||
|
if (sInstance == null) {
|
||||||
|
sInstance = new ContactCacheUtils(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ContactCacheUtils getInstance() {
|
||||||
|
if (sInstance == null) {
|
||||||
|
throw new IllegalStateException("You must be init AlarmUtils first");
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContentValues getValuesFromAlarmClock(Contact contact) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ContactCacheHelper.KEY_ID, contact.getId());
|
||||||
|
values.put(ContactCacheHelper.KEY_NAME, contact.getName());
|
||||||
|
values.put(ContactCacheHelper.KEY_URGENT, contact.getIs_urgent());
|
||||||
|
values.put(ContactCacheHelper.KEY_MOBILE, contact.getMobile());
|
||||||
|
values.put(ContactCacheHelper.KEY_AVATAR, contact.getAvatar());
|
||||||
|
values.put(ContactCacheHelper.KEY_TAG, contact.getTag());
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加数据
|
||||||
|
*
|
||||||
|
* @param contact
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean addContact(Contact contact) {
|
||||||
|
ContentValues values = getValuesFromAlarmClock(contact);
|
||||||
|
long id = 0;
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
id = mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_ALARM, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "addContact: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
return id > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入数据
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
public void insertAlarmClockList(List<Contact> list) {
|
||||||
|
List<ContentValues> contentValuesList = new ArrayList<>();
|
||||||
|
for (Contact alarmClockData : list) {
|
||||||
|
ContentValues values = getValuesFromAlarmClock(alarmClockData);
|
||||||
|
contentValuesList.add(values);
|
||||||
|
}
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
for (ContentValues v : contentValuesList) {
|
||||||
|
mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_ALARM, null, v, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
}
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "insertListValues: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
*
|
||||||
|
* @param contact
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean deleteContact(Contact contact) {
|
||||||
|
if (contact == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return deleteContact(contact.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteContact(int rowId) {
|
||||||
|
long id = 0;
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
id = mDatabase.delete(ContactCacheHelper.TABLE_ALARM, " id =" + rowId, null);
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "deleteContact: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
Log.e(TAG, "deleteContact: " + id);
|
||||||
|
return id > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有Alarm
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Contact> getDatabaseContact() {
|
||||||
|
List<Contact> list = new ArrayList<>();
|
||||||
|
String selectQuery = "SELECT * FROM " + ContactCacheHelper.TABLE_ALARM;
|
||||||
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
Contact contact = new Contact();
|
||||||
|
contact.setId(cursor.getInt(cursor.getColumnIndex(ContactCacheHelper.KEY_ID)));
|
||||||
|
contact.setName(cursor.getString(cursor.getColumnIndex(ContactCacheHelper.KEY_NAME)));
|
||||||
|
contact.setIs_urgent(cursor.getInt(cursor.getColumnIndex(ContactCacheHelper.KEY_URGENT)));
|
||||||
|
contact.setMobile(cursor.getString(cursor.getColumnIndex(ContactCacheHelper.KEY_MOBILE)));
|
||||||
|
contact.setAvatar(cursor.getString(cursor.getColumnIndex(ContactCacheHelper.KEY_AVATAR)));
|
||||||
|
contact.setTag(cursor.getString(cursor.getColumnIndex(ContactCacheHelper.KEY_TAG)));
|
||||||
|
list.add(contact);
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
Log.e(TAG, "getDatabaseContact: " + list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,8 +18,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||||||
|
|
||||||
import com.hjq.toast.Toaster;
|
import com.hjq.toast.Toaster;
|
||||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
@@ -35,13 +33,9 @@ import com.xxpatx.os.config.CommonConfig;
|
|||||||
import com.xxpatx.os.databinding.FragmentContactHomeBinding;
|
import com.xxpatx.os.databinding.FragmentContactHomeBinding;
|
||||||
import com.xxpatx.os.dialog.EditContactDialog;
|
import com.xxpatx.os.dialog.EditContactDialog;
|
||||||
import com.xxpatx.os.utils.DayUtils;
|
import com.xxpatx.os.utils.DayUtils;
|
||||||
import com.xxpatx.os.utils.ScreenUtils;
|
|
||||||
import com.xxpatx.os.utils.TimeUtils;
|
import com.xxpatx.os.utils.TimeUtils;
|
||||||
import com.xxpatx.os.view.EquallyDividedItemDecoration;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ContactFragment extends BaseMvvmFragment<ContactViewModel, FragmentContactHomeBinding> {
|
public class ContactFragment extends BaseMvvmFragment<ContactViewModel, FragmentContactHomeBinding> {
|
||||||
@@ -139,63 +133,63 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LiveEventBus
|
// LiveEventBus
|
||||||
.get("getWeather24HourlyKey", WeatherHourlyBean.HourlyBean.class)
|
// .get("getWeather24HourlyKey", WeatherHourlyBean.HourlyBean.class)
|
||||||
.observe(this, new Observer<WeatherHourlyBean.HourlyBean>() {
|
// .observe(this, new Observer<WeatherHourlyBean.HourlyBean>() {
|
||||||
@Override
|
// @Override
|
||||||
public void onChanged(@Nullable WeatherHourlyBean.HourlyBean hourlyBean) {
|
// public void onChanged(@Nullable WeatherHourlyBean.HourlyBean hourlyBean) {
|
||||||
String imageName = "he" + hourlyBean.getIcon();
|
// String imageName = "he" + hourlyBean.getIcon();
|
||||||
Log.e(TAG, "onSuccess: " + imageName);
|
// Log.e(TAG, "onSuccess: " + imageName);
|
||||||
if (isAdded()) {
|
// if (isAdded()) {
|
||||||
int resId = getResources().getIdentifier(imageName, "drawable", mContext.getPackageName());
|
// int resId = getResources().getIdentifier(imageName, "drawable", mContext.getPackageName());
|
||||||
// Log.e(TAG, "onSuccess: " + resId);
|
//// Log.e(TAG, "onSuccess: " + resId);
|
||||||
// if (resId == 0) {
|
//// if (resId == 0) {
|
||||||
// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(R.drawable.he100));
|
//// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(R.drawable.he100));
|
||||||
// } else {
|
//// } else {
|
||||||
// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(resId));
|
//// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(resId));
|
||||||
|
//// }
|
||||||
|
// mViewDataBinding.tvTemp.setText(hourlyBean.getTemp() + "℃");
|
||||||
// }
|
// }
|
||||||
mViewDataBinding.tvTemp.setText(hourlyBean.getTemp() + "℃");
|
// }
|
||||||
}
|
// });
|
||||||
}
|
//
|
||||||
});
|
// LiveEventBus
|
||||||
|
// .get("getWeather7DKey", WeatherDailyBean.DailyBean.class)
|
||||||
|
// .observe(this, new Observer<WeatherDailyBean.DailyBean>() {
|
||||||
|
// @Override
|
||||||
|
// public void onChanged(@Nullable WeatherDailyBean.DailyBean dailyBean) {
|
||||||
|
// mViewDataBinding.tvWeather.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// LiveEventBus
|
||||||
|
// .get("time", String.class)
|
||||||
|
// .observe(this, new Observer<String>() {
|
||||||
|
// @Override
|
||||||
|
// public void onChanged(@Nullable String s) {
|
||||||
|
// mViewDataBinding.tvTime.setText(s);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// LiveEventBus
|
||||||
|
// .get("date", String.class)
|
||||||
|
// .observe(this, new Observer<String>() {
|
||||||
|
// @Override
|
||||||
|
// public void onChanged(@Nullable String s) {
|
||||||
|
// mViewDataBinding.tvData.setText(s);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// LiveEventBus
|
||||||
|
// .get("week", String.class)
|
||||||
|
// .observe(this, new Observer<String>() {
|
||||||
|
// @Override
|
||||||
|
// public void onChanged(@Nullable String s) {
|
||||||
|
// mViewDataBinding.tvWeek.setText(s);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
LiveEventBus
|
mViewModel.getContactListData().observe(this, new Observer<List<Contact>>() {
|
||||||
.get("getWeather7DKey", WeatherDailyBean.DailyBean.class)
|
|
||||||
.observe(this, new Observer<WeatherDailyBean.DailyBean>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable WeatherDailyBean.DailyBean dailyBean) {
|
|
||||||
mViewDataBinding.tvWeather.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LiveEventBus
|
|
||||||
.get("time", String.class)
|
|
||||||
.observe(this, new Observer<String>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable String s) {
|
|
||||||
mViewDataBinding.tvTime.setText(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LiveEventBus
|
|
||||||
.get("date", String.class)
|
|
||||||
.observe(this, new Observer<String>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable String s) {
|
|
||||||
mViewDataBinding.tvData.setText(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LiveEventBus
|
|
||||||
.get("week", String.class)
|
|
||||||
.observe(this, new Observer<String>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable String s) {
|
|
||||||
mViewDataBinding.tvWeek.setText(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mViewModel.getContactList().observe(this, new Observer<List<Contact>>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(List<Contact> contacts) {
|
public void onChanged(List<Contact> contacts) {
|
||||||
if (contacts == null || contacts.size() == 0) {
|
if (contacts == null || contacts.size() == 0) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.xxpatx.os.bean.BaseResponse;
|
|||||||
import com.xxpatx.os.bean.Contact;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
import com.xxpatx.os.databinding.FragmentContactHomeBinding;
|
import com.xxpatx.os.databinding.FragmentContactHomeBinding;
|
||||||
|
import com.xxpatx.os.db.ContactCacheUtils;
|
||||||
import com.xxpatx.os.gson.GsonUtils;
|
import com.xxpatx.os.gson.GsonUtils;
|
||||||
import com.xxpatx.os.network.NetInterfaceManager;
|
import com.xxpatx.os.network.NetInterfaceManager;
|
||||||
import com.xxpatx.os.network.UrlAddress;
|
import com.xxpatx.os.network.UrlAddress;
|
||||||
@@ -40,10 +41,10 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MutableLiveData<List<Contact>> mContactList = new MutableLiveData<>();
|
private MutableLiveData<List<Contact>> mContactListData = new MutableLiveData<>();
|
||||||
|
|
||||||
public MutableLiveData<List<Contact>> getContactList() {
|
public MutableLiveData<List<Contact>> getContactListData() {
|
||||||
return mContactList;
|
return mContactListData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getCacheContact() {
|
public void getCacheContact() {
|
||||||
@@ -54,7 +55,8 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
|||||||
if (!TextUtils.isEmpty(jsonString)) {
|
if (!TextUtils.isEmpty(jsonString)) {
|
||||||
List<Contact> contacts = gson.fromJson(jsonString, type);
|
List<Contact> contacts = gson.fromJson(jsonString, type);
|
||||||
if (contacts != null) {
|
if (contacts != null) {
|
||||||
mContactList.setValue(contacts);
|
contacts.addAll(ContactCacheUtils.getInstance().getDatabaseContact());
|
||||||
|
mContactListData.setValue(contacts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getContact();
|
getContact();
|
||||||
@@ -75,10 +77,10 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
|||||||
Log.e("getContactList", "onNext: " + listBaseResponse);
|
Log.e("getContactList", "onNext: " + listBaseResponse);
|
||||||
if (listBaseResponse.code == 200) {
|
if (listBaseResponse.code == 200) {
|
||||||
mMMKV.putString(UrlAddress.GET_MAIL_LIST, GsonUtils.toJSONString(listBaseResponse.data));
|
mMMKV.putString(UrlAddress.GET_MAIL_LIST, GsonUtils.toJSONString(listBaseResponse.data));
|
||||||
mContactList.setValue(listBaseResponse.data);
|
mContactListData.setValue(listBaseResponse.data);
|
||||||
} else {
|
} else {
|
||||||
mMMKV.putString(UrlAddress.GET_MAIL_LIST, "");
|
mMMKV.putString(UrlAddress.GET_MAIL_LIST, "");
|
||||||
mContactList.setValue(new ArrayList<>());
|
mContactListData.setValue(new ArrayList<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +93,10 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
|||||||
}.getType();
|
}.getType();
|
||||||
List<Contact> contacts = gson.fromJson(jsonString, type);
|
List<Contact> contacts = gson.fromJson(jsonString, type);
|
||||||
if (contacts == null) {
|
if (contacts == null) {
|
||||||
mContactList.setValue(new ArrayList<>());
|
mContactListData.setValue(ContactCacheUtils.getInstance().getDatabaseContact());
|
||||||
} else {
|
} else {
|
||||||
mContactList.setValue(contacts);
|
contacts.addAll(ContactCacheUtils.getInstance().getDatabaseContact());
|
||||||
|
mContactListData.setValue(contacts);
|
||||||
}
|
}
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
@@ -112,7 +115,7 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
|||||||
return mDeleteData;
|
return mDeleteData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteContact(String id) {
|
public void deleteContact(int id) {
|
||||||
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
||||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class ContactViewModel extends BaseViewModel<FragmentContactBinding, Frag
|
|||||||
return mDeleteData;
|
return mDeleteData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteContact(String id) {
|
public void deleteContact(int id) {
|
||||||
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
||||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.xxpatx.os.fragment.settings;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -15,30 +14,18 @@ import androidx.lifecycle.Observer;
|
|||||||
import com.blankj.utilcode.util.NetworkUtils;
|
import com.blankj.utilcode.util.NetworkUtils;
|
||||||
import com.hjq.toast.Toaster;
|
import com.hjq.toast.Toaster;
|
||||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.xxpatx.os.BuildConfig;
|
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.activity.alarm.port.PortAlarmActivity;
|
import com.xxpatx.os.activity.alarm.list.AlarmListActivity;
|
||||||
import com.xxpatx.os.activity.contact.AddWechatContactActivity;
|
|
||||||
import com.xxpatx.os.activity.dailyapp.DailyAppActivity;
|
import com.xxpatx.os.activity.dailyapp.DailyAppActivity;
|
||||||
import com.xxpatx.os.activity.emergency.EmergencyActivity;
|
import com.xxpatx.os.activity.emergency.EmergencyActivity;
|
||||||
import com.xxpatx.os.activity.setting.SettingActivity;
|
import com.xxpatx.os.activity.setting.SettingActivity;
|
||||||
import com.xxpatx.os.activity.weather.WeatherActivity;
|
|
||||||
import com.xxpatx.os.base.mvvm.fragment.BaseMvvmFragment;
|
import com.xxpatx.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||||
import com.xxpatx.os.bean.MapBean;
|
import com.xxpatx.os.bean.MapBean;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
import com.xxpatx.os.databinding.FragmentHomeBinding;
|
|
||||||
import com.xxpatx.os.databinding.FragmentSettingsBinding;
|
import com.xxpatx.os.databinding.FragmentSettingsBinding;
|
||||||
import com.xxpatx.os.manager.AmapManager;
|
import com.xxpatx.os.manager.AmapManager;
|
||||||
import com.xxpatx.os.utils.ApkUtils;
|
import com.xxpatx.os.utils.ApkUtils;
|
||||||
import com.xxpatx.os.utils.DayUtils;
|
|
||||||
import com.xxpatx.os.utils.TimeUtils;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
@@ -163,7 +150,7 @@ public class SettingsFragment extends BaseMvvmFragment<SettingsViewModel, Fragme
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void openAlarmClock(View view) {
|
public void openAlarmClock(View view) {
|
||||||
startActivity(new Intent(mContext, PortAlarmActivity.class));
|
startActivity(new Intent(mContext, AlarmListActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openEmergency(View view) {
|
public void openEmergency(View view) {
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ import android.database.sqlite.SQLiteDatabase;
|
|||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class IconPositionDBHelper extends SQLiteOpenHelper {
|
public class IconPositionDBHelper extends SQLiteOpenHelper {
|
||||||
public static final String DATABASE_NAME = "requestlog.db";
|
public static final String DATABASE_NAME = "IconPosition.db";
|
||||||
private static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
public static final int DATABASE_VERSION = 1;
|
||||||
private static final int DATABASE_VERSION = 1;
|
|
||||||
|
|
||||||
public IconPositionDBHelper(Context context) {
|
public IconPositionDBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
|
||||||
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, name, factory, version);
|
||||||
super(context, DATABASE_FILE_NAME, null, DATABASE_VERSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class IconPositionManager {
|
|||||||
throw new RuntimeException("Context is NULL");
|
throw new RuntimeException("Context is NULL");
|
||||||
}
|
}
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mDBHelper = new IconPositionDBHelper(context);
|
mDBHelper = new IconPositionDBHelper(context, IconPositionDBHelper.DATABASE_NAME, null, IconPositionDBHelper.DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
@@ -45,7 +45,7 @@ public class IconPositionManager {
|
|||||||
|
|
||||||
public IconPositionDBHelper getDBHelper() {
|
public IconPositionDBHelper getDBHelper() {
|
||||||
if (mDBHelper == null) {
|
if (mDBHelper == null) {
|
||||||
mDBHelper = new IconPositionDBHelper(mContext);
|
mDBHelper = new IconPositionDBHelper(mContext, IconPositionDBHelper.DATABASE_NAME, null, IconPositionDBHelper.DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
return mDBHelper;
|
return mDBHelper;
|
||||||
}
|
}
|
||||||
@@ -106,6 +106,4 @@ public class IconPositionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.tencent.mmkv.MMKV;
|
|||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||||
import com.uiui.video.bean.VideoInfo;
|
|
||||||
import com.xxpatx.os.BuildConfig;
|
import com.xxpatx.os.BuildConfig;
|
||||||
import com.xxpatx.os.alarm.AlarmClockData;
|
import com.xxpatx.os.alarm.AlarmClockData;
|
||||||
import com.xxpatx.os.alarm.AlarmUtils;
|
import com.xxpatx.os.alarm.AlarmUtils;
|
||||||
@@ -23,7 +22,6 @@ import com.xxpatx.os.bean.AppInfo;
|
|||||||
import com.xxpatx.os.bean.ArticleList;
|
import com.xxpatx.os.bean.ArticleList;
|
||||||
import com.xxpatx.os.bean.BaiduMapGeoBean;
|
import com.xxpatx.os.bean.BaiduMapGeoBean;
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
import com.xxpatx.os.bean.BaseResponse;
|
||||||
import com.xxpatx.os.bean.CategoryBean;
|
|
||||||
import com.xxpatx.os.bean.Contact;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.bean.DemandBean;
|
import com.xxpatx.os.bean.DemandBean;
|
||||||
import com.xxpatx.os.bean.ExpressData;
|
import com.xxpatx.os.bean.ExpressData;
|
||||||
@@ -55,7 +53,6 @@ import com.xxpatx.os.network.api.uiui.AppUpdate;
|
|||||||
import com.xxpatx.os.network.api.uiui.AppUsageRecordApi;
|
import com.xxpatx.os.network.api.uiui.AppUsageRecordApi;
|
||||||
import com.xxpatx.os.network.api.uiui.ArticleCategorysListApi;
|
import com.xxpatx.os.network.api.uiui.ArticleCategorysListApi;
|
||||||
import com.xxpatx.os.network.api.uiui.ArticleListApi;
|
import com.xxpatx.os.network.api.uiui.ArticleListApi;
|
||||||
import com.xxpatx.os.network.api.uiui.CategorysApi;
|
|
||||||
import com.xxpatx.os.network.api.uiui.DemandListApi;
|
import com.xxpatx.os.network.api.uiui.DemandListApi;
|
||||||
import com.xxpatx.os.network.api.uiui.GetAdminSnSettingApi;
|
import com.xxpatx.os.network.api.uiui.GetAdminSnSettingApi;
|
||||||
import com.xxpatx.os.network.api.uiui.GetMailList;
|
import com.xxpatx.os.network.api.uiui.GetMailList;
|
||||||
@@ -64,7 +61,6 @@ import com.xxpatx.os.network.api.uiui.GoodsListApi;
|
|||||||
import com.xxpatx.os.network.api.uiui.GoodsTypeApi;
|
import com.xxpatx.os.network.api.uiui.GoodsTypeApi;
|
||||||
import com.xxpatx.os.network.api.uiui.GoodsTypeListApi;
|
import com.xxpatx.os.network.api.uiui.GoodsTypeListApi;
|
||||||
import com.xxpatx.os.network.api.uiui.HealthCodeApi;
|
import com.xxpatx.os.network.api.uiui.HealthCodeApi;
|
||||||
import com.xxpatx.os.network.api.uiui.KnowledgeVideoListApi;
|
|
||||||
import com.xxpatx.os.network.api.uiui.SnIsActivationApi;
|
import com.xxpatx.os.network.api.uiui.SnIsActivationApi;
|
||||||
import com.xxpatx.os.network.api.uiui.contact.MailListAddApi;
|
import com.xxpatx.os.network.api.uiui.contact.MailListAddApi;
|
||||||
import com.xxpatx.os.network.api.uiui.contact.MailListDeleteApi;
|
import com.xxpatx.os.network.api.uiui.contact.MailListDeleteApi;
|
||||||
@@ -82,7 +78,6 @@ import com.xxpatx.os.network.api.uiui.app.RunNewApp;
|
|||||||
import com.xxpatx.os.network.api.uiui.contact.MailListEditApi;
|
import com.xxpatx.os.network.api.uiui.contact.MailListEditApi;
|
||||||
import com.xxpatx.os.network.api.uiui.desktop.GetDesktopApi;
|
import com.xxpatx.os.network.api.uiui.desktop.GetDesktopApi;
|
||||||
import com.xxpatx.os.network.api.uiui.desktop.UpdateDesktopApi;
|
import com.xxpatx.os.network.api.uiui.desktop.UpdateDesktopApi;
|
||||||
import com.xxpatx.os.network.api.uiui.liven.LivenVideoListApi;
|
|
||||||
import com.xxpatx.os.network.api.uiui.order.AllOrderApi;
|
import com.xxpatx.os.network.api.uiui.order.AllOrderApi;
|
||||||
import com.xxpatx.os.network.api.uiui.order.OrderExpressApi;
|
import com.xxpatx.os.network.api.uiui.order.OrderExpressApi;
|
||||||
import com.xxpatx.os.network.api.uiui.order.OrderIndexApi;
|
import com.xxpatx.os.network.api.uiui.order.OrderIndexApi;
|
||||||
@@ -101,7 +96,6 @@ import com.xxpatx.os.utils.Utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -402,13 +396,6 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse<List<CategoryBean>>> getCategorysObservable() {
|
|
||||||
return mRetrofit.create(CategorysApi.class)
|
|
||||||
.getArticleCategorys(Utils.getSerial())
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable<BaseResponse<ArticleList>> getArticleListObservable() {
|
public Observable<BaseResponse<ArticleList>> getArticleListObservable() {
|
||||||
return mRetrofit.create(ArticleListApi.class)
|
return mRetrofit.create(ArticleListApi.class)
|
||||||
.getArticleList(Utils.getSerial())
|
.getArticleList(Utils.getSerial())
|
||||||
@@ -458,7 +445,7 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse> getMailListDeleteObservable(String id) {
|
public Observable<BaseResponse> getMailListDeleteObservable(int id) {
|
||||||
return mRetrofit.create(MailListDeleteApi.class)
|
return mRetrofit.create(MailListDeleteApi.class)
|
||||||
.deleteMailList(Utils.getSerial(), id)
|
.deleteMailList(Utils.getSerial(), id)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
@@ -528,20 +515,6 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse<ArrayList<VideoInfo>>> getLivenVideoListObservable() {
|
|
||||||
return mRetrofit.create(LivenVideoListApi.class)
|
|
||||||
.getLivenVideoList(Utils.getSerial())
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable<BaseResponse<ArrayList<VideoInfo>>> getKnowledgeVideoListObservable() {
|
|
||||||
return mRetrofit.create(KnowledgeVideoListApi.class)
|
|
||||||
.getKnowledgeVideoList(Utils.getSerial())
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable<BaseResponse<List<RegionInfo>>> getRegionListObservable(String id) {
|
public Observable<BaseResponse<List<RegionInfo>>> getRegionListObservable(String id) {
|
||||||
return mRetrofit.create(RegionListApi.class)
|
return mRetrofit.create(RegionListApi.class)
|
||||||
.getRegionList(id)
|
.getRegionList(id)
|
||||||
|
|||||||
@@ -117,16 +117,6 @@ public class UrlAddress {
|
|||||||
/*获取闹钟*/
|
/*获取闹钟*/
|
||||||
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
||||||
|
|
||||||
/**
|
|
||||||
* 养生视频分类
|
|
||||||
*/
|
|
||||||
/*养生视频列表*/
|
|
||||||
public static final String GET_LIVEN_VIDEO_LIST = "livenVideo/getLivenVideoList";
|
|
||||||
/*知识视频列表*/
|
|
||||||
public static final String GET_KNOWLEDGE_VIDEO_LIST = "knowledgeVideo/getKnowledgeVideoList";
|
|
||||||
/*养生资讯分类*/
|
|
||||||
public static final String ARTICLE_CATEGORYS = "article/categorys";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品购买
|
* 商品购买
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xxpatx.os.network.api.uiui;
|
|
||||||
|
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
|
||||||
import com.xxpatx.os.bean.CategoryBean;
|
|
||||||
import com.xxpatx.os.network.UrlAddress;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.Query;
|
|
||||||
|
|
||||||
public interface CategorysApi {
|
|
||||||
@GET(UrlAddress.ARTICLE_CATEGORYS)
|
|
||||||
Observable<BaseResponse<List<CategoryBean>>> getArticleCategorys(
|
|
||||||
@Query("sn") String sn
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xxpatx.os.network.api.uiui;
|
|
||||||
|
|
||||||
import com.uiui.video.bean.VideoInfo;
|
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
|
||||||
import com.xxpatx.os.network.UrlAddress;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.Query;
|
|
||||||
|
|
||||||
public interface KnowledgeVideoListApi {
|
|
||||||
@GET(UrlAddress.GET_KNOWLEDGE_VIDEO_LIST)
|
|
||||||
Observable<BaseResponse<ArrayList<VideoInfo>>> getKnowledgeVideoList(
|
|
||||||
@Query("sn") String sn
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,6 @@ public interface MailListDeleteApi {
|
|||||||
@POST(UrlAddress.MAIL_LIST_DELETE)
|
@POST(UrlAddress.MAIL_LIST_DELETE)
|
||||||
Observable<BaseResponse> deleteMailList(
|
Observable<BaseResponse> deleteMailList(
|
||||||
@Field("sn") String sn,
|
@Field("sn") String sn,
|
||||||
@Field("id") String id
|
@Field("id") int id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xxpatx.os.network.api.uiui.liven;
|
|
||||||
|
|
||||||
import com.uiui.video.bean.VideoInfo;
|
|
||||||
import com.xxpatx.os.bean.BaseResponse;
|
|
||||||
import com.xxpatx.os.network.UrlAddress;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.Query;
|
|
||||||
|
|
||||||
public interface LivenVideoListApi {
|
|
||||||
@GET(UrlAddress.GET_LIVEN_VIDEO_LIST)
|
|
||||||
Observable<BaseResponse<ArrayList<VideoInfo>>> getLivenVideoList(
|
|
||||||
@Query("sn") String sn
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,9 @@ import com.tencent.mmkv.MMKV;
|
|||||||
import com.xxpatx.os.bean.Contact;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过微信标签最高支持8.0.49,8.0.50 获取不到数据
|
||||||
|
*/
|
||||||
public class WeAccessibilityService extends AccessibilityService {
|
public class WeAccessibilityService extends AccessibilityService {
|
||||||
private static final String TAG = "WeAccessibilityService";
|
private static final String TAG = "WeAccessibilityService";
|
||||||
|
|
||||||
|
|||||||
@@ -251,22 +251,23 @@ public class MainService extends BaseRxService
|
|||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
Log.e(TAG, "setNextAlarm: " + day_of_week);
|
Log.e(TAG, "setNextAlarm: " + day_of_week);
|
||||||
|
boolean local = alarmClockData.isIs_local();
|
||||||
switch (alarmClockData.getType()) {
|
switch (alarmClockData.getType()) {
|
||||||
case AlarmUtils.ONCE:
|
case AlarmUtils.ONCE:
|
||||||
break;
|
break;
|
||||||
case AlarmUtils.LOOP:
|
case AlarmUtils.LOOP:
|
||||||
AlarmUtils.getInstance().setDayLoopAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
AlarmUtils.getInstance().setDayLoopAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
||||||
alarmClockData.getId(), alarmClockData.getTime());
|
alarmClockData.getId(), alarmClockData.getTime(), local);
|
||||||
break;
|
break;
|
||||||
case AlarmUtils.WORKING_DAY:
|
case AlarmUtils.WORKING_DAY:
|
||||||
if (day_of_week < 5 || day_of_week == 7) {
|
if (day_of_week < 5 || day_of_week == 7) {
|
||||||
AlarmUtils.getInstance().setWorkDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
AlarmUtils.getInstance().setWorkDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
||||||
alarmClockData.getId(), alarmClockData.getTime());
|
alarmClockData.getId(), alarmClockData.getTime(), local);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AlarmUtils.OFF_DAY:
|
case AlarmUtils.OFF_DAY:
|
||||||
AlarmUtils.getInstance().setOffDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
AlarmUtils.getInstance().setOffDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(),
|
||||||
alarmClockData.getId(), alarmClockData.getTime());
|
alarmClockData.getId(), alarmClockData.getTime(), local);
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
package com.xxpatx.os.utils;
|
package com.xxpatx.os.utils;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
@@ -56,5 +64,109 @@ public class FileUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File uriToFile(Uri uri, Context context) {
|
||||||
|
String path = null;
|
||||||
|
if ("file".equals(uri.getScheme())) {
|
||||||
|
path = uri.getEncodedPath();
|
||||||
|
if (path != null) {
|
||||||
|
path = Uri.decode(path);
|
||||||
|
ContentResolver cr = context.getContentResolver();
|
||||||
|
StringBuffer buff = new StringBuffer();
|
||||||
|
buff.append("(").append(MediaStore.Images.ImageColumns.DATA).append("=").append("'" + path + "'").append(")");
|
||||||
|
Cursor cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA}, buff.toString(), null, null);
|
||||||
|
int index = 0;
|
||||||
|
int dataIdx = 0;
|
||||||
|
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
||||||
|
index = cur.getColumnIndex(MediaStore.Images.ImageColumns._ID);
|
||||||
|
index = cur.getInt(index);
|
||||||
|
dataIdx = cur.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
|
||||||
|
path = cur.getString(dataIdx);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
if (index == 0) {
|
||||||
|
} else {
|
||||||
|
Uri u = Uri.parse("content://media/external/images/media/" + index);
|
||||||
|
System.out.println("temp uri is :" + u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (path != null) {
|
||||||
|
return new File(path);
|
||||||
|
}
|
||||||
|
} else if ("content".equals(uri.getScheme())) {
|
||||||
|
// 4.2.2以后
|
||||||
|
String[] proj = {MediaStore.Images.Media.DATA};
|
||||||
|
Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||||
|
path = cursor.getString(columnIndex);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
return new File(path);
|
||||||
|
} else {
|
||||||
|
//Log.i(TAG, "Uri Scheme:" + uri.getScheme());
|
||||||
|
return new File(uri.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drawable转为file
|
||||||
|
*
|
||||||
|
* @param drawableId drawable的ID
|
||||||
|
* @param fileName 转换后的文件名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static File drawableToFile(Context context, int drawableId, String fileName) {
|
||||||
|
// InputStream is = view.getContext().getResources().openRawResource(R.drawable.logo);
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), drawableId);
|
||||||
|
// Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||||
|
String defaultPath = context.getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
||||||
|
File file = new File(defaultPath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
String defaultImgPath = defaultPath + "/" + fileName;
|
||||||
|
file = new File(defaultImgPath);
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
FileOutputStream fOut = new FileOutputStream(file);
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
||||||
|
// is.close();
|
||||||
|
fOut.flush();
|
||||||
|
fOut.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bitmap
|
||||||
|
*
|
||||||
|
* @param bitmap bitmap
|
||||||
|
* @param fileName 转换后的文件名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static File bitmapToFile(Context context, Bitmap bitmap, String fileName) {
|
||||||
|
String defaultPath = context.getFilesDir().getAbsolutePath() + "/defaultGoodInfo";
|
||||||
|
File file = new File(defaultPath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
String defaultImgPath = defaultPath + "/" + fileName;
|
||||||
|
file = new File(defaultImgPath);
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
FileOutputStream fOut = new FileOutputStream(file);
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
|
||||||
|
// is.close();
|
||||||
|
fOut.flush();
|
||||||
|
fOut.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,7 +240,7 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_group"
|
android:id="@+id/et_tag"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
|||||||
@@ -1,303 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context=".activity.alarm.main.AlarmActivity">
|
|
||||||
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="click"
|
|
||||||
type="com.xxpatx.os.activity.alarmclock.main.AlarmClockActivity.BtnClick" />
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/alarm_background_color">
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/constraintLayout14"
|
|
||||||
android:layout_width="140dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/white"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_exit"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_back"
|
|
||||||
android:layout_width="16dp"
|
|
||||||
android:layout_height="16dp"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/back_black"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="6dp"
|
|
||||||
android:text="闹钟设置"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="13sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/iv_back"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="140dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/cl_exit">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_all"
|
|
||||||
android:layout_width="124dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:background="@drawable/alarm_pressed_background">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView1"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_alarm_all"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="所有闹钟"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView2"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView1"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView2"
|
|
||||||
android:layout_width="18dp"
|
|
||||||
android:layout_height="18dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_touch"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_medicine"
|
|
||||||
android:layout_width="124dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_gravity="end">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView3"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_alarm_medicine"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="用药闹钟"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView4"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView4"
|
|
||||||
android:layout_width="18dp"
|
|
||||||
android:layout_height="18dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_look"
|
|
||||||
android:layout_width="124dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_gravity="end">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView5"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_alarm_look"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="接送闹钟"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView6"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView5"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView6"
|
|
||||||
android:layout_width="18dp"
|
|
||||||
android:layout_height="18dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_reserve"
|
|
||||||
android:layout_width="124dp"
|
|
||||||
android:layout_height="52dp"
|
|
||||||
android:layout_gravity="end">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView7"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_alarm_reserve"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="预约闹钟"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView8"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView7"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView8"
|
|
||||||
android:layout_width="18dp"
|
|
||||||
android:layout_height="18dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_add"
|
|
||||||
android:layout_width="75dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_add_alarm"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/constraintLayout14"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rv_data"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#e6e6e6" />
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_nodata"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#e6e6e6"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView9"
|
|
||||||
android:layout_width="120dp"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_nodata"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.501"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintVertical_bias="0.343" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="没有数据"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="14sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/imageView9"
|
|
||||||
app:layout_constraintHorizontal_bias="0.487"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/imageView9"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/imageView9" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".activity.alarmclock.add.port.PortAlarmClockAddActivity">
|
tools:context=".activity.alarm.add.AlarmAddActivity">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="click"
|
name="click"
|
||||||
type="com.xxpatx.os.activity.alarmclock.add.port.PortAlarmClockAddActivity.Click" />
|
type="com.xxpatx.os.activity.alarm.add.AlarmAddActivity.Click" />
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
@@ -2,10 +2,19 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".activity.alarmclock.add.AlarmClockAddActivity">
|
tools:context=".activity.alarm.edit.AlarmEditActivity">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="click"
|
||||||
|
type="com.xxpatx.os.activity.alarm.edit.AlarmEditActivity.Click" />
|
||||||
|
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="alarmClockData"
|
||||||
|
type="com.xxpatx.os.alarm.AlarmClockData" />
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@@ -14,48 +23,67 @@
|
|||||||
android:background="@color/gray">
|
android:background="@color/gray">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/constraintLayout13"
|
android:id="@+id/cl_exit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="48dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<ImageView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/iv_back"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="16dp"
|
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
|
android:onClick="@{click::exit}"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView12"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/icon_close"
|
android:src="@drawable/back_black"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="编辑闹钟"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/imageView12"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/tv_add"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/cl_exit">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/tv_add"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout13">
|
app:layout_constraintTop_toBottomOf="@+id/cl_exit">
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_picker"
|
android:id="@+id/cl_picker"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="200dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_weight="4"
|
|
||||||
android:background="@drawable/add_alarm_background">
|
android:background="@drawable/add_alarm_background">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -66,7 +94,7 @@
|
|||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="选择时间"
|
android:text="选择时间"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="12sp"
|
android:textSize="16sp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
@@ -89,8 +117,8 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_weight="1"
|
android:background="@drawable/add_alarm_background"
|
||||||
android:background="@drawable/add_alarm_background">
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView25"
|
android:id="@+id/textView25"
|
||||||
@@ -147,19 +175,11 @@
|
|||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="120dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_weight="2"
|
|
||||||
android:background="@drawable/add_alarm_background">
|
android:background="@drawable/add_alarm_background">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -183,7 +203,7 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:text="重复"
|
android:text="重复"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="12sp"
|
android:textSize="16sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@@ -216,22 +236,22 @@
|
|||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb1"
|
android:id="@+id/rb1"
|
||||||
android:layout_width="40dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="25dp"
|
||||||
android:background="@drawable/tv_times_bg_once_selector"
|
android:background="@drawable/tv_times_bg_once_selector"
|
||||||
android:button="@null"
|
android:button="@null"
|
||||||
android:textColor="@color/radio_botton_gray"
|
android:textColor="@color/radio_botton_gray"
|
||||||
android:textSize="9sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb2"
|
android:id="@+id/rb2"
|
||||||
android:layout_width="40dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="25dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:background="@drawable/tv_times_bg_loop_selector"
|
android:background="@drawable/tv_times_bg_loop_selector"
|
||||||
android:button="@null"
|
android:button="@null"
|
||||||
android:textColor="@color/radio_botton_gray"
|
android:textColor="@color/radio_botton_gray"
|
||||||
android:textSize="9sp" />
|
android:textSize="12sp" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -249,6 +269,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -257,7 +278,7 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:text="提醒方式"
|
android:text="提醒方式"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="12sp"
|
android:textSize="16sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@@ -267,8 +288,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:text="弹窗"
|
android:text="弹窗"
|
||||||
android:textColor="@color/title_gray"
|
android:textColor="@color/black"
|
||||||
android:textSize="12sp"
|
android:textSize="14sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@@ -281,10 +302,10 @@
|
|||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/add_alarm_background">
|
android:background="@drawable/add_alarm_background">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -304,7 +325,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_activation"
|
android:id="@+id/cl_activation"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="28dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:background="@drawable/edit_background"
|
android:background="@drawable/edit_background"
|
||||||
@@ -316,26 +337,19 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_activation"
|
android:id="@+id/et_activation"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="26dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:hint="请输入标题"
|
android:hint="请输入标题"
|
||||||
|
android:padding="4dp"
|
||||||
android:maxLength="13"
|
android:maxLength="13"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="用药闹钟"
|
|
||||||
android:textColorHint="@color/radio_botton_gray"
|
android:textColorHint="@color/radio_botton_gray"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:textSize="18sp"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView6"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView6"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="12dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -344,34 +358,22 @@
|
|||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="160dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_weight="3"
|
|
||||||
android:background="@drawable/add_alarm_background">
|
android:background="@drawable/add_alarm_background">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_add"
|
|
||||||
android:layout_width="60dp"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/icon_add_alarm"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView28"
|
android:id="@+id/textView28"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="选择图片或视频"
|
android:text="选择图片或视频"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="12sp"
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/cl_pic"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
@@ -379,21 +381,13 @@
|
|||||||
android:id="@+id/cl_pic"
|
android:id="@+id/cl_pic"
|
||||||
android:layout_width="72dp"
|
android:layout_width="72dp"
|
||||||
android:layout_height="72dp"
|
android:layout_height="72dp"
|
||||||
android:background="@drawable/add"
|
android:background="@drawable/icon_add"
|
||||||
|
android:onClick="@{click::openGallery}"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@+id/textView28"
|
app:layout_constraintStart_toStartOf="@+id/textView28"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView28">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<com.shehuan.niv.NiceImageView
|
<com.shehuan.niv.NiceImageView
|
||||||
@@ -401,6 +395,7 @@
|
|||||||
android:layout_width="72dp"
|
android:layout_width="72dp"
|
||||||
android:layout_height="72dp"
|
android:layout_height="72dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
|
android:onClick="@{click::openGallery}"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:corner_radius="4dp"
|
app:corner_radius="4dp"
|
||||||
@@ -424,8 +419,25 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/tv_add"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:background="@drawable/tv_add_alarm_background"
|
||||||
|
android:gravity="center"
|
||||||
|
android:onClick="@{click::submit}"
|
||||||
|
android:text="保存"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".activity.alarm.port.PortAlarmActivity">
|
tools:context=".activity.alarm.list.AlarmListActivity">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="click"
|
name="click"
|
||||||
type="com.xxpatx.os.activity.alarm.port.PortAlarmActivity.Click" />
|
type="com.xxpatx.os.activity.alarm.list.AlarmListActivity.Click" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context=".activity.noti.NoticeInfoActivity"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
tools:context=".activity.noti.NoticeInfoActivity">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
@@ -10,8 +10,7 @@
|
|||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_title"
|
android:id="@+id/tv_title"
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
<com.shehuan.niv.NiceImageView
|
<com.shehuan.niv.NiceImageView
|
||||||
android:id="@+id/iv_head"
|
android:id="@+id/iv_head"
|
||||||
android:layout_width="100dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="120dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/default_avatar"
|
android:src="@drawable/default_avatar"
|
||||||
|
|||||||
Reference in New Issue
Block a user