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