mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
fbfd74f269
@ -202,7 +202,10 @@ class MainActivity : BaseActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun removeSearchFocus() {
|
||||
/**
|
||||
* Remove the focus of the search view in the toolbar
|
||||
*/
|
||||
fun removeSearchFocus() {
|
||||
searchView.setQuery("", false)
|
||||
searchView.clearFocus()
|
||||
searchView.onActionViewCollapsed()
|
||||
|
@ -7,7 +7,9 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.MainActivity
|
||||
import com.github.libretube.adapters.SearchHistoryAdapter
|
||||
import com.github.libretube.adapters.SearchSuggestionsAdapter
|
||||
@ -18,6 +20,7 @@ import com.github.libretube.extensions.BaseFragment
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.await
|
||||
import com.github.libretube.models.SearchViewModel
|
||||
import kotlinx.android.synthetic.main.activity_main.toolbar
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
@ -109,4 +112,14 @@ class SearchFragment() : BaseFragment() {
|
||||
binding.historyEmpty.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
if (findNavController().currentDestination?.id != R.id.searchResultFragment) {
|
||||
// remove the search focus
|
||||
(activity as MainActivity)
|
||||
.toolbar.menu
|
||||
.findItem(R.id.action_search).collapseActionView()
|
||||
}
|
||||
super.onStop()
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.MainActivity
|
||||
import com.github.libretube.adapters.SearchAdapter
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.databinding.FragmentSearchResultBinding
|
||||
@ -18,6 +20,7 @@ import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.hideKeyboard
|
||||
import kotlinx.android.synthetic.main.activity_main.toolbar
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
@ -141,4 +144,14 @@ class SearchResultFragment : BaseFragment() {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
if (findNavController().currentDestination?.id != R.id.searchFragment) {
|
||||
// remove the search focus
|
||||
(activity as MainActivity)
|
||||
.toolbar.menu
|
||||
.findItem(R.id.action_search).collapseActionView()
|
||||
}
|
||||
super.onStop()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user