|
@@ -48,22 +48,15 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
|
|
|
|
|
|
private static final String TAG = RemoteTrashbinRepository.class.getSimpleName();
|
|
private static final String TAG = RemoteTrashbinRepository.class.getSimpleName();
|
|
|
|
|
|
- private String userId;
|
|
|
|
private OwnCloudClient client;
|
|
private OwnCloudClient client;
|
|
|
|
|
|
RemoteTrashbinRepository(final Context context, final Account account) {
|
|
RemoteTrashbinRepository(final Context context, final Account account) {
|
|
- AccountManager platformAccountManager = AccountManager.get(context);
|
|
|
|
try {
|
|
try {
|
|
OwnCloudAccount nextcloudAccount = new OwnCloudAccount(account, context);
|
|
OwnCloudAccount nextcloudAccount = new OwnCloudAccount(account, context);
|
|
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(nextcloudAccount, context);
|
|
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(nextcloudAccount, context);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
Log_OC.e(TAG, e.getMessage());
|
|
Log_OC.e(TAG, e.getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
- userId = platformAccountManager.getUserData(
|
|
|
|
- account,
|
|
|
|
- com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID
|
|
|
|
- );
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void removeTrashbinFile(TrashbinFile file, OperationCallback callback) {
|
|
public void removeTrashbinFile(TrashbinFile file, OperationCallback callback) {
|
|
@@ -99,24 +92,22 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
|
|
}
|
|
}
|
|
|
|
|
|
public void emptyTrashbin(OperationCallback callback) {
|
|
public void emptyTrashbin(OperationCallback callback) {
|
|
- new EmptyTrashbinTask(client, userId, callback).execute();
|
|
|
|
|
|
+ new EmptyTrashbinTask(client, callback).execute();
|
|
}
|
|
}
|
|
|
|
|
|
private static class EmptyTrashbinTask extends AsyncTask<Void, Void, Boolean> {
|
|
private static class EmptyTrashbinTask extends AsyncTask<Void, Void, Boolean> {
|
|
|
|
|
|
private OwnCloudClient client;
|
|
private OwnCloudClient client;
|
|
- private String userId;
|
|
|
|
private OperationCallback callback;
|
|
private OperationCallback callback;
|
|
|
|
|
|
- private EmptyTrashbinTask(OwnCloudClient client, String userId, OperationCallback callback) {
|
|
|
|
|
|
+ private EmptyTrashbinTask(OwnCloudClient client, OperationCallback callback) {
|
|
this.client = client;
|
|
this.client = client;
|
|
- this.userId = userId;
|
|
|
|
this.callback = callback;
|
|
this.callback = callback;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected Boolean doInBackground(Void... voids) {
|
|
protected Boolean doInBackground(Void... voids) {
|
|
- EmptyTrashbinRemoteOperation emptyTrashbinFileOperation = new EmptyTrashbinRemoteOperation(userId);
|
|
|
|
|
|
+ EmptyTrashbinRemoteOperation emptyTrashbinFileOperation = new EmptyTrashbinRemoteOperation();
|
|
RemoteOperationResult result = emptyTrashbinFileOperation.execute(client);
|
|
RemoteOperationResult result = emptyTrashbinFileOperation.execute(client);
|
|
|
|
|
|
return result.isSuccess();
|
|
return result.isSuccess();
|
|
@@ -132,28 +123,26 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void restoreFile(TrashbinFile file, OperationCallback callback) {
|
|
public void restoreFile(TrashbinFile file, OperationCallback callback) {
|
|
- new RestoreTrashbinFileTask(file, userId, client, callback).execute();
|
|
|
|
|
|
+ new RestoreTrashbinFileTask(file, client, callback).execute();
|
|
}
|
|
}
|
|
|
|
|
|
private static class RestoreTrashbinFileTask extends AsyncTask<Void, Void, Boolean> {
|
|
private static class RestoreTrashbinFileTask extends AsyncTask<Void, Void, Boolean> {
|
|
|
|
|
|
private TrashbinFile file;
|
|
private TrashbinFile file;
|
|
- private String userId;
|
|
|
|
private OwnCloudClient client;
|
|
private OwnCloudClient client;
|
|
private TrashbinRepository.OperationCallback callback;
|
|
private TrashbinRepository.OperationCallback callback;
|
|
|
|
|
|
- private RestoreTrashbinFileTask(TrashbinFile file, String userId, OwnCloudClient client,
|
|
|
|
|
|
+ private RestoreTrashbinFileTask(TrashbinFile file, OwnCloudClient client,
|
|
TrashbinRepository.OperationCallback callback) {
|
|
TrashbinRepository.OperationCallback callback) {
|
|
this.file = file;
|
|
this.file = file;
|
|
- this.userId = userId;
|
|
|
|
this.client = client;
|
|
this.client = client;
|
|
this.callback = callback;
|
|
this.callback = callback;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected Boolean doInBackground(Void... voids) {
|
|
protected Boolean doInBackground(Void... voids) {
|
|
- RemoteOperationResult result = new RestoreTrashbinFileRemoteOperation(
|
|
|
|
- file.getFullRemotePath(), file.getFileName(), userId).execute(client);
|
|
|
|
|
|
+ RemoteOperationResult result = new RestoreTrashbinFileRemoteOperation(file.getFullRemotePath(),
|
|
|
|
+ file.getFileName()).execute(client);
|
|
|
|
|
|
return result.isSuccess();
|
|
return result.isSuccess();
|
|
}
|
|
}
|
|
@@ -168,28 +157,25 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void getFolder(String remotePath, @NonNull LoadFolderCallback callback) {
|
|
public void getFolder(String remotePath, @NonNull LoadFolderCallback callback) {
|
|
- new ReadRemoteTrashbinFolderTask(remotePath, userId, client, callback).execute();
|
|
|
|
|
|
+ new ReadRemoteTrashbinFolderTask(remotePath, client, callback).execute();
|
|
}
|
|
}
|
|
|
|
|
|
private static class ReadRemoteTrashbinFolderTask extends AsyncTask<Void, Void, Boolean> {
|
|
private static class ReadRemoteTrashbinFolderTask extends AsyncTask<Void, Void, Boolean> {
|
|
|
|
|
|
private String remotePath;
|
|
private String remotePath;
|
|
- private String userId;
|
|
|
|
private OwnCloudClient client;
|
|
private OwnCloudClient client;
|
|
private List<Object> trashbinFiles;
|
|
private List<Object> trashbinFiles;
|
|
private LoadFolderCallback callback;
|
|
private LoadFolderCallback callback;
|
|
|
|
|
|
- private ReadRemoteTrashbinFolderTask(String remotePath, String userId, OwnCloudClient client,
|
|
|
|
- LoadFolderCallback callback) {
|
|
|
|
|
|
+ private ReadRemoteTrashbinFolderTask(String remotePath, OwnCloudClient client, LoadFolderCallback callback) {
|
|
this.remotePath = remotePath;
|
|
this.remotePath = remotePath;
|
|
- this.userId = userId;
|
|
|
|
this.client = client;
|
|
this.client = client;
|
|
this.callback = callback;
|
|
this.callback = callback;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected Boolean doInBackground(Void... voids) {
|
|
protected Boolean doInBackground(Void... voids) {
|
|
- RemoteOperationResult result = new ReadTrashbinFolderRemoteOperation(remotePath, userId).execute(client);
|
|
|
|
|
|
+ RemoteOperationResult result = new ReadTrashbinFolderRemoteOperation(remotePath).execute(client);
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
if (result.isSuccess()) {
|
|
trashbinFiles = result.getData();
|
|
trashbinFiles = result.getData();
|