|
@@ -24,6 +24,7 @@
|
|
|
package com.owncloud.android.ui.trashbin;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.util.Log;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
@@ -67,11 +68,15 @@ public class TrashbinActivity extends DrawerActivity implements
|
|
|
TrashbinContract.View,
|
|
|
Injectable {
|
|
|
|
|
|
+ private static final String TAG = TrashbinActivity.class.getSimpleName();
|
|
|
+ private static final String ARG_TARGET_ACCOUNT_NAME = "TARGET_ACCOUNT_NAME";
|
|
|
+
|
|
|
public static final int EMPTY_LIST_COUNT = 1;
|
|
|
@Inject AppPreferences preferences;
|
|
|
@Inject CurrentAccountProvider accountProvider;
|
|
|
@Inject ClientFactory clientFactory;
|
|
|
private TrashbinListAdapter trashbinListAdapter;
|
|
|
+ private User user;
|
|
|
|
|
|
@VisibleForTesting
|
|
|
TrashbinPresenter trashbinPresenter;
|
|
@@ -82,7 +87,17 @@ public class TrashbinActivity extends DrawerActivity implements
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
- final User user = accountProvider.getUser();
|
|
|
+ user = accountProvider.getUser();
|
|
|
+ final String targetAccount = getIntent().getStringExtra(ARG_TARGET_ACCOUNT_NAME);
|
|
|
+ if (!user.getAccountName().equals(targetAccount)) {
|
|
|
+ final boolean accountSwitchSuccessful = getUserAccountManager().setCurrentOwnCloudAccount(targetAccount);
|
|
|
+ if (accountSwitchSuccessful) {
|
|
|
+ user = getUserAccountManager().getUser(targetAccount).orElse(user);
|
|
|
+ } else {
|
|
|
+ Log.w(TAG, "Tried to switch current account to \"" + targetAccount + "\", but could not be found.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
final RemoteTrashbinRepository trashRepository = new RemoteTrashbinRepository(user, clientFactory);
|
|
|
trashbinPresenter = new TrashbinPresenter(trashRepository, this);
|
|
|
|
|
@@ -118,7 +133,7 @@ public class TrashbinActivity extends DrawerActivity implements
|
|
|
getStorageManager(),
|
|
|
preferences,
|
|
|
this,
|
|
|
- getUserAccountManager().getUser()
|
|
|
+ user
|
|
|
);
|
|
|
recyclerView.setAdapter(trashbinListAdapter);
|
|
|
recyclerView.setHasFixedSize(true);
|