fix codacy issues

This commit is contained in:
David Luhmer 2018-12-27 13:22:39 +01:00
parent 62ebc7b82f
commit 5e11303e87
2 changed files with 14 additions and 17 deletions

View file

@ -133,9 +133,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
private static MenuItem menuItemUpdater; private static MenuItem menuItemUpdater;
private static MenuItem menuItemDownloadMoreItems; private static MenuItem menuItemDownloadMoreItems;
//private Date mLastSyncDate = new Date(0);
private boolean mSyncOnStartupPerformed = false;
protected @BindView(R.id.toolbar) Toolbar toolbar; protected @BindView(R.id.toolbar) Toolbar toolbar;
//private ServiceConnection mConnection = null; //private ServiceConnection mConnection = null;

View file

@ -98,9 +98,9 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
private class NextcloudSyncResult { private class NextcloudSyncResult {
final List<Folder> folders; private final List<Folder> folders;
final List<Feed> feeds; private final List<Feed> feeds;
final boolean stateSyncSuccessful; private final boolean stateSyncSuccessful;
NextcloudSyncResult(List<Folder> folders, List<Feed> feeds, Boolean stateSyncSuccessful) { NextcloudSyncResult(List<Folder> folders, List<Feed> feeds, Boolean stateSyncSuccessful) {
this.folders = folders; this.folders = folders;
@ -113,7 +113,7 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
// Start sync // Start sync
private void sync() { private void sync() {
if(mApi.getAPI() == null) { if(mApi.getAPI() == null) {
ThrowException(new IllegalStateException("API is NOT initialized")); throwException(new IllegalStateException("API is NOT initialized"));
Log.e(TAG, "API is NOT initialized.."); Log.e(TAG, "API is NOT initialized..");
} else { } else {
Log.v(TAG, "API is initialized.."); Log.v(TAG, "API is initialized..");
@ -164,12 +164,13 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
InsertIntoDatabase.InsertFoldersIntoDatabase(syncResult.folders, dbConn); InsertIntoDatabase.InsertFoldersIntoDatabase(syncResult.folders, dbConn);
InsertIntoDatabase.InsertFeedsIntoDatabase(syncResult.feeds, dbConn); InsertIntoDatabase.InsertFeedsIntoDatabase(syncResult.feeds, dbConn);
Log.v(TAG, "State sync successful: " + syncResult.stateSyncSuccessful);
// Start the sync (Rss Items) // Start the sync (Rss Items)
syncRssItems(dbConn); syncRssItems(dbConn);
} catch(Exception ex) { } catch(Exception ex) {
//Log.e(TAG, "ThrowException: ", ex); //Log.e(TAG, "throwException: ", ex);
ThrowException(ex); throwException(ex);
} }
} }
@ -205,7 +206,7 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
@Override @Override
public void onError(@NonNull Throwable e) { public void onError(@NonNull Throwable e) {
Log.v(TAG, "[syncRssItems] - onError() called with: throwable = [" + e + "]"); Log.v(TAG, "[syncRssItems] - onError() called with: throwable = [" + e + "]");
ThrowException(e); throwException(e);
} }
@Override @Override
@ -216,8 +217,8 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
} }
private void ThrowException(Throwable ex) { private void throwException(Throwable ex) {
Log.e(TAG, "ThrowException() called [" + Thread.currentThread().getName() + "]", ex); Log.e(TAG, "throwException() called [" + Thread.currentThread().getName() + "]", ex);
syncRunning = false; syncRunning = false;
if(ex instanceof Exception) { if(ex instanceof Exception) {
EventBus.getDefault().post(SyncFailedEvent.create(OkHttpSSLClient.HandleExceptions((Exception) ex))); EventBus.getDefault().post(SyncFailedEvent.create(OkHttpSSLClient.HandleExceptions((Exception) ex)));
@ -234,13 +235,12 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
//int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0); //int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
if(newItemsCount > 0) { if(newItemsCount > 0) {
String foregroundActivityPackageName = getForegroundActivityPackageName(); String fgActivityPackageName = getForegroundActivityPackageName();
boolean showNotifcationOnNewArticles = mPrefs.getBoolean(SettingsActivity.CB_SHOW_NOTIFICATION_NEW_ARTICLES_STRING, true);
// If another app is opened show a notification // If another app is opened show a notification
if (!foregroundActivityPackageName.equals(getContext().getPackageName())) { if (!fgActivityPackageName.equals(getContext().getPackageName()) && showNotifcationOnNewArticles) {
if (mPrefs.getBoolean(SettingsActivity.CB_SHOW_NOTIFICATION_NEW_ARTICLES_STRING, true)) { NextcloudNotificationManager.showUnreadRssItemsNotification(getContext(), newItemsCount);
NextcloudNotificationManager.showUnreadRssItemsNotification(getContext(), newItemsCount);
}
} }
} }
} }