mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-06-20 17:03:57 +03:00
Convert MusicDirectory domain entity to kotlin.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
47d5a4dba1
commit
1fe6da5f46
@ -35,6 +35,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
||||||
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
||||||
|
|
||||||
import org.moire.ultrasonic.R;
|
import org.moire.ultrasonic.R;
|
||||||
import org.moire.ultrasonic.domain.MusicDirectory;
|
import org.moire.ultrasonic.domain.MusicDirectory;
|
||||||
import org.moire.ultrasonic.domain.Share;
|
import org.moire.ultrasonic.domain.Share;
|
||||||
@ -594,7 +595,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity
|
|||||||
{
|
{
|
||||||
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
|
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
|
||||||
|
|
||||||
allSongs.setIsDirectory(true);
|
allSongs.setDirectory(true);
|
||||||
allSongs.setArtist(name);
|
allSongs.setArtist(name);
|
||||||
allSongs.setParent(id);
|
allSongs.setParent(id);
|
||||||
allSongs.setId(allSongsId);
|
allSongs.setId(allSongsId);
|
||||||
@ -663,7 +664,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity
|
|||||||
{
|
{
|
||||||
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
|
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
|
||||||
|
|
||||||
allSongs.setIsDirectory(true);
|
allSongs.setDirectory(true);
|
||||||
allSongs.setArtist(name);
|
allSongs.setArtist(name);
|
||||||
allSongs.setParent(id);
|
allSongs.setParent(id);
|
||||||
allSongs.setId(allSongsId);
|
allSongs.setId(allSongsId);
|
||||||
|
@ -1,474 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of Subsonic.
|
|
||||||
|
|
||||||
Subsonic is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Subsonic is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Copyright 2009 (C) Sindre Mehus
|
|
||||||
*/
|
|
||||||
package org.moire.ultrasonic.domain;
|
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sindre Mehus
|
|
||||||
*/
|
|
||||||
public class MusicDirectory
|
|
||||||
{
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private final List<Entry> children = new ArrayList<Entry>();
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAll(Collection<Entry> entries)
|
|
||||||
{
|
|
||||||
children.addAll(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFirst(Entry child)
|
|
||||||
{
|
|
||||||
children.add(0, child);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addChild(Entry child)
|
|
||||||
{
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entry> getChildren()
|
|
||||||
{
|
|
||||||
return getChildren(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entry findChild(String id)
|
|
||||||
{
|
|
||||||
Entry entry = null;
|
|
||||||
|
|
||||||
for (Entry song : getChildren())
|
|
||||||
{
|
|
||||||
if (song.getId().equals(id))
|
|
||||||
{
|
|
||||||
entry = song;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entry> getChildren(boolean includeDirs, boolean includeFiles)
|
|
||||||
{
|
|
||||||
if (includeDirs && includeFiles)
|
|
||||||
{
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Entry> result = new ArrayList<Entry>(children.size());
|
|
||||||
for (Entry child : children)
|
|
||||||
{
|
|
||||||
if (child.isDirectory() && includeDirs || !child.isDirectory() && includeFiles)
|
|
||||||
{
|
|
||||||
result.add(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Entry implements Serializable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -3339106650010798108L;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private String id;
|
|
||||||
private String parent;
|
|
||||||
private boolean isDirectory;
|
|
||||||
private String title;
|
|
||||||
private String album;
|
|
||||||
private String albumId;
|
|
||||||
private String artist;
|
|
||||||
private String artistId;
|
|
||||||
private Integer track;
|
|
||||||
private Integer year;
|
|
||||||
private String genre;
|
|
||||||
private String contentType;
|
|
||||||
private String suffix;
|
|
||||||
private String transcodedContentType;
|
|
||||||
private String transcodedSuffix;
|
|
||||||
private String coverArt;
|
|
||||||
private Long size;
|
|
||||||
private Long songCount;
|
|
||||||
private Integer duration;
|
|
||||||
private Integer bitRate;
|
|
||||||
private String path;
|
|
||||||
private boolean isVideo;
|
|
||||||
private boolean isStarred;
|
|
||||||
private Integer discNumber;
|
|
||||||
private String type;
|
|
||||||
private Date created;
|
|
||||||
private int closeness;
|
|
||||||
private int bookmarkPosition;
|
|
||||||
|
|
||||||
public Integer getDiscNumber()
|
|
||||||
{
|
|
||||||
return discNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiscNumber(Integer discNumber)
|
|
||||||
{
|
|
||||||
this.discNumber = discNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getStarred()
|
|
||||||
{
|
|
||||||
return isStarred;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStarred(boolean starred)
|
|
||||||
{
|
|
||||||
this.isStarred = starred;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParent()
|
|
||||||
{
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParent(String parent)
|
|
||||||
{
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDirectory()
|
|
||||||
{
|
|
||||||
return isDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsDirectory(boolean directory)
|
|
||||||
{
|
|
||||||
this.isDirectory = directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlbum()
|
|
||||||
{
|
|
||||||
return album;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbum(String album)
|
|
||||||
{
|
|
||||||
this.album = album;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlbumId()
|
|
||||||
{
|
|
||||||
return albumId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumId(String albumId)
|
|
||||||
{
|
|
||||||
this.albumId = albumId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArtist()
|
|
||||||
{
|
|
||||||
return artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtist(String artist)
|
|
||||||
{
|
|
||||||
this.artist = artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArtistId()
|
|
||||||
{
|
|
||||||
return artistId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistId(String artistId)
|
|
||||||
{
|
|
||||||
this.artistId = artistId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTrack()
|
|
||||||
{
|
|
||||||
return track == null ? 0 : track;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrack(Integer track)
|
|
||||||
{
|
|
||||||
this.track = track;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSongCount()
|
|
||||||
{
|
|
||||||
return songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongCount(Long songCount)
|
|
||||||
{
|
|
||||||
this.songCount = songCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getYear()
|
|
||||||
{
|
|
||||||
return year == null ? 0 : year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYear(Integer year)
|
|
||||||
{
|
|
||||||
this.year = year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenre()
|
|
||||||
{
|
|
||||||
return genre;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGenre(String genre)
|
|
||||||
{
|
|
||||||
this.genre = genre;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContentType()
|
|
||||||
{
|
|
||||||
return contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContentType(String contentType)
|
|
||||||
{
|
|
||||||
this.contentType = contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSuffix()
|
|
||||||
{
|
|
||||||
return suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuffix(String suffix)
|
|
||||||
{
|
|
||||||
this.suffix = suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranscodedContentType()
|
|
||||||
{
|
|
||||||
return transcodedContentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTranscodedContentType(String transcodedContentType)
|
|
||||||
{
|
|
||||||
this.transcodedContentType = transcodedContentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranscodedSuffix()
|
|
||||||
{
|
|
||||||
return transcodedSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTranscodedSuffix(String transcodedSuffix)
|
|
||||||
{
|
|
||||||
this.transcodedSuffix = transcodedSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSize()
|
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSize(Long size)
|
|
||||||
{
|
|
||||||
this.size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getDuration()
|
|
||||||
{
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(Integer duration)
|
|
||||||
{
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(long duration)
|
|
||||||
{
|
|
||||||
this.duration = (int) duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getBitRate()
|
|
||||||
{
|
|
||||||
return bitRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBitRate(Integer bitRate)
|
|
||||||
{
|
|
||||||
this.bitRate = bitRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public String getCoverArt()
|
|
||||||
{
|
|
||||||
return coverArt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCoverArt(String coverArt)
|
|
||||||
{
|
|
||||||
this.coverArt = coverArt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath()
|
|
||||||
{
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPath(String path)
|
|
||||||
{
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVideo()
|
|
||||||
{
|
|
||||||
return isVideo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsVideo(boolean video)
|
|
||||||
{
|
|
||||||
this.isVideo = video;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated()
|
|
||||||
{
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(String created)
|
|
||||||
{
|
|
||||||
if (created != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.created = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH).parse(created);
|
|
||||||
}
|
|
||||||
catch (ParseException e)
|
|
||||||
{
|
|
||||||
this.created = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.created = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCloseness()
|
|
||||||
{
|
|
||||||
return closeness;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCloseness(int closeness)
|
|
||||||
{
|
|
||||||
this.closeness = closeness;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBookmarkPosition()
|
|
||||||
{
|
|
||||||
return bookmarkPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBookmarkPosition(int bookmarkPosition)
|
|
||||||
{
|
|
||||||
this.bookmarkPosition = bookmarkPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
if (this == o)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entry entry = (Entry) o;
|
|
||||||
return id.equals(entry.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return id.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -185,7 +185,7 @@ public class OfflineMusicService extends RESTMusicService
|
|||||||
private static MusicDirectory.Entry createEntry(Context context, File file, String name)
|
private static MusicDirectory.Entry createEntry(Context context, File file, String name)
|
||||||
{
|
{
|
||||||
MusicDirectory.Entry entry = new MusicDirectory.Entry();
|
MusicDirectory.Entry entry = new MusicDirectory.Entry();
|
||||||
entry.setIsDirectory(file.isDirectory());
|
entry.setDirectory(file.isDirectory());
|
||||||
entry.setId(file.getPath());
|
entry.setId(file.getPath());
|
||||||
entry.setParent(file.getParent());
|
entry.setParent(file.getParent());
|
||||||
entry.setSize(file.length());
|
entry.setSize(file.length());
|
||||||
@ -232,7 +232,7 @@ public class OfflineMusicService extends RESTMusicService
|
|||||||
entry.setTitle(title);
|
entry.setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.setIsVideo(hasVideo != null);
|
entry.setVideo(hasVideo != null);
|
||||||
|
|
||||||
Log.i("OfflineMusicService", String.format("Offline Stuff: %s", track));
|
Log.i("OfflineMusicService", String.format("Offline Stuff: %s", track));
|
||||||
|
|
||||||
|
@ -5,19 +5,19 @@ package org.moire.ultrasonic.domain
|
|||||||
|
|
||||||
import org.moire.ultrasonic.api.subsonic.models.Album
|
import org.moire.ultrasonic.api.subsonic.models.Album
|
||||||
|
|
||||||
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry(
|
||||||
id = this@toDomainEntity.id
|
id = this@toDomainEntity.id,
|
||||||
setIsDirectory(true)
|
isDirectory = true,
|
||||||
title = this@toDomainEntity.name
|
title = this@toDomainEntity.name,
|
||||||
coverArt = this@toDomainEntity.coverArt
|
coverArt = this@toDomainEntity.coverArt,
|
||||||
artist = this@toDomainEntity.artist
|
artist = this@toDomainEntity.artist,
|
||||||
artistId = this@toDomainEntity.artistId
|
artistId = this@toDomainEntity.artistId,
|
||||||
songCount = this@toDomainEntity.songCount.toLong()
|
songCount = this@toDomainEntity.songCount.toLong(),
|
||||||
duration = this@toDomainEntity.duration
|
duration = this@toDomainEntity.duration,
|
||||||
created = this@toDomainEntity.created?.time
|
created = this@toDomainEntity.created?.time,
|
||||||
year = this@toDomainEntity.year
|
year = this@toDomainEntity.year,
|
||||||
genre = this@toDomainEntity.genre
|
genre = this@toDomainEntity.genre
|
||||||
}
|
)
|
||||||
|
|
||||||
fun Album.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
fun Album.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
|
||||||
addAll(this@toMusicDirectoryDomainEntity.songList.map { it.toDomainEntity() })
|
addAll(this@toMusicDirectoryDomainEntity.songList.map { it.toDomainEntity() })
|
||||||
|
@ -16,7 +16,7 @@ internal val dateFormat: DateFormat by lazy {
|
|||||||
fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
|
||||||
id = this@toDomainEntity.id
|
id = this@toDomainEntity.id
|
||||||
parent = this@toDomainEntity.parent
|
parent = this@toDomainEntity.parent
|
||||||
setIsDirectory(this@toDomainEntity.isDir)
|
isDirectory = this@toDomainEntity.isDir
|
||||||
title = this@toDomainEntity.title
|
title = this@toDomainEntity.title
|
||||||
album = this@toDomainEntity.album
|
album = this@toDomainEntity.album
|
||||||
albumId = this@toDomainEntity.albumId
|
albumId = this@toDomainEntity.albumId
|
||||||
@ -34,7 +34,7 @@ fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.
|
|||||||
duration = this@toDomainEntity.duration
|
duration = this@toDomainEntity.duration
|
||||||
bitRate = this@toDomainEntity.bitRate
|
bitRate = this@toDomainEntity.bitRate
|
||||||
path = this@toDomainEntity.path
|
path = this@toDomainEntity.path
|
||||||
setIsVideo(this@toDomainEntity.isVideo)
|
isVideo = this@toDomainEntity.isVideo
|
||||||
created = this@toDomainEntity.created?.time
|
created = this@toDomainEntity.created?.time
|
||||||
starred = this@toDomainEntity.starred != null
|
starred = this@toDomainEntity.starred != null
|
||||||
discNumber = this@toDomainEntity.discNumber
|
discNumber = this@toDomainEntity.discNumber
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package org.moire.ultrasonic.domain
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
class MusicDirectory {
|
||||||
|
var name: String? = null
|
||||||
|
private val children = mutableListOf<Entry>()
|
||||||
|
|
||||||
|
fun addAll(entries: Collection<Entry>) {
|
||||||
|
children.addAll(entries)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addFirst(child: Entry) {
|
||||||
|
children.add(0, child)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addChild(child: Entry) {
|
||||||
|
children.add(child)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findChild(id: String): Entry? = children.lastOrNull { it.id == id }
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun getChildren(
|
||||||
|
includeDirs: Boolean = true,
|
||||||
|
includeFiles: Boolean = true): List<Entry> {
|
||||||
|
if (includeDirs && includeFiles) {
|
||||||
|
return children
|
||||||
|
}
|
||||||
|
|
||||||
|
return children.filter { it.isDirectory && includeDirs || !it.isDirectory && includeFiles }
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Entry(
|
||||||
|
var id: String? = null,
|
||||||
|
var parent: String? = null,
|
||||||
|
var isDirectory: Boolean = false,
|
||||||
|
var title: String? = null,
|
||||||
|
var album: String? = null,
|
||||||
|
var albumId: String? = null,
|
||||||
|
var artist: String? = null,
|
||||||
|
var artistId: String? = null,
|
||||||
|
var track: Int? = 0,
|
||||||
|
var year: Int? = 0,
|
||||||
|
var genre: String? = null,
|
||||||
|
var contentType: String? = null,
|
||||||
|
var suffix: String? = null,
|
||||||
|
var transcodedContentType: String? = null,
|
||||||
|
var transcodedSuffix: String? = null,
|
||||||
|
var coverArt: String? = null,
|
||||||
|
var size: Long? = null,
|
||||||
|
var songCount: Long? = null,
|
||||||
|
var duration: Int? = null,
|
||||||
|
var bitRate: Int? = null,
|
||||||
|
var path: String? = null,
|
||||||
|
var isVideo: Boolean = false,
|
||||||
|
var starred: Boolean = false,
|
||||||
|
var discNumber: Int? = null,
|
||||||
|
var type: String? = null,
|
||||||
|
var created: Date? = null,
|
||||||
|
var closeness: Int = 0,
|
||||||
|
var bookmarkPosition: Int = 0
|
||||||
|
) : Serializable {
|
||||||
|
fun setDuration(duration: Long) {
|
||||||
|
this.duration = duration.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID = -3339106650010798108L
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,17 +22,17 @@ class APIAlbumConverterTest {
|
|||||||
val convertedEntity = entity.toDomainEntity()
|
val convertedEntity = entity.toDomainEntity()
|
||||||
|
|
||||||
with(convertedEntity) {
|
with(convertedEntity) {
|
||||||
id `should equal to` entity.id
|
id `should equal` entity.id
|
||||||
title `should equal to` entity.name
|
title `should equal` entity.name
|
||||||
isDirectory `should equal to` true
|
isDirectory `should equal` true
|
||||||
coverArt `should equal to` entity.coverArt
|
coverArt `should equal` entity.coverArt
|
||||||
artist `should equal to` entity.artist
|
artist `should equal` entity.artist
|
||||||
artistId `should equal to` entity.artistId
|
artistId `should equal` entity.artistId
|
||||||
songCount `should equal to` entity.songCount.toLong()
|
songCount `should equal` entity.songCount.toLong()
|
||||||
duration `should equal to` entity.duration
|
duration `should equal` entity.duration
|
||||||
created `should equal` entity.created?.time
|
created `should equal` entity.created?.time
|
||||||
year `should equal to` entity.year
|
year `should equal` entity.year
|
||||||
genre `should equal to` entity.genre
|
genre `should equal` entity.genre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ class APIAlbumConverterTest {
|
|||||||
|
|
||||||
with(convertedEntity) {
|
with(convertedEntity) {
|
||||||
name `should equal` null
|
name `should equal` null
|
||||||
children.size `should equal to` entity.songList.size
|
getChildren().size `should equal to` entity.songList.size
|
||||||
children[0] `should equal` entity.songList[0].toDomainEntity()
|
getChildren()[0] `should equal` entity.songList[0].toDomainEntity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user