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

TV: Message for no result in search

See #468
parent e06b9cca
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="org.videolan.vlc.gui.tv.SearchFragment"
android:id="@+id/search_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/search_fragment"
android:name="org.videolan.vlc.gui.tv.SearchFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/no_result"
android:visibility="gone"/>
</FrameLayout>
\ No newline at end of file
......@@ -23,15 +23,19 @@ package org.videolan.vlc.gui.tv;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;
import org.videolan.vlc.R;
import androidx.fragment.app.FragmentActivity;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class SearchActivity extends FragmentActivity {
private static final String TAG = "VLC/SearchActivity";
private SearchFragment mFragment;
private TextView mEmptyView;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -39,6 +43,11 @@ public class SearchActivity extends FragmentActivity {
setContentView(R.layout.tv_search);
mFragment = (SearchFragment) getSupportFragmentManager()
.findFragmentById(R.id.search_fragment);
mEmptyView = findViewById(R.id.empty);
}
public void updateEmptyView(boolean empty) {
mEmptyView.setVisibility(empty ? View.VISIBLE : View.GONE);
}
@Override
......
......@@ -26,9 +26,9 @@ import android.app.SearchManager
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import androidx.leanback.app.SearchSupportFragment
import androidx.leanback.widget.*
import android.text.TextUtils
import kotlinx.coroutines.launch
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.media.*
......@@ -76,8 +76,10 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
}
private fun loadRows(query: String?) = coroutineScope.launch {
val searchAggregate = context?.getFromMl { search(query) } ?: return@launch
val empty = searchAggregate.isEmpty
val searchAggregate = context?.getFromMl { search(query) }
val empty = searchAggregate == null || searchAggregate.isEmpty
updateEmtyView(empty)
if (searchAggregate == null || empty) return@launch
val mediaEmpty = empty || (Tools.isArrayEmpty(searchAggregate.tracks) && Tools.isArrayEmpty(searchAggregate.videos))
val cp = CardPresenter(requireActivity())
val videoAdapter = ArrayObjectAdapter(cp)
......@@ -110,6 +112,10 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
rowsAdapter.add(ListRow(HeaderItem(0, resources.getString(R.string.genres)), genresAdapter))
}
private fun updateEmtyView(empty: Boolean) {
(activity as? SearchActivity)?.updateEmptyView(empty)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
if (requestCode == REQUEST_SPEECH && resultCode == Activity.RESULT_OK) setSearchQuery(data, true)
}
......
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