From c3b027e8b5e6b1f20d6c404981d4f9570c04dabe Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 18 Aug 2014 00:55:01 +0200 Subject: [PATCH] Optimized imports, removed unused function, removed assert. --- .../syncthingandroid/fragments/RepoSettingsFragment.java | 5 ----- .../syncthingandroid/fragments/SettingsFragment.java | 7 ------- .../syncthingandroid/syncthing/DeviceStateHolder.java | 2 -- .../syncthingandroid/syncthing/NetworkReceiver.java | 4 ---- .../com/nutomic/syncthingandroid/syncthing/RestApi.java | 9 ++++----- 5 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java index adf2ad8f..bf20f6c2 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java @@ -2,14 +2,10 @@ package com.nutomic.syncthingandroid.fragments; import android.app.Activity; import android.app.AlertDialog; -import android.content.ComponentName; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.ServiceConnection; import android.os.Bundle; import android.os.Environment; -import android.os.IBinder; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; @@ -26,7 +22,6 @@ import com.nutomic.syncthingandroid.activities.SettingsActivity; import com.nutomic.syncthingandroid.activities.SyncthingActivity; import com.nutomic.syncthingandroid.syncthing.RestApi; import com.nutomic.syncthingandroid.syncthing.SyncthingService; -import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder; import com.nutomic.syncthingandroid.util.ExtendedCheckBoxPreference; import java.util.ArrayList; diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java index 4ad777be..39eb866f 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java @@ -1,18 +1,12 @@ package com.nutomic.syncthingandroid.fragments; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; import android.os.Bundle; -import android.os.IBinder; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.PreferenceScreen; import android.support.v4.app.NavUtils; import android.support.v4.preference.PreferenceFragment; -import android.support.v7.app.ActionBarActivity; import android.text.InputType; import android.view.MenuItem; @@ -20,7 +14,6 @@ import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.activities.SyncthingActivity; import com.nutomic.syncthingandroid.syncthing.RestApi; import com.nutomic.syncthingandroid.syncthing.SyncthingService; -import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder; public class SettingsFragment extends PreferenceFragment implements SyncthingActivity.OnServiceConnectedListener, diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java index ecb8e228..97c1f52c 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/DeviceStateHolder.java @@ -3,10 +3,8 @@ package com.nutomic.syncthingandroid.syncthing; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.net.ConnectivityManager; import android.os.BatteryManager; -import android.util.Log; /** * Holds information about the current wifi and charging state of the device. diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/NetworkReceiver.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/NetworkReceiver.java index 73d9b352..7a1c054c 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/NetworkReceiver.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/NetworkReceiver.java @@ -3,12 +3,8 @@ package com.nutomic.syncthingandroid.syncthing; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.os.BatteryManager; -import android.preference.PreferenceManager; -import android.util.Log; /** * Receives network connection change intents and sends the wifi state to {@link SyncthingService}. diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index b2b71585..8c34f996 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -17,6 +17,7 @@ import android.util.Log; import android.view.WindowManager; import android.widget.Toast; +import com.nutomic.syncthingandroid.BuildConfig; import com.nutomic.syncthingandroid.R; import org.json.JSONArray; @@ -231,7 +232,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { */ private void tryIsAvailable() { int value = mAvailableCount.incrementAndGet(); - assert(value <= TOTAL_STARTUP_CALLS); + if (BuildConfig.DEBUG && value > TOTAL_STARTUP_CALLS) { + throw new AssertionError("Too many startup calls"); + } if (value == TOTAL_STARTUP_CALLS) { mSyncthingService.onApiChange(); } @@ -855,10 +858,6 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener { }.execute(mUrl, GetTask.URI_NODEID, mApiKey, "id", id); } - public boolean isApiAvailable() { - return mAvailableCount.get() == TOTAL_STARTUP_CALLS; - } - /** * Shares the given node id via Intent. Must be called from an Activity. */