aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java49
1 files changed, 30 insertions, 19 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
index b8633624..da6c37f1 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -21,6 +21,7 @@ package github.daneren2005.dsub.service;
import java.io.File;
import java.io.Reader;
import java.io.FileReader;
+import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -34,13 +35,12 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.util.Log;
-import org.apache.http.HttpResponse;
-
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.ArtistInfo;
import github.daneren2005.dsub.domain.ChatMessage;
import github.daneren2005.dsub.domain.Genre;
import github.daneren2005.dsub.domain.Indexes;
+import github.daneren2005.dsub.domain.InternetRadioStation;
import github.daneren2005.dsub.domain.MusicDirectory.Entry;
import github.daneren2005.dsub.domain.PlayerQueue;
import github.daneren2005.dsub.domain.PodcastEpisode;
@@ -95,7 +95,7 @@ public class OfflineMusicService implements MusicService {
artist.setIndex(file.getName().substring(0, 1));
artist.setName(file.getName());
artists.add(artist);
- } else {
+ } else if(!file.getName().equals("albumart.jpg") && !file.getName().equals(".nomedia")) {
entries.add(createEntry(context, file));
}
}
@@ -226,7 +226,7 @@ public class OfflineMusicService implements MusicService {
}
@Override
- public HttpResponse getDownloadInputStream(Context context, Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception {
+ public HttpURLConnection getDownloadInputStream(Context context, Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception {
throw new OfflineException(ERRORMSG);
}
@@ -307,7 +307,15 @@ public class OfflineMusicService implements MusicService {
}
}
});
-
+
+ // Respect counts in search criteria
+ int artistCount = Math.min(artists.size(), criteria.getArtistCount());
+ int albumCount = Math.min(albums.size(), criteria.getAlbumCount());
+ int songCount = Math.min(songs.size(), criteria.getSongCount());
+ artists = artists.subList(0, artistCount);
+ albums = albums.subList(0, albumCount);
+ songs = songs.subList(0, songCount);
+
return new SearchResult(artists, albums, songs);
}
@@ -359,20 +367,13 @@ public class OfflineMusicService implements MusicService {
}
}
private int matchCriteria(SearchCritera criteria, String name) {
- String query = criteria.getQuery().toLowerCase();
- String[] queryParts = query.split(" ");
- String[] nameParts = name.toLowerCase().split(" ");
-
- int closeness = 0;
- for(String queryPart : queryParts) {
- for(String namePart : nameParts) {
- if(namePart.equals(queryPart)) {
- closeness++;
- }
- }
+ if (criteria.getPattern().matcher(name).matches()) {
+ return Util.getStringDistance(
+ criteria.getQuery().toLowerCase(),
+ name.toLowerCase());
+ } else {
+ return 0;
}
-
- return closeness;
}
@Override
@@ -587,6 +588,11 @@ public class OfflineMusicService implements MusicService {
}
@Override
+ public MusicDirectory getSongList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException(ERRORMSG);
+ }
+
+ @Override
public MusicDirectory getRandomSongs(int size, String artistId, Context context, ProgressListener progressListener) throws Exception {
throw new OfflineException(ERRORMSG);
}
@@ -769,7 +775,7 @@ public class OfflineMusicService implements MusicService {
}
@Override
- public MusicDirectory getNewestPodcastEpisodes(int count, Context context, ProgressListener progressListener) throws Exception {
+ public MusicDirectory getNewestPodcastEpisodes(boolean refresh, Context context, ProgressListener progressListener, int count) throws Exception {
throw new OfflineException(ERRORMSG);
}
@@ -884,6 +890,11 @@ public class OfflineMusicService implements MusicService {
}
@Override
+ public List<InternetRadioStation> getInternetRadioStations(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException(ERRORMSG);
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
throw new OfflineException(ERRORMSG);
}