|
|
|
@ -1,7 +1,6 @@
@@ -1,7 +1,6 @@
|
|
|
|
|
package cc.niushuai.dididone.ui.calendar; |
|
|
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.icu.text.DateFormat; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.util.Log; |
|
|
|
|
import android.view.Gravity; |
|
|
|
@ -44,6 +43,7 @@ import cc.niushuai.dididone.util.XLog;
@@ -44,6 +43,7 @@ import cc.niushuai.dididone.util.XLog;
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import io.reactivex.Completable; |
|
|
|
|
import io.reactivex.CompletableObserver; |
|
|
|
|
import io.reactivex.Flowable; |
|
|
|
@ -60,10 +60,8 @@ public class CalendarFragment extends Fragment {
@@ -60,10 +60,8 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
private List<Project> floatingActionProjectList; |
|
|
|
|
|
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, |
|
|
|
|
ViewGroup container, Bundle savedInstanceState) { |
|
|
|
|
CalendarViewModel calendarViewModel = |
|
|
|
|
new ViewModelProvider(this).get(CalendarViewModel.class); |
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
|
|
|
|
CalendarViewModel calendarViewModel = new ViewModelProvider(this).get(CalendarViewModel.class); |
|
|
|
|
|
|
|
|
|
binding = FragmentCalendarBinding.inflate(inflater, container, false); |
|
|
|
|
View root = binding.getRoot(); |
|
|
|
@ -117,10 +115,11 @@ public class CalendarFragment extends Fragment {
@@ -117,10 +115,11 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
actionButton.show(true); |
|
|
|
|
actionButton.setTag(project.getName() + project.getId()); |
|
|
|
|
actionButton.setLabelText(project.getName()); |
|
|
|
|
actionButton.setImageDrawable(new IconicsDrawable(context).icon(project.getIcon()).color(project.getIconColor()).sizeDp(24)); |
|
|
|
|
actionButton.setImageDrawable(new IconicsDrawable(context).icon(project.getIcon()).color(project.getIconColor()).sizeDp(32)); |
|
|
|
|
actionButton.setButtonSize(FloatingActionButton.SIZE_NORMAL); |
|
|
|
|
actionButton.setColorNormal(getResources().getColor(R.color.white)); |
|
|
|
|
actionButton.setColorPressed(getResources().getColor(R.color.white)); |
|
|
|
|
|
|
|
|
|
actionButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onClick(View v) { |
|
|
|
@ -135,9 +134,7 @@ public class CalendarFragment extends Fragment {
@@ -135,9 +134,7 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
// 插入数据库
|
|
|
|
|
Completable completable = DBManager.INSTANCE.recordDao().insertAll(record); |
|
|
|
|
completable.subscribeOn(Schedulers.io()) |
|
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
.subscribe(new CompletableObserver() { |
|
|
|
|
completable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new CompletableObserver() { |
|
|
|
|
@Override |
|
|
|
|
public void onSubscribe(Disposable d) { |
|
|
|
|
} |
|
|
|
@ -184,6 +181,8 @@ public class CalendarFragment extends Fragment {
@@ -184,6 +181,8 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
// 重置上次选中日期
|
|
|
|
|
lastDate = localDate.toString(); |
|
|
|
|
|
|
|
|
|
binding.tvResult.setText(StrUtil.format("{} | {}", lastDate, lunarDate)); |
|
|
|
|
|
|
|
|
|
// 重组日期
|
|
|
|
|
rebuildRecordListViewByDate(lastDate); |
|
|
|
|
} |
|
|
|
@ -197,8 +196,7 @@ public class CalendarFragment extends Fragment {
@@ -197,8 +196,7 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
binding.cCalendarCheckInList.removeAllViews(); |
|
|
|
|
// 添加新内容项
|
|
|
|
|
Flowable<List<Record>> flowable = DBManager.INSTANCE.recordDao().queryByDate(dateTime.getTime()); |
|
|
|
|
flowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
.subscribe(new FlowableSubscriber<List<Record>>() { |
|
|
|
|
flowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new FlowableSubscriber<List<Record>>() { |
|
|
|
|
@Override |
|
|
|
|
public void onSubscribe(Subscription s) { |
|
|
|
|
// 3s超时
|
|
|
|
@ -296,7 +294,6 @@ public class CalendarFragment extends Fragment {
@@ -296,7 +294,6 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
private void fetchNewestActionButtonData() { |
|
|
|
|
Flowable<List<Project>> listFlowable = DBManager.INSTANCE.projectDao().listAll(); |
|
|
|
|
listFlowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|
.subscribe(projectList -> floatingActionProjectList = projectList); |
|
|
|
|
listFlowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(projectList -> floatingActionProjectList = projectList); |
|
|
|
|
} |
|
|
|
|
} |