Skip to content

Commit

Permalink
Handle null user in FileDisplayActivity#startSyncFolderOperation()
Browse files Browse the repository at this point in the history
Signed-off-by: ZetaTom <[email protected]>
  • Loading branch information
ZetaTom committed Feb 12, 2024
1 parent de5a7b9 commit dafb395
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1921,28 +1921,29 @@ public void startSyncFolderOperation(final OCFile folder, final boolean ignoreET
// the execution is slightly delayed to allow the activity get the window focus if it's being started
// or if the method is called from a dialog that is being dismissed
if (TextUtils.isEmpty(searchQuery) && getUser().isPresent()) {
getHandler().postDelayed(new Runnable() {
@Override
public void run() {
if (ignoreFocus || hasWindowFocus()) {
long currentSyncTime = System.currentTimeMillis();
mSyncInProgress = true;
getHandler().postDelayed(() -> {
Optional<User> user = getUser();

// perform folder synchronization
RemoteOperation synchFolderOp = new RefreshFolderOperation(folder, currentSyncTime, false, ignoreETag, getStorageManager(), getUser().orElseThrow(RuntimeException::new), getApplicationContext());
synchFolderOp.execute(getAccount(), MainApp.getAppContext(), FileDisplayActivity.this, null, null);
if (!ignoreFocus && !hasWindowFocus() || !user.isPresent()) {
// do not refresh if the user rotates the device while another window has focus
// or if the current user is no longer valid
return;
}

OCFileListFragment fragment = getListOfFilesFragment();
long currentSyncTime = System.currentTimeMillis();
mSyncInProgress = true;

if (fragment != null && !(fragment instanceof GalleryFragment)) {
fragment.setLoading(true);
}
// perform folder synchronization
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, ignoreETag, getStorageManager(), user.get(), getApplicationContext());
refreshFolderOperation.execute(getAccount(), MainApp.getAppContext(), FileDisplayActivity.this, null, null);

setBackgroundText();
OCFileListFragment fragment = getListOfFilesFragment();

} // else: NOTHING ; lets' not refresh when the user rotates the device but there is
// another window floating over
if (fragment != null && !(fragment instanceof GalleryFragment)) {
fragment.setLoading(true);
}

setBackgroundText();
}, DELAY_TO_REQUEST_REFRESH_OPERATION_LATER);
}
}
Expand Down

0 comments on commit dafb395

Please sign in to comment.