...
This commit is contained in:
parent
fb444ee292
commit
a1162f2f4c
@ -7,8 +7,10 @@ import android.util.AttributeSet
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.core.view.size
|
||||||
import com.example.calrendarview.model.CalendarFactory
|
import com.example.calrendarview.model.CalendarFactory
|
||||||
import com.example.calrendarview.model.DayInfo
|
import com.example.calrendarview.model.DayInfo
|
||||||
|
|
||||||
@ -27,7 +29,6 @@ class MonthView : BaseCustomViews {
|
|||||||
var numberOfRow : Int = 7
|
var numberOfRow : Int = 7
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
initChildViews()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var dayInfo: DayInfo? = null
|
var dayInfo: DayInfo? = null
|
||||||
@ -41,25 +42,48 @@ class MonthView : BaseCustomViews {
|
|||||||
field = value
|
field = value
|
||||||
numOfDayView = findViewById<TextView>(field)
|
numOfDayView = findViewById<TextView>(field)
|
||||||
}
|
}
|
||||||
|
var itemLayout : Int = -1
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
var numOfDayView : TextView? = null
|
var numOfDayView : TextView? = null
|
||||||
|
|
||||||
|
var mWidth: Int? = null
|
||||||
|
var mHeight: Int? = null
|
||||||
|
|
||||||
|
|
||||||
override fun onTypedArray(context: Context, typedArray: TypedArray) {
|
override fun onTypedArray(context: Context, typedArray: TypedArray) {
|
||||||
super.onTypedArray(context, typedArray)
|
super.onTypedArray(context, typedArray)
|
||||||
numberOfday = typedArray.getResourceId(R.styleable.BaseCustomViews_numOfDayId, R.id.day_num)
|
numberOfday = typedArray.getResourceId(R.styleable.BaseCustomViews_numOfDayId, R.id.day_num)
|
||||||
|
itemLayout = typedArray.getResourceId(R.styleable.BaseCustomViews_item_layout, R.id.day_num)
|
||||||
displayDayNumber()
|
displayDayNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initChildViews(): Array<DayView?> {
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
|
super.onLayout(changed, left, top, right, bottom)
|
||||||
|
Log.i("MonthView >>> ","onLayout")
|
||||||
|
initChildViews()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun initChildViews(): Array<View?> {
|
||||||
//todo : 7 * numberOfRow 의 차일드 뷰를 만든다.
|
//todo : 7 * numberOfRow 의 차일드 뷰를 만든다.
|
||||||
val infos = CalendarFactory().getBeansOfThisWeek()
|
val infos = CalendarFactory().getBeansOfThisWeek()
|
||||||
val childrens = Array<DayView?>(numberOfRow) {
|
val childrens = Array<View?>(numberOfRow) {i ->
|
||||||
val dayView = inflate(context, R.layout.item_day, this) as? DayView
|
val dayView = LayoutInflater.from(context).inflate(layouId, this, false)
|
||||||
dayView?.dayInfo = infos[it]
|
val p = ViewGroup.LayoutParams(100, 100)
|
||||||
addView(dayView)
|
Log.i("MonthView >>> ","numberOfRow ${numberOfRow}")
|
||||||
|
dayView?.let {
|
||||||
|
it.layoutParams = p
|
||||||
|
Log.i("MonthView >>> ","dayView.width ${dayView.width}")
|
||||||
|
numOfDayView?.text = infos[i].getNumOfDay().toString()
|
||||||
|
addView(it)
|
||||||
|
}
|
||||||
return@Array dayView
|
return@Array dayView
|
||||||
}
|
}
|
||||||
|
Log.i("MonthView initChildViews >>> ","childrens count ${childrens.size}")
|
||||||
|
Log.i("MonthView initChildViews >>> ","mWidth ${width}")
|
||||||
|
Log.i("MonthView initChildViews >>> ","mHeight ${height}")
|
||||||
return childrens
|
return childrens
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class ActivityCalendarEx: AppCompatActivity() {
|
|||||||
|
|
||||||
// for (i in 0 until 7) {
|
// for (i in 0 until 7) {
|
||||||
val infos = CalendarFactory().getBeansOfThisWeek()
|
val infos = CalendarFactory().getBeansOfThisWeek()
|
||||||
bind.otherViews.numberOfRow = 7
|
// bind.otherViews.numberOfRow = 7
|
||||||
// (bind.otherViews.getChildAt(i) as? DayView)?.dayInfo = infos.get(i)
|
// (bind.otherViews.getChildAt(i) as? DayView)?.dayInfo = infos.get(i)
|
||||||
// }
|
// }
|
||||||
setContentView(bind.root)
|
setContentView(bind.root)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user