@ -7,9 +7,12 @@ import android.widget.LinearLayout;
@@ -7,9 +7,12 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout ;
import android.widget.TextView ;
import com.loper7.date_time_picker.DateTimeConfig ;
import com.loper7.date_time_picker.dialog.CardDatePickerDialog ;
import com.mikepenz.iconics.IconicsDrawable ;
import com.mikepenz.iconics.view.IconicsImageView ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@ -28,6 +31,8 @@ import cn.hutool.core.date.DateUtil;
@@ -28,6 +31,8 @@ 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 ;
/ * *
* 业务全局对象
@ -101,44 +106,44 @@ public class BizGlobal {
@@ -101,44 +106,44 @@ public class BizGlobal {
}
public static RelativeLayout getItemLayout ( Context context , Project project , Record record ) {
// 外层layout 白色背景 存在边距
RelativeLayout itemLayout = new RelativeLayout ( context ) ;
RelativeLayout . LayoutParams layoutParams = new RelativeLayout . LayoutParams ( RelativeLayout . LayoutParams . MATCH_PARENT , 175 ) ;
layoutParams . setMargins ( 25 , 20 , 25 , 15 ) ;
itemLayout . setId ( IntSnowflake . next_id ( ) ) ;
itemLayout . setLayoutParams ( layoutParams ) ;
itemLayout . setPadding ( 15 , 15 , 15 , 5 ) ;
itemLayout . setBackgroundResource ( R . drawable . bg_miui10 ) ;
// 外层layout 白色背景 存在边距
RelativeLayout itemLayout = new RelativeLayout ( context ) ;
RelativeLayout . LayoutParams layoutParams = new RelativeLayout . LayoutParams ( RelativeLayout . LayoutParams . MATCH_PARENT , 175 ) ;
layoutParams . setMargins ( 25 , 20 , 25 , 15 ) ;
itemLayout . setId ( IntSnowflake . next_id ( ) ) ;
itemLayout . setLayoutParams ( layoutParams ) ;
itemLayout . setPadding ( 15 , 15 , 15 , 5 ) ;
itemLayout . setBackgroundResource ( R . drawable . bg_miui10 ) ;
// itemLayout.setOrientation(LinearLayout.VERTICAL);
// projectIcon layout
RelativeLayout . LayoutParams iconLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . WRAP_CONTENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
iconLayout . setMargins ( 10 , 5 , 0 , 0 ) ;
IconicsImageView iconView = new IconicsImageView ( context ) ;
int iconViewId = IntSnowflake . next_id ( ) ;
iconView . setId ( iconViewId ) ;
iconView . setLayoutParams ( iconLayout ) ;
IconicsDrawable icon = new IconicsDrawable ( context ) ;
icon . icon ( project . getIcon ( ) ) . color ( project . getIconColor ( ) ) . sizeDp ( 50 ) ;
iconView . setIcon ( icon ) ;
itemLayout . addView ( iconView ) ;
RelativeLayout . LayoutParams projectLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . MATCH_PARENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
projectLayout . setMargins ( 20 , 5 , 0 , 0 ) ;
projectLayout . addRule ( RelativeLayout . RIGHT_OF , iconViewId ) ;
int projectNameViewId = IntSnowflake . next_id ( ) ;
TextView projectTextView = getTextView ( context , projectNameViewId , record . getName ( ) , projectLayout , R . color . _333333 , 16 , Gravity . CENTER_VERTICAL ) ;
itemLayout . addView ( projectTextView ) ;
RelativeLayout . LayoutParams dateLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . MATCH_PARENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
dateLayout . setMargins ( 20 , 25 , 0 , 0 ) ;
dateLayout . addRule ( RelativeLayout . RIGHT_OF , iconViewId ) ;
dateLayout . addRule ( RelativeLayout . BELOW , projectNameViewId ) ;
TextView dateTextView = getTextView ( context , IntSnowflake . next_id ( ) , DateUtil . date ( record . getCreateDate ( ) ) . toString ( DatePattern . NORM_DATETIME_PATTERN ) , dateLayout , R . color . _666666 , 12 , Gravity . TOP ) ;
itemLayout . addView ( dateTextView ) ;
return itemLayout ;
// projectIcon layout
RelativeLayout . LayoutParams iconLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . WRAP_CONTENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
iconLayout . setMargins ( 10 , 5 , 0 , 0 ) ;
IconicsImageView iconView = new IconicsImageView ( context ) ;
int iconViewId = IntSnowflake . next_id ( ) ;
iconView . setId ( iconViewId ) ;
iconView . setLayoutParams ( iconLayout ) ;
IconicsDrawable icon = new IconicsDrawable ( context ) ;
icon . icon ( project . getIcon ( ) ) . color ( project . getIconColor ( ) ) . sizeDp ( 50 ) ;
iconView . setIcon ( icon ) ;
itemLayout . addView ( iconView ) ;
RelativeLayout . LayoutParams projectLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . MATCH_PARENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
projectLayout . setMargins ( 20 , 5 , 0 , 0 ) ;
projectLayout . addRule ( RelativeLayout . RIGHT_OF , iconViewId ) ;
int projectNameViewId = IntSnowflake . next_id ( ) ;
TextView projectTextView = getTextView ( context , projectNameViewId , record . getName ( ) , projectLayout , R . color . _333333 , 16 , Gravity . CENTER_VERTICAL ) ;
itemLayout . addView ( projectTextView ) ;
RelativeLayout . LayoutParams dateLayout = new RelativeLayout . LayoutParams ( LinearLayout . LayoutParams . MATCH_PARENT , LinearLayout . LayoutParams . WRAP_CONTENT ) ;
dateLayout . setMargins ( 20 , 25 , 0 , 0 ) ;
dateLayout . addRule ( RelativeLayout . RIGHT_OF , iconViewId ) ;
dateLayout . addRule ( RelativeLayout . BELOW , projectNameViewId ) ;
TextView dateTextView = getTextView ( context , IntSnowflake . next_id ( ) , DateUtil . date ( record . getCreateDate ( ) ) . toString ( DatePattern . NORM_DATETIME_PATTERN ) , dateLayout , R . color . _666666 , 12 , Gravity . TOP ) ;
itemLayout . addView ( dateTextView ) ;
return itemLayout ;
}
private static TextView getTextView ( Context context , int id , String text , ViewGroup . LayoutParams textLayoutParams , int textColor , int textSize , int gravity ) {
@ -152,4 +157,48 @@ public class BizGlobal {
@@ -152,4 +157,48 @@ public class BizGlobal {
textView . setGravity ( gravity ) ;
return textView ;
}
public static void buildCardDatePickerDialog ( Context context , String title ,
Long defaultDate , Long minDate , Long maxDate , boolean showTime ,
String confirmTxt , Function1 < Long , Unit > unitFunction ) {
CardDatePickerDialog . Builder builder = new CardDatePickerDialog . Builder ( context ) ;
builder . setTitle ( title )
. setBackGroundModel ( CardDatePickerDialog . STACK )
. showBackNow ( false )
. setWrapSelectorWheel ( false )
. showDateLabel ( true )
. showFocusDateInfo ( true )
. setOnChoose ( confirmTxt , unitFunction ) ;
if ( null ! = defaultDate ) {
builder . setDefaultTime ( defaultDate ) ;
}
List < Integer > displayTypeList = new ArrayList < > ( 6 ) ;
displayTypeList . add ( DateTimeConfig . YEAR ) ;
displayTypeList . add ( DateTimeConfig . MONTH ) ;
displayTypeList . add ( DateTimeConfig . DAY ) ;
if ( showTime ) {
displayTypeList . add ( DateTimeConfig . HOUR ) ;
displayTypeList . add ( DateTimeConfig . MIN ) ;
displayTypeList . add ( DateTimeConfig . SECOND ) ;
}
builder . setDisplayType ( displayTypeList ) ;
if ( null ! = minDate ) {
builder . setMinTime ( minDate ) ;
}
if ( null ! = maxDate ) {
builder . setMaxTime ( maxDate ) ;
}
builder . build ( ) . show ( ) ;
}
public static Long getTextViewDate ( TextView textView ) {
return DateUtil . parseDate ( textView . getText ( ) . toString ( ) ) . getTime ( ) ;
}
}