Cleanup code
This commit is contained in:
parent
30bbeb7594
commit
d8b032e2e3
|
@ -35,6 +35,9 @@ exceptions:
|
|||
|
||||
empty-blocks:
|
||||
active: true
|
||||
EmptyFunctionBlock:
|
||||
active: true
|
||||
ignoreOverridden: true
|
||||
|
||||
complexity:
|
||||
active: true
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,66 +16,28 @@
|
|||
|
||||
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
|
||||
*/
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
override fun updateProgress(messageId: Int) {}
|
||||
override fun updateProgress(message: String) {}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
|||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>) {
|
||||
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||
cachedPlaylists.clear()
|
||||
musicService.createPlaylist(id, name, entries)
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ interface MusicService {
|
|||
fun getPlaylists(refresh: Boolean): List<Playlist>
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>)
|
||||
fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>)
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun deletePlaylist(id: String)
|
||||
|
|
|
@ -221,7 +221,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@Throws(Exception::class)
|
||||
override fun createPlaylist(id: String, name: String, entries: List<MusicDirectory.Entry>) {
|
||||
override fun createPlaylist(id: String?, name: String?, entries: List<MusicDirectory.Entry>) {
|
||||
val playlistFile =
|
||||
FileUtil.getPlaylistFile(activeServerProvider.getActiveServer().name, name)
|
||||
val fw = FileWriter(playlistFile)
|
||||
|
|
|
@ -295,12 +295,20 @@ open class RESTMusicService(
|
|||
return response.body()!!.playlists.toDomainEntitiesList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Either ID or String is required.
|
||||
* ID is required when updating
|
||||
* String is required when creating
|
||||
*/
|
||||
@Throws(Exception::class)
|
||||
override fun createPlaylist(
|
||||
id: String,
|
||||
name: String,
|
||||
id: String?,
|
||||
name: String?,
|
||||
entries: List<MusicDirectory.Entry>
|
||||
) {
|
||||
if (id == null && name == null)
|
||||
throw IllegalArgumentException("Either id or name is required.")
|
||||
|
||||
val pSongIds: MutableList<String> = ArrayList(entries.size)
|
||||
|
||||
for ((id1) in entries) {
|
||||
|
|
Loading…
Reference in New Issue