|
|
|
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
|
|
|
|
package cc.niushuai.dididone.ui.calendar; |
|
|
|
|
|
|
|
|
|
import android.graphics.Color; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.util.Log; |
|
|
|
|
import android.view.Gravity; |
|
|
|
@ -14,6 +15,9 @@ import androidx.annotation.NonNull;
@@ -14,6 +15,9 @@ import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.fragment.app.Fragment; |
|
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
|
|
import com.mikepenz.fontawesome_typeface_library.FontAwesome; |
|
|
|
|
import com.mikepenz.iconics.IconicsDrawable; |
|
|
|
|
import com.mikepenz.iconics.view.IconicsImageView; |
|
|
|
|
import com.necer.calendar.BaseCalendar; |
|
|
|
|
import com.necer.entity.CalendarDate; |
|
|
|
|
import com.necer.entity.Lunar; |
|
|
|
@ -94,30 +98,43 @@ public class CalendarFragment extends Fragment {
@@ -94,30 +98,43 @@ public class CalendarFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
private void add2Top(String localDate, String lunarDate) { |
|
|
|
|
// 外层layout 白色背景 存在边距
|
|
|
|
|
LinearLayout itemLayout = new LinearLayout(getContext()); |
|
|
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 175); |
|
|
|
|
RelativeLayout itemLayout = new RelativeLayout(getContext()); |
|
|
|
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 175); |
|
|
|
|
layoutParams.setMargins(25, 20, 25, 15); |
|
|
|
|
|
|
|
|
|
itemLayout.setId(13); |
|
|
|
|
itemLayout.setLayoutParams(layoutParams); |
|
|
|
|
itemLayout.setPadding(15, 15, 15, 5); |
|
|
|
|
itemLayout.setBackgroundResource(R.drawable.bg_miui10); |
|
|
|
|
itemLayout.setOrientation(LinearLayout.VERTICAL); |
|
|
|
|
// itemLayout.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
|
|
|
|
|
ViewGroup.LayoutParams textLayoutParams = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
|
|
TextView projectTextView = this.getTextView(11, localDate, textLayoutParams, R.color._333333, 16, Gravity.CENTER_VERTICAL); |
|
|
|
|
itemLayout.addView(projectTextView); |
|
|
|
|
|
|
|
|
|
// empty textview 占位view 撑大位置
|
|
|
|
|
TextView emptyTextView = new TextView(getContext()); |
|
|
|
|
emptyTextView.setId(33); |
|
|
|
|
itemLayout.addView(emptyTextView); |
|
|
|
|
// icon 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(getContext()); |
|
|
|
|
iconView.setId(111); |
|
|
|
|
iconView.setLayoutParams(iconLayout); |
|
|
|
|
IconicsDrawable icon = new IconicsDrawable(getContext()); |
|
|
|
|
icon.icon(FontAwesome.Icon.faw_swimmer).color(Color.BLUE).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, 111); |
|
|
|
|
TextView projectTextView = this.getTextView(222, localDate, projectLayout, R.color._333333, 16, Gravity.CENTER_VERTICAL); |
|
|
|
|
itemLayout.addView(projectTextView); |
|
|
|
|
|
|
|
|
|
TextView dateTextView = this.getTextView(22, DateUtil.now(), textLayoutParams, R.color._666666, 12, Gravity.TOP); |
|
|
|
|
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, 111); |
|
|
|
|
dateLayout.addRule(RelativeLayout.BELOW, 222); |
|
|
|
|
TextView dateTextView = this.getTextView(333, DateUtil.now(), dateLayout, R.color._666666, 12, Gravity.TOP); |
|
|
|
|
itemLayout.addView(dateTextView); |
|
|
|
|
|
|
|
|
|
binding.cCalendarCheckInList.removeAllViews(); |
|
|
|
|
binding.cCalendarCheckInList.removeAllViewsInLayout(); |
|
|
|
|
binding.cCalendarCheckInList.addView(itemLayout, 0); |
|
|
|
|
binding.cCalendarCheckInList.requestLayout(); |
|
|
|
|
} |
|
|
|
|