@@ -9,6 +9,7 @@ import android.view.View
99import android.widget.TextView
1010import androidx.annotation.CallSuper
1111import androidx.annotation.StringRes
12+ import androidx.core.content.withStyledAttributes
1213import com.otaliastudios.zoom.ZoomApi
1314import com.otaliastudios.zoom.ZoomLayout
1415import de.markusressel.kodeeditor.library.R
@@ -149,23 +150,21 @@ open class CodeEditorView
149150 }
150151
151152 private fun readParameters (attrs : AttributeSet ? , defStyleAttr : Int ) {
152- val a = context.obtainStyledAttributes (attrs, R .styleable.CodeEditorView , defStyleAttr, 0 )
153-
154- val editTextBackgroundColor = a.getColor(
155- context ,
156- defaultColor = Color . WHITE ,
157- styleableRes = R .styleable. CodeEditorView_ke_editor_backgroundColor ,
158- attr = intArrayOf(
159- R .attr.ke_editor_backgroundColor,
160- android. R .attr.windowBackground
153+ context.withStyledAttributes (attrs, R .styleable.CodeEditorView , defStyleAttr, 0 ) {
154+ val editTextBackgroundColor = getColor(
155+ context,
156+ defaultColor = Color . WHITE ,
157+ styleableRes = R .styleable. CodeEditorView_ke_editor_backgroundColor ,
158+ attr = intArrayOf(
159+ R .attr.ke_editor_backgroundColor,
160+ android. R .attr.windowBackground
161+ )
161162 )
162- )
163- codeEditText.setBackgroundColor(editTextBackgroundColor)
163+ codeEditText.setBackgroundColor(editTextBackgroundColor)
164164
165- val maxRealZoom = a.getFloat(R .styleable.CodeEditorView_ke_editor_maxZoom , DEFAULT_MAX_ZOOM )
166- setMaxZoom(maxRealZoom, ZoomApi .TYPE_REAL_ZOOM )
167-
168- a.recycle()
165+ val maxRealZoom = getFloat(R .styleable.CodeEditorView_ke_editor_maxZoom , DEFAULT_MAX_ZOOM )
166+ setMaxZoom(maxRealZoom, ZoomApi .TYPE_REAL_ZOOM )
167+ }
169168 }
170169
171170 private fun inflateViews (inflater : LayoutInflater ) {
0 commit comments