mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-24 13:34:45 +00:00
Add search type selector to suggestions fragment.
This commit is contained in:
parent
63761cfc9a
commit
daa91986ef
2 changed files with 75 additions and 22 deletions
|
@ -18,6 +18,8 @@ import com.futo.platformplayer.states.StatePlatform
|
|||
import com.futo.platformplayer.stores.FragmentedStorage
|
||||
import com.futo.platformplayer.stores.SearchHistoryStorage
|
||||
import com.futo.platformplayer.views.adapters.SearchSuggestionAdapter
|
||||
import com.futo.platformplayer.views.others.RadioGroupView
|
||||
import com.futo.platformplayer.views.others.TagsView
|
||||
|
||||
data class SuggestionsFragmentData(val query: String, val searchType: SearchType, val channelUrl: String? = null);
|
||||
|
||||
|
@ -28,6 +30,7 @@ class SuggestionsFragment : MainFragment {
|
|||
|
||||
private var _recyclerSuggestions: RecyclerView? = null;
|
||||
private var _llmSuggestions: LinearLayoutManager? = null;
|
||||
private var _radioGroupView: RadioGroupView? = null;
|
||||
private val _suggestions: ArrayList<String> = ArrayList();
|
||||
private var _query: String? = null;
|
||||
private var _searchType: SearchType = SearchType.VIDEO;
|
||||
|
@ -73,6 +76,15 @@ class SuggestionsFragment : MainFragment {
|
|||
recyclerSuggestions.adapter = _adapterSuggestions;
|
||||
_recyclerSuggestions = recyclerSuggestions;
|
||||
|
||||
_radioGroupView = view.findViewById<RadioGroupView>(R.id.radio_group).apply {
|
||||
onSelectedChange.subscribe {
|
||||
if (it.size != 1)
|
||||
_searchType = SearchType.VIDEO
|
||||
else
|
||||
_searchType = (it[0] ?: SearchType.VIDEO) as SearchType
|
||||
}
|
||||
}
|
||||
|
||||
loadSuggestions();
|
||||
return view;
|
||||
}
|
||||
|
@ -103,31 +115,27 @@ class SuggestionsFragment : MainFragment {
|
|||
_channelUrl = null;
|
||||
}
|
||||
|
||||
_radioGroupView?.setOptions(listOf(Pair("Media", SearchType.VIDEO), Pair("Creators", SearchType.CREATOR), Pair("Playlists", SearchType.PLAYLIST)), listOf(_searchType), false, true)
|
||||
|
||||
topBar?.apply {
|
||||
if (this is SearchTopBarFragment) {
|
||||
onSearch.subscribe(this) {
|
||||
if (_searchType == SearchType.CREATOR) {
|
||||
navigate<CreatorSearchResultsFragment>(it);
|
||||
} else if (_searchType == SearchType.PLAYLIST) {
|
||||
navigate<PlaylistSearchResultsFragment>(it);
|
||||
} else {
|
||||
if(it.isHttpUrl()) {
|
||||
if(StatePlatform.instance.hasEnabledPlaylistClient(it))
|
||||
navigate<RemotePlaylistFragment>(it);
|
||||
else if(StatePlatform.instance.hasEnabledChannelClient(it))
|
||||
navigate<ChannelFragment>(it);
|
||||
else {
|
||||
val url = it;
|
||||
activity?.let {
|
||||
close()
|
||||
if(it is MainActivity)
|
||||
it.navigate(it.getFragment<VideoDetailFragment>(), url);
|
||||
}
|
||||
if(it.isHttpUrl()) {
|
||||
if(StatePlatform.instance.hasEnabledPlaylistClient(it))
|
||||
navigate<RemotePlaylistFragment>(it);
|
||||
else if(StatePlatform.instance.hasEnabledChannelClient(it))
|
||||
navigate<ChannelFragment>(it);
|
||||
else {
|
||||
val url = it;
|
||||
activity?.let {
|
||||
close()
|
||||
if(it is MainActivity)
|
||||
it.navigate(it.getFragment<VideoDetailFragment>(), url);
|
||||
}
|
||||
}
|
||||
else
|
||||
navigate<ContentSearchResultsFragment>(SuggestionsFragmentData(it, SearchType.VIDEO, _channelUrl));
|
||||
}
|
||||
else
|
||||
navigate<ContentSearchResultsFragment>(SuggestionsFragmentData(it, _searchType, _channelUrl));
|
||||
};
|
||||
|
||||
onTextChange.subscribe(this) {
|
||||
|
@ -189,6 +197,7 @@ class SuggestionsFragment : MainFragment {
|
|||
super.onDestroyMainView();
|
||||
_getSuggestions.onError.clear();
|
||||
_recyclerSuggestions = null;
|
||||
_radioGroupView = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
@ -1,14 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".fragment.mainactivity.main.SuggestionsFragment">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
app:layout_scrollFlags="scroll"
|
||||
app:contentInsetStart="0dp"
|
||||
app:contentInsetEnd="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container_toolbar_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.futo.platformplayer.views.announcements.AnnouncementView
|
||||
android:id="@+id/announcement_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.futo.platformplayer.views.others.RadioGroupView
|
||||
android:id="@+id/radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list_suggestions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Add table
Reference in a new issue