update
This commit is contained in:
parent
6aea370d98
commit
c2b80a6763
@ -38,8 +38,8 @@ class PrimaryActivity : MoBaseActivity(), SearchFragment.SearchFragmentCancelCli
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
initClick()
|
||||
initFragment()
|
||||
initClick()
|
||||
}
|
||||
|
||||
private fun initClick() {
|
||||
@ -69,6 +69,9 @@ class PrimaryActivity : MoBaseActivity(), SearchFragment.SearchFragmentCancelCli
|
||||
}
|
||||
|
||||
private fun changeFragment(index: Int) {
|
||||
if (isFinishing || isDestroyed) {
|
||||
return
|
||||
}
|
||||
currentIndex = index
|
||||
val ft: FragmentTransaction = supportFragmentManager.beginTransaction()
|
||||
if (null != mCurrentFragment) {
|
||||
@ -87,7 +90,7 @@ class PrimaryActivity : MoBaseActivity(), SearchFragment.SearchFragmentCancelCli
|
||||
} else {
|
||||
ft.show(fragment)
|
||||
}
|
||||
ft.commit()
|
||||
ft.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
private fun updateBtnState(index: Int) {
|
||||
|
||||
@ -66,6 +66,7 @@ class SearchFragment : MoBaseFragment<FragmentSearchBinding>(), TextWatcher,
|
||||
private var searchHistorySet: MutableSet<String> = mutableSetOf()
|
||||
private var searchHistory: MutableList<String> = mutableListOf()
|
||||
private var searchHistoryAdapter: SearchHistoryAdapter? = null
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> FragmentSearchBinding
|
||||
get() = FragmentSearchBinding::inflate
|
||||
@ -287,27 +288,29 @@ class SearchFragment : MoBaseFragment<FragmentSearchBinding>(), TextWatcher,
|
||||
}
|
||||
|
||||
override fun onFocusChange(v: View?, hasFocus: Boolean) {
|
||||
if (hasFocus) {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
handler.postDelayed({
|
||||
if (hasFocus) {
|
||||
showImm()
|
||||
}, 200)
|
||||
} else {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
} else {
|
||||
hideImm()
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
|
||||
private fun showImm() {
|
||||
val imm =
|
||||
requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(binding.searchEdit, InputMethodManager.SHOW_IMPLICIT)
|
||||
if (isAdded) {
|
||||
val imm =
|
||||
requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(binding.searchEdit, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideImm() {
|
||||
val imm =
|
||||
requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(binding.searchEdit.windowToken, 0)
|
||||
if (isAdded) {
|
||||
val imm =
|
||||
requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(binding.searchEdit.windowToken, 0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showResultContent() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user