2024-11-26 16:09:31 +09:00
|
|
|
package com.example.calrendarview
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.util.AttributeSet
|
2024-11-26 16:52:07 +09:00
|
|
|
import android.util.Log
|
|
|
|
|
import android.view.LayoutInflater
|
2024-11-26 16:09:31 +09:00
|
|
|
import android.view.View
|
2024-11-26 16:52:07 +09:00
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
2024-11-26 16:09:31 +09:00
|
|
|
|
2024-11-26 16:52:07 +09:00
|
|
|
abstract class BaseCustomViews : ConstraintLayout {
|
|
|
|
|
constructor(context: Context) : super(context){appyAttrs(context,null)}
|
|
|
|
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs){appyAttrs(context,attrs)}
|
|
|
|
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
2024-11-26 16:09:31 +09:00
|
|
|
context,
|
|
|
|
|
attrs,
|
|
|
|
|
defStyleAttr
|
2024-11-26 16:52:07 +09:00
|
|
|
){appyAttrs(context,attrs)}
|
2024-11-26 16:09:31 +09:00
|
|
|
|
|
|
|
|
constructor(
|
2024-11-26 16:52:07 +09:00
|
|
|
context: Context,
|
2024-11-26 16:09:31 +09:00
|
|
|
attrs: AttributeSet?,
|
|
|
|
|
defStyleAttr: Int,
|
|
|
|
|
defStyleRes: Int
|
2024-11-26 16:52:07 +09:00
|
|
|
) : super(context, attrs, defStyleAttr, defStyleRes) {appyAttrs(context,attrs)}
|
2024-11-26 16:09:31 +09:00
|
|
|
|
2024-11-26 16:52:07 +09:00
|
|
|
var layouId : Int = -1
|
|
|
|
|
open fun appyAttrs(context: Context?, attrs: AttributeSet?) {
|
|
|
|
|
context?.let {
|
|
|
|
|
val typedArray = it.obtainStyledAttributes(attrs, R.styleable.BaseCustomViews)
|
|
|
|
|
layouId = typedArray.getResourceId(R.styleable.BaseCustomViews_item_layout,R.layout.item_day)
|
|
|
|
|
initLayout(it)
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-26 16:09:31 +09:00
|
|
|
|
2024-11-26 16:52:07 +09:00
|
|
|
fun initLayout(context: Context?) {
|
|
|
|
|
createdLayout(LayoutInflater.from(context).inflate(layouId, this, true))
|
|
|
|
|
}
|
2024-11-26 16:09:31 +09:00
|
|
|
|
2024-11-26 16:52:07 +09:00
|
|
|
open fun createdLayout(view : View) {
|
|
|
|
|
Log.e(this::class.simpleName,"view si $view")
|
2024-11-26 16:09:31 +09:00
|
|
|
}
|
2024-11-26 16:52:07 +09:00
|
|
|
|
|
|
|
|
// override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
|
|
|
|
// if (changed) {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|