|  |  | @ -1,7 +1,6 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package cc.niushuai.dididone.ui.calendar; |  |  |  | package cc.niushuai.dididone.ui.calendar; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.content.Context; |  |  |  | import android.content.Context; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.icu.text.DateFormat; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.os.Bundle; |  |  |  | import android.os.Bundle; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.util.Log; |  |  |  | import android.util.Log; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.view.Gravity; |  |  |  | import android.view.Gravity; | 
			
		
	
	
		
		
			
				
					|  |  | @ -44,6 +43,7 @@ import cc.niushuai.dididone.util.XLog; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.date.DatePattern; |  |  |  | import cn.hutool.core.date.DatePattern; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.date.DateTime; |  |  |  | import cn.hutool.core.date.DateTime; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.date.DateUtil; |  |  |  | import cn.hutool.core.date.DateUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import io.reactivex.Completable; |  |  |  | import io.reactivex.Completable; | 
			
		
	
		
		
			
				
					
					|  |  |  | import io.reactivex.CompletableObserver; |  |  |  | import io.reactivex.CompletableObserver; | 
			
		
	
		
		
			
				
					
					|  |  |  | import io.reactivex.Flowable; |  |  |  | import io.reactivex.Flowable; | 
			
		
	
	
		
		
			
				
					|  |  | @ -60,10 +60,8 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private List<Project> floatingActionProjectList; |  |  |  |     private List<Project> floatingActionProjectList; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public View onCreateView(@NonNull LayoutInflater inflater, |  |  |  |     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                              ViewGroup container, Bundle savedInstanceState) { |  |  |  |         CalendarViewModel calendarViewModel = new ViewModelProvider(this).get(CalendarViewModel.class); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         CalendarViewModel calendarViewModel = |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 new ViewModelProvider(this).get(CalendarViewModel.class); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         binding = FragmentCalendarBinding.inflate(inflater, container, false); |  |  |  |         binding = FragmentCalendarBinding.inflate(inflater, container, false); | 
			
		
	
		
		
			
				
					
					|  |  |  |         View root = binding.getRoot(); |  |  |  |         View root = binding.getRoot(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -117,10 +115,11 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.show(true); |  |  |  |             actionButton.show(true); | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.setTag(project.getName() + project.getId()); |  |  |  |             actionButton.setTag(project.getName() + project.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.setLabelText(project.getName()); |  |  |  |             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.setButtonSize(FloatingActionButton.SIZE_NORMAL); | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.setColorNormal(getResources().getColor(R.color.white)); |  |  |  |             actionButton.setColorNormal(getResources().getColor(R.color.white)); | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.setColorPressed(getResources().getColor(R.color.white)); |  |  |  |             actionButton.setColorPressed(getResources().getColor(R.color.white)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             actionButton.setOnClickListener(new View.OnClickListener() { |  |  |  |             actionButton.setOnClickListener(new View.OnClickListener() { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 @Override |  |  |  |                 @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |                 public void onClick(View v) { |  |  |  |                 public void onClick(View v) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -135,28 +134,26 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     // 插入数据库
 |  |  |  |                     // 插入数据库
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     Completable completable = DBManager.INSTANCE.recordDao().insertAll(record); |  |  |  |                     Completable completable = DBManager.INSTANCE.recordDao().insertAll(record); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     completable.subscribeOn(Schedulers.io()) |  |  |  |                     completable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new CompletableObserver() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             .observeOn(AndroidSchedulers.mainThread()) |  |  |  |                         @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             .subscribe(new CompletableObserver() { |  |  |  |                         public void onSubscribe(Disposable d) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 @Override |  |  |  |                         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 public void onSubscribe(Disposable d) { |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  |                         @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                         public void onComplete() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 @Override |  |  |  |                             XLog.i("[{}]打卡成功", project.getName()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 public void onComplete() { |  |  |  |                             Toasts.shortShow(getActivity(), "[{}]打卡成功", project.getName()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     XLog.i("[{}]打卡成功", project.getName()); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     Toasts.shortShow(getActivity(), "[{}]打卡成功", project.getName()); |  |  |  |                             // 更新视图
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                             add2Top(project, record); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     // 更新视图
 |  |  |  |                         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     add2Top(project, record); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  |                         @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                         public void onError(Throwable e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 @Override |  |  |  |                             XLog.e("[{}]打卡失败, {}", project.getName(), e); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 public void onError(Throwable e) { |  |  |  |                             Toasts.shortShow(getActivity(), "[{}]打卡失败, {}", project.getName(), e.getMessage()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     XLog.e("[{}]打卡失败, {}", project.getName(), e); |  |  |  |                         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     Toasts.shortShow(getActivity(), "[{}]打卡失败, {}", project.getName(), e.getMessage()); |  |  |  |                     }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                             }); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             }); |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -184,6 +181,8 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 // 重置上次选中日期
 |  |  |  |                 // 重置上次选中日期
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 lastDate = localDate.toString(); |  |  |  |                 lastDate = localDate.toString(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 binding.tvResult.setText(StrUtil.format("{} | {}", lastDate, lunarDate)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 // 重组日期
 |  |  |  |                 // 重组日期
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 rebuildRecordListViewByDate(lastDate); |  |  |  |                 rebuildRecordListViewByDate(lastDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
	
		
		
			
				
					|  |  | @ -197,37 +196,36 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  |         binding.cCalendarCheckInList.removeAllViews(); |  |  |  |         binding.cCalendarCheckInList.removeAllViews(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         // 添加新内容项
 |  |  |  |         // 添加新内容项
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         Flowable<List<Record>> flowable = DBManager.INSTANCE.recordDao().queryByDate(dateTime.getTime()); |  |  |  |         Flowable<List<Record>> flowable = DBManager.INSTANCE.recordDao().queryByDate(dateTime.getTime()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         flowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) |  |  |  |         flowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new FlowableSubscriber<List<Record>>() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 .subscribe(new FlowableSubscriber<List<Record>>() { |  |  |  |             @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     @Override |  |  |  |             public void onSubscribe(Subscription s) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     public void onSubscribe(Subscription s) { |  |  |  |                 // 3s超时
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         // 3s超时
 |  |  |  |                 s.request(1); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         s.request(1); |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     @Override |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     public void onNext(List<Record> recordList) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         XLog.d("DataListOnNext 查询到数据: {}", recordList.size()); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                         for (Record record : recordList) { |  |  |  |             @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             Project project = BizGlobal.CACHE_PROJECT.get(record.getProjectId()); |  |  |  |             public void onNext(List<Record> recordList) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if (null == project) { |  |  |  |                 XLog.d("DataListOnNext 查询到数据: {}", recordList.size()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 Toasts.longShow(getContext(), "ProjectId: {}不存在, 可能存在BUG", String.valueOf(record.getProjectId())); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 return; |  |  |  |                 for (Record record : recordList) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  |                     Project project = BizGlobal.CACHE_PROJECT.get(record.getProjectId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             add2Top(project, record); |  |  |  |                     if (null == project) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  |                         Toasts.longShow(getContext(), "ProjectId: {}不存在, 可能存在BUG", String.valueOf(record.getProjectId())); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         return; | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     add2Top(project, record); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     @Override |  |  |  |             @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     public void onError(Throwable t) { |  |  |  |             public void onError(Throwable t) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         Toasts.shortShow(getActivity(), "DataList根据时间拉取历史数据失败: ", t.getLocalizedMessage()); |  |  |  |                 Toasts.shortShow(getActivity(), "DataList根据时间拉取历史数据失败: ", t.getLocalizedMessage()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |             } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     @Override |  |  |  |             @Override | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     public void onComplete() { |  |  |  |             public void onComplete() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 }); |  |  |  |         }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -296,7 +294,6 @@ public class CalendarFragment extends Fragment { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void fetchNewestActionButtonData() { |  |  |  |     private void fetchNewestActionButtonData() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Flowable<List<Project>> listFlowable = DBManager.INSTANCE.projectDao().listAll(); |  |  |  |         Flowable<List<Project>> listFlowable = DBManager.INSTANCE.projectDao().listAll(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         listFlowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) |  |  |  |         listFlowable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(projectList -> floatingActionProjectList = projectList); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 .subscribe(projectList -> floatingActionProjectList = projectList); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } |