use of com.owncloud.android.ui.events.TokenPushEvent in project android by nextcloud.
the class FileDisplayActivity method onStart.
@Override
public void onStart() {
super.onStart();
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();
// get parent from path
String parentPath = "";
if (file != null) {
if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
// upload in progress - right now, files are not inserted in the local
// cache until the upload is successful get parent from path
parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName()));
if (storageManager.getFileByPath(parentPath) == null) {
// not able to know the directory where the file is uploading
file = null;
}
} else {
file = storageManager.getFileByPath(file.getRemotePath());
// currentDir = null if not in the current Account
}
}
if (file == null) {
// fall back to root folder
// never returns null
file = storageManager.getFileByPath(OCFile.ROOT_PATH);
}
setFile(file);
User user = optionalUser.get();
setupDrawer();
mSwitchAccountButton.setTag(user.getAccountName());
DisplayUtils.setAvatar(user, this, getResources().getDimension(R.dimen.nav_drawer_menu_avatar_radius), getResources(), mSwitchAccountButton, this);
final boolean userChanged = !user.nameEquals(lastDisplayedUser.orElse(null));
if (userChanged) {
Log_OC.d(TAG, "Initializing Fragments in onAccountChanged..");
initFragmentsWithFile(user, file);
if (file.isFolder() && TextUtils.isEmpty(searchQuery)) {
startSyncFolderOperation(file, false);
}
} else {
updateActionBarTitleAndHomeButton(file.isFolder() ? null : file);
}
}
lastDisplayedUser = optionalUser;
EventBus.getDefault().post(new TokenPushEvent());
checkForNewDevVersionNecessary(getApplicationContext());
}
Aggregations