diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java index 9cb9eecb..0075447e 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java @@ -32,6 +32,7 @@ import com.google.common.collect.Sets; import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.SyncthingApp; import com.nutomic.syncthingandroid.service.SyncthingService; +import com.nutomic.syncthingandroid.service.SyncthingServiceBinder; import com.nutomic.syncthingandroid.util.Util; import java.io.File; @@ -156,7 +157,8 @@ public class FolderPickerActivity extends SyncthingActivity @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { super.onServiceConnected(componentName, iBinder); - getService().registerOnServiceStateChangeListener(this); + SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder; + syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this); } @Override diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java index 148fce1c..5670cbdf 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java @@ -51,6 +51,7 @@ import com.nutomic.syncthingandroid.fragments.DrawerFragment; import com.nutomic.syncthingandroid.fragments.FolderListFragment; import com.nutomic.syncthingandroid.model.Options; import com.nutomic.syncthingandroid.service.SyncthingService; +import com.nutomic.syncthingandroid.service.SyncthingServiceBinder; import com.nutomic.syncthingandroid.util.Util; import java.util.Date; @@ -286,9 +287,11 @@ public class MainActivity extends StateDialogActivity @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { super.onServiceConnected(componentName, iBinder); - getService().registerOnServiceStateChangeListener(this); - getService().registerOnServiceStateChangeListener(mFolderListFragment); - getService().registerOnServiceStateChangeListener(mDeviceListFragment); + SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder; + SyncthingService syncthingService = syncthingServiceBinder.getService(); + syncthingService.registerOnServiceStateChangeListener(this); + syncthingService.registerOnServiceStateChangeListener(mFolderListFragment); + syncthingService.registerOnServiceStateChangeListener(mDeviceListFragment); } /** diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java index 847abd4c..827f2cbb 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/SyncthingActivity.java @@ -69,8 +69,8 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { - SyncthingServiceBinder binder = (SyncthingServiceBinder) iBinder; - mSyncthingService = binder.getService(); + SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder; + mSyncthingService = syncthingServiceBinder.getService(); Stream.of(mServiceConnectedListeners).forEach(OnServiceConnectedListener::onServiceConnected); mServiceConnectedListeners.clear(); } diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/WebGuiActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/WebGuiActivity.java index 5512d2bb..1b5f2b1e 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/WebGuiActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/WebGuiActivity.java @@ -23,6 +23,7 @@ import android.webkit.WebViewClient; import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.service.Constants; import com.nutomic.syncthingandroid.service.SyncthingService; +import com.nutomic.syncthingandroid.service.SyncthingServiceBinder; import com.nutomic.syncthingandroid.util.ConfigXml; import java.io.File; @@ -149,7 +150,8 @@ public class WebGuiActivity extends StateDialogActivity @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { super.onServiceConnected(componentName, iBinder); - getService().registerOnServiceStateChangeListener(this); + SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder; + syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this); } @Override diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index a5e83806..50db28eb 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -7,7 +7,6 @@ import android.content.SharedPreferences; import android.Manifest; import android.os.AsyncTask; import android.os.Handler; -import android.os.IBinder; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.util.Log; @@ -388,7 +387,7 @@ public class SyncthingService extends Service { } @Override - public IBinder onBind(Intent intent) { + public SyncthingServiceBinder onBind(Intent intent) { return mBinder; }