Misc refactor

This commit is contained in:
Andrew Rabert 2018-12-03 20:08:27 -05:00
parent 665bbb3788
commit e5702c1761
15 changed files with 43 additions and 44 deletions

View File

@ -827,7 +827,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
if (service != null) { if (service != null) {
new SilentBackgroundTask<Void>(this) { new SilentBackgroundTask<Void>(this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
service.clearIncomplete(); service.clearIncomplete();
return null; return null;
} }

View File

@ -233,7 +233,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
rewindButton = findViewById(R.id.download_rewind); rewindButton = findViewById(R.id.download_rewind);
rewindButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { rewindButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
if (getDownloadService() != null) { if (getDownloadService() != null) {
getDownloadService().rewind(); getDownloadService().rewind();
} }
@ -244,7 +244,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
previousButton = findViewById(R.id.download_previous); previousButton = findViewById(R.id.download_previous);
previousButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { previousButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
if (getDownloadService() != null) { if (getDownloadService() != null) {
getDownloadService().previous(); getDownloadService().previous();
} }
@ -255,7 +255,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
startButton = findViewById(R.id.download_start); startButton = findViewById(R.id.download_start);
startButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { startButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
PlayerState state = getDownloadService().getPlayerState(); PlayerState state = getDownloadService().getPlayerState();
if (state == PlayerState.STARTED) { if (state == PlayerState.STARTED) {
getDownloadService().pause(); getDownloadService().pause();
@ -269,7 +269,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
nextButton = findViewById(R.id.download_next); nextButton = findViewById(R.id.download_next);
nextButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { nextButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
if (getDownloadService() != null) { if (getDownloadService() != null) {
getDownloadService().next(); getDownloadService().next();
} }
@ -280,7 +280,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
fastforwardButton = findViewById(R.id.download_fastforward); fastforwardButton = findViewById(R.id.download_fastforward);
fastforwardButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { fastforwardButton.setOnClickListener(v -> new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
if (getDownloadService() == null) { if (getDownloadService() == null) {
return null; return null;
} }
@ -613,7 +613,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo
new SilentBackgroundTask<Void>(this) { new SilentBackgroundTask<Void>(this) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE); AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
Account account = new Account(Constants.SYNC_ACCOUNT_NAME, Constants.SYNC_ACCOUNT_TYPE); Account account = new Account(Constants.SYNC_ACCOUNT_NAME, Constants.SYNC_ACCOUNT_TYPE);
accountManager.addAccountExplicitly(account, null, null); accountManager.addAccountExplicitly(account, null, null);

View File

@ -91,7 +91,7 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
} }
@Override @Override
public List<DownloadFile> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { public List<DownloadFile> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) {
DownloadService downloadService = getDownloadService(); DownloadService downloadService = getDownloadService();
if (downloadService == null) { if (downloadService == null) {
return new ArrayList<>(); return new ArrayList<>();
@ -139,7 +139,7 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
case R.id.menu_remove_all: case R.id.menu_remove_all:
Util.confirmDialog(context, R.string.download_menu_remove_all, "", (dialog, which) -> new SilentBackgroundTask<Void>(context) { Util.confirmDialog(context, R.string.download_menu_remove_all, "", (dialog, which) -> new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().clearBackground(); getDownloadService().clearBackground();
return null; return null;
} }

View File

@ -65,7 +65,7 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
} }
@Override @Override
public List<Integer> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { public List<Integer> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) {
return Collections.singletonList(0); return Collections.singletonList(0);
} }

View File

@ -191,7 +191,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
warnIfStorageUnavailable(); warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().previous(); getDownloadService().previous();
return null; return null;
} }
@ -204,7 +204,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
warnIfStorageUnavailable(); warnIfStorageUnavailable();
new SilentBackgroundTask<Boolean>(context) { new SilentBackgroundTask<Boolean>(context) {
@Override @Override
protected Boolean doInBackground() throws Throwable { protected Boolean doInBackground() {
getDownloadService().next(); getDownloadService().next();
return true; return true;
} }
@ -222,7 +222,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
pauseButton.setOnClickListener(view -> new SilentBackgroundTask<Void>(context) { pauseButton.setOnClickListener(view -> new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().pause(); getDownloadService().pause();
return null; return null;
} }
@ -230,7 +230,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
stopButton.setOnClickListener(view -> new SilentBackgroundTask<Void>(context) { stopButton.setOnClickListener(view -> new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().reset(); getDownloadService().reset();
return null; return null;
} }
@ -240,7 +240,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
warnIfStorageUnavailable(); warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
start(); start();
return null; return null;
} }
@ -286,7 +286,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
public void onStopTrackingTouch(final SeekBar seekBar) { public void onStopTrackingTouch(final SeekBar seekBar) {
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().seekTo(progressBar.getProgress()); getDownloadService().seekTo(progressBar.getProgress());
return null; return null;
} }
@ -421,7 +421,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
case R.id.menu_remove_all: case R.id.menu_remove_all:
Util.confirmDialog(context, R.string.download_menu_remove_all, "", (dialog, which) -> new SilentBackgroundTask<Void>(context) { Util.confirmDialog(context, R.string.download_menu_remove_all, "", (dialog, which) -> new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().setShufflePlayEnabled(false); getDownloadService().setShufflePlayEnabled(false);
getDownloadService().clear(); getDownloadService().clear();
return null; return null;
@ -444,7 +444,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
case R.id.menu_shuffle: case R.id.menu_shuffle:
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().shuffle(); getDownloadService().shuffle();
return null; return null;
} }
@ -674,7 +674,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
int seekTo; int seekTo;
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
if (rewind) { if (rewind) {
seekTo = downloadService.rewind(); seekTo = downloadService.rewind();
} else { } else {
@ -726,7 +726,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
warnIfStorageUnavailable(); warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
switch (performAction) { switch (performAction) {
case ACTION_NEXT: case ACTION_NEXT:
downloadService.next(); downloadService.next();
@ -774,7 +774,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
warnIfStorageUnavailable(); warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().play(item); getDownloadService().play(item);
return null; return null;
} }

View File

@ -176,7 +176,7 @@ public abstract class SelectRecyclerFragment<T> extends SubsonicFragment impleme
} }
@Override @Override
public List<T> doInBackground() throws Exception { public List<T> doInBackground() {
MusicService musicService = MusicServiceFactory.getMusicService(context); MusicService musicService = MusicServiceFactory.getMusicService(context);
objects = new ArrayList<>(); objects = new ArrayList<>();

View File

@ -51,7 +51,7 @@ public class SelectYearFragment extends SelectRecyclerFragment<String> {
} }
@Override @Override
public List<String> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { public List<String> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) {
List<String> decades = new ArrayList<>(); List<String> decades = new ArrayList<>();
for (int i = 2010; i >= 1800; i -= 10) { for (int i = 2010; i >= 1800; i -= 10) {
decades.add(String.valueOf(i)); decades.add(String.valueOf(i));

View File

@ -224,7 +224,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
this.findPreference("clearCache").setOnPreferenceClickListener(preference -> { this.findPreference("clearCache").setOnPreferenceClickListener(preference -> {
Util.confirmDialog(context, (dialog, which) -> new LoadingTask<Void>(context, false) { Util.confirmDialog(context, (dialog, which) -> new LoadingTask<Void>(context, false) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
FileUtil.deleteMusicDirectory(context); FileUtil.deleteMusicDirectory(context);
FileUtil.deleteSerializedCache(context); FileUtil.deleteSerializedCache(context);
FileUtil.deleteArtworkCache(context); FileUtil.deleteArtworkCache(context);

View File

@ -1151,7 +1151,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
new LoadingTask<Void>(context) { new LoadingTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
MediaStoreService mediaStore = new MediaStoreService(context); MediaStoreService mediaStore = new MediaStoreService(context);
FileUtil.recursiveDelete(dir, mediaStore); FileUtil.recursiveDelete(dir, mediaStore);
return null; return null;
@ -1176,7 +1176,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
private void deleteSongs(final List<Entry> songs) { private void deleteSongs(final List<Entry> songs) {
new LoadingTask<Void>(context) { new LoadingTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
getDownloadService().delete(songs); getDownloadService().delete(songs);
return null; return null;
} }
@ -1287,7 +1287,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
private void playNow(final List<Entry> entries, final Entry song, final String playlistName, final String playlistId) { private void playNow(final List<Entry> entries, final Entry song, final String playlistName, final String playlistId) {
new LoadingTask<Void>(context) { new LoadingTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
playNowInTask(entries, song, playlistName, playlistId); playNowInTask(entries, song, playlistName, playlistId);
return null; return null;
} }

View File

@ -617,7 +617,7 @@ public class CachedMusicService implements MusicService {
} }
@Override @Override
public User getUser(boolean refresh, String username, Context context, ProgressListener progressListener) throws Exception { public User getUser(boolean refresh, String username, Context context, ProgressListener progressListener) {
User result = null; User result = null;
try { try {

View File

@ -62,12 +62,12 @@ public class OfflineMusicService implements MusicService {
private static final Random random = new Random(); private static final Random random = new Random();
@Override @Override
public void ping(Context context, ProgressListener progressListener) throws Exception { public void ping(Context context, ProgressListener progressListener) {
} }
@Override @Override
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception { public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) {
List<Artist> artists = new ArrayList<>(); List<Artist> artists = new ArrayList<>();
List<Entry> entries = new ArrayList<>(); List<Entry> entries = new ArrayList<>();
File root = FileUtil.getMusicDirectory(context); File root = FileUtil.getMusicDirectory(context);
@ -91,7 +91,7 @@ public class OfflineMusicService implements MusicService {
return getMusicDirectory(id, context); return getMusicDirectory(id, context);
} }
private MusicDirectory getMusicDirectory(String id, Context context) throws Exception { private MusicDirectory getMusicDirectory(String id, Context context) {
File dir = new File(id); File dir = new File(id);
MusicDirectory result = new MusicDirectory(); MusicDirectory result = new MusicDirectory();
result.setName(dir.getName()); result.setName(dir.getName());
@ -186,7 +186,7 @@ public class OfflineMusicService implements MusicService {
} }
@Override @Override
public Bitmap getCoverArt(Context context, Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception { public Bitmap getCoverArt(Context context, Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) {
try { try {
return FileUtil.getAlbumArtBitmap(context, entry, size); return FileUtil.getAlbumArtBitmap(context, entry, size);
} catch (Exception e) { } catch (Exception e) {
@ -205,7 +205,7 @@ public class OfflineMusicService implements MusicService {
} }
@Override @Override
public SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) throws Exception { public SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) {
List<Artist> artists = new ArrayList<>(); List<Artist> artists = new ArrayList<>();
List<Entry> albums = new ArrayList<>(); List<Entry> albums = new ArrayList<>();
List<Entry> songs = new ArrayList<>(); List<Entry> songs = new ArrayList<>();
@ -294,7 +294,7 @@ public class OfflineMusicService implements MusicService {
} }
@Override @Override
public List<Playlist> getPlaylists(boolean refresh, Context context, ProgressListener progressListener) throws Exception { public List<Playlist> getPlaylists(boolean refresh, Context context, ProgressListener progressListener) {
List<Playlist> playlists = new ArrayList<>(); List<Playlist> playlists = new ArrayList<>();
File root = FileUtil.getPlaylistDirectory(context); File root = FileUtil.getPlaylistDirectory(context);
String lastServer = null; String lastServer = null;
@ -481,7 +481,7 @@ public class OfflineMusicService implements MusicService {
} }
@Override @Override
public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception { public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) {
File root = FileUtil.getMusicDirectory(context); File root = FileUtil.getMusicDirectory(context);
List<File> children = new LinkedList<>(); List<File> children = new LinkedList<>();
listFilesRecursively(root, children); listFilesRecursively(root, children);

View File

@ -729,7 +729,7 @@ public class RESTMusicService implements MusicService {
} }
@Override @Override
public void setInstance(Integer instance) throws Exception { public void setInstance(Integer instance) {
this.instance = instance; this.instance = instance;
} }

View File

@ -22,7 +22,6 @@ package net.nullsum.audinaut.service.sync;
import android.accounts.AbstractAccountAuthenticator; import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse; import android.accounts.AccountAuthenticatorResponse;
import android.accounts.NetworkErrorException;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -58,17 +57,17 @@ public class AuthenticatorService extends Service {
} }
@Override @Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException { public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) {
return null; return null;
} }
@Override @Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException { public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
return null; return null;
} }
@Override @Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) {
return null; return null;
} }
@ -78,12 +77,12 @@ public class AuthenticatorService extends Service {
} }
@Override @Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) {
return null; return null;
} }
@Override @Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException { public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) {
return null; return null;
} }
} }

View File

@ -68,7 +68,7 @@ public class DownloadFileItemHelperCallback extends ItemTouchHelper.SimpleCallba
pendingTask = new SilentBackgroundTask<Void>(downloadService) { pendingTask = new SilentBackgroundTask<Void>(downloadService) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
boolean running = true; boolean running = true;
while (running) { while (running) {
Object nextOperation = null; Object nextOperation = null;

View File

@ -99,7 +99,7 @@ public class ImageLoader {
nowPlayingSmall = null; nowPlayingSmall = null;
new SilentBackgroundTask<Void>(context) { new SilentBackgroundTask<Void>(context) {
@Override @Override
protected Void doInBackground() throws Throwable { protected Void doInBackground() {
clearingCache = true; clearingCache = true;
cache.evictAll(); cache.evictAll();
clearingCache = false; clearingCache = false;