feat: 优化代码

pull/167/head
kunfei 5 years ago
parent 97b644db0f
commit 1a699bb4b8
  1. 9
      app/src/main/java/io/legado/app/ui/widget/SearchView.kt

@ -11,7 +11,6 @@ import android.text.style.ImageSpan
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue import android.util.TypedValue
import android.view.Gravity import android.view.Gravity
import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import io.legado.app.R import io.legado.app.R
@ -41,8 +40,7 @@ class SearchView : SearchView {
super.onLayout(changed, left, top, right, bottom) super.onLayout(changed, left, top, right, bottom)
try { try {
if (textView == null) { if (textView == null) {
textView = textView = findViewById(androidx.appcompat.R.id.search_src_text)
findViewById<View>(androidx.appcompat.R.id.search_src_text) as TextView
mSearchHintIcon = this.context.getDrawable(R.drawable.ic_search_hint) mSearchHintIcon = this.context.getDrawable(R.drawable.ic_search_hint)
updateQueryHint() updateQueryHint()
} }
@ -69,9 +67,8 @@ class SearchView : SearchView {
} }
private fun updateQueryHint() { private fun updateQueryHint() {
if (textView != null) { textView?.let {
val hint = queryHint it.hint = getDecoratedHint(queryHint ?: "")
textView!!.hint = getDecoratedHint(hint ?: "")
} }
} }

Loading…
Cancel
Save