mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 19:50:35 +01:00
Cleanup code
This commit is contained in:
parent
30bbeb7594
commit
d8b032e2e3
@ -35,6 +35,9 @@ exceptions:
|
|||||||
|
|
||||||
empty-blocks:
|
empty-blocks:
|
||||||
active: true
|
active: true
|
||||||
|
EmptyFunctionBlock:
|
||||||
|
active: true
|
||||||
|
ignoreOverridden: true
|
||||||
|
|
||||||
complexity:
|
complexity:
|
||||||
active: true
|
active: true
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -16,66 +16,28 @@
|
|||||||
|
|
||||||
Copyright 2010 (C) Sindre Mehus
|
Copyright 2010 (C) Sindre Mehus
|
||||||
*/
|
*/
|
||||||
package org.moire.ultrasonic.util;
|
package org.moire.ultrasonic.util
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sindre Mehus
|
* @author Sindre Mehus
|
||||||
*/
|
*/
|
||||||
public abstract class SilentBackgroundTask<T> extends BackgroundTask<T>
|
abstract class SilentBackgroundTask<T>(activity: Activity?) : BackgroundTask<T>(activity) {
|
||||||
{
|
override fun execute() {
|
||||||
|
val thread: Thread = object : Thread() {
|
||||||
|
override fun run() {
|
||||||
|
try {
|
||||||
|
val result = doInBackground()
|
||||||
|
handler.post { done(result) }
|
||||||
|
} catch (all: Throwable) {
|
||||||
|
handler.post { error(all) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread.start()
|
||||||
|
}
|
||||||
|
|
||||||
public SilentBackgroundTask(Activity activity)
|
override fun updateProgress(messageId: Int) {}
|
||||||
{
|
override fun updateProgress(message: String) {}
|
||||||
super(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute()
|
|
||||||
{
|
|
||||||
Thread thread = new Thread()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final T result = doInBackground();
|
|
||||||
|
|
||||||
getHandler().post(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
done(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (final Throwable t)
|
|
||||||
{
|
|
||||||
getHandler().post(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
error(t);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgress(int messageId)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgress(String message)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>) {
|
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||||
cachedPlaylists.clear()
|
cachedPlaylists.clear()
|
||||||
musicService.createPlaylist(id, name, entries)
|
musicService.createPlaylist(id, name, entries)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ interface MusicService {
|
|||||||
fun getPlaylists(refresh: Boolean): List<Playlist>
|
fun getPlaylists(refresh: Boolean): List<Playlist>
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>)
|
fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>)
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun deletePlaylist(id: String)
|
fun deletePlaylist(id: String)
|
||||||
|
@ -221,7 +221,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||||||
|
|
||||||
@Suppress("TooGenericExceptionCaught")
|
@Suppress("TooGenericExceptionCaught")
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>) {
|
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||||
val playlistFile =
|
val playlistFile =
|
||||||
FileUtil.getPlaylistFile(activeServerProvider.getActiveServer().name, name)
|
FileUtil.getPlaylistFile(activeServerProvider.getActiveServer().name, name)
|
||||||
val fw = FileWriter(playlistFile)
|
val fw = FileWriter(playlistFile)
|
||||||
|
@ -295,12 +295,20 @@ open class RESTMusicService(
|
|||||||
return response.body()!!.playlists.toDomainEntitiesList()
|
return response.body()!!.playlists.toDomainEntitiesList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Either ID or String is required.
|
||||||
|
* ID is required when updating
|
||||||
|
* String is required when creating
|
||||||
|
*/
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun createPlaylist(
|
override fun createPlaylist(
|
||||||
id: String,
|
id: String?,
|
||||||
name: String,
|
name: String?,
|
||||||
entries: List<MusicDirectory.Entry>
|
entries: List<MusicDirectory.Entry>
|
||||||
) {
|
) {
|
||||||
|
if (id == null && name == null)
|
||||||
|
throw IllegalArgumentException("Either id or name is required.")
|
||||||
|
|
||||||
val pSongIds: MutableList<String> = ArrayList(entries.size)
|
val pSongIds: MutableList<String> = ArrayList(entries.size)
|
||||||
|
|
||||||
for ((id1) in entries) {
|
for ((id1) in entries) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user