기본 테스트

This commit is contained in:
lunaticbum 2024-11-26 16:52:07 +09:00
parent 17ecb69646
commit 4226235569
6 changed files with 92 additions and 45 deletions

View File

@ -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) {
//
// }
// }
}

View File

@ -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)
}
}

View File

@ -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

View 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>

View 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>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>