-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/issue 110/content observer (#113)
Issue-110 - added functionality to react to changes in audio files, i.e. the add/deletion of files and reacted by updating the search database accordingly. Also fixed bug viewing songs from folders.
- Loading branch information
Showing
44 changed files
with
1,179 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/github/goldy1992/mp3player/commons/Normaliser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.goldy1992.mp3player.commons; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public final class Normaliser { | ||
|
||
private Normaliser() { | ||
|
||
} | ||
|
||
public static String normalise(@NonNull String query) { | ||
query = StringUtils.stripAccents(query); | ||
return query.trim().toUpperCase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...thub/goldy1992/mp3player/service/library/content/filter/SongsFromFolderResultsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.goldy1992.mp3player.service.library.content.filter; | ||
|
||
import android.support.v4.media.MediaBrowserCompat.MediaItem; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.github.goldy1992.mp3player.commons.MediaItemUtils; | ||
|
||
import java.io.File; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class SongsFromFolderResultsFilter implements ResultsFilter { | ||
|
||
|
||
@Inject | ||
public SongsFromFolderResultsFilter() { | ||
/* Empty constructor declared for dagger insert */ | ||
} | ||
|
||
|
||
@Override | ||
public List<MediaItem> filter(@NonNull String query, | ||
@NonNull List<MediaItem> results) { | ||
File queryPath = new File(query); | ||
Iterator<MediaItem> iterator = results.listIterator(); | ||
|
||
while(iterator.hasNext()) { | ||
MediaItem currentItem = iterator.next(); | ||
String directoryPath = MediaItemUtils.getDirectoryPath(currentItem); | ||
if (directoryPath == null || !directoryPath.equalsIgnoreCase(queryPath.getAbsolutePath().toUpperCase())) { | ||
iterator.remove(); | ||
} | ||
} | ||
return results; | ||
} | ||
} |
Oops, something went wrong.