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