use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class UploadPathActivity method onAccountSet.
/**
* Called when the ownCloud {@link Account} associated to the Activity was
* just updated.
*/
@Override
protected void onAccountSet(boolean stateWasRecovered) {
super.onAccountSet(stateWasRecovered);
if (getAccount() != null) {
updateFileFromDB();
OCFile folder = getFile();
if (folder == null || !folder.isFolder()) {
// fall back to root folder
setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
folder = getFile();
}
onBrowsedDownTo(folder);
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
// TODO Enable when "On Device" is recovered ?
listOfFolders.listDirectory(folder);
startSyncFolderOperation(folder, false);
}
updateNavigationElementsInActionBar();
}
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class UploadPathActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
// The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
OCFile folder = new OCFile(instantUploadPath);
setFile(folder);
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class FileOperationsHelper method copyFiles.
/**
* Start operations to copy one or several files
*
* @param files Files to copy
* @param targetFolder Folder where the files while be copied into
*/
public void copyFiles(Collection<OCFile> files, OCFile targetFolder) {
for (OCFile file : files) {
Intent service = new Intent(mFileActivity, OperationsService.class);
service.setAction(OperationsService.ACTION_COPY_FILE);
service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
}
mFileActivity.showLoadingDialog(R.string.wait_a_moment);
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class FileOperationsHelper method moveFiles.
/**
* Start operations to move one or several files
*
* @param files Files to move
* @param targetFolder Folder where the files while be moved into
*/
public void moveFiles(Collection<OCFile> files, OCFile targetFolder) {
for (OCFile file : files) {
Intent service = new Intent(mFileActivity, OperationsService.class);
service.setAction(OperationsService.ACTION_MOVE_FILE);
service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
}
mFileActivity.showLoadingDialog(R.string.wait_a_moment);
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class OCFileListFragment method onBrowseUp.
/**
* Call this, when the user presses the up button.
*
* Tries to move up the current folder one level. If the parent folder was removed from the
* database, it continues browsing up until finding an existing folders.
* <p/>
* return Count of folder levels browsed up.
*/
public int onBrowseUp() {
OCFile parentDir;
int moveCount = 0;
if (mFile != null) {
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
String parentPath = null;
if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
parentPath = new File(mFile.getRemotePath()).getParent();
parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR;
parentDir = storageManager.getFileByPath(parentPath);
moveCount++;
} else {
parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);
}
while (parentDir == null) {
parentPath = new File(parentPath).getParent();
parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR;
parentDir = storageManager.getFileByPath(parentPath);
moveCount++;
}
// exit is granted because storageManager.getFileByPath("/") never returns null
mFile = parentDir;
// TODO Enable when "On Device" is recovered ?
listDirectory(mFile);
onRefresh(false);
// restore index and top position
restoreIndexAndTopPosition();
}
return moveCount;
}
Aggregations