@@ -22,7 +22,11 @@ import io.github.kbiakov.codeview.highlight.color
2222 *
2323 * @author Kirill Biakov
2424 */
25- class CodeView (context : Context , attrs : AttributeSet ) : RelativeLayout(context, attrs) {
25+ class CodeView @JvmOverloads constructor(
26+ context : Context ,
27+ attrs : AttributeSet ? = null ,
28+ defStyleAttr : Int = 0
29+ ) : RelativeLayout(context, attrs, defStyleAttr) {
2630
2731 private val vCodeList: RecyclerView
2832 private val vShadows: Map <ShadowPosition , View >
@@ -32,7 +36,7 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
3236 */
3337 init {
3438 inflate(context, R .layout.layout_code_view, this )
35- checkStartAnimation( attrs)
39+ attrs?. let (::checkStartAnimation )
3640
3741 vCodeList = findViewById<RecyclerView >(R .id.rv_code_content)
3842 vCodeList.layoutManager = LinearLayoutManager (context)
@@ -227,9 +231,9 @@ class CodeView(context: Context, attrs: AttributeSet) : RelativeLayout(context,
227231 RightBorder -> GradientDrawable .Orientation .LEFT_RIGHT to theme.bgContent
228232 NumBottom -> GradientDrawable .Orientation .TOP_BOTTOM to theme.bgNum
229233 ContentBottom -> GradientDrawable .Orientation .TOP_BOTTOM to theme.bgContent
230- }.let {
231- val colors = arrayOf(android.R .color.transparent, it.second )
232- GradientDrawable (it.first , colors.map(Int ::color).toIntArray())
234+ }.let { (orientation, color) ->
235+ val colors = arrayOf(android.R .color.transparent, color )
236+ GradientDrawable (orientation , colors.map(Int ::color).toIntArray())
233237 }
234238 }
235239}
0 commit comments