forked from timusus/Shuttle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add song data POJO (timusus#41)
Step 1 to implement timusus#17.
- Loading branch information
1 parent
ee699db
commit 393df18
Showing
6 changed files
with
159 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package edu.usf.sas.pal.muser.model | ||
|
||
/** | ||
* A model class that stores the actions performed on the song track. The actions like play, pause, | ||
* skip, repeat and seek are stored along with the nested [SongData] class. | ||
*/ | ||
|
||
data class Event | ||
|
||
/** | ||
* [event] - The event attribute includes events like play, pause, skip, repeat and seek. | ||
* [currentTimeMs] - Stores the timestamp of the action recorded. | ||
* [nanoTime] - Stores the value of the running JVM's time source in nanoseconds. | ||
* [startTime] - Start time of the song. | ||
* [elapsedTime] - Elapsed time of the song when the event occurred. | ||
* [song] - Song on which the action was performed. | ||
*/ | ||
(val event:EventType, | ||
val currentTimeMs: Long, | ||
val nanoTime: Long, | ||
val startTime: Long, | ||
val elapsedTime: Long, | ||
val song: SongData | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/edu/usf/sas/pal/muser/model/EventType.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,18 @@ | ||
package edu.usf.sas.pal.muser.model; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* The provider enumerator that stores different types of action that can be performed by the user | ||
* on a sound track. | ||
*/ | ||
public enum EventType { | ||
|
||
PLAY, | ||
PLAY_MANUAL, | ||
PAUSE, | ||
PAUSE_MANUAL, | ||
SKIP, | ||
REPEAT, | ||
SEEK | ||
} |
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,60 @@ | ||
package edu.usf.sas.pal.muser.model | ||
|
||
import android.content.Context | ||
import com.simplecity.amp_library.model.Song | ||
|
||
|
||
/** | ||
* A model class that holds the information about the song that is currently being played by the | ||
* user. | ||
*/ | ||
data class SongData | ||
|
||
/** | ||
* [id] - The id of the track. | ||
* [name] - Name of the track. | ||
* [artistID] - The id of the artist. | ||
* [artistName] - Name of the Artist who composed the track. | ||
* [albumID] - The id of the album. | ||
* [albumName] - Name of the album that the current track belongs to. | ||
* [playlistID] - The id of the playlist that track belongs to. | ||
* [playlistPlayOrder] - The queue number of the song in a playlist. | ||
* [discNumber] - The disc number that the track belongs to. | ||
* [bitrateLabel] - The bitrate of the song. | ||
* [fileSizeLabel] - The file size of the song. | ||
* [isPodCast] - Boolean value to determine if the current audio file is a pod cast or not. | ||
* [duration] - The length of the track. | ||
* [dateAdded] - The date on which the track was added. | ||
* [year] - The year during which the track was released. | ||
* [playCount] - The number of times the user played this track. | ||
* [sampleRateLabel] - The sample rate of the song. | ||
* [formatLabel] - The format of the song. (mp3 or wav etc.) | ||
*/ | ||
(val id: Long, | ||
val name: String, | ||
val artistID: Long, | ||
val artistName: String, | ||
val albumID: Long, | ||
val albumName: String, | ||
val playlistID: Long, | ||
val playlistPlayOrder: Long, | ||
val lastPlayed: Long, | ||
val track: Int, | ||
val discNumber: Int, | ||
val bitrateLabel: String, | ||
val fileSizeLabel: String, | ||
val isPodCast: Boolean, | ||
val duration: Long, | ||
val dateAdded: Int, | ||
val year: Int, | ||
val path: String, | ||
val playCount: Int, | ||
val sampleRateLabel: String, | ||
val formatLabel: String | ||
){ | ||
constructor(song: Song, context: Context): this(song.id, song.name, song.artistId, song.albumName, song.albumId, | ||
song.albumName, song.playlistSongId, song.playlistSongPlayOrder, song.lastPlayed, | ||
song.track, song.discNumber, song.getBitrateLabel(context), song.getFileSizeLabel(), | ||
song.isPodcast, song.duration, song.dateAdded, song.year, song.path, song.playCount, | ||
song.getSampleRateLabel(context), song.getFormatLabel()) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/edu/usf/sas/pal/muser/util/EventUtils.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,30 @@ | ||
package edu.usf.sas.pal.muser.util; | ||
|
||
import android.content.Context; | ||
|
||
import com.simplecity.amp_library.ShuttleApplication; | ||
import com.simplecity.amp_library.model.Song; | ||
|
||
import edu.usf.sas.pal.muser.model.Event; | ||
import edu.usf.sas.pal.muser.model.EventType; | ||
import edu.usf.sas.pal.muser.model.SongData; | ||
|
||
|
||
|
||
public class EventUtils { | ||
|
||
/** | ||
* Function to populate the Event data class. | ||
* @param song - The song for which the event occurred. | ||
* @param capturedEvent - The event that was captured. | ||
* @param context - The context of the Fragment. | ||
* @return - Event object | ||
*/ | ||
public static Event newEvent(Song song, EventType capturedEvent, Context context){ | ||
long currentTimeMS = System.currentTimeMillis(); | ||
long nanoTime = System.nanoTime(); | ||
SongData songData = new SongData(song, context); | ||
long elapsedTime = song.getElapsedTime(); | ||
return new Event(capturedEvent, currentTimeMS, nanoTime, song.startTime, elapsedTime, songData); | ||
} | ||
} |