기본 테스트
This commit is contained in:
parent
17ecb69646
commit
4226235569
@ -2,26 +2,48 @@ package com.example.calrendarview
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
class BaseCustomViews : View {
|
||||
constructor(context: Context?) : super(context){appyAttrs(null)}
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs){appyAttrs(attrs)}
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
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(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
){appyAttrs(attrs)}
|
||||
){appyAttrs(context,attrs)}
|
||||
|
||||
constructor(
|
||||
context: Context?,
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes) {appyAttrs(attrs)}
|
||||
|
||||
|
||||
fun appyAttrs(attrs: AttributeSet?) {
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes) {appyAttrs(context,attrs)}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun initLayout(context: Context?) {
|
||||
createdLayout(LayoutInflater.from(context).inflate(layouId, this, true))
|
||||
}
|
||||
|
||||
open fun createdLayout(view : View) {
|
||||
Log.e(this::class.simpleName,"view si $view")
|
||||
}
|
||||
|
||||
// override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||
// if (changed) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@ -1,28 +1,20 @@
|
||||
package com.example.calrendarview
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
class DayView : View {
|
||||
constructor(context: Context?) : super(context){appyAttrs(null)}
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs){appyAttrs(attrs)}
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
){appyAttrs(attrs)}
|
||||
|
||||
constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes) {appyAttrs(attrs)}
|
||||
class DayView : BaseCustomViews {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
|
||||
fun appyAttrs(attrs: AttributeSet?) {
|
||||
|
||||
override fun appyAttrs(context: Context?, attrs: AttributeSet?) {
|
||||
super.appyAttrs(context, attrs)
|
||||
}
|
||||
|
||||
fun displayDayNumber() {
|
||||
@ -37,4 +29,11 @@ class DayView : View {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
override fun draw(canvas: Canvas) {
|
||||
canvas.drawColor(Color.CYAN)
|
||||
super.draw(canvas)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,25 +6,15 @@ import android.view.View
|
||||
import com.example.calrendarview.model.DayInfo
|
||||
|
||||
|
||||
class MonthView : View {
|
||||
constructor(context: Context?) : super(context){appyAttrs(null)}
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs){appyAttrs(attrs)}
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
){appyAttrs(attrs)}
|
||||
|
||||
constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes) {appyAttrs(attrs)}
|
||||
class MonthView : BaseCustomViews {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
|
||||
fun appyAttrs(attrs: AttributeSet?) {
|
||||
|
||||
override fun appyAttrs(context: Context?, attrs: AttributeSet?) {
|
||||
super.appyAttrs(context, attrs)
|
||||
}
|
||||
|
||||
var numberOfRow : Int = 7
|
||||
|
||||
14
CalrendarView/src/main/res/layout/item_day.xml
Normal file
14
CalrendarView/src/main/res/layout/item_day.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:src="@android:drawable/btn_dialog"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
18
CalrendarView/src/main/res/values/attr.xml
Normal file
18
CalrendarView/src/main/res/values/attr.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<attr name="item_layout" format="reference"/>
|
||||
|
||||
|
||||
<declare-styleable name="BaseCustomViews">
|
||||
<attr name="item_layout"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DayView">
|
||||
<attr name="item_layout"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="MonthView">
|
||||
<attr name="item_layout"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
4
CalrendarView/src/main/res/values/values.xml
Normal file
4
CalrendarView/src/main/res/values/values.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
||||
Loading…
x
Reference in New Issue
Block a user