public class MidiLibrary extends Object implements Map<String,MidiLibrary.MapNode>
Modifier and Type | Class and Description |
---|---|
static interface |
MidiLibrary.Callback
Callback interface used for running code upon completion of asynchronous
MidiLibrary creation. |
static class |
MidiLibrary.Folder
A structure representing a folder in a
MidiLibrary . |
static interface |
MidiLibrary.MapNode
Represents an entry in a
MidiLibrary.Folder . |
static class |
MidiLibrary.MidiFile
A structure representing a MIDI file that can be contained in a
MidiLibrary.Folder . |
protected static class |
MidiLibrary.RootFolder
Subclass of
MidiLibrary.Folder that allows for a null name. |
Modifier and Type | Field and Description |
---|---|
static String |
ALBUM_ICON_URI
URI for the album icon.
|
static String |
ALBUM_ID
The ID of the folder containing the songs sorted by album.
|
static String |
ARTIST_ICON_URI
URI for the artist icon.
|
static String |
ARTIST_ID
The ID of the folder containing the songs sorted by artist.
|
protected static String |
CLASS_NAME
The package and name of the
MidiLibrary class. |
static String |
FOLDER_ICON_URI
URI for the default folder icon.
|
static String |
MUSIC_FILE_ICON_URI
URI for the music file icon.
|
static String |
PATH_ID
The ID of the folder containing the songs sorted by path.
|
static String |
ROOT_ID
The ID of the root folder.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
DISABLED METHOD
Throws UnsupportedOperationException . |
boolean |
containsKey(Object key)
Checks if the passed
String is one of the names of the items in the root of this MIDI library. |
boolean |
containsValue(Object value)
Checks if the passed
MidiLibrary.MapNode is one of the items in the root of this MIDI library. |
Set<Map.Entry<String,MidiLibrary.MapNode>> |
entrySet()
DISABLED METHOD
throws UnsupportedOperationException . |
MidiLibrary.MapNode |
get(Object key)
Gets the
MidiLibrary.MapNode associated with the provided name. |
static MidiLibrary |
getMidiLibrary(Context context)
Factory method for creating a MIDI library.
|
static void |
getMidiLibraryAsync(Context context,
MidiLibrary.Callback callback) |
static boolean |
hasStoragePermission(Context context)
Checks if the provided context has permission to read external storage.
|
boolean |
isEmpty()
Checks if the root of this MIDI library is empty.
|
Set<String> |
keySet()
Gets the names of all items in the root of this MIDI library.
|
Set<String> |
keySetRecursive()
Gets the names of all dead-end items in this MIDI library, including those in subfolders.
|
MidiLibrary.MidiFile |
put(String key,
MidiLibrary.MapNode value)
DISABLED METHOD
Throws UnsupportedOperationException . |
void |
putAll(Map<? extends String,? extends MidiLibrary.MapNode> m)
DISABLED METHOD
Throws UnsupportedOperationException . |
MidiLibrary.MidiFile |
remove(Object key)
DISABLED METHOD
Throws UnsupportedOperationException . |
static void |
requestStoragePermission(Activity activity,
int requestCode)
Requests permission to read external storage for the provided activity.
|
MidiLibrary.MidiFile |
searchFileFuzzy(String query)
Searches for a MIDI file with a similar name
|
MidiLibrary.MidiFile |
searchFileFuzzy(String query,
Predicate<MidiLibrary.MidiFile> predicate)
Searches for a
MidiLibrary.MidiFile using a Predicate to allow the caller to specify
attributes needed by a found MidiFile to be considered valid. |
int |
size()
Gets the number of items in the root of this MIDI library.
|
Collection<MidiLibrary.MapNode> |
values()
Gets all of the
MidiLibrary.MapNode objects in the root of this MIDI library |
Collection<MidiLibrary.MapNode> |
valuesRecursive()
Gets all of the dead-end
MidiLibrary.MapNode objects in this MIDI library, including those in subfolders. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
protected static final String CLASS_NAME
MidiLibrary
class. Refactors must ensure this is accurate.public static final String ROOT_ID
public static final String PATH_ID
public static final String ALBUM_ID
public static final String ARTIST_ID
public static final String FOLDER_ICON_URI
public static final String ALBUM_ICON_URI
public static final String ARTIST_ICON_URI
public static final String MUSIC_FILE_ICON_URI
public static boolean hasStoragePermission(Context context)
context
- the context to checktrue
if permission has been granted, otherwise false
public static void requestStoragePermission(Activity activity, int requestCode)
activity
- the activity to request permission on@Nullable public static MidiLibrary getMidiLibrary(Context context)
context
- the context to use for retrieving filesnull
if read permission has not been granted, otherwise a valid MIDI librarypublic static void getMidiLibraryAsync(Context context, MidiLibrary.Callback callback)
public int size()
size
in interface Map<String,MidiLibrary.MapNode>
public boolean isEmpty()
isEmpty
in interface Map<String,MidiLibrary.MapNode>
true
if the library is empty, otherwise false
public boolean containsKey(Object key)
String
is one of the names of the items in the root of this MIDI library.containsKey
in interface Map<String,MidiLibrary.MapNode>
key
- the name to check fortrue
if key
is the name of a root item, false
otherwisepublic boolean containsValue(Object value)
MidiLibrary.MapNode
is one of the items in the root of this MIDI library.containsValue
in interface Map<String,MidiLibrary.MapNode>
value
- the MapNode
object to check fortrue
if value
is a root item, false
otherwise@Nullable public MidiLibrary.MapNode get(Object key)
MidiLibrary.MapNode
associated with the provided name.get
in interface Map<String,MidiLibrary.MapNode>
key
- the name of the item to retrievenull
if the item wasn't found, the requested MapNode
otherwise@Nullable public MidiLibrary.MidiFile put(String key, MidiLibrary.MapNode value)
UnsupportedOperationException
.put
in interface Map<String,MidiLibrary.MapNode>
@Nullable public MidiLibrary.MidiFile remove(@Nullable Object key)
UnsupportedOperationException
.remove
in interface Map<String,MidiLibrary.MapNode>
public void putAll(@NonNull Map<? extends String,? extends MidiLibrary.MapNode> m)
UnsupportedOperationException
.putAll
in interface Map<String,MidiLibrary.MapNode>
public void clear()
UnsupportedOperationException
.clear
in interface Map<String,MidiLibrary.MapNode>
@NonNull public Set<String> keySet()
keySet
in interface Map<String,MidiLibrary.MapNode>
Set
of keys for all root items@NonNull public Set<String> keySetRecursive()
MidiLibrary.Folder.getKeysRecursive()
.Set
of all item names@NonNull public Collection<MidiLibrary.MapNode> values()
MidiLibrary.MapNode
objects in the root of this MIDI libraryvalues
in interface Map<String,MidiLibrary.MapNode>
Collection
of root items@NonNull public Collection<MidiLibrary.MapNode> valuesRecursive()
MidiLibrary.MapNode
objects in this MIDI library, including those in subfolders.
For a more detailed explanation of dead-end objects, see MidiLibrary.Folder.getChildrenRecursive()
Collection
of all items@NonNull public Set<Map.Entry<String,MidiLibrary.MapNode>> entrySet()
UnsupportedOperationException
.entrySet
in interface Map<String,MidiLibrary.MapNode>
@Nullable public MidiLibrary.MidiFile searchFileFuzzy(String query)
query
- the name to search fornull
if query
didn't match any files, otherwise the first matched file@Nullable public MidiLibrary.MidiFile searchFileFuzzy(String query, Predicate<MidiLibrary.MidiFile> predicate)
MidiLibrary.MidiFile
using a Predicate
to allow the caller to specify
attributes needed by a found MidiFile
to be considered valid.
e.g. predicate could be (file) -> { return file.getAlbum() == "Greatest Hits"; }
query
- the name of the file to search forpredicate
- the functional interface used to validate a matching MidiFile
null
if no matching files were found, otherwise the first matched file