mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Merge pull request #5031 from nextcloud/ezaquarii/fix-npe-crash-when-storage-manager-is-not-set
Fix NPE crash on startup when storage manager is not set
This commit is contained in:
commit
d7d1c475ae
2 changed files with 14 additions and 11 deletions
|
@ -69,6 +69,13 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
return accountManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
setAccount(account, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
@ -97,12 +104,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
}
|
||||
}
|
||||
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
setAccount(account, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -177,6 +178,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
if (newAccount == null) {
|
||||
/// no account available: force account creation
|
||||
createAccount(true);
|
||||
finish();
|
||||
} else {
|
||||
currentAccount = newAccount;
|
||||
}
|
||||
|
|
|
@ -2558,8 +2558,9 @@ public class FileDisplayActivity extends FileActivity
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent()) {
|
||||
final Optional<User> optionalUser = getUser();
|
||||
final FileDataStorageManager storageManager = getStorageManager();
|
||||
if (optionalUser.isPresent() && storageManager != null) {
|
||||
/// Check whether the 'main' OCFile handled by the Activity is contained in the
|
||||
// current Account
|
||||
OCFile file = getFile();
|
||||
|
@ -2571,17 +2572,17 @@ public class FileDisplayActivity extends FileActivity
|
|||
// cache until the upload is successful get parent from path
|
||||
parentPath = file.getRemotePath().substring(0,
|
||||
file.getRemotePath().lastIndexOf(file.getFileName()));
|
||||
if (getStorageManager().getFileByPath(parentPath) == null) {
|
||||
if (storageManager.getFileByPath(parentPath) == null) {
|
||||
file = null; // not able to know the directory where the file is uploading
|
||||
}
|
||||
} else {
|
||||
file = getStorageManager().getFileByPath(file.getRemotePath());
|
||||
file = storageManager.getFileByPath(file.getRemotePath());
|
||||
// currentDir = null if not in the current Account
|
||||
}
|
||||
}
|
||||
if (file == null) {
|
||||
// fall back to root folder
|
||||
file = getStorageManager().getFileByPath(OCFile.ROOT_PATH); // never returns null
|
||||
file = storageManager.getFileByPath(OCFile.ROOT_PATH); // never returns null
|
||||
}
|
||||
setFile(file);
|
||||
|
||||
|
|
Loading…
Reference in a new issue