Commit b92107fd authored by Geoffrey Métais's avatar Geoffrey Métais

Prevent search with too short queries

parent b03e88b4
......@@ -108,7 +108,7 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
vsp.isGenreFocus -> items = playbackService.medialibrary.searchGenre(vsp.genre)
vsp.isSongFocus -> tracks = playbackService.medialibrary.searchMedia(vsp.song)!!
}
if (Tools.isArrayEmpty(tracks)) playbackService.medialibrary.search(query)?.run {
if (Tools.isArrayEmpty(tracks) && query !== null && query.length > 2) playbackService.medialibrary.search(query)?.run {
when {
!Tools.isArrayEmpty(albums) -> tracks = albums[0].tracks
!Tools.isArrayEmpty(artists) -> tracks = artists[0].tracks
......
......@@ -5,13 +5,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
......@@ -33,6 +27,13 @@ import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.Settings;
import org.videolan.vlc.util.WorkersKt;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class SearchActivity extends AppCompatActivity implements TextWatcher, TextView.OnEditorActionListener {
public final static String TAG = "VLC/SearchActivity";
......@@ -68,6 +69,7 @@ public class SearchActivity extends AppCompatActivity implements TextWatcher, Te
}
private void performSearh(final String query) {
if (query == null || query.length() < 3) return;
WorkersKt.runIO(new Runnable() {
@Override
public void run() {
......
......@@ -78,6 +78,7 @@ class SearchFragment : SearchSupportFragment(), SearchSupportFragment.SearchResu
}
private fun loadRows(query: String?) = coroutineScope.launch {
if (query == null || query.length < 3) return@launch
val searchAggregate = context?.getFromMl { search(query) }
val empty = searchAggregate == null || searchAggregate.isEmpty
updateEmtyView(empty)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment