2020-10-31 19:45:39 +00:00
|
|
|
package com.vanced.manager.ui.core
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
import com.vanced.manager.R
|
2021-01-10 12:41:56 +00:00
|
|
|
import com.vanced.manager.databinding.ViewPreferenceCategoryBinding
|
2020-10-31 19:45:39 +00:00
|
|
|
|
|
|
|
class PreferenceCategory @JvmOverloads constructor(
|
2021-01-15 14:24:07 +00:00
|
|
|
context: Context,
|
|
|
|
attrs: AttributeSet? = null,
|
2021-02-19 13:51:34 +00:00
|
|
|
defStyle: Int = 0
|
2020-10-31 19:45:39 +00:00
|
|
|
) : LinearLayout(context, attrs, defStyle) {
|
|
|
|
|
2021-01-10 12:41:56 +00:00
|
|
|
private var _binding: ViewPreferenceCategoryBinding? = null
|
|
|
|
|
|
|
|
val binding: ViewPreferenceCategoryBinding
|
|
|
|
get() = requireNotNull(_binding)
|
|
|
|
|
2020-10-31 19:45:39 +00:00
|
|
|
init {
|
2021-01-10 12:41:56 +00:00
|
|
|
_binding = ViewPreferenceCategoryBinding.inflate(LayoutInflater.from(context), this, true)
|
2020-10-31 19:45:39 +00:00
|
|
|
initAttrs(context, attrs)
|
|
|
|
setPadding(0, 4, 0, 0)
|
|
|
|
orientation = VERTICAL
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun initAttrs(context: Context, attrs: AttributeSet?) {
|
|
|
|
attrs.let { mAttrs ->
|
2021-04-19 15:57:14 +00:00
|
|
|
val typedArray =
|
|
|
|
context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceCategory, 0, 0)
|
2020-10-31 19:45:39 +00:00
|
|
|
val title = typedArray.getText(R.styleable.PreferenceCategory_category_title)
|
|
|
|
|
2021-01-10 12:41:56 +00:00
|
|
|
binding.categoryTitle.text = title
|
2020-10-31 19:45:39 +00:00
|
|
|
typedArray.recycle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|