@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
package cc.niushuai.dididone.ui.statistic.charts ;
import static cc.niushuai.dididone.biz.BizGlobal.getTextViewDate ;
import android.os.Bundle ;
import android.view.LayoutInflater ;
import android.view.View ;
@ -25,8 +27,9 @@ import cc.niushuai.dididone.databinding.FragmentStatListBinding;
@@ -25,8 +27,9 @@ import cc.niushuai.dididone.databinding.FragmentStatListBinding;
import cc.niushuai.dididone.util.XLog ;
import cn.hutool.core.date.DateUtil ;
import io.reactivex.Flowable ;
import io.reactivex.android.schedulers.AndroidSchedulers ;
import io.reactivex.schedulers.Schedulers ;
import kotlin.Unit ;
import kotlin.jvm.functions.Function1 ;
public class ListFragment extends BaseChartFragment {
@ -39,9 +42,10 @@ public class ListFragment extends BaseChartFragment {
@@ -39,9 +42,10 @@ public class ListFragment extends BaseChartFragment {
@Nullable
@Override
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 ) ;
binding = FragmentStatListBinding . bind ( view ) ;
return view ;
return binding . getRoot ( ) ;
}
@Override
@ -84,6 +88,8 @@ public class ListFragment extends BaseChartFragment {
@@ -84,6 +88,8 @@ public class ListFragment extends BaseChartFragment {
dateStr2mills ( startDate . toString ( ) ) ,
dateStr2mills ( endDate . toString ( ) ) ) ;
listFlowable . subscribeOn ( Schedulers . io ( ) ) . subscribe ( recordList - > {
XLog . d ( "recordList: {}" , recordList . size ( ) ) ;
recordList . forEach ( item - > XLog . d ( "{} at {}" , item . getName ( ) , DateUtil . date ( item . getCheckDate ( ) ) . toDateStr ( ) ) ) ;
@ -93,14 +99,17 @@ public class ListFragment extends BaseChartFragment {
@@ -93,14 +99,17 @@ public class ListFragment extends BaseChartFragment {
}
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 - - ) {
// 查出来的数据是倒叙的
Record record = recordList . get ( i ) ;
getActivity ( ) . runOnUiThread ( ( ) - > {
binding . statListCheckInList . removeAllViews ( ) ;
add2Top ( BizGlobal . CACHE_PROJECT . get ( record . getProjectId ( ) ) , record ) ;
} ) ;
getActivity ( ) . runOnUiThread ( ( ) - > add2Top ( BizGlobal . CACHE_PROJECT . get ( record . getProjectId ( ) ) , record ) ) ;
}
}
@ -116,11 +125,38 @@ public class ListFragment extends BaseChartFragment {
@@ -116,11 +125,38 @@ public class ListFragment extends BaseChartFragment {
public void setListeners ( ) {
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 - > {
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 ) ;
} ) ;
}
}