mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Context handling made consistent
This commit is contained in:
parent
4460e43145
commit
aef73a5263
3 changed files with 11 additions and 13 deletions
|
@ -41,14 +41,14 @@ public class OwnCloudFileObserver extends FileObserver {
|
|||
|
||||
public static int CHANGES_ONLY = CLOSE_WRITE;
|
||||
|
||||
private static String TAG = "OwnCloudFileObserver";
|
||||
private static String TAG = OwnCloudFileObserver.class.getSimpleName();
|
||||
private String mPath;
|
||||
private int mMask;
|
||||
DataStorageManager mStorage;
|
||||
Account mOCAccount;
|
||||
OCFile mFile;
|
||||
static Context mContext; // ISSUE 4: why is this static?
|
||||
List<FileObserverStatusListener> mListeners;
|
||||
private DataStorageManager mStorage;
|
||||
private Account mOCAccount;
|
||||
private OCFile mFile;
|
||||
private Context mContext;
|
||||
private List<FileObserverStatusListener> mListeners;
|
||||
|
||||
public OwnCloudFileObserver(String path) {
|
||||
this(path, ALL_EVENTS);
|
||||
|
@ -101,7 +101,7 @@ public class OwnCloudFileObserver extends FileObserver {
|
|||
return;
|
||||
}
|
||||
WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(mOCAccount, mContext);
|
||||
SynchronizeFileOperation sfo = new SynchronizeFileOperation(mFile.getRemotePath(), mStorage, mOCAccount, mContext);
|
||||
SynchronizeFileOperation sfo = new SynchronizeFileOperation(mFile.getRemotePath(), mStorage, mOCAccount);
|
||||
RemoteOperationResult result = sfo.execute(wc);
|
||||
|
||||
if (result.getExtraData() == Boolean.TRUE) {
|
||||
|
|
|
@ -158,12 +158,12 @@ public class FileObserverService extends Service implements FileObserverStatusLi
|
|||
observer = mObservers.get(i);
|
||||
if (observer.getPath().equals(path))
|
||||
duplicate = true;
|
||||
observer.setContext(getBaseContext());
|
||||
observer.setContext(getApplicationContext());
|
||||
}
|
||||
if (duplicate) return;
|
||||
observer = new OwnCloudFileObserver(path, OwnCloudFileObserver.CHANGES_ONLY);
|
||||
observer.setContext(getBaseContext());
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(getBaseContext());
|
||||
observer.setContext(getApplicationContext());
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
|
||||
observer.setAccount(account);
|
||||
FileDataStorageManager storage =
|
||||
new FileDataStorageManager(account, getContentResolver());
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.jackrabbit.webdav.MultiStatus;
|
|||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.owncloud.android.datamodel.DataStorageManager;
|
||||
|
@ -46,8 +45,7 @@ public class SynchronizeFileOperation extends RemoteOperation {
|
|||
public SynchronizeFileOperation(
|
||||
String remotePath,
|
||||
DataStorageManager dataStorageManager,
|
||||
Account account,
|
||||
Context context ) {
|
||||
Account account) {
|
||||
mRemotePath = remotePath;
|
||||
mStorageManager = dataStorageManager;
|
||||
mAccount = account;
|
||||
|
|
Loading…
Reference in a new issue