mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
Fix ClassCastException in SyncthingService onCreate (fixes #1150)
This commit is contained in:
parent
b93da522e1
commit
eb1266508f
5 changed files with 15 additions and 9 deletions
|
@ -32,6 +32,7 @@ import com.google.common.collect.Sets;
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
import com.nutomic.syncthingandroid.SyncthingApp;
|
import com.nutomic.syncthingandroid.SyncthingApp;
|
||||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||||
|
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
|
||||||
import com.nutomic.syncthingandroid.util.Util;
|
import com.nutomic.syncthingandroid.util.Util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -156,7 +157,8 @@ public class FolderPickerActivity extends SyncthingActivity
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||||
super.onServiceConnected(componentName, iBinder);
|
super.onServiceConnected(componentName, iBinder);
|
||||||
getService().registerOnServiceStateChangeListener(this);
|
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
|
||||||
|
syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,6 +51,7 @@ import com.nutomic.syncthingandroid.fragments.DrawerFragment;
|
||||||
import com.nutomic.syncthingandroid.fragments.FolderListFragment;
|
import com.nutomic.syncthingandroid.fragments.FolderListFragment;
|
||||||
import com.nutomic.syncthingandroid.model.Options;
|
import com.nutomic.syncthingandroid.model.Options;
|
||||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||||
|
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
|
||||||
import com.nutomic.syncthingandroid.util.Util;
|
import com.nutomic.syncthingandroid.util.Util;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -286,9 +287,11 @@ public class MainActivity extends StateDialogActivity
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||||
super.onServiceConnected(componentName, iBinder);
|
super.onServiceConnected(componentName, iBinder);
|
||||||
getService().registerOnServiceStateChangeListener(this);
|
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
|
||||||
getService().registerOnServiceStateChangeListener(mFolderListFragment);
|
SyncthingService syncthingService = syncthingServiceBinder.getService();
|
||||||
getService().registerOnServiceStateChangeListener(mDeviceListFragment);
|
syncthingService.registerOnServiceStateChangeListener(this);
|
||||||
|
syncthingService.registerOnServiceStateChangeListener(mFolderListFragment);
|
||||||
|
syncthingService.registerOnServiceStateChangeListener(mDeviceListFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,8 +69,8 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||||
SyncthingServiceBinder binder = (SyncthingServiceBinder) iBinder;
|
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
|
||||||
mSyncthingService = binder.getService();
|
mSyncthingService = syncthingServiceBinder.getService();
|
||||||
Stream.of(mServiceConnectedListeners).forEach(OnServiceConnectedListener::onServiceConnected);
|
Stream.of(mServiceConnectedListeners).forEach(OnServiceConnectedListener::onServiceConnected);
|
||||||
mServiceConnectedListeners.clear();
|
mServiceConnectedListeners.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.webkit.WebViewClient;
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
import com.nutomic.syncthingandroid.service.Constants;
|
import com.nutomic.syncthingandroid.service.Constants;
|
||||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||||
|
import com.nutomic.syncthingandroid.service.SyncthingServiceBinder;
|
||||||
import com.nutomic.syncthingandroid.util.ConfigXml;
|
import com.nutomic.syncthingandroid.util.ConfigXml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -149,7 +150,8 @@ public class WebGuiActivity extends StateDialogActivity
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||||
super.onServiceConnected(componentName, iBinder);
|
super.onServiceConnected(componentName, iBinder);
|
||||||
getService().registerOnServiceStateChangeListener(this);
|
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
|
||||||
|
syncthingServiceBinder.getService().registerOnServiceStateChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.content.SharedPreferences;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -388,7 +387,7 @@ public class SyncthingService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public SyncthingServiceBinder onBind(Intent intent) {
|
||||||
return mBinder;
|
return mBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue