mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
fix the search when no results were found
This commit is contained in:
parent
8345269179
commit
785180c64f
@ -18,8 +18,8 @@ import com.github.libretube.extensions.hideKeyboard
|
|||||||
import com.github.libretube.ui.adapters.SearchAdapter
|
import com.github.libretube.ui.adapters.SearchAdapter
|
||||||
import com.github.libretube.ui.base.BaseFragment
|
import com.github.libretube.ui.base.BaseFragment
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import java.io.IOException
|
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class SearchResultFragment : BaseFragment() {
|
class SearchResultFragment : BaseFragment() {
|
||||||
private lateinit var binding: FragmentSearchResultBinding
|
private lateinit var binding: FragmentSearchResultBinding
|
||||||
@ -47,6 +47,8 @@ class SearchResultFragment : BaseFragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
binding.searchRecycler.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
|
||||||
// add the query to the history
|
// add the query to the history
|
||||||
addToHistory(query)
|
addToHistory(query)
|
||||||
|
|
||||||
@ -92,13 +94,12 @@ class SearchResultFragment : BaseFragment() {
|
|||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (response.items?.isNotEmpty() == true) {
|
searchAdapter = SearchAdapter(response.items.orEmpty().toMutableList())
|
||||||
binding.searchRecycler.layoutManager = LinearLayoutManager(requireContext())
|
binding.searchRecycler.adapter = searchAdapter
|
||||||
searchAdapter = SearchAdapter(response.items)
|
binding.noSearchResult.visibility = if (response.items.orEmpty().isEmpty()) {
|
||||||
binding.searchRecycler.adapter = searchAdapter
|
View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.searchContainer.visibility = View.GONE
|
View.GONE
|
||||||
binding.noSearchResult.visibility = View.VISIBLE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextPage = response.nextpage
|
nextPage = response.nextpage
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -7,87 +7,81 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.fragments.SearchFragment">
|
tools:context=".ui.fragments.SearchFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<HorizontalScrollView
|
||||||
android:id="@+id/search_container"
|
android:id="@+id/filter_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:paddingHorizontal="10dp"
|
||||||
|
android:scrollbars="none"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/recycler_view"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<HorizontalScrollView
|
<com.google.android.material.chip.ChipGroup
|
||||||
android:id="@+id/filter_bar"
|
android:id="@+id/filter_chip_group"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="10dp"
|
app:checkedChip="@id/chip_all"
|
||||||
android:scrollbars="none"
|
app:selectionRequired="true"
|
||||||
app:layout_constraintBottom_toTopOf="@id/recycler_view"
|
app:singleLine="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:singleSelection="true">
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<com.google.android.material.chip.ChipGroup
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/filter_chip_group"
|
android:id="@+id/chip_all"
|
||||||
android:layout_width="wrap_content"
|
style="@style/Chip"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/all" />
|
||||||
app:checkedChip="@id/chip_all"
|
|
||||||
app:selectionRequired="true"
|
|
||||||
app:singleLine="true"
|
|
||||||
app:singleSelection="true">
|
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_all"
|
android:id="@+id/chip_videos"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/all" />
|
android:text="@string/videos" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_videos"
|
android:id="@+id/chip_channels"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/videos" />
|
android:text="@string/channels" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_channels"
|
android:id="@+id/chip_playlists"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/channels" />
|
android:text="@string/playlists" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_playlists"
|
android:id="@+id/chip_music_songs"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/playlists" />
|
android:text="@string/music_songs" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_music_songs"
|
android:id="@+id/chip_music_videos"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/music_songs" />
|
android:text="@string/music_videos" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_music_videos"
|
android:id="@+id/chip_music_albums"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/music_videos" />
|
android:text="@string/music_albums" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/chip_music_albums"
|
android:id="@+id/chip_music_playlists"
|
||||||
style="@style/Chip"
|
style="@style/Chip"
|
||||||
android:text="@string/music_albums" />
|
android:text="@string/music_playlists" />
|
||||||
|
</com.google.android.material.chip.ChipGroup>
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/chip_music_playlists"
|
android:id="@+id/search_recycler"
|
||||||
style="@style/Chip"
|
android:layout_width="match_parent"
|
||||||
android:text="@string/music_playlists" />
|
android:layout_height="wrap_content"
|
||||||
</com.google.android.material.chip.ChipGroup>
|
android:layout_marginVertical="10dp" />
|
||||||
</HorizontalScrollView>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/search_recycler"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginVertical="10dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/no_search_result"
|
android:id="@+id/no_search_result"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="150dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
@ -108,4 +102,4 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user