Merge pull request #169 from ultrasonic/convert_entities_to_data_class

Convert domain entities to kotlin
This commit is contained in:
Yahor Berdnikau 2018-02-24 23:07:41 +01:00 committed by GitHub
commit 4c85213c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
79 changed files with 634 additions and 2467 deletions

View File

@ -21,6 +21,7 @@ ext.versions = [
retrofit : "2.1.0",
jackson : "2.9.0",
okhttp : "3.9.0",
semver : "1.0.0",
junit : "4.12",
mockito : "2.12.0",
@ -50,6 +51,7 @@ ext.other = [
jacksonConverter : "com.squareup.retrofit2:converter-jackson:$versions.retrofit",
jacksonKotlin : "com.fasterxml.jackson.module:jackson-module-kotlin:$versions.jackson",
okhttpLogging : "com.squareup.okhttp3:logging-interceptor:$versions.okhttp",
semver : "net.swiftzer.semver:semver:$versions.semver",
]
ext.testing = [

View File

@ -54,6 +54,8 @@ dependencies {
implementation other.kotlinStdlib
implementation other.semver
testImplementation other.kotlinReflect
testImplementation testing.junit
testImplementation testing.kotlinJunit
@ -66,7 +68,6 @@ ext {
jacocoExclude = [
'**/activity/**',
'**/audiofx/**',
'**/domain/**',
'**/fragment/**',
'**/provider/**',
'**/receiver/**',

View File

@ -35,6 +35,7 @@ import android.widget.TextView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.domain.Share;
@ -594,7 +595,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity
{
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
allSongs.setIsDirectory(true);
allSongs.setDirectory(true);
allSongs.setArtist(name);
allSongs.setParent(id);
allSongs.setId(allSongsId);
@ -663,7 +664,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity
{
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
allSongs.setIsDirectory(true);
allSongs.setDirectory(true);
allSongs.setArtist(name);
allSongs.setParent(id);
allSongs.setId(allSongsId);

View File

@ -1,132 +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 java.io.Serializable;
/**
* @author Sindre Mehus
*/
public class Artist implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -5790532593784846982L;
private String id;
private String name;
private String index;
private String coverArt;
private Long albumCount;
private int closeness;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getIndex()
{
return index;
}
public void setIndex(String index)
{
this.index = index;
}
public String getCoverArt()
{
return coverArt;
}
public void setCoverArt(String coverArt)
{
this.coverArt = coverArt;
}
public long getAlbumCount()
{
return albumCount;
}
public void setAlbumCount(Long albumCount)
{
this.albumCount = albumCount;
}
public int getCloseness()
{
return closeness;
}
public void setCloseness(int closeness)
{
this.closeness = closeness;
}
@Override
public String toString()
{
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Artist artist = (Artist) o;
if (closeness != artist.closeness) return false;
if (id != null ? !id.equals(artist.id) : artist.id != null) return false;
if (name != null ? !name.equals(artist.name) : artist.name != null) return false;
if (index != null ? !index.equals(artist.index) : artist.index != null) return false;
if (coverArt != null ? !coverArt.equals(artist.coverArt) : artist.coverArt != null)
return false;
return albumCount != null ? albumCount.equals(artist.albumCount) : artist.albumCount == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (index != null ? index.hashCode() : 0);
result = 31 * result + (coverArt != null ? coverArt.hashCode() : 0);
result = 31 * result + (albumCount != null ? albumCount.hashCode() : 0);
result = 31 * result + closeness;
return result;
}
}

View File

@ -1,106 +0,0 @@
package org.moire.ultrasonic.domain;
import org.moire.ultrasonic.domain.MusicDirectory.Entry;
import java.io.Serializable;
import java.util.Date;
public class Bookmark implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 8988990025189807803L;
private int position;
private String username;
private String comment;
private Date created;
private Date changed;
private Entry entry;
public int getPosition()
{
return position;
}
public void setPosition(int position)
{
this.position = position;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getComment()
{
return comment;
}
public void setComment(String comment)
{
this.comment = comment;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getChanged() {
return changed;
}
public void setChanged(Date changed) {
this.changed = changed;
}
public Entry getEntry()
{
return this.entry;
}
public void setEntry(Entry entry)
{
this.entry = entry;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Bookmark bookmark = (Bookmark) o;
if (position != bookmark.position) return false;
if (username != null ? !username.equals(bookmark.username) : bookmark.username != null)
return false;
if (comment != null ? !comment.equals(bookmark.comment) : bookmark.comment != null)
return false;
if (created != null ? !created.equals(bookmark.created) : bookmark.created != null)
return false;
if (changed != null ? !changed.equals(bookmark.changed) : bookmark.changed != null)
return false;
return entry != null ? entry.equals(bookmark.entry) : bookmark.entry == null;
}
@Override
public int hashCode() {
int result = position;
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (comment != null ? comment.hashCode() : 0);
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (changed != null ? changed.hashCode() : 0);
result = 31 * result + (entry != null ? entry.hashCode() : 0);
return result;
}
}

View File

@ -1,64 +0,0 @@
package org.moire.ultrasonic.domain;
import java.io.Serializable;
public class ChatMessage implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 496544310289324167L;
private String username;
private Long time;
private String message;
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public Long getTime()
{
return time;
}
public void setTime(Long time)
{
this.time = time;
}
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ChatMessage that = (ChatMessage) o;
return message.equals(that.message) && time.equals(that.time) && username.equals(that.username);
}
@Override
public int hashCode()
{
int result = username.hashCode();
result = 31 * result + time.hashCode();
result = 31 * result + message.hashCode();
return result;
}
}

View File

@ -1,57 +0,0 @@
package org.moire.ultrasonic.domain;
import java.io.Serializable;
public class Genre implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -3943025175219134028L;
private String name;
private String index;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getIndex()
{
return index;
}
public void setIndex(String index)
{
this.index = index;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Genre genre = (Genre) o;
if (name != null ? !name.equals(genre.name) : genre.name != null) return false;
return index != null ? index.equals(genre.index) : genre.index == null;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (index != null ? index.hashCode() : 0);
return result;
}
@Override
public String toString()
{
return name;
}
}

View File

@ -1,66 +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 java.io.Serializable;
import java.util.List;
/**
* @author Sindre Mehus
*/
public class Indexes implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 8156117238598414701L;
private final long lastModified;
private final String ignoredArticles;
private final List<org.moire.ultrasonic.domain.Artist> shortcuts;
private final List<org.moire.ultrasonic.domain.Artist> artists;
public Indexes(long lastModified, String ignoredArticles, List<Artist> shortcuts, List<Artist> artists)
{
this.lastModified = lastModified;
this.ignoredArticles = ignoredArticles;
this.shortcuts = shortcuts;
this.artists = artists;
}
public long getLastModified()
{
return lastModified;
}
public List<org.moire.ultrasonic.domain.Artist> getShortcuts()
{
return shortcuts;
}
public List<org.moire.ultrasonic.domain.Artist> getArtists()
{
return artists;
}
public String getIgnoredArticles()
{
return ignoredArticles;
}
}

View File

@ -1,72 +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;
/**
* @author Sindre Mehus
* @version $Id$
*/
public class JukeboxStatus
{
private Integer positionSeconds;
private Integer currentPlayingIndex;
private Float gain;
private boolean playing;
public Integer getPositionSeconds()
{
return positionSeconds;
}
public void setPositionSeconds(Integer positionSeconds)
{
this.positionSeconds = positionSeconds;
}
public Integer getCurrentPlayingIndex()
{
return currentPlayingIndex;
}
public void setCurrentIndex(Integer currentPlayingIndex)
{
this.currentPlayingIndex = currentPlayingIndex;
}
public boolean isPlaying()
{
return playing;
}
public void setPlaying(boolean playing)
{
this.playing = playing;
}
public Float getGain()
{
return gain;
}
public void setGain(float gain)
{
this.gain = gain;
}
}

View File

@ -1,62 +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 2010 (C) Sindre Mehus
*/
package org.moire.ultrasonic.domain;
/**
* Song lyrics.
*
* @author Sindre Mehus
*/
public class Lyrics
{
private String artist;
private String title;
private String text;
public String getArtist()
{
return artist;
}
public void setArtist(String artist)
{
this.artist = artist;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}

View File

@ -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;
}
}
}

View File

@ -1,48 +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;
/**
* Represents a top level directory in which music or other media is stored.
*
* @author Sindre Mehus
* @version $Id$
*/
public class MusicFolder
{
private final String id;
private final String name;
public MusicFolder(String id, String name)
{
this.id = id;
this.name = name;
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
}

View File

@ -1,35 +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;
/**
* @author Sindre Mehus
* @version $Id$
*/
public enum PlayerState
{
IDLE,
DOWNLOADING,
PREPARING,
PREPARED,
STARTED,
STOPPED,
PAUSED,
COMPLETED
}

View File

@ -1,171 +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 java.io.Serializable;
/**
* @author Sindre Mehus
*/
public class Playlist implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -4160515427075433798L;
private String id;
private String name;
private String owner;
private String comment;
private String songCount;
private String created;
private Boolean pub;
public Playlist(String id, String name)
{
this.id = id;
this.name = name;
}
public Playlist(String id, String name, String owner, String comment, String songCount, String created, String pub)
{
this.id = id;
this.name = name;
this.owner = (owner == null) ? "" : owner;
this.comment = (comment == null) ? "" : comment;
this.songCount = (songCount == null) ? "" : songCount;
this.created = (created == null) ? "" : created;
this.pub = (pub == null) ? null : ("true".equals(pub));
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getOwner()
{
return this.owner;
}
public void setOwner(String owner)
{
this.owner = owner;
}
public String getComment()
{
return this.comment;
}
public void setComment(String comment)
{
this.comment = comment;
}
public String getSongCount()
{
return this.songCount;
}
public void setSongCount(String songCount)
{
this.songCount = songCount;
}
public String getCreated()
{
return this.created;
}
public void setCreated(String created)
{
this.created = created;
}
public Boolean getPublic()
{
return this.pub;
}
public void setPublic(Boolean pub)
{
this.pub = pub;
}
@Override
public String toString() {
return "Playlist{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", owner='" + owner + '\'' +
", comment='" + comment + '\'' +
", songCount='" + songCount + '\'' +
", created='" + created + '\'' +
", pub=" + pub +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Playlist playlist = (Playlist) o;
if (id != null ? !id.equals(playlist.id) : playlist.id != null) return false;
if (name != null ? !name.equals(playlist.name) : playlist.name != null) return false;
if (owner != null ? !owner.equals(playlist.owner) : playlist.owner != null) return false;
if (comment != null ? !comment.equals(playlist.comment) : playlist.comment != null)
return false;
if (songCount != null ? !songCount.equals(playlist.songCount) : playlist.songCount != null)
return false;
if (created != null ? !created.equals(playlist.created) : playlist.created != null)
return false;
return pub != null ? pub.equals(playlist.pub) : playlist.pub == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (owner != null ? owner.hashCode() : 0);
result = 31 * result + (comment != null ? comment.hashCode() : 0);
result = 31 * result + (songCount != null ? songCount.hashCode() : 0);
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (pub != null ? pub.hashCode() : 0);
return result;
}
}

View File

@ -1,94 +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 java.io.Serializable;
/**
* @author Sindre Mehus
*/
public class PodcastEpisode implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -4160515427075433798L;
private String id;
private String title;
private String url;
private String description;
private String status;
public PodcastEpisode(String id, String title, String url, String description, String status)
{
this.id = id;
this.title = title;
this.url = url;
this.description = description;
this.status = status;
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return getTitle();
}
}

View File

@ -1,119 +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 java.io.Serializable;
/**
* @author Sindre Mehus
*/
public class PodcastsChannel implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -4160515427075433798L;
private String id;
private String title;
private String url;
private String description;
private String status;
public PodcastsChannel(String id, String title,String url, String description, String status)
{
this.id = id;
this.title = title;
this.url = url;
this.description = description;
this.status = status;
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return getTitle();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PodcastsChannel that = (PodcastsChannel) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (title != null ? !title.equals(that.title) : that.title != null) return false;
if (url != null ? !url.equals(that.url) : that.url != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null)
return false;
return status != null ? status.equals(that.status) : that.status == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (url != null ? url.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
}

View File

@ -1,35 +0,0 @@
package org.moire.ultrasonic.domain;
/**
* @author Sindre Mehus
* @version $Id$
*/
public enum RepeatMode
{
OFF
{
@Override
public RepeatMode next()
{
return ALL;
}
},
ALL
{
@Override
public RepeatMode next()
{
return SINGLE;
}
},
SINGLE
{
@Override
public RepeatMode next()
{
return OFF;
}
};
public abstract RepeatMode next();
}

View File

@ -1,61 +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;
/**
* The criteria for a music search.
*
* @author Sindre Mehus
*/
public class SearchCriteria
{
private final String query;
private final int artistCount;
private final int albumCount;
private final int songCount;
public SearchCriteria(String query, int artistCount, int albumCount, int songCount)
{
this.query = query;
this.artistCount = artistCount;
this.albumCount = albumCount;
this.songCount = songCount;
}
public String getQuery()
{
return query;
}
public int getArtistCount()
{
return artistCount;
}
public int getAlbumCount()
{
return albumCount;
}
public int getSongCount()
{
return songCount;
}
}

View File

@ -1,56 +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 java.util.List;
/**
* The result of a search. Contains matching artists, albums and songs.
*
* @author Sindre Mehus
*/
public class SearchResult
{
private final List<Artist> artists;
private final List<MusicDirectory.Entry> albums;
private final List<MusicDirectory.Entry> songs;
public SearchResult(List<Artist> artists, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs)
{
this.artists = artists;
this.albums = albums;
this.songs = songs;
}
public List<Artist> getArtists()
{
return artists;
}
public List<MusicDirectory.Entry> getAlbums()
{
return albums;
}
public List<MusicDirectory.Entry> getSongs()
{
return songs;
}
}

View File

@ -1,158 +0,0 @@
package org.moire.ultrasonic.domain;
import org.moire.ultrasonic.domain.MusicDirectory.Entry;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class Share implements Serializable {
private static final long serialVersionUID = 1487561657691009668L;
private static final Pattern urlPattern = Pattern.compile(".*/([^/?]+).*");
private String id;
private String url;
private String description;
private String username;
private String created;
private String lastVisited;
private String expires;
private Long visitCount;
private List<Entry> entries;
public Share()
{
entries = new ArrayList<Entry>();
}
public String getName()
{
return urlPattern.matcher(url).replaceFirst("$1");
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getCreated()
{
return this.created;
}
public void setCreated(String created)
{
this.created = created;
}
public String getLastVisited()
{
return lastVisited;
}
public void setLastVisited(String lastVisited)
{
this.lastVisited = lastVisited;
}
public String getExpires()
{
return expires;
}
public void setExpires(String expires)
{
this.expires = expires;
}
public Long getVisitCount()
{
return visitCount;
}
public void setVisitCount(Long visitCount)
{
this.visitCount = visitCount;
}
public List<Entry> getEntries()
{
return this.entries;
}
public void addEntry(Entry entry)
{
entries.add(entry);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Share share = (Share) o;
if (id != null ? !id.equals(share.id) : share.id != null) return false;
if (url != null ? !url.equals(share.url) : share.url != null) return false;
if (description != null ? !description.equals(share.description) : share.description != null)
return false;
if (username != null ? !username.equals(share.username) : share.username != null)
return false;
if (created != null ? !created.equals(share.created) : share.created != null) return false;
if (lastVisited != null ? !lastVisited.equals(share.lastVisited) : share.lastVisited != null)
return false;
if (expires != null ? !expires.equals(share.expires) : share.expires != null) return false;
if (visitCount != null ? !visitCount.equals(share.visitCount) : share.visitCount != null)
return false;
return entries != null ? entries.equals(share.entries) : share.entries == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (url != null ? url.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (username != null ? username.hashCode() : 0);
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (lastVisited != null ? lastVisited.hashCode() : 0);
result = 31 * result + (expires != null ? expires.hashCode() : 0);
result = 31 * result + (visitCount != null ? visitCount.hashCode() : 0);
result = 31 * result + (entries != null ? entries.hashCode() : 0);
return result;
}
}

View File

@ -1,182 +0,0 @@
/*
This file is part of UltraSonic.
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 2013 (C) Joshua Bahnsen
*/
package org.moire.ultrasonic.domain;
/**
* Information about the Subsonic server.
*
* @author Joshua Bahnsen
*/
public class UserInfo
{
private String userName;
private String email;
private boolean scrobblingEnabled;
private boolean adminRole;
private boolean settingsRole;
private boolean downloadRole;
private boolean uploadRole;
private boolean playlistRole;
private boolean coverArtRole;
private boolean commentRole;
private boolean podcastRole;
private boolean streamRole;
private boolean jukeboxRole;
private boolean shareRole;
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getEmail()
{
return this.email;
}
public void setEmail(String email)
{
this.email = email;
}
public boolean getScrobblingEnabled()
{
return this.scrobblingEnabled;
}
public void setScrobblingEnabled(boolean scrobblingEnabled)
{
this.scrobblingEnabled = scrobblingEnabled;
}
public boolean getAdminRole()
{
return this.adminRole;
}
public void setAdminRole(boolean adminRole)
{
this.adminRole = adminRole;
}
public boolean getSettingsRole()
{
return this.settingsRole;
}
public void setSettingsRole(boolean settingsRole)
{
this.settingsRole = settingsRole;
}
public boolean getDownloadRole()
{
return this.downloadRole;
}
public void setDownloadRole(boolean downloadRole)
{
this.downloadRole = downloadRole;
}
public boolean getUploadRole()
{
return this.uploadRole;
}
public void setUploadRole(boolean uploadRole)
{
this.uploadRole = uploadRole;
}
public boolean getPlaylistRole()
{
return this.playlistRole;
}
public void setPlaylistRole(boolean playlistRole)
{
this.playlistRole = playlistRole;
}
public boolean getCoverArtRole()
{
return this.coverArtRole;
}
public void setCoverArtRole(boolean coverArtRole)
{
this.coverArtRole = coverArtRole;
}
public boolean getCommentRole()
{
return this.commentRole;
}
public void setCommentRole(boolean commentRole)
{
this.commentRole = commentRole;
}
public boolean getPodcastRole()
{
return this.podcastRole;
}
public void setPodcastRole(boolean podcastRole)
{
this.podcastRole = podcastRole;
}
public boolean getStreamRole()
{
return this.streamRole;
}
public void setStreamRole(boolean streamRole)
{
this.streamRole = streamRole;
}
public boolean getJukeboxRole()
{
return this.jukeboxRole;
}
public void setJukeboxRole(boolean jukeboxRole)
{
this.jukeboxRole = jukeboxRole;
}
public boolean getShareRole()
{
return this.shareRole;
}
public void setShareRole(boolean shareRole)
{
this.shareRole = shareRole;
}
}

View File

@ -1,178 +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 java.util.regex.Pattern;
/**
* Represents the version number of the Subsonic Android app.
*
* @author Sindre Mehus
* @version $Revision: 1.3 $ $Date: 2006/01/20 21:25:16 $
*/
public class Version implements Comparable<Version>
{
private static final Pattern COMPILE = Pattern.compile("\\.");
private int major;
private int minor;
private int beta;
private int bugFix;
/**
* Creates a new version instance by parsing the given string.
*
* @param version A string of the format "1.27", "1.27.2" or "1.27.beta3".
*/
public Version(CharSequence version)
{
String[] s = COMPILE.split(version);
major = Integer.valueOf(s[0]);
minor = Integer.valueOf(s[1]);
if (s.length > 2)
{
if (s[2].contains("beta"))
{
beta = Integer.valueOf(s[2].replace("beta", ""));
}
else
{
bugFix = Integer.valueOf(s[2]);
}
}
}
public int getMajor()
{
return major;
}
public int getMinor()
{
return minor;
}
/**
* Return whether this object is equal to another.
*
* @param o Object to compare to.
* @return Whether this object is equals to another.
*/
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final Version version = (Version) o;
return beta == version.beta && bugFix == version.bugFix && major == version.major && minor == version.minor;
}
/**
* Returns a hash code for this object.
*
* @return A hash code for this object.
*/
public int hashCode()
{
int result;
result = major;
result = 29 * result + minor;
result = 29 * result + beta;
result = 29 * result + bugFix;
return result;
}
/**
* Returns a string representation of the form "1.27", "1.27.2" or "1.27.beta3".
*
* @return A string representation of the form "1.27", "1.27.2" or "1.27.beta3".
*/
public String toString()
{
StringBuilder buf = new StringBuilder(3);
buf.append(major).append('.').append(minor);
if (beta != 0)
{
buf.append(".beta").append(beta);
}
else if (bugFix != 0)
{
buf.append('.').append(bugFix);
}
return buf.toString();
}
/**
* Compares this object with the specified object for order.
*
* @param version The object to compare to.
* @return A negative integer, zero, or a positive integer as this object is less than, equal to, or
* greater than the specified object.
*/
@Override
public int compareTo(Version version)
{
if (major < version.major)
{
return -1;
}
if (major > version.major)
{
return 1;
}
if (minor < version.minor)
{
return -1;
}
if (minor > version.minor)
{
return 1;
}
if (bugFix < version.bugFix)
{
return -1;
}
if (bugFix > version.bugFix)
{
return 1;
}
int thisBeta = beta == 0 ? Integer.MAX_VALUE : beta;
int otherBeta = version.beta == 0 ? Integer.MAX_VALUE : version.beta;
if (thisBeta < otherBeta)
{
return -1;
}
if (thisBeta > otherBeta)
{
return 1;
}
return 0;
}
}

View File

@ -185,7 +185,7 @@ public class OfflineMusicService extends RESTMusicService
private static MusicDirectory.Entry createEntry(Context context, File file, String name)
{
MusicDirectory.Entry entry = new MusicDirectory.Entry();
entry.setIsDirectory(file.isDirectory());
entry.setDirectory(file.isDirectory());
entry.setId(file.getPath());
entry.setParent(file.getParent());
entry.setSize(file.length());
@ -232,7 +232,7 @@ public class OfflineMusicService extends RESTMusicService
entry.setTitle(title);
}
entry.setIsVideo(hasVideo != null);
entry.setVideo(hasVideo != null);
Log.i("OfflineMusicService", String.format("Offline Stuff: %s", track));

View File

@ -61,21 +61,21 @@ import org.moire.ultrasonic.api.subsonic.response.SharesResponse;
import org.moire.ultrasonic.api.subsonic.response.StreamResponse;
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse;
import org.moire.ultrasonic.api.subsonic.response.VideosResponse;
import org.moire.ultrasonic.data.APIAlbumConverter;
import org.moire.ultrasonic.data.APIArtistConverter;
import org.moire.ultrasonic.data.APIBookmarkConverter;
import org.moire.ultrasonic.data.APIChatMessageConverter;
import org.moire.ultrasonic.data.APIIndexesConverter;
import org.moire.ultrasonic.data.APIJukeboxConverter;
import org.moire.ultrasonic.data.APILyricsConverter;
import org.moire.ultrasonic.data.APIMusicDirectoryConverter;
import org.moire.ultrasonic.data.APIMusicFolderConverter;
import org.moire.ultrasonic.data.APIPlaylistConverter;
import org.moire.ultrasonic.data.APIPodcastConverter;
import org.moire.ultrasonic.data.APISearchConverter;
import org.moire.ultrasonic.data.APIShareConverter;
import org.moire.ultrasonic.data.APIUserConverter;
import org.moire.ultrasonic.data.ApiGenreConverter;
import org.moire.ultrasonic.domain.APIAlbumConverter;
import org.moire.ultrasonic.domain.APIArtistConverter;
import org.moire.ultrasonic.domain.APIBookmarkConverter;
import org.moire.ultrasonic.domain.APIChatMessageConverter;
import org.moire.ultrasonic.domain.APIIndexesConverter;
import org.moire.ultrasonic.domain.APIJukeboxConverter;
import org.moire.ultrasonic.domain.APILyricsConverter;
import org.moire.ultrasonic.domain.APIMusicDirectoryConverter;
import org.moire.ultrasonic.domain.APIMusicFolderConverter;
import org.moire.ultrasonic.domain.APIPlaylistConverter;
import org.moire.ultrasonic.domain.APIPodcastConverter;
import org.moire.ultrasonic.domain.APISearchConverter;
import org.moire.ultrasonic.domain.APIShareConverter;
import org.moire.ultrasonic.domain.APIUserConverter;
import org.moire.ultrasonic.domain.ApiGenreConverter;
import org.moire.ultrasonic.domain.Bookmark;
import org.moire.ultrasonic.domain.ChatMessage;
import org.moire.ultrasonic.domain.Genre;

View File

@ -19,8 +19,14 @@
package org.moire.ultrasonic.view;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.SectionIndexer;
import android.widget.TextView;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.domain.Artist;
@ -35,6 +41,7 @@ import java.util.List;
*/
public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer
{
private final LayoutInflater layoutInflater;
// Both arrays are indexed by section ID.
private final Object[] sections;
@ -44,6 +51,8 @@ public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexe
{
super(context, R.layout.artist_list_item, artists);
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Collection<String> sectionSet = new LinkedHashSet<String>(30);
List<Integer> positionList = new ArrayList<Integer>(30);
@ -63,6 +72,23 @@ public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexe
positions = positionList.toArray(new Integer[positionList.size()]);
}
@NonNull
@Override
public View getView(
int position,
@Nullable View convertView,
@NonNull ViewGroup parent
) {
View rowView = convertView;
if (rowView == null) {
rowView = layoutInflater.inflate(R.layout.artist_list_item, parent, false);
}
((TextView) rowView).setText(getItem(position).getName());
return rowView;
}
@Override
public Object[] getSections()
{

View File

@ -19,8 +19,14 @@
package org.moire.ultrasonic.view;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.SectionIndexer;
import android.widget.TextView;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.domain.Genre;
@ -35,7 +41,7 @@ import java.util.List;
*/
public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
{
private final LayoutInflater layoutInflater;
// Both arrays are indexed by section ID.
private final Object[] sections;
private final Integer[] positions;
@ -44,6 +50,8 @@ public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
{
super(context, R.layout.artist_list_item, genres);
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Collection<String> sectionSet = new LinkedHashSet<String>(30);
List<Integer> positionList = new ArrayList<Integer>(30);
@ -62,7 +70,20 @@ public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
positions = positionList.toArray(new Integer[positionList.size()]);
}
@Override
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
rowView = layoutInflater.inflate(R.layout.artist_list_item, parent, false);
}
((TextView) rowView).setText(getItem(position).getName());
return rowView;
}
@Override
public Object[] getSections()
{
return sections;

View File

@ -1,83 +1,46 @@
package org.moire.ultrasonic.view;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.activity.SubsonicTabActivity;
import org.moire.ultrasonic.domain.Playlist;
import org.moire.ultrasonic.domain.PodcastsChannel;
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author Sindre Mehus
*/
public class PodcastsChannelsAdapter extends ArrayAdapter<PodcastsChannel>
{
public class PodcastsChannelsAdapter extends ArrayAdapter<PodcastsChannel> {
private final LayoutInflater layoutInflater;
//private final SubsonicTabActivity activity;
public PodcastsChannelsAdapter(Context context, List<PodcastsChannel> channels) {
super(context, R.layout.podcasts_channel_item, channels);
public PodcastsChannelsAdapter(Activity activity, List<PodcastsChannel> channels)
{
super(activity, R.layout.podcasts_channel_item, channels);
//this.activity = activity;
}
@Override
public void add(PodcastsChannel object) {
super.add(object);
layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/* @Override
public View getView(int position, View convertView, ViewGroup parent)
{
PodcastsChannel entry = getItem(position);
PlaylistView view;
if (convertView != null && convertView instanceof PlaylistView)
{
PlaylistView currentView = (PlaylistView) convertView;
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
PodcastsChannel entry = getItem(position);
ViewHolder viewHolder = (ViewHolder) convertView.getTag();
view = currentView;
view.setViewHolder(viewHolder);
}
else
{
view = new PlaylistView(activity);
view.setLayout();
}
TextView view;
if (convertView != null && convertView instanceof PlaylistView) {
view = (TextView) convertView;
} else {
view = (TextView) layoutInflater
.inflate(R.layout.podcasts_channel_item, parent, false);
}
view.setPlaylist(entry);
return view;
}
*/
view.setText(entry.getTitle());
/* public static class PlaylistComparator implements Comparator<Playlist>, Serializable
{
private static final long serialVersionUID = -6201663557439120008L;
@Override
public int compare(Playlist playlist1, Playlist playlist2)
{
return playlist1.getName().compareToIgnoreCase(playlist2.getName());
}
public static List<Playlist> sort(List<Playlist> playlists)
{
Collections.sort(playlists, new PlaylistComparator());
return playlists;
}
} */
/* static class ViewHolder
{
TextView name;
} */
}
return view;
}
}

View File

@ -188,7 +188,7 @@ public class SongView extends UpdateView implements Checkable
}
}
int trackNumber = song.getTrack();
int trackNumber = (song.getTrack() == null) ? 0 : song.getTrack();
if (viewHolder.track != null)
{

View File

@ -1,17 +0,0 @@
// Contains helper functions to convert api Bookmark entity to domain entity
@file:JvmName("APIBookmarkConverter")
package org.moire.ultrasonic.data
import org.moire.ultrasonic.domain.Bookmark
import org.moire.ultrasonic.api.subsonic.models.Bookmark as ApiBookmark
fun ApiBookmark.toDomainEntity(): Bookmark = Bookmark().apply {
position = this@toDomainEntity.position.toInt()
username = this@toDomainEntity.username
comment = this@toDomainEntity.comment
created = this@toDomainEntity.created?.time
changed = this@toDomainEntity.changed?.time
entry = this@toDomainEntity.entry.toDomainEntity()
}
fun List<ApiBookmark>.toDomainEntitiesList(): List<Bookmark> = map { it.toDomainEntity() }

View File

@ -1,23 +0,0 @@
// Helper functions to convert User entity to domain entity
@file:JvmName("APIUserConverter")
package org.moire.ultrasonic.data
import org.moire.ultrasonic.domain.UserInfo
import org.moire.ultrasonic.api.subsonic.models.User
fun User.toDomainEntity(): UserInfo = UserInfo().apply {
adminRole = this@toDomainEntity.adminRole
commentRole = this@toDomainEntity.commentRole
coverArtRole = this@toDomainEntity.coverArtRole
downloadRole = this@toDomainEntity.downloadRole
email = this@toDomainEntity.email
jukeboxRole = this@toDomainEntity.jukeboxRole
playlistRole = this@toDomainEntity.playlistRole
podcastRole = this@toDomainEntity.podcastRole
scrobblingEnabled = this@toDomainEntity.scrobblingEnabled
settingsRole = this@toDomainEntity.settingsRole
shareRole = this@toDomainEntity.shareRole
streamRole = this@toDomainEntity.streamRole
uploadRole = this@toDomainEntity.uploadRole
userName = this@toDomainEntity.username
}

View File

@ -1,24 +1,23 @@
// Converts Album entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIAlbumConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.Album
import org.moire.ultrasonic.domain.MusicDirectory
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
id = this@toDomainEntity.id
setIsDirectory(true)
title = this@toDomainEntity.name
coverArt = this@toDomainEntity.coverArt
artist = this@toDomainEntity.artist
artistId = this@toDomainEntity.artistId
songCount = this@toDomainEntity.songCount.toLong()
duration = this@toDomainEntity.duration
created = this@toDomainEntity.created?.time
year = this@toDomainEntity.year
fun Album.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry(
id = this@toDomainEntity.id,
isDirectory = true,
title = this@toDomainEntity.name,
coverArt = this@toDomainEntity.coverArt,
artist = this@toDomainEntity.artist,
artistId = this@toDomainEntity.artistId,
songCount = this@toDomainEntity.songCount.toLong(),
duration = this@toDomainEntity.duration,
created = this@toDomainEntity.created?.time,
year = this@toDomainEntity.year,
genre = this@toDomainEntity.genre
}
)
fun Album.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
addAll(this@toMusicDirectoryDomainEntity.songList.map { it.toDomainEntity() })

View File

@ -1,16 +1,14 @@
// Converts Artist entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIArtistConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.Artist
import org.moire.ultrasonic.domain.MusicDirectory
import org.moire.ultrasonic.api.subsonic.models.Artist as APIArtist
fun APIArtist.toDomainEntity(): Artist = Artist().apply {
id = this@toDomainEntity.id
fun APIArtist.toDomainEntity(): Artist = Artist(
id = this@toDomainEntity.id,
name = this@toDomainEntity.name
}
)
fun APIArtist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory().apply {
name = this@toMusicDirectoryDomainEntity.name

View File

@ -0,0 +1,16 @@
// Contains helper functions to convert api Bookmark entity to domain entity
@file:JvmName("APIBookmarkConverter")
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.Bookmark as ApiBookmark
fun ApiBookmark.toDomainEntity(): Bookmark = Bookmark(
position = this@toDomainEntity.position.toInt(),
username = this@toDomainEntity.username,
comment = this@toDomainEntity.comment,
created = this@toDomainEntity.created?.time,
changed = this@toDomainEntity.changed?.time,
entry = this@toDomainEntity.entry.toDomainEntity()
)
fun List<ApiBookmark>.toDomainEntitiesList(): List<Bookmark> = map { it.toDomainEntity() }

View File

@ -1,15 +1,14 @@
// Contains helper functions to convert from api ChatMessage entity to domain entity
@file:JvmName("APIChatMessageConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.ChatMessage
import org.moire.ultrasonic.api.subsonic.models.ChatMessage as ApiChatMessage
fun ApiChatMessage.toDomainEntity(): ChatMessage = ChatMessage().apply {
username = this@toDomainEntity.username
time = this@toDomainEntity.time
fun ApiChatMessage.toDomainEntity(): ChatMessage = ChatMessage(
username = this@toDomainEntity.username,
time = this@toDomainEntity.time,
message = this@toDomainEntity.message
}
)
fun List<ApiChatMessage>.toDomainEntitiesList(): List<ChatMessage> = this
.map { it.toDomainEntity() }

View File

@ -1,13 +1,12 @@
// Collection of functions to convert api Genre entity to domain entity
@file:JvmName("ApiGenreConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.Genre
import org.moire.ultrasonic.api.subsonic.models.Genre as APIGenre
fun APIGenre.toDomainEntity(): Genre = Genre().apply {
name = this@toDomainEntity.name
fun APIGenre.toDomainEntity(): Genre = Genre(
name = this@toDomainEntity.name,
index = this@toDomainEntity.name.substring(0, 1)
}
)
fun List<APIGenre>.toDomainEntityList(): List<Genre> = this.map { it.toDomainEntity() }

View File

@ -1,15 +1,15 @@
// Converts Indexes entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIIndexesConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.Index
import org.moire.ultrasonic.domain.Artist
import org.moire.ultrasonic.domain.Indexes
import org.moire.ultrasonic.api.subsonic.models.Indexes as APIIndexes
fun APIIndexes.toDomainEntity(): Indexes = Indexes(this.lastModified, this.ignoredArticles,
this.shortcutList.map { it.toDomainEntity() }, this.indexList.foldIndexToArtistList())
this.shortcutList.map { it.toDomainEntity() }.toMutableList(),
this.indexList.foldIndexToArtistList().toMutableList()
)
private fun List<Index>.foldIndexToArtistList(): List<Artist> = this.fold(listOf(), {
acc, index -> acc + index.artists.map { it.toDomainEntity() }

View File

@ -1,13 +1,12 @@
// Collection of function to convert subsonic api jukebox responses to app entities
@file:JvmName("APIJukeboxConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.JukeboxStatus
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus as ApiJukeboxStatus
fun ApiJukeboxStatus.toDomainEntity(): JukeboxStatus = JukeboxStatus().apply {
positionSeconds = this@toDomainEntity.position
setCurrentIndex(this@toDomainEntity.currentIndex)
isPlaying = this@toDomainEntity.playing
fun ApiJukeboxStatus.toDomainEntity(): JukeboxStatus = JukeboxStatus(
positionSeconds = this@toDomainEntity.position,
currentPlayingIndex = this@toDomainEntity.currentIndex,
isPlaying = this@toDomainEntity.playing,
gain = this@toDomainEntity.gain
}
)

View File

@ -1,13 +1,12 @@
// Converts Lyrics entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APILyricsConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.Lyrics
import org.moire.ultrasonic.api.subsonic.models.Lyrics as APILyrics
fun APILyrics.toDomainEntity(): Lyrics = Lyrics().apply {
artist = this@toDomainEntity.artist
title = this@toDomainEntity.title
fun APILyrics.toDomainEntity(): Lyrics = Lyrics(
artist = this@toDomainEntity.artist,
title = this@toDomainEntity.title,
text = this@toDomainEntity.text
}
)

View File

@ -1,10 +1,9 @@
// Converts MusicDirectory entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIMusicDirectoryConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
import org.moire.ultrasonic.domain.MusicDirectory
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Locale
@ -17,7 +16,7 @@ internal val dateFormat: DateFormat by lazy {
fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.Entry().apply {
id = this@toDomainEntity.id
parent = this@toDomainEntity.parent
setIsDirectory(this@toDomainEntity.isDir)
isDirectory = this@toDomainEntity.isDir
title = this@toDomainEntity.title
album = this@toDomainEntity.album
albumId = this@toDomainEntity.albumId
@ -35,7 +34,7 @@ fun MusicDirectoryChild.toDomainEntity(): MusicDirectory.Entry = MusicDirectory.
duration = this@toDomainEntity.duration
bitRate = this@toDomainEntity.bitRate
path = this@toDomainEntity.path
setIsVideo(this@toDomainEntity.isVideo)
isVideo = this@toDomainEntity.isVideo
created = this@toDomainEntity.created?.time
starred = this@toDomainEntity.starred != null
discNumber = this@toDomainEntity.discNumber

View File

@ -1,9 +1,8 @@
// Converts MusicFolder entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIMusicFolderConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.MusicFolder
import org.moire.ultrasonic.api.subsonic.models.MusicFolder as APIMusicFolder
fun APIMusicFolder.toDomainEntity(): MusicFolder = MusicFolder(this.id, this.name)

View File

@ -1,10 +1,8 @@
// Converts Playlist entity from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIPlaylistConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.MusicDirectory
import org.moire.ultrasonic.domain.Playlist
import java.text.SimpleDateFormat
import kotlin.LazyThreadSafetyMode.NONE
import org.moire.ultrasonic.api.subsonic.models.Playlist as APIPlaylist
@ -18,7 +16,7 @@ fun APIPlaylist.toMusicDirectoryDomainEntity(): MusicDirectory = MusicDirectory(
fun APIPlaylist.toDomainEntity(): Playlist = Playlist(this.id, this.name, this.owner,
this.comment, this.songCount.toString(),
this.created?.let { playlistDateFormat.format(it.time) },
public.toString())
this.created?.let { playlistDateFormat.format(it.time) } ?: "",
public)
fun List<APIPlaylist>.toDomainEntitiesList(): List<Playlist> = this.map { it.toDomainEntity() }

View File

@ -1,10 +1,9 @@
// Converts podcasts entities from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APIPodcastConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.PodcastChannel
import org.moire.ultrasonic.domain.PodcastsChannel
fun PodcastChannel.toDomainEntity(): PodcastsChannel = PodcastsChannel(
this.id, this.title, this.url, this.description, this.status)

View File

@ -1,11 +1,10 @@
// Converts SearchResult entities from [org.moire.ultrasonic.api.subsonic.SubsonicAPIClient]
// to app domain entities.
@file:JvmName("APISearchConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.SearchThreeResult
import org.moire.ultrasonic.api.subsonic.models.SearchTwoResult
import org.moire.ultrasonic.domain.SearchResult
import org.moire.ultrasonic.api.subsonic.models.SearchResult as APISearchResult
fun APISearchResult.toDomainEntity(): SearchResult = SearchResult(emptyList(), emptyList(),

View File

@ -1,8 +1,7 @@
// Contains helper method to convert subsonic api share to domain model
@file:JvmName("APIShareConverter")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.Share
import java.text.SimpleDateFormat
import kotlin.LazyThreadSafetyMode.NONE
import org.moire.ultrasonic.api.subsonic.models.Share as APIShare
@ -13,14 +12,14 @@ fun List<APIShare>.toDomainEntitiesList(): List<Share> = this.map {
it.toDomainEntity()
}
fun APIShare.toDomainEntity(): Share = Share().apply {
created = this@toDomainEntity.created?.let { shareTimeFormat.format(it.time) }
description = this@toDomainEntity.description
expires = this@toDomainEntity.expires?.let { shareTimeFormat.format(it.time) }
id = this@toDomainEntity.id
lastVisited = this@toDomainEntity.lastVisited?.let { shareTimeFormat.format(it.time) }
url = this@toDomainEntity.url
username = this@toDomainEntity.username
visitCount = this@toDomainEntity.visitCount.toLong()
entries.addAll(this@toDomainEntity.items.toDomainEntityList())
}
fun APIShare.toDomainEntity(): Share = Share(
created = this@toDomainEntity.created?.let { shareTimeFormat.format(it.time) },
description = this@toDomainEntity.description,
expires = this@toDomainEntity.expires?.let { shareTimeFormat.format(it.time) },
id = this@toDomainEntity.id,
lastVisited = this@toDomainEntity.lastVisited?.let { shareTimeFormat.format(it.time) },
url = this@toDomainEntity.url,
username = this@toDomainEntity.username,
visitCount = this@toDomainEntity.visitCount.toLong(),
entries = this@toDomainEntity.items.toDomainEntityList().toMutableList()
)

View File

@ -0,0 +1,22 @@
// Helper functions to convert User entity to domain entity
@file:JvmName("APIUserConverter")
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.api.subsonic.models.User
fun User.toDomainEntity(): UserInfo = UserInfo(
adminRole = this@toDomainEntity.adminRole,
commentRole = this@toDomainEntity.commentRole,
coverArtRole = this@toDomainEntity.coverArtRole,
downloadRole = this@toDomainEntity.downloadRole,
email = this@toDomainEntity.email,
jukeboxRole = this@toDomainEntity.jukeboxRole,
playlistRole = this@toDomainEntity.playlistRole,
podcastRole = this@toDomainEntity.podcastRole,
scrobblingEnabled = this@toDomainEntity.scrobblingEnabled,
settingsRole = this@toDomainEntity.settingsRole,
shareRole = this@toDomainEntity.shareRole,
streamRole = this@toDomainEntity.streamRole,
uploadRole = this@toDomainEntity.uploadRole,
userName = this@toDomainEntity.username
)

View File

@ -0,0 +1,16 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class Artist(
var id: String? = null,
var name: String? = null,
var index: String? = null,
var coverArt: String? = null,
var albumCount: Long? = null,
var closeness: Int = 0
) : Serializable {
companion object {
private const val serialVersionUID = -5790532593784846982L
}
}

View File

@ -0,0 +1,19 @@
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.MusicDirectory.Entry
import java.io.Serializable
import java.util.Date
data class Bookmark(
val position: Int = 0,
val username: String,
val comment: String,
val created: Date? = null,
val changed: Date? = null,
val entry: Entry
) : Serializable {
companion object {
private const val serialVersionUID = 8988990025189807803L
}
}

View File

@ -0,0 +1,13 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class ChatMessage(
val username: String,
val time: Long,
val message: String
) : Serializable {
companion object {
private const val serialVersionUID = 496544310289324167L
}
}

View File

@ -0,0 +1,12 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class Genre(
val name: String,
val index: String
) : Serializable {
companion object {
private const val serialVersionUID = -3943025175219134028L
}
}

View File

@ -0,0 +1,14 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class Indexes(
val lastModified: Long,
val ignoredArticles: String,
val shortcuts: MutableList<Artist> = mutableListOf(),
val artists: MutableList<Artist> = mutableListOf()
) : Serializable {
companion object {
private const val serialVersionUID = 8156117238598414701L
}
}

View File

@ -0,0 +1,8 @@
package org.moire.ultrasonic.domain
data class JukeboxStatus(
var positionSeconds: Int? = null,
var currentPlayingIndex: Int? = null,
var gain: Float? = null,
var isPlaying: Boolean = false
)

View File

@ -0,0 +1,10 @@
package org.moire.ultrasonic.domain
/**
* Song lyrics.
*/
data class Lyrics(
val artist: String? = null,
val title: String? = null,
val text: String? = null
)

View File

@ -0,0 +1,75 @@
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 }
fun getAllChild(): List<Entry> = children.toList()
@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
}
}
}

View File

@ -0,0 +1,9 @@
package org.moire.ultrasonic.domain
/**
* Represents a top level directory in which music or other media is stored.
*/
data class MusicFolder(
val id: String,
val name: String
)

View File

@ -0,0 +1,12 @@
package org.moire.ultrasonic.domain
enum class PlayerState {
IDLE,
DOWNLOADING,
PREPARING,
PREPARED,
STARTED,
STOPPED,
PAUSED,
COMPLETED
}

View File

@ -0,0 +1,17 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class Playlist @JvmOverloads constructor(
val id: String,
var name: String,
val owner: String = "",
val comment: String = "",
val songCount: String = "",
val created: String = "",
val public: Boolean? = null
) : Serializable {
companion object {
private const val serialVersionUID = -4160515427075433798L
}
}

View File

@ -0,0 +1,15 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class PodcastsChannel(
val id: String,
val title: String?,
val url: String?,
val description: String?,
val status: String?
) : Serializable {
companion object {
private const val serialVersionUID = -4160515427075433798L
}
}

View File

@ -0,0 +1,15 @@
package org.moire.ultrasonic.domain
enum class RepeatMode {
OFF {
override operator fun next(): RepeatMode = ALL
},
ALL {
override operator fun next(): RepeatMode = SINGLE
},
SINGLE {
override operator fun next(): RepeatMode = OFF
};
abstract operator fun next(): RepeatMode
}

View File

@ -0,0 +1,11 @@
package org.moire.ultrasonic.domain
/**
* The criteria for a music search.
*/
data class SearchCriteria(
val query: String,
val artistCount: Int,
val albumCount: Int,
val songCount: Int
)

View File

@ -0,0 +1,10 @@
package org.moire.ultrasonic.domain
/**
* The result of a search. Contains matching artists, albums and songs.
*/
data class SearchResult(
val artists: List<Artist>,
val albums: List<MusicDirectory.Entry>,
val songs: List<MusicDirectory.Entry>
)

View File

@ -0,0 +1,32 @@
package org.moire.ultrasonic.domain
import org.moire.ultrasonic.domain.MusicDirectory.Entry
import java.io.Serializable
data class Share(
var id: String? = null,
var url: String? = null,
var description: String? = null,
var username: String? = null,
var created: String? = null,
var lastVisited: String? = null,
var expires: String? = null,
var visitCount: Long? = null,
private val entries: MutableList<Entry> = mutableListOf()
) : Serializable {
val name: String?
get() = url?.let { urlPattern.matcher(url).replaceFirst("$1") }
fun getEntries(): List<Entry> {
return entries.toList()
}
fun addEntry(entry: Entry) {
entries.add(entry)
}
companion object {
private const val serialVersionUID = 1487561657691009668L
private val urlPattern = ".*/([^/?]+).*".toPattern()
}
}

View File

@ -0,0 +1,21 @@
package org.moire.ultrasonic.domain
/**
* Information about user
*/
data class UserInfo(
val userName: String? = null,
val email: String? = null,
val scrobblingEnabled: Boolean = false,
val adminRole: Boolean = false,
val settingsRole: Boolean = false,
val downloadRole: Boolean = false,
val uploadRole: Boolean = false,
val playlistRole: Boolean = false,
val coverArtRole: Boolean = false,
val commentRole: Boolean = false,
val podcastRole: Boolean = false,
val streamRole: Boolean = false,
val jukeboxRole: Boolean = false,
val shareRole: Boolean = false
)

View File

@ -0,0 +1,27 @@
package org.moire.ultrasonic.domain
import net.swiftzer.semver.SemVer
/**
* Represents the version number of the Subsonic Android app.
*/
data class Version(
val version: SemVer
) : Comparable<Version> {
override fun compareTo(other: Version): Int {
return version.compareTo(other.version)
}
companion object {
/**
* Creates a new version instance by parsing the given string.
*
* @param version A string of the format "1.27", "1.27.2" or "1.27.beta3".
*/
@JvmStatic
fun fromCharSequence(version: String): Version {
return Version(SemVer.parse(version))
}
}
}

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/podcast_channel_item"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:visibility="visible" />
<TextView xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/podcast_channel_item"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:visibility="visible" />

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -22,17 +22,17 @@ class APIAlbumConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id
title `should equal to` entity.name
isDirectory `should equal to` true
coverArt `should equal to` entity.coverArt
artist `should equal to` entity.artist
artistId `should equal to` entity.artistId
songCount `should equal to` entity.songCount.toLong()
duration `should equal to` entity.duration
id `should equal` entity.id
title `should equal` entity.name
isDirectory `should equal` true
coverArt `should equal` entity.coverArt
artist `should equal` entity.artist
artistId `should equal` entity.artistId
songCount `should equal` entity.songCount.toLong()
duration `should equal` entity.duration
created `should equal` entity.created?.time
year `should equal to` entity.year
genre `should equal to` entity.genre
year `should equal` entity.year
genre `should equal` entity.genre
}
}
@ -47,8 +47,8 @@ class APIAlbumConverterTest {
with(convertedEntity) {
name `should equal` null
children.size `should equal to` entity.songList.size
children[0] `should equal` entity.songList[0].toDomainEntity()
getChildren().size `should equal to` entity.songList.size
getChildren()[0] `should equal` entity.songList[0].toDomainEntity()
}
}

View File

@ -1,8 +1,7 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.Album
@ -20,8 +19,8 @@ class APIArtistConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id
name `should equal to` entity.name
id `should equal` entity.id
name `should equal` entity.name
}
}
@ -36,8 +35,9 @@ class APIArtistConverterTest {
val convertedEntity = entity.toMusicDirectoryDomainEntity()
with(convertedEntity) {
name `should equal to` entity.name
children `should equal` entity.albumsList.map { it.toDomainEntity() }.toMutableList()
name `should equal` entity.name
getAllChild() `should equal` entity.albumsList
.map { it.toDomainEntity() }.toMutableList()
}
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -22,8 +22,8 @@ class APIBookmarkConverterTest {
with(domainEntity) {
position `should equal to` entity.position.toInt()
username `should equal to` entity.username
comment `should equal to` entity.comment
username `should equal` entity.username
comment `should equal` entity.comment
created `should equal` entity.created?.time
changed `should equal` entity.changed?.time
entry `should equal` entity.entry.toDomainEntity()

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -18,9 +18,9 @@ class APIChatMessageConverterTest {
val domainEntity = entity.toDomainEntity()
with(domainEntity) {
username `should equal to` entity.username
time `should equal to` entity.time
message `should equal to` entity.message
username `should equal` entity.username
time `should equal` entity.time
message `should equal` entity.message
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`

View File

@ -1,8 +1,9 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.JukeboxStatus
@ -17,10 +18,10 @@ class APIJukeboxConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
currentPlayingIndex `should equal to` entity.currentIndex
gain `should equal to` entity.gain
currentPlayingIndex `should equal` entity.currentIndex
gain `should equal` entity.gain
isPlaying `should equal to` entity.playing
positionSeconds `should equal to` entity.position
positionSeconds `should equal` entity.position
}
}
}

View File

@ -1,8 +1,8 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.Lyrics
@ -17,9 +17,9 @@ class APILyricsConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
artist `should equal to` entity.artist
title `should equal to` entity.title
text `should equal to` entity.text
artist `should equal` entity.artist
title `should equal` entity.title
text `should equal` entity.text
}
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -22,9 +22,10 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
name `should equal to` entity.name
children.size `should equal to` entity.childList.size
children `should equal` entity.childList.map { it.toDomainEntity() }.toMutableList()
name `should equal` entity.name
getAllChild().size `should equal to` entity.childList.size
getAllChild() `should equal` entity.childList
.map { it.toDomainEntity() }.toMutableList()
}
}
@ -43,31 +44,31 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.id
parent `should equal to` entity.parent
id `should equal` entity.id
parent `should equal` entity.parent
isDirectory `should equal to` entity.isDir
title `should equal` entity.title
album `should equal` entity.album
albumId `should equal to` entity.albumId
artist `should equal to` entity.artist
artistId `should equal to` entity.artistId
track `should equal to` entity.track
year `should equal to` entity.year!!
genre `should equal to` entity.genre
contentType `should equal to` entity.contentType
suffix `should equal to` entity.suffix
transcodedContentType `should equal to` entity.transcodedContentType
transcodedSuffix `should equal to` entity.transcodedSuffix
coverArt `should equal to` entity.coverArt
size `should equal to` entity.size
duration `should equal to` entity.duration
bitRate `should equal to` entity.bitRate
path `should equal to` entity.path
albumId `should equal` entity.albumId
artist `should equal` entity.artist
artistId `should equal` entity.artistId
track `should equal` entity.track
year `should equal` entity.year!!
genre `should equal` entity.genre
contentType `should equal` entity.contentType
suffix `should equal` entity.suffix
transcodedContentType `should equal` entity.transcodedContentType
transcodedSuffix `should equal` entity.transcodedSuffix
coverArt `should equal` entity.coverArt
size `should equal` entity.size
duration `should equal` entity.duration
bitRate `should equal` entity.bitRate
path `should equal` entity.path
isVideo `should equal to` entity.isVideo
created `should equal` entity.created?.time
starred `should equal to` (entity.starred != null)
discNumber `should equal to` entity.discNumber
type `should equal to` entity.type
discNumber `should equal` entity.discNumber
type `should equal` entity.type
}
}
@ -79,8 +80,8 @@ class APIMusicDirectoryConverterTest {
val convertedEntity = entity.toDomainEntity()
with(convertedEntity) {
id `should equal to` entity.streamId
artist `should equal to` dateFormat.format(entity.publishDate?.time)
id `should equal` entity.streamId
artist `should equal` dateFormat.format(entity.publishDate?.time)
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.junit.Test

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -23,10 +23,10 @@ class APIPlaylistConverterTest {
val convertedEntity = entity.toMusicDirectoryDomainEntity()
with(convertedEntity) {
name `should equal to` entity.name
children.size `should equal to` entity.entriesList.size
children[0] `should equal` entity.entriesList[0].toDomainEntity()
children[1] `should equal` entity.entriesList[1].toDomainEntity()
name `should equal` entity.name
getAllChild().size `should equal to` entity.entriesList.size
getAllChild()[0] `should equal` entity.entriesList[0].toDomainEntity()
getAllChild()[1] `should equal` entity.entriesList[1].toDomainEntity()
}
}
@ -44,7 +44,7 @@ class APIPlaylistConverterTest {
name `should equal to` entity.name
comment `should equal to` entity.comment
owner `should equal to` entity.owner
public `should equal to` entity.public
public `should equal` entity.public
songCount `should equal to` entity.songCount.toString()
created `should equal to` playlistDateFormat.format(entity.created?.time)
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -20,11 +20,11 @@ class APIPodcastConverterTest {
val converterEntity = entity.toDomainEntity()
with(converterEntity) {
id = entity.id
description = entity.description
status = entity.status
title = entity.title
url = entity.url
id `should equal` entity.id
description `should equal` entity.description
status `should equal` entity.status
title `should equal` entity.title
url `should equal` entity.url
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -20,15 +20,15 @@ class APIShareConverterTest {
val domainEntity = entity.toDomainEntity()
with(domainEntity) {
id `should equal to` entity.id
url `should equal to` entity.url
description `should equal to` entity.description
username `should equal to` entity.username
created `should equal to` shareTimeFormat.format(entity.created?.time)
lastVisited `should equal to` shareTimeFormat.format(entity.lastVisited?.time)
expires `should equal to` shareTimeFormat.format(entity.expires?.time)
visitCount `should equal to` entity.visitCount.toLong()
entries `should equal` entity.items.toDomainEntityList()
id `should equal` entity.id
url `should equal` entity.url
description `should equal` entity.description
username `should equal` entity.username
created `should equal` shareTimeFormat.format(entity.created?.time)
lastVisited `should equal` shareTimeFormat.format(entity.lastVisited?.time)
expires `should equal` shareTimeFormat.format(entity.expires?.time)
visitCount `should equal` entity.visitCount.toLong()
this.getEntries() `should equal` entity.items.toDomainEntityList()
}
}

View File

@ -1,8 +1,9 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
import org.junit.Test
import org.moire.ultrasonic.api.subsonic.models.User
@ -22,7 +23,7 @@ class APIUserConverterTest {
commentRole `should equal to` entity.commentRole
coverArtRole `should equal to` entity.coverArtRole
downloadRole `should equal to` entity.downloadRole
email `should equal to` entity.email
email `should equal` entity.email
jukeboxRole `should equal to` entity.jukeboxRole
playlistRole `should equal to` entity.playlistRole
podcastRole `should equal to` entity.podcastRole
@ -31,7 +32,7 @@ class APIUserConverterTest {
shareRole `should equal to` entity.shareRole
streamRole `should equal to` entity.streamRole
uploadRole `should equal to` entity.uploadRole
userName `should equal to` entity.username
userName `should equal` entity.username
}
}
}

View File

@ -1,6 +1,6 @@
@file:Suppress("IllegalIdentifier")
package org.moire.ultrasonic.data
package org.moire.ultrasonic.domain
import org.amshove.kluent.`should equal to`
import org.amshove.kluent.`should equal`
@ -18,8 +18,8 @@ class ApiGenreConverterTest {
val domainEntity = entity.toDomainEntity()
with(domainEntity) {
name `should equal to` entity.name
index `should equal to` "s"
name `should equal` entity.name
index `should equal` "s"
}
}