mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-27 06:41:15 +00:00
Add FolderObservers in background thread (fixes #262).
This commit is contained in:
parent
6f4741daee
commit
2bac0d9504
1 changed files with 11 additions and 9 deletions
|
@ -27,12 +27,9 @@ import com.nutomic.syncthingandroid.util.FolderObserver;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOError;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -290,14 +287,19 @@ public class SyncthingService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onApiAvailable() {
|
public void onApiAvailable() {
|
||||||
onApiChange();
|
onApiChange();
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
for (RestApi.Folder r : mApi.getFolders()) {
|
for (RestApi.Folder r : mApi.getFolders()) {
|
||||||
try {
|
try {
|
||||||
mObservers.add(new FolderObserver(mApi, r));
|
mObservers.add(new FolderObserver(mApi, r));
|
||||||
} catch (FolderObserver.FolderNotExistingException e) {
|
} catch (FolderObserver.FolderNotExistingException e) {
|
||||||
Log.w(TAG, e.getMessage());
|
Log.w(TAG, "Failed to add observer for folder", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
registerOnWebGuiAvailableListener(mApi);
|
registerOnWebGuiAvailableListener(mApi);
|
||||||
Log.i(TAG, "Web GUI will be available at " + mConfig.getWebGuiUrl());
|
Log.i(TAG, "Web GUI will be available at " + mConfig.getWebGuiUrl());
|
||||||
|
|
Loading…
Reference in a new issue