|
|
@ -1,5 +1,7 @@ |
|
|
|
package cc.niushuai.dididone.ui.statistic.charts; |
|
|
|
package cc.niushuai.dididone.ui.statistic.charts; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static cc.niushuai.dididone.biz.BizGlobal.getTextViewDate; |
|
|
|
|
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
@ -25,8 +27,9 @@ import cc.niushuai.dididone.databinding.FragmentStatListBinding; |
|
|
|
import cc.niushuai.dididone.util.XLog; |
|
|
|
import cc.niushuai.dididone.util.XLog; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import io.reactivex.Flowable; |
|
|
|
import io.reactivex.Flowable; |
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
|
|
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
|
|
|
|
import kotlin.Unit; |
|
|
|
|
|
|
|
import kotlin.jvm.functions.Function1; |
|
|
|
|
|
|
|
|
|
|
|
public class ListFragment extends BaseChartFragment { |
|
|
|
public class ListFragment extends BaseChartFragment { |
|
|
|
|
|
|
|
|
|
|
@ -39,9 +42,10 @@ public class ListFragment extends BaseChartFragment { |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
|
|
|
|
|
|
XLog.d("{} onCreateView", getTitle()); |
|
|
|
View view = inflater.inflate(R.layout.fragment_stat_list, container, false); |
|
|
|
View view = inflater.inflate(R.layout.fragment_stat_list, container, false); |
|
|
|
binding = FragmentStatListBinding.bind(view); |
|
|
|
binding = FragmentStatListBinding.bind(view); |
|
|
|
return view; |
|
|
|
return binding.getRoot(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -84,6 +88,8 @@ public class ListFragment extends BaseChartFragment { |
|
|
|
dateStr2mills(startDate.toString()), |
|
|
|
dateStr2mills(startDate.toString()), |
|
|
|
dateStr2mills(endDate.toString())); |
|
|
|
dateStr2mills(endDate.toString())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listFlowable.subscribeOn(Schedulers.io()).subscribe(recordList -> { |
|
|
|
listFlowable.subscribeOn(Schedulers.io()).subscribe(recordList -> { |
|
|
|
XLog.d("recordList: {}", recordList.size()); |
|
|
|
XLog.d("recordList: {}", recordList.size()); |
|
|
|
recordList.forEach(item -> XLog.d("{} at {}", item.getName(), DateUtil.date(item.getCheckDate()).toDateStr())); |
|
|
|
recordList.forEach(item -> XLog.d("{} at {}", item.getName(), DateUtil.date(item.getCheckDate()).toDateStr())); |
|
|
@ -93,14 +99,17 @@ public class ListFragment extends BaseChartFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onRecordDataList(List<Record> recordList) { |
|
|
|
private void onRecordDataList(List<Record> recordList) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getActivity().runOnUiThread(() -> { |
|
|
|
|
|
|
|
binding.statTotalMsg.setText("总计: " + recordList.size() + "条记录"); |
|
|
|
|
|
|
|
binding.statListCheckInList.removeAllViews(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 更新视图
|
|
|
|
// 更新视图
|
|
|
|
for (int i = recordList.size() - 1; i >= 0; i--) { |
|
|
|
for (int i = recordList.size() - 1; i >= 0; i--) { |
|
|
|
// 查出来的数据是倒叙的
|
|
|
|
// 查出来的数据是倒叙的
|
|
|
|
Record record = recordList.get(i); |
|
|
|
Record record = recordList.get(i); |
|
|
|
getActivity().runOnUiThread(() -> { |
|
|
|
getActivity().runOnUiThread(() -> add2Top(BizGlobal.CACHE_PROJECT.get(record.getProjectId()), record)); |
|
|
|
binding.statListCheckInList.removeAllViews(); |
|
|
|
|
|
|
|
add2Top(BizGlobal.CACHE_PROJECT.get(record.getProjectId()), record); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,11 +125,38 @@ public class ListFragment extends BaseChartFragment { |
|
|
|
public void setListeners() { |
|
|
|
public void setListeners() { |
|
|
|
|
|
|
|
|
|
|
|
binding.statListStartDate.setOnClickListener(v -> { |
|
|
|
binding.statListStartDate.setOnClickListener(v -> { |
|
|
|
|
|
|
|
Function1<Long, Unit> unitFunction = millisecond -> { |
|
|
|
|
|
|
|
String dateStr = DateUtil.date(millisecond).toDateStr(); |
|
|
|
|
|
|
|
XLog.d("select date = {}", dateStr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.statListStartDate.setText(dateStr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onConditionChange(binding.statListSpinnerProject.getSelectedItemPosition(), binding.statListStartDate.getText(), binding.statListEndDate.getText()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BizGlobal.buildCardDatePickerDialog(getContext(), "选择起始日期", getTextViewDate(binding.statListStartDate), null, getTextViewDate(binding.statListEndDate), |
|
|
|
|
|
|
|
false, "确定", unitFunction); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
binding.statListEndDate.setOnClickListener(v -> { |
|
|
|
binding.statListEndDate.setOnClickListener(v -> { |
|
|
|
|
|
|
|
Function1<Long, Unit> unitFunction = millisecond -> { |
|
|
|
|
|
|
|
String dateStr = DateUtil.date(millisecond).toDateStr(); |
|
|
|
|
|
|
|
XLog.d("select date = {}", dateStr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.statListEndDate.setText(dateStr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onConditionChange(binding.statListSpinnerProject.getSelectedItemPosition(), binding.statListStartDate.getText(), binding.statListEndDate.getText()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BizGlobal.buildCardDatePickerDialog(getContext(), "选择结束日期", getTextViewDate(binding.statListEndDate), getTextViewDate(binding.statListStartDate), null, |
|
|
|
|
|
|
|
false, "确定", unitFunction); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |