Skip to content
Snippets Groups Projects
Commit abd6e65f authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Update search UIs to match medialibrary API

parent b5f89936
No related branches found
No related tags found
No related merge requests found
......@@ -126,56 +126,56 @@
android:layout_marginLeft="10dp"
android:textAppearance="@style/Result.Title"
android:text="@string/episodes"
android:visibility="@{searchAggregate.mediaSearchAggregate.episodes.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{View.GONE}"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/episodes_results"
style="@style/Result.List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_default"
android:visibility="@{searchAggregate.mediaSearchAggregate.episodes.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{View.GONE}"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="@style/Result.Title"
android:text="@string/movies"
android:visibility="@{searchAggregate.mediaSearchAggregate.movies.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{View.GONE}"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/movies_results"
style="@style/Result.List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_default"
android:visibility="@{searchAggregate.mediaSearchAggregate.movies.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{View.GONE}"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="@style/Result.Title"
android:text="@string/videos"
android:visibility="@{searchAggregate.mediaSearchAggregate.others.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{searchAggregate.videos.length == 0 ? View.GONE : View.VISIBLE}"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/others_results"
style="@style/Result.List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_default"
android:visibility="@{searchAggregate.mediaSearchAggregate.others.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{searchAggregate.videos.length == 0 ? View.GONE : View.VISIBLE}"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="@style/Result.Title"
android:text="@string/songs"
android:visibility="@{searchAggregate.mediaSearchAggregate.tracks.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{searchAggregate.tracks.length == 0 ? View.GONE : View.VISIBLE}"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_results"
style="@style/Result.List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_default"
android:visibility="@{searchAggregate.mediaSearchAggregate.tracks.length == 0 ? View.GONE : View.VISIBLE}"/>
android:visibility="@{searchAggregate.tracks.length == 0 ? View.GONE : View.VISIBLE}"/>
</LinearLayout>
</ScrollView>
......
......@@ -86,7 +86,7 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
vsp.isArtistFocus -> items = playbackService.medialibrary.searchArtist(vsp.artist)
vsp.isAlbumFocus -> items = playbackService.medialibrary.searchAlbum(vsp.album)
vsp.isGenreFocus -> items = playbackService.medialibrary.searchGenre(vsp.genre)
vsp.isSongFocus -> tracks = playbackService.medialibrary.searchMedia(vsp.song)!!.tracks
vsp.isSongFocus -> tracks = playbackService.medialibrary.searchMedia(vsp.song)!!
}
if (Tools.isArrayEmpty(tracks)) {
val result = playbackService.medialibrary.search(query)
......
......@@ -81,10 +81,8 @@ public class SearchActivity extends AppCompatActivity implements TextWatcher, Te
((SearchResultAdapter)mBinding.artistsResults.getAdapter()).add(searchAggregate.getArtists());
((SearchResultAdapter)mBinding.genresResults.getAdapter()).add(searchAggregate.getGenres());
((SearchResultAdapter)mBinding.playlistsResults.getAdapter()).add(searchAggregate.getPlaylists());
((SearchResultAdapter)mBinding.episodesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getEpisodes());
((SearchResultAdapter)mBinding.moviesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getMovies());
((SearchResultAdapter)mBinding.othersResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getOthers());
((SearchResultAdapter)mBinding.songsResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getTracks());
((SearchResultAdapter)mBinding.othersResults.getAdapter()).add(searchAggregate.getVideos());
((SearchResultAdapter)mBinding.songsResults.getAdapter()).add(searchAggregate.getTracks());
}
});
}
......
......@@ -31,6 +31,7 @@ import android.support.v17.leanback.widget.*
import android.text.TextUtils
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.launch
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.media.*
import org.videolan.vlc.R
import org.videolan.vlc.util.getFromMl
......@@ -77,16 +78,16 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
private fun loadRows(query: String?) = launch(UI.immediate) {
val searchAggregate = context?.getFromMl { search(query) } ?: return@launch
val empty = searchAggregate.isEmpty
val mediaEmpty = empty || searchAggregate.mediaSearchAggregate.isEmpty
val mediaEmpty = empty || (Tools.isArrayEmpty(searchAggregate.tracks) && Tools.isArrayEmpty(searchAggregate.videos))
val cp = CardPresenter(requireActivity())
val videoAdapter = ArrayObjectAdapter(cp)
if (!mediaEmpty) videoAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.others))
val episodesAdapter = ArrayObjectAdapter(cp)
if (!mediaEmpty) episodesAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.episodes))
val moviesAdapter = ArrayObjectAdapter(cp)
if (!mediaEmpty) moviesAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.movies))
if (!mediaEmpty) videoAdapter.addAll(0, Arrays.asList(*searchAggregate.videos))
// val episodesAdapter = ArrayObjectAdapter(cp)
// if (!mediaEmpty) episodesAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.episodes))
// val moviesAdapter = ArrayObjectAdapter(cp)
// if (!mediaEmpty) moviesAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.movies))
val songsAdapter = ArrayObjectAdapter(cp)
if (!mediaEmpty) songsAdapter.addAll(0, Arrays.asList(searchAggregate.mediaSearchAggregate.tracks))
if (!mediaEmpty) songsAdapter.addAll(0, Arrays.asList(*searchAggregate.tracks))
val artistsAdapter = ArrayObjectAdapter(cp)
if (!empty) artistsAdapter.addAll(0, Arrays.asList<Artist>(*searchAggregate.artists))
val albumsAdapter = ArrayObjectAdapter(cp)
......@@ -95,10 +96,10 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
if (!empty) genresAdapter.addAll(0, Arrays.asList<Genre>(*searchAggregate.genres))
if (!mediaEmpty && videoAdapter.size() > 0)
rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.videos)), videoAdapter))
if (!mediaEmpty && episodesAdapter.size() > 0)
rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.episodes)), episodesAdapter))
if (!mediaEmpty && moviesAdapter.size() > 0)
rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.movies)), moviesAdapter))
// if (!mediaEmpty && episodesAdapter.size() > 0)
// rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.episodes)), episodesAdapter))
// if (!mediaEmpty && moviesAdapter.size() > 0)
// rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.movies)), moviesAdapter))
if (!mediaEmpty && songsAdapter.size() > 0)
rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.songs)), songsAdapter))
if (!empty && artistsAdapter.size() > 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment