Rename MusicDirectory.Entry to Track to make more clear what it is
This commit is contained in:
parent
34c13d7908
commit
2de59b2206
|
@ -2,7 +2,7 @@ package org.moire.ultrasonic.domain
|
|||
|
||||
import java.io.Serializable
|
||||
import java.util.Date
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Entry
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Track
|
||||
|
||||
data class Bookmark(
|
||||
val position: Int = 0,
|
||||
|
@ -10,7 +10,7 @@ data class Bookmark(
|
|||
val comment: String,
|
||||
val created: Date? = null,
|
||||
val changed: Date? = null,
|
||||
val entry: Entry
|
||||
val track: Track
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 8988990025189807803L
|
||||
|
|
|
@ -20,9 +20,9 @@ class MusicDirectory : ArrayList<MusicDirectory.Child>() {
|
|||
return filter { it.isDirectory && includeDirs || !it.isDirectory && includeFiles }
|
||||
}
|
||||
|
||||
fun getTracks(): List<Entry> {
|
||||
fun getTracks(): List<Track> {
|
||||
return mapNotNull {
|
||||
it as? Entry
|
||||
it as? Track
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,8 @@ class MusicDirectory : ArrayList<MusicDirectory.Child>() {
|
|||
abstract var isVideo: Boolean
|
||||
}
|
||||
|
||||
// TODO: Rename to Track
|
||||
@Entity
|
||||
data class Entry(
|
||||
data class Track(
|
||||
@PrimaryKey override var id: String,
|
||||
override var parent: String? = null,
|
||||
override var isDirectory: Boolean = false,
|
||||
|
@ -97,7 +96,7 @@ class MusicDirectory : ArrayList<MusicDirectory.Child>() {
|
|||
private const val serialVersionUID = -3339106650010798108L
|
||||
}
|
||||
|
||||
fun compareTo(other: Entry): Int {
|
||||
fun compareTo(other: Track): Int {
|
||||
when {
|
||||
this.closeness == other.closeness -> {
|
||||
return 0
|
||||
|
@ -111,7 +110,7 @@ class MusicDirectory : ArrayList<MusicDirectory.Child>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun compareTo(other: Identifiable) = compareTo(other as Entry)
|
||||
override fun compareTo(other: Identifiable) = compareTo(other as Track)
|
||||
}
|
||||
|
||||
data class Album(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.moire.ultrasonic.domain
|
||||
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Album
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Entry
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Track
|
||||
|
||||
/**
|
||||
* The result of a search. Contains matching artists, albums and songs.
|
||||
|
@ -9,5 +9,5 @@ import org.moire.ultrasonic.domain.MusicDirectory.Entry
|
|||
data class SearchResult(
|
||||
val artists: List<ArtistOrIndex> = listOf(),
|
||||
val albums: List<Album> = listOf(),
|
||||
val songs: List<Entry> = listOf()
|
||||
val songs: List<Track> = listOf()
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.moire.ultrasonic.domain
|
||||
|
||||
import java.io.Serializable
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Entry
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Track
|
||||
|
||||
data class Share(
|
||||
override var id: String,
|
||||
|
@ -12,7 +12,7 @@ data class Share(
|
|||
var lastVisited: String? = null,
|
||||
var expires: String? = null,
|
||||
var visitCount: Long? = null,
|
||||
private val entries: MutableList<Entry> = mutableListOf()
|
||||
private val tracks: MutableList<Track> = mutableListOf()
|
||||
) : Serializable, GenericEntry() {
|
||||
override val name: String?
|
||||
get() {
|
||||
|
@ -22,12 +22,12 @@ data class Share(
|
|||
return null
|
||||
}
|
||||
|
||||
fun getEntries(): List<Entry> {
|
||||
return entries.toList()
|
||||
fun getEntries(): List<Track> {
|
||||
return tracks.toList()
|
||||
}
|
||||
|
||||
fun addEntry(entry: Entry) {
|
||||
entries.add(entry)
|
||||
fun addEntry(track: Track) {
|
||||
tracks.add(track)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
|
|||
/**
|
||||
* Handle a change notification coming over from {@link MediaPlayerController}
|
||||
*/
|
||||
public void notifyChange(Context context, MusicDirectory.Entry currentSong, boolean playing, boolean setAlbum)
|
||||
public void notifyChange(Context context, MusicDirectory.Track currentSong, boolean playing, boolean setAlbum)
|
||||
{
|
||||
if (hasInstances(context))
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
|
|||
/**
|
||||
* Update all active widget instances by pushing changes
|
||||
*/
|
||||
private void performUpdate(Context context, MusicDirectory.Entry currentSong, boolean playing, boolean setAlbum)
|
||||
private void performUpdate(Context context, MusicDirectory.Track currentSong, boolean playing, boolean setAlbum)
|
||||
{
|
||||
final Resources res = context.getResources();
|
||||
final RemoteViews views = new RemoteViews(context.getPackageName(), this.layoutId);
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Entry;
|
||||
import org.moire.ultrasonic.domain.MusicDirectory.Track;
|
||||
import org.moire.ultrasonic.service.MediaPlayerController;
|
||||
|
||||
import kotlin.Lazy;
|
||||
|
@ -21,7 +21,7 @@ public class A2dpIntentReceiver extends BroadcastReceiver
|
|||
{
|
||||
if (mediaPlayerControllerLazy.getValue().getCurrentPlaying() == null) return;
|
||||
|
||||
Entry song = mediaPlayerControllerLazy.getValue().getCurrentPlaying().getSong();
|
||||
Track song = mediaPlayerControllerLazy.getValue().getCurrentPlaying().getSong();
|
||||
if (song == null) return;
|
||||
|
||||
Intent avrcpIntent = new Intent(PLAYSTATUS_RESPONSE);
|
||||
|
|
|
@ -13,7 +13,7 @@ public class State implements Serializable
|
|||
{
|
||||
public static final long serialVersionUID = -6346438781062572270L;
|
||||
|
||||
public List<MusicDirectory.Entry> songs = new ArrayList<>();
|
||||
public List<MusicDirectory.Track> songs = new ArrayList<>();
|
||||
public int currentPlayingIndex;
|
||||
public int currentPlayingPosition;
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ public class ShareDetails
|
|||
public String Description;
|
||||
public boolean ShareOnServer;
|
||||
public long Expiration;
|
||||
public List<MusicDirectory.Entry> Entries;
|
||||
public List<MusicDirectory.Track> Entries;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ShufflePlayBuffer
|
|||
private static final int CAPACITY = 50;
|
||||
private static final int REFILL_THRESHOLD = 40;
|
||||
|
||||
private final List<MusicDirectory.Entry> buffer = new ArrayList<>();
|
||||
private final List<MusicDirectory.Track> buffer = new ArrayList<>();
|
||||
private ScheduledExecutorService executorService;
|
||||
private int currentServer;
|
||||
|
||||
|
@ -64,11 +64,11 @@ public class ShufflePlayBuffer
|
|||
Timber.i("ShufflePlayBuffer destroyed");
|
||||
}
|
||||
|
||||
public List<MusicDirectory.Entry> get(int size)
|
||||
public List<MusicDirectory.Track> get(int size)
|
||||
{
|
||||
clearBufferIfNecessary();
|
||||
|
||||
List<MusicDirectory.Entry> result = new ArrayList<>(size);
|
||||
List<MusicDirectory.Track> result = new ArrayList<>(size);
|
||||
synchronized (buffer)
|
||||
{
|
||||
while (!buffer.isEmpty() && result.size() < size)
|
||||
|
|
|
@ -180,7 +180,7 @@ public class StreamProxy implements Runnable
|
|||
{
|
||||
Timber.i("Streaming song in background");
|
||||
DownloadFile downloadFile = currentPlaying == null? null : currentPlaying.get();
|
||||
MusicDirectory.Entry song = downloadFile.getSong();
|
||||
MusicDirectory.Track song = downloadFile.getSong();
|
||||
long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
|
||||
Timber.i("Streaming fileSize: %d", fileSize);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class TrackViewBinder(
|
|||
val diffAdapter = adapter as BaseAdapter<*>
|
||||
|
||||
when (item) {
|
||||
is MusicDirectory.Entry -> {
|
||||
is MusicDirectory.Track -> {
|
||||
downloadFile = downloader.getDownloadFileForSong(item)
|
||||
}
|
||||
is DownloadFile -> {
|
||||
|
|
|
@ -44,7 +44,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable
|
|||
var duration: TextView = view.findViewById(R.id.song_duration)
|
||||
var progress: TextView = view.findViewById(R.id.song_status)
|
||||
|
||||
var entry: MusicDirectory.Entry? = null
|
||||
var entry: MusicDirectory.Track? = null
|
||||
private set
|
||||
var downloadFile: DownloadFile? = null
|
||||
private set
|
||||
|
@ -131,7 +131,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupStarButtons(song: MusicDirectory.Entry, useFiveStarRating: Boolean) {
|
||||
private fun setupStarButtons(song: MusicDirectory.Track, useFiveStarRating: Boolean) {
|
||||
if (useFiveStarRating) {
|
||||
// Hide single star
|
||||
star.isVisible = false
|
||||
|
|
|
@ -10,7 +10,7 @@ fun ApiBookmark.toDomainEntity(): Bookmark = Bookmark(
|
|||
comment = this@toDomainEntity.comment,
|
||||
created = this@toDomainEntity.created?.time,
|
||||
changed = this@toDomainEntity.changed?.time,
|
||||
entry = this@toDomainEntity.entry.toTrackEntity()
|
||||
track = this@toDomainEntity.entry.toTrackEntity()
|
||||
)
|
||||
|
||||
fun List<ApiBookmark>.toDomainEntitiesList(): List<Bookmark> = map { it.toDomainEntity() }
|
||||
|
|
|
@ -26,7 +26,7 @@ internal val dateFormat: DateFormat by lazy {
|
|||
SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault())
|
||||
}
|
||||
|
||||
fun MusicDirectoryChild.toTrackEntity(): MusicDirectory.Entry = MusicDirectory.Entry(id).apply {
|
||||
fun MusicDirectoryChild.toTrackEntity(): MusicDirectory.Track = MusicDirectory.Track(id).apply {
|
||||
populateCommonProps(this, this@toTrackEntity)
|
||||
populateTrackProps(this, this@toTrackEntity)
|
||||
}
|
||||
|
@ -64,20 +64,20 @@ private fun populateCommonProps(
|
|||
}
|
||||
|
||||
private fun populateTrackProps(
|
||||
entry: MusicDirectory.Entry,
|
||||
track: MusicDirectory.Track,
|
||||
source: MusicDirectoryChild
|
||||
) {
|
||||
entry.size = source.size
|
||||
entry.contentType = source.contentType
|
||||
entry.suffix = source.suffix
|
||||
entry.transcodedContentType = source.transcodedContentType
|
||||
entry.transcodedSuffix = source.transcodedSuffix
|
||||
entry.track = source.track
|
||||
entry.albumId = source.albumId
|
||||
entry.bitRate = source.bitRate
|
||||
entry.type = source.type
|
||||
entry.userRating = source.userRating
|
||||
entry.averageRating = source.averageRating
|
||||
track.size = source.size
|
||||
track.contentType = source.contentType
|
||||
track.suffix = source.suffix
|
||||
track.transcodedContentType = source.transcodedContentType
|
||||
track.transcodedSuffix = source.transcodedSuffix
|
||||
track.track = source.track
|
||||
track.albumId = source.albumId
|
||||
track.bitRate = source.bitRate
|
||||
track.type = source.type
|
||||
track.userRating = source.userRating
|
||||
track.averageRating = source.averageRating
|
||||
}
|
||||
|
||||
fun List<MusicDirectoryChild>.toDomainEntityList(): List<MusicDirectory.Child> {
|
||||
|
@ -93,7 +93,7 @@ fun List<MusicDirectoryChild>.toDomainEntityList(): List<MusicDirectory.Child> {
|
|||
return newList
|
||||
}
|
||||
|
||||
fun List<MusicDirectoryChild>.toTrackList(): List<MusicDirectory.Entry> = this.map {
|
||||
fun List<MusicDirectoryChild>.toTrackList(): List<MusicDirectory.Track> = this.map {
|
||||
it.toTrackEntity()
|
||||
}
|
||||
|
||||
|
|
|
@ -22,5 +22,5 @@ fun APIShare.toDomainEntity(): Share = Share(
|
|||
url = this@toDomainEntity.url,
|
||||
username = this@toDomainEntity.username,
|
||||
visitCount = this@toDomainEntity.visitCount.toLong(),
|
||||
entries = this@toDomainEntity.items.toTrackList().toMutableList()
|
||||
tracks = this@toDomainEntity.items.toTrackList().toMutableList()
|
||||
)
|
||||
|
|
|
@ -61,7 +61,7 @@ class BookmarksFragment : TrackCollectionFragment() {
|
|||
/**
|
||||
* Custom playback function which uses the restore functionality. A bit of a hack..
|
||||
*/
|
||||
private fun playNow(songs: List<MusicDirectory.Entry>) {
|
||||
private fun playNow(songs: List<MusicDirectory.Track>) {
|
||||
if (songs.isNotEmpty()) {
|
||||
|
||||
val position = songs[0].bookmarkPosition
|
||||
|
|
|
@ -118,7 +118,7 @@ class PlayerFragment :
|
|||
private val imageLoaderProvider: ImageLoaderProvider by inject()
|
||||
private lateinit var executorService: ScheduledExecutorService
|
||||
private var currentPlaying: DownloadFile? = null
|
||||
private var currentSong: MusicDirectory.Entry? = null
|
||||
private var currentSong: MusicDirectory.Track? = null
|
||||
private lateinit var viewManager: LinearLayoutManager
|
||||
private var rxBusSubscription: Disposable? = null
|
||||
private var ioScope = CoroutineScope(Dispatchers.IO)
|
||||
|
@ -544,7 +544,7 @@ class PlayerFragment :
|
|||
val downloadFile = viewAdapter.getCurrentList()[info!!.position] as DownloadFile
|
||||
val menuInflater = requireActivity().menuInflater
|
||||
menuInflater.inflate(R.menu.nowplaying_context, menu)
|
||||
val song: MusicDirectory.Entry?
|
||||
val song: MusicDirectory.Track?
|
||||
|
||||
song = downloadFile.song
|
||||
|
||||
|
@ -571,21 +571,21 @@ class PlayerFragment :
|
|||
|
||||
@Suppress("ComplexMethod", "LongMethod", "ReturnCount")
|
||||
private fun menuItemSelected(menuItemId: Int, song: DownloadFile?): Boolean {
|
||||
var entry: MusicDirectory.Entry? = null
|
||||
var track: MusicDirectory.Track? = null
|
||||
val bundle: Bundle
|
||||
if (song != null) {
|
||||
entry = song.song
|
||||
track = song.song
|
||||
}
|
||||
|
||||
when (menuItemId) {
|
||||
R.id.menu_show_artist -> {
|
||||
if (entry == null) return false
|
||||
if (track == null) return false
|
||||
|
||||
if (Settings.shouldUseId3Tags) {
|
||||
bundle = Bundle()
|
||||
bundle.putString(Constants.INTENT_ID, entry.artistId)
|
||||
bundle.putString(Constants.INTENT_NAME, entry.artist)
|
||||
bundle.putString(Constants.INTENT_PARENT_ID, entry.artistId)
|
||||
bundle.putString(Constants.INTENT_ID, track.artistId)
|
||||
bundle.putString(Constants.INTENT_NAME, track.artist)
|
||||
bundle.putString(Constants.INTENT_PARENT_ID, track.artistId)
|
||||
bundle.putBoolean(Constants.INTENT_ARTIST, true)
|
||||
Navigation.findNavController(requireView())
|
||||
.navigate(R.id.playerToSelectAlbum, bundle)
|
||||
|
@ -593,24 +593,24 @@ class PlayerFragment :
|
|||
return true
|
||||
}
|
||||
R.id.menu_show_album -> {
|
||||
if (entry == null) return false
|
||||
if (track == null) return false
|
||||
|
||||
val albumId = if (Settings.shouldUseId3Tags) entry.albumId else entry.parent
|
||||
val albumId = if (Settings.shouldUseId3Tags) track.albumId else track.parent
|
||||
bundle = Bundle()
|
||||
bundle.putString(Constants.INTENT_ID, albumId)
|
||||
bundle.putString(Constants.INTENT_NAME, entry.album)
|
||||
bundle.putString(Constants.INTENT_PARENT_ID, entry.parent)
|
||||
bundle.putString(Constants.INTENT_NAME, track.album)
|
||||
bundle.putString(Constants.INTENT_PARENT_ID, track.parent)
|
||||
bundle.putBoolean(Constants.INTENT_IS_ALBUM, true)
|
||||
Navigation.findNavController(requireView())
|
||||
.navigate(R.id.playerToSelectAlbum, bundle)
|
||||
return true
|
||||
}
|
||||
R.id.menu_lyrics -> {
|
||||
if (entry == null) return false
|
||||
if (track == null) return false
|
||||
|
||||
bundle = Bundle()
|
||||
bundle.putString(Constants.INTENT_ARTIST, entry.artist)
|
||||
bundle.putString(Constants.INTENT_TITLE, entry.title)
|
||||
bundle.putString(Constants.INTENT_ARTIST, track.artist)
|
||||
bundle.putString(Constants.INTENT_TITLE, track.title)
|
||||
Navigation.findNavController(requireView()).navigate(R.id.playerToLyrics, bundle)
|
||||
return true
|
||||
}
|
||||
|
@ -746,22 +746,22 @@ class PlayerFragment :
|
|||
}
|
||||
R.id.menu_item_share -> {
|
||||
val mediaPlayerController = mediaPlayerController
|
||||
val entries: MutableList<MusicDirectory.Entry?> = ArrayList()
|
||||
val tracks: MutableList<MusicDirectory.Track?> = ArrayList()
|
||||
val downloadServiceSongs = mediaPlayerController.playList
|
||||
for (downloadFile in downloadServiceSongs) {
|
||||
val playlistEntry = downloadFile.song
|
||||
entries.add(playlistEntry)
|
||||
tracks.add(playlistEntry)
|
||||
}
|
||||
shareHandler.createShare(this, entries, null, cancellationToken)
|
||||
shareHandler.createShare(this, tracks, null, cancellationToken)
|
||||
return true
|
||||
}
|
||||
R.id.menu_item_share_song -> {
|
||||
if (currentSong == null) return true
|
||||
|
||||
val entries: MutableList<MusicDirectory.Entry?> = ArrayList()
|
||||
entries.add(currentSong)
|
||||
val tracks: MutableList<MusicDirectory.Track?> = ArrayList()
|
||||
tracks.add(currentSong)
|
||||
|
||||
shareHandler.createShare(this, entries, null, cancellationToken)
|
||||
shareHandler.createShare(this, tracks, null, cancellationToken)
|
||||
return true
|
||||
}
|
||||
else -> return false
|
||||
|
|
|
@ -199,7 +199,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
private fun downloadBackground(save: Boolean, songs: List<MusicDirectory.Entry?>) {
|
||||
private fun downloadBackground(save: Boolean, songs: List<MusicDirectory.Track?>) {
|
||||
val onValid = Runnable {
|
||||
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
|
||||
mediaPlayerController.downloadBackground(songs, save)
|
||||
|
@ -296,7 +296,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||
Navigation.findNavController(requireView()).navigate(R.id.searchToTrackCollection, bundle)
|
||||
}
|
||||
|
||||
private fun onSongSelected(song: MusicDirectory.Entry, append: Boolean) {
|
||||
private fun onSongSelected(song: MusicDirectory.Track, append: Boolean) {
|
||||
if (!append) {
|
||||
mediaPlayerController.clear()
|
||||
}
|
||||
|
@ -312,8 +312,8 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||
toast(context, resources.getQuantityString(R.plurals.select_album_n_songs_added, 1, 1))
|
||||
}
|
||||
|
||||
private fun onVideoSelected(entry: MusicDirectory.Entry) {
|
||||
playVideo(requireContext(), entry)
|
||||
private fun onVideoSelected(track: MusicDirectory.Track) {
|
||||
playVideo(requireContext(), track)
|
||||
}
|
||||
|
||||
private fun autoplay() {
|
||||
|
@ -329,7 +329,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||
is ArtistOrIndex -> {
|
||||
onArtistSelected(item)
|
||||
}
|
||||
is MusicDirectory.Entry -> {
|
||||
is MusicDirectory.Track -> {
|
||||
if (item.isVideo) {
|
||||
onVideoSelected(item)
|
||||
} else {
|
||||
|
@ -356,7 +356,7 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
|
|||
|
||||
if (found || item !is DownloadFile) return true
|
||||
|
||||
val songs = mutableListOf<MusicDirectory.Entry>()
|
||||
val songs = mutableListOf<MusicDirectory.Track>()
|
||||
|
||||
when (menuItem.itemId) {
|
||||
R.id.song_menu_play_now -> {
|
||||
|
|
|
@ -249,7 +249,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
|
||||
private fun playNow(
|
||||
append: Boolean,
|
||||
selectedSongs: List<MusicDirectory.Entry> = getSelectedSongs()
|
||||
selectedSongs: List<MusicDirectory.Track> = getSelectedSongs()
|
||||
) {
|
||||
if (selectedSongs.isNotEmpty()) {
|
||||
downloadHandler.download(
|
||||
|
@ -314,10 +314,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun getAllSongs(): List<MusicDirectory.Entry> {
|
||||
private fun getAllSongs(): List<MusicDirectory.Track> {
|
||||
return viewAdapter.getCurrentList().filter {
|
||||
it is MusicDirectory.Entry && !it.isDirectory
|
||||
} as List<MusicDirectory.Entry>
|
||||
it is MusicDirectory.Track && !it.isDirectory
|
||||
} as List<MusicDirectory.Track>
|
||||
}
|
||||
|
||||
internal fun selectAllOrNone() {
|
||||
|
@ -338,7 +338,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
}
|
||||
}
|
||||
|
||||
internal open fun enableButtons(selection: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||
internal open fun enableButtons(selection: List<MusicDirectory.Track> = getSelectedSongs()) {
|
||||
val enabled = selection.isNotEmpty()
|
||||
var unpinEnabled = false
|
||||
var deleteEnabled = false
|
||||
|
@ -378,7 +378,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
|
||||
private fun downloadBackground(
|
||||
save: Boolean,
|
||||
songs: List<MusicDirectory.Entry?>
|
||||
songs: List<MusicDirectory.Track?>
|
||||
) {
|
||||
val onValid = Runnable {
|
||||
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
|
||||
|
@ -403,7 +403,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
onValid.run()
|
||||
}
|
||||
|
||||
internal fun delete(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||
internal fun delete(songs: List<MusicDirectory.Track> = getSelectedSongs()) {
|
||||
Util.toast(
|
||||
context,
|
||||
resources.getQuantityString(
|
||||
|
@ -414,7 +414,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
mediaPlayerController.delete(songs)
|
||||
}
|
||||
|
||||
internal fun unpin(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
|
||||
internal fun unpin(songs: List<MusicDirectory.Track> = getSelectedSongs()) {
|
||||
Util.toast(
|
||||
context,
|
||||
resources.getQuantityString(
|
||||
|
@ -533,10 +533,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun getSelectedSongs(): List<MusicDirectory.Entry> {
|
||||
internal fun getSelectedSongs(): List<MusicDirectory.Track> {
|
||||
// Walk through selected set and get the Entries based on the saved ids.
|
||||
return viewAdapter.getCurrentList().mapNotNull {
|
||||
if (it is MusicDirectory.Entry && viewAdapter.isSelected(it.longId))
|
||||
if (it is MusicDirectory.Track && viewAdapter.isSelected(it.longId))
|
||||
it
|
||||
else
|
||||
null
|
||||
|
@ -655,7 +655,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
playAll()
|
||||
}
|
||||
R.id.song_menu_share -> {
|
||||
if (item is MusicDirectory.Entry) {
|
||||
if (item is MusicDirectory.Track) {
|
||||
shareHandler.createShare(
|
||||
this, listOf(item), refreshListView,
|
||||
cancellationToken!!
|
||||
|
@ -669,10 +669,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
return true
|
||||
}
|
||||
|
||||
internal fun getClickedSong(item: MusicDirectory.Child): List<MusicDirectory.Entry> {
|
||||
internal fun getClickedSong(item: MusicDirectory.Child): List<MusicDirectory.Track> {
|
||||
// This can probably be done better
|
||||
return viewAdapter.getCurrentList().mapNotNull {
|
||||
if (it is MusicDirectory.Entry && (it.id == item.id))
|
||||
if (it is MusicDirectory.Track && (it.id == item.id))
|
||||
it
|
||||
else
|
||||
null
|
||||
|
@ -692,7 +692,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
|
|||
bundle
|
||||
)
|
||||
}
|
||||
item is MusicDirectory.Entry && item.isVideo -> {
|
||||
item is MusicDirectory.Track && item.isVideo -> {
|
||||
VideoPlayer.playVideo(requireContext(), item)
|
||||
}
|
||||
else -> {
|
||||
|
|
|
@ -26,11 +26,11 @@ class BitmapUtils {
|
|||
}
|
||||
|
||||
fun getAlbumArtBitmapFromDisk(
|
||||
entry: MusicDirectory.Entry?,
|
||||
track: MusicDirectory.Track?,
|
||||
size: Int
|
||||
): Bitmap? {
|
||||
if (entry == null) return null
|
||||
val albumArtFile = FileUtil.getAlbumArtFile(entry)
|
||||
if (track == null) return null
|
||||
val albumArtFile = FileUtil.getAlbumArtFile(track)
|
||||
val bitmap: Bitmap? = null
|
||||
if (albumArtFile != null && File(albumArtFile).exists()) {
|
||||
return getBitmapFromDisk(albumArtFile, size, bitmap)
|
||||
|
|
|
@ -148,28 +148,28 @@ class ImageLoader(
|
|||
* Download a cover art file and cache it on disk
|
||||
*/
|
||||
fun cacheCoverArt(
|
||||
entry: MusicDirectory.Entry
|
||||
track: MusicDirectory.Track
|
||||
) {
|
||||
|
||||
// Synchronize on the entry so that we don't download concurrently for
|
||||
// the same song.
|
||||
synchronized(entry) {
|
||||
synchronized(track) {
|
||||
// Always download the large size..
|
||||
val size = config.largeSize
|
||||
|
||||
// Check cache to avoid downloading existing files
|
||||
val file = FileUtil.getAlbumArtFile(entry)
|
||||
val file = FileUtil.getAlbumArtFile(track)
|
||||
|
||||
// Return if have a cache hit
|
||||
if (file != null && File(file).exists()) return
|
||||
File(file!!).createNewFile()
|
||||
|
||||
// Can't load empty string ids
|
||||
val id = entry.coverArt
|
||||
val id = track.coverArt
|
||||
if (TextUtils.isEmpty(id)) return
|
||||
|
||||
// Query the API
|
||||
Timber.d("Loading cover art for: %s", entry)
|
||||
Timber.d("Loading cover art for: %s", track)
|
||||
val response = API.getCoverArt(id!!, size.toLong()).execute().toStreamResponse()
|
||||
response.throwOnFailure()
|
||||
|
||||
|
|
|
@ -80,10 +80,10 @@ class AutoMediaBrowserService : MediaBrowserServiceCompat() {
|
|||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
|
||||
private var playlistCache: List<MusicDirectory.Entry>? = null
|
||||
private var starredSongsCache: List<MusicDirectory.Entry>? = null
|
||||
private var randomSongsCache: List<MusicDirectory.Entry>? = null
|
||||
private var searchSongsCache: List<MusicDirectory.Entry>? = null
|
||||
private var playlistCache: List<MusicDirectory.Track>? = null
|
||||
private var starredSongsCache: List<MusicDirectory.Track>? = null
|
||||
private var randomSongsCache: List<MusicDirectory.Track>? = null
|
||||
private var searchSongsCache: List<MusicDirectory.Track>? = null
|
||||
|
||||
private val isOffline get() = ActiveServerProvider.isOffline()
|
||||
private val useId3Tags get() = Settings.shouldUseId3Tags
|
||||
|
@ -1070,7 +1070,7 @@ class AutoMediaBrowserService : MediaBrowserServiceCompat() {
|
|||
return section.toString()
|
||||
}
|
||||
|
||||
private fun playSongs(songs: List<MusicDirectory.Entry?>?) {
|
||||
private fun playSongs(songs: List<MusicDirectory.Track?>?) {
|
||||
mediaPlayerController.addToPlaylist(
|
||||
songs,
|
||||
save = false,
|
||||
|
@ -1081,7 +1081,7 @@ class AutoMediaBrowserService : MediaBrowserServiceCompat() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun playSong(song: MusicDirectory.Entry) {
|
||||
private fun playSong(song: MusicDirectory.Track) {
|
||||
mediaPlayerController.addToPlaylist(
|
||||
listOf(song),
|
||||
save = false,
|
||||
|
|
|
@ -218,9 +218,9 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
|||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||
override fun createPlaylist(id: String?, name: String?, tracks: List<MusicDirectory.Track>) {
|
||||
cachedPlaylists.clear()
|
||||
musicService.createPlaylist(id, name, entries)
|
||||
musicService.createPlaylist(id, name, tracks)
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
|
@ -276,7 +276,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
|||
|
||||
@Throws(Exception::class)
|
||||
override fun getDownloadInputStream(
|
||||
song: MusicDirectory.Entry,
|
||||
song: MusicDirectory.Track,
|
||||
offset: Long,
|
||||
maxBitrate: Int,
|
||||
save: Boolean
|
||||
|
|
|
@ -38,7 +38,7 @@ import timber.log.Timber
|
|||
*
|
||||
*/
|
||||
class DownloadFile(
|
||||
val song: MusicDirectory.Entry,
|
||||
val song: MusicDirectory.Track,
|
||||
save: Boolean
|
||||
) : KoinComponent, Identifiable {
|
||||
val partialFile: String
|
||||
|
|
|
@ -45,7 +45,7 @@ class Downloader(
|
|||
private val jukeboxMediaPlayer: JukeboxMediaPlayer by inject()
|
||||
|
||||
// This cache helps us to avoid creating duplicate DownloadFile instances when showing Entries
|
||||
private val downloadFileCache = LRUCache<MusicDirectory.Entry, DownloadFile>(100)
|
||||
private val downloadFileCache = LRUCache<MusicDirectory.Track, DownloadFile>(100)
|
||||
|
||||
private var executorService: ScheduledExecutorService? = null
|
||||
private var wifiLock: WifiManager.WifiLock? = null
|
||||
|
@ -345,7 +345,7 @@ class Downloader(
|
|||
|
||||
@Synchronized
|
||||
fun addToPlaylist(
|
||||
songs: List<MusicDirectory.Entry>,
|
||||
songs: List<MusicDirectory.Track>,
|
||||
save: Boolean,
|
||||
autoPlay: Boolean,
|
||||
playNext: Boolean,
|
||||
|
@ -407,7 +407,7 @@ class Downloader(
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
fun downloadBackground(songs: List<MusicDirectory.Entry>, save: Boolean) {
|
||||
fun downloadBackground(songs: List<MusicDirectory.Track>, save: Boolean) {
|
||||
|
||||
// By using the counter we ensure that the songs are added in the correct order
|
||||
for (song in songs) {
|
||||
|
@ -435,7 +435,7 @@ class Downloader(
|
|||
|
||||
@Synchronized
|
||||
@Suppress("ReturnCount")
|
||||
fun getDownloadFileForSong(song: MusicDirectory.Entry): DownloadFile {
|
||||
fun getDownloadFileForSong(song: MusicDirectory.Track): DownloadFile {
|
||||
for (downloadFile in playlist) {
|
||||
if (downloadFile.song == song) {
|
||||
return downloadFile
|
||||
|
@ -513,7 +513,7 @@ class Downloader(
|
|||
* Extension function
|
||||
* Gathers the download file for a given song, and modifies shouldSave if provided.
|
||||
*/
|
||||
fun MusicDirectory.Entry.getDownloadFile(save: Boolean? = null): DownloadFile {
|
||||
fun MusicDirectory.Track.getDownloadFile(save: Boolean? = null): DownloadFile {
|
||||
return getDownloadFileForSong(this).apply {
|
||||
if (save != null) this.shouldSave = save
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class MediaPlayerController(
|
|||
|
||||
@Synchronized
|
||||
fun restore(
|
||||
songs: List<MusicDirectory.Entry?>?,
|
||||
songs: List<MusicDirectory.Track?>?,
|
||||
currentPlayingIndex: Int,
|
||||
currentPlayingPosition: Int,
|
||||
autoPlay: Boolean,
|
||||
|
@ -165,7 +165,7 @@ class MediaPlayerController(
|
|||
@Synchronized
|
||||
@Suppress("LongParameterList")
|
||||
fun addToPlaylist(
|
||||
songs: List<MusicDirectory.Entry?>?,
|
||||
songs: List<MusicDirectory.Track?>?,
|
||||
save: Boolean,
|
||||
autoPlay: Boolean,
|
||||
playNext: Boolean,
|
||||
|
@ -202,7 +202,7 @@ class MediaPlayerController(
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
fun downloadBackground(songs: List<MusicDirectory.Entry?>?, save: Boolean) {
|
||||
fun downloadBackground(songs: List<MusicDirectory.Track?>?, save: Boolean) {
|
||||
if (songs == null) return
|
||||
val filteredSongs = songs.filterNotNull()
|
||||
downloader.downloadBackground(filteredSongs, save)
|
||||
|
@ -325,7 +325,7 @@ class MediaPlayerController(
|
|||
|
||||
@Synchronized
|
||||
// TODO: Make it require not null
|
||||
fun delete(songs: List<MusicDirectory.Entry?>) {
|
||||
fun delete(songs: List<MusicDirectory.Track?>) {
|
||||
for (song in songs.filterNotNull()) {
|
||||
downloader.getDownloadFileForSong(song).delete()
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ class MediaPlayerController(
|
|||
|
||||
@Synchronized
|
||||
// TODO: Make it require not null
|
||||
fun unpin(songs: List<MusicDirectory.Entry?>) {
|
||||
fun unpin(songs: List<MusicDirectory.Track?>) {
|
||||
for (song in songs.filterNotNull()) {
|
||||
downloader.getDownloadFileForSong(song).unpin()
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ class MediaPlayerController(
|
|||
val playListDuration: Long
|
||||
get() = downloader.downloadListDuration
|
||||
|
||||
fun getDownloadFileForSong(song: MusicDirectory.Entry): DownloadFile {
|
||||
fun getDownloadFileForSong(song: MusicDirectory.Track): DownloadFile {
|
||||
return downloader.getDownloadFileForSong(song)
|
||||
}
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ class MediaPlayerService : Service() {
|
|||
localMediaPlayer.setPlayerState(PlayerState.STARTED, localMediaPlayer.currentPlaying)
|
||||
}
|
||||
|
||||
private fun updateWidget(playerState: PlayerState, song: MusicDirectory.Entry?) {
|
||||
private fun updateWidget(playerState: PlayerState, song: MusicDirectory.Track?) {
|
||||
val started = playerState === PlayerState.STARTED
|
||||
val context = this@MediaPlayerService
|
||||
|
||||
|
@ -589,7 +589,7 @@ class MediaPlayerService : Service() {
|
|||
context: Context,
|
||||
notificationBuilder: NotificationCompat.Builder,
|
||||
playerState: PlayerState,
|
||||
song: MusicDirectory.Entry?
|
||||
song: MusicDirectory.Track?
|
||||
): IntArray {
|
||||
// Init
|
||||
val compactActionList = ArrayList<Int>()
|
||||
|
|
|
@ -75,7 +75,7 @@ interface MusicService {
|
|||
fun getPlaylists(refresh: Boolean): List<Playlist>
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>)
|
||||
fun createPlaylist(id: String?, name: String?, tracks: List<MusicDirectory.Track>)
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun deletePlaylist(id: String)
|
||||
|
@ -123,7 +123,7 @@ interface MusicService {
|
|||
*/
|
||||
@Throws(Exception::class)
|
||||
fun getDownloadInputStream(
|
||||
song: MusicDirectory.Entry,
|
||||
song: MusicDirectory.Track,
|
||||
offset: Long,
|
||||
maxBitrate: Int,
|
||||
save: Boolean
|
||||
|
|
|
@ -127,7 +127,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
override fun search(criteria: SearchCriteria): SearchResult {
|
||||
val artists: MutableList<ArtistOrIndex> = ArrayList()
|
||||
val albums: MutableList<MusicDirectory.Album> = ArrayList()
|
||||
val songs: MutableList<MusicDirectory.Entry> = ArrayList()
|
||||
val songs: MutableList<MusicDirectory.Track> = ArrayList()
|
||||
val root = FileUtil.musicDirectory
|
||||
var closeness: Int
|
||||
for (artistFile in FileUtil.listFiles(root)) {
|
||||
|
@ -227,14 +227,14 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@Throws(Exception::class)
|
||||
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||
override fun createPlaylist(id: String?, name: String?, tracks: List<MusicDirectory.Track>) {
|
||||
val playlistFile =
|
||||
FileUtil.getPlaylistFile(activeServerProvider.getActiveServer().name, name)
|
||||
val fw = FileWriter(playlistFile)
|
||||
val bw = BufferedWriter(fw)
|
||||
try {
|
||||
fw.write("#EXTM3U\n")
|
||||
for (e in entries) {
|
||||
for (e in tracks) {
|
||||
var filePath = FileUtil.getSongFile(e)
|
||||
if (!Storage.isPathExists(filePath)) {
|
||||
val ext = FileUtil.getExtension(filePath)
|
||||
|
@ -471,7 +471,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
|
||||
@Throws(OfflineException::class)
|
||||
override fun getDownloadInputStream(
|
||||
song: MusicDirectory.Entry,
|
||||
song: MusicDirectory.Track,
|
||||
offset: Long,
|
||||
maxBitrate: Int,
|
||||
save: Boolean
|
||||
|
@ -502,8 +502,8 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
return FileUtil.getBaseName(name)
|
||||
}
|
||||
|
||||
private fun createEntry(file: AbstractFile, name: String?): MusicDirectory.Entry {
|
||||
val entry = MusicDirectory.Entry(file.path)
|
||||
private fun createEntry(file: AbstractFile, name: String?): MusicDirectory.Track {
|
||||
val entry = MusicDirectory.Track(file.path)
|
||||
entry.populateWithDataFrom(file, name)
|
||||
return entry
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
* More extensive variant of Child.populateWithDataFrom(), which also parses the ID3 tags of
|
||||
* a given track file.
|
||||
*/
|
||||
private fun MusicDirectory.Entry.populateWithDataFrom(file: AbstractFile, name: String?) {
|
||||
private fun MusicDirectory.Track.populateWithDataFrom(file: AbstractFile, name: String?) {
|
||||
(this as MusicDirectory.Child).populateWithDataFrom(file, name)
|
||||
|
||||
val meta = RawMetadata(null)
|
||||
|
@ -610,7 +610,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
file: AbstractFile,
|
||||
criteria: SearchCriteria,
|
||||
albums: MutableList<MusicDirectory.Album>,
|
||||
songs: MutableList<MusicDirectory.Entry>
|
||||
songs: MutableList<MusicDirectory.Track>
|
||||
) {
|
||||
var closeness: Int
|
||||
for (albumFile in FileUtil.listMediaFiles(file)) {
|
||||
|
|
|
@ -262,14 +262,14 @@ open class RESTMusicService(
|
|||
override fun createPlaylist(
|
||||
id: String?,
|
||||
name: String?,
|
||||
entries: List<MusicDirectory.Entry>
|
||||
tracks: List<MusicDirectory.Track>
|
||||
) {
|
||||
if (id == null && name == null)
|
||||
throw IllegalArgumentException("Either id or name is required.")
|
||||
|
||||
val pSongIds: MutableList<String> = ArrayList(entries.size)
|
||||
val pSongIds: MutableList<String> = ArrayList(tracks.size)
|
||||
|
||||
for ((id1) in entries) {
|
||||
for ((id1) in tracks) {
|
||||
pSongIds.add(id1)
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ open class RESTMusicService(
|
|||
|
||||
@Throws(Exception::class)
|
||||
override fun getDownloadInputStream(
|
||||
song: MusicDirectory.Entry,
|
||||
song: MusicDirectory.Track,
|
||||
offset: Long,
|
||||
maxBitrate: Int,
|
||||
save: Boolean
|
||||
|
|
|
@ -33,7 +33,7 @@ class DownloadHandler(
|
|||
autoPlay: Boolean,
|
||||
playNext: Boolean,
|
||||
shuffle: Boolean,
|
||||
songs: List<MusicDirectory.Entry?>
|
||||
songs: List<MusicDirectory.Track?>
|
||||
) {
|
||||
val onValid = Runnable {
|
||||
if (!append && !playNext) {
|
||||
|
@ -195,15 +195,15 @@ class DownloadHandler(
|
|||
isArtist: Boolean
|
||||
) {
|
||||
val activity = fragment.activity as Activity
|
||||
val task = object : ModalBackgroundTask<List<MusicDirectory.Entry>>(
|
||||
val task = object : ModalBackgroundTask<List<MusicDirectory.Track>>(
|
||||
activity,
|
||||
false
|
||||
) {
|
||||
|
||||
@Throws(Throwable::class)
|
||||
override fun doInBackground(): List<MusicDirectory.Entry> {
|
||||
override fun doInBackground(): List<MusicDirectory.Track> {
|
||||
val musicService = getMusicService()
|
||||
val songs: MutableList<MusicDirectory.Entry> = LinkedList()
|
||||
val songs: MutableList<MusicDirectory.Track> = LinkedList()
|
||||
val root: MusicDirectory
|
||||
if (!isOffline() && isArtist && Settings.shouldUseId3Tags) {
|
||||
getSongsForArtist(id, songs)
|
||||
|
@ -235,7 +235,7 @@ class DownloadHandler(
|
|||
@Throws(Exception::class)
|
||||
private fun getSongsRecursively(
|
||||
parent: MusicDirectory,
|
||||
songs: MutableList<MusicDirectory.Entry>
|
||||
songs: MutableList<MusicDirectory.Track>
|
||||
) {
|
||||
if (songs.size > maxSongs) {
|
||||
return
|
||||
|
@ -259,7 +259,7 @@ class DownloadHandler(
|
|||
@Throws(Exception::class)
|
||||
private fun getSongsForArtist(
|
||||
id: String,
|
||||
songs: MutableCollection<MusicDirectory.Entry>
|
||||
songs: MutableCollection<MusicDirectory.Track>
|
||||
) {
|
||||
if (songs.size > maxSongs) {
|
||||
return
|
||||
|
@ -280,7 +280,7 @@ class DownloadHandler(
|
|||
}
|
||||
}
|
||||
|
||||
override fun done(songs: List<MusicDirectory.Entry>) {
|
||||
override fun done(songs: List<MusicDirectory.Track>) {
|
||||
if (Settings.shouldSortByDisc) {
|
||||
Collections.sort(songs, EntryByDiscAndTrackComparator())
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ class ShareHandler(val context: Context) {
|
|||
|
||||
fun createShare(
|
||||
fragment: Fragment,
|
||||
entries: List<MusicDirectory.Entry?>?,
|
||||
tracks: List<MusicDirectory.Track?>?,
|
||||
swipe: SwipeRefreshLayout?,
|
||||
cancellationToken: CancellationToken
|
||||
) {
|
||||
val askForDetails = Settings.shouldAskForShareDetails
|
||||
val shareDetails = ShareDetails()
|
||||
shareDetails.Entries = entries
|
||||
shareDetails.Entries = tracks
|
||||
if (askForDetails) {
|
||||
showDialog(fragment, shareDetails, swipe, cancellationToken)
|
||||
} else {
|
||||
|
|
|
@ -14,14 +14,14 @@ import org.moire.ultrasonic.util.Util
|
|||
@Suppress("UtilityClassWithPublicConstructor")
|
||||
class VideoPlayer {
|
||||
companion object {
|
||||
fun playVideo(context: Context, entry: MusicDirectory.Entry?) {
|
||||
if (!Util.isNetworkConnected() || entry == null) {
|
||||
fun playVideo(context: Context, track: MusicDirectory.Track?) {
|
||||
if (!Util.isNetworkConnected() || track == null) {
|
||||
Util.toast(context, R.string.select_album_no_network)
|
||||
return
|
||||
}
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
val url = MusicServiceFactory.getMusicService().getVideoUrl(entry.id)
|
||||
val url = MusicServiceFactory.getMusicService().getVideoUrl(track.id)
|
||||
intent.setDataAndType(
|
||||
Uri.parse(url),
|
||||
"video/*"
|
||||
|
|
|
@ -7,8 +7,8 @@ class EntryByDiscAndTrackComparator : Comparator<MusicDirectory.Child> {
|
|||
override fun compare(x: MusicDirectory.Child, y: MusicDirectory.Child): Int {
|
||||
val discX = x.discNumber
|
||||
val discY = y.discNumber
|
||||
val trackX = if (x is MusicDirectory.Entry) x.track else null
|
||||
val trackY = if (y is MusicDirectory.Entry) y.track else null
|
||||
val trackX = if (x is MusicDirectory.Track) x.track else null
|
||||
val trackY = if (y is MusicDirectory.Track) y.track else null
|
||||
val albumX = x.album
|
||||
val albumY = y.album
|
||||
val pathX = x.path
|
||||
|
|
|
@ -49,7 +49,7 @@ object FileUtil {
|
|||
const val SUFFIX_SMALL = ".jpeg-small"
|
||||
private const val UNNAMED = "unnamed"
|
||||
|
||||
fun getSongFile(song: MusicDirectory.Entry): String {
|
||||
fun getSongFile(song: MusicDirectory.Track): String {
|
||||
val dir = getAlbumDirectory(song)
|
||||
|
||||
// Do not generate new name for offline files. Offline files will have their Path as their Id.
|
||||
|
|
|
@ -438,9 +438,9 @@ object Util {
|
|||
@JvmStatic
|
||||
fun getSongsFromBookmarks(bookmarks: Iterable<Bookmark>): MusicDirectory {
|
||||
val musicDirectory = MusicDirectory()
|
||||
var song: MusicDirectory.Entry
|
||||
var song: MusicDirectory.Track
|
||||
for (bookmark in bookmarks) {
|
||||
song = bookmark.entry
|
||||
song = bookmark.track
|
||||
song.bookmarkPosition = bookmark.position
|
||||
musicDirectory.add(song)
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ object Util {
|
|||
/**
|
||||
* Broadcasts the given song info as the new song being played.
|
||||
*/
|
||||
fun broadcastNewTrackInfo(context: Context, song: MusicDirectory.Entry?) {
|
||||
fun broadcastNewTrackInfo(context: Context, song: MusicDirectory.Track?) {
|
||||
val intent = Intent(EVENT_META_CHANGED)
|
||||
if (song != null) {
|
||||
intent.putExtra("title", song.title)
|
||||
|
@ -476,7 +476,7 @@ object Util {
|
|||
) {
|
||||
if (!Settings.shouldSendBluetoothNotifications) return
|
||||
|
||||
var song: MusicDirectory.Entry? = null
|
||||
var song: MusicDirectory.Track? = null
|
||||
val avrcpIntent = Intent(CM_AVRCP_METADATA_CHANGED)
|
||||
if (currentPlaying != null) song = currentPlaying.song
|
||||
|
||||
|
@ -489,7 +489,7 @@ object Util {
|
|||
fun broadcastA2dpPlayStatusChange(
|
||||
context: Context,
|
||||
state: PlayerState?,
|
||||
newSong: MusicDirectory.Entry?,
|
||||
newSong: MusicDirectory.Track?,
|
||||
listSize: Int,
|
||||
id: Int,
|
||||
playerPosition: Int
|
||||
|
@ -520,7 +520,7 @@ object Util {
|
|||
|
||||
private fun fillIntent(
|
||||
intent: Intent,
|
||||
song: MusicDirectory.Entry?,
|
||||
song: MusicDirectory.Track?,
|
||||
playerPosition: Int,
|
||||
id: Int,
|
||||
listSize: Int
|
||||
|
@ -776,7 +776,7 @@ object Util {
|
|||
)
|
||||
|
||||
fun getMediaDescriptionForEntry(
|
||||
song: MusicDirectory.Entry,
|
||||
song: MusicDirectory.Track,
|
||||
mediaId: String? = null,
|
||||
groupNameId: Int? = null
|
||||
): MediaDescriptionCompat {
|
||||
|
@ -809,7 +809,7 @@ object Util {
|
|||
}
|
||||
|
||||
@Suppress("ComplexMethod", "LongMethod")
|
||||
fun readableEntryDescription(song: MusicDirectory.Entry): ReadableEntryDescription {
|
||||
fun readableEntryDescription(song: MusicDirectory.Track): ReadableEntryDescription {
|
||||
val artist = StringBuilder(LINE_LENGTH)
|
||||
var bitRate: String? = null
|
||||
var trackText = ""
|
||||
|
|
|
@ -27,7 +27,7 @@ class APIBookmarkConverterTest {
|
|||
comment `should be equal to` entity.comment
|
||||
created `should be equal to` entity.created?.time
|
||||
changed `should be equal to` entity.changed?.time
|
||||
entry `should be equal to` entity.entry.toTrackEntity()
|
||||
track `should be equal to` entity.entry.toTrackEntity()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue