use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class ReceiveExternalFilesActivity method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// click on folder in the list
Timber.d("on item click");
// get current representation of files:
// This does not necessarily mean this is the content of the current folder.
// If the user searches for a folder mAdapter.getFiles() returns only the folders/files
// that match the currently entered search query.
Vector<OCFile> tmpfiles = mAdapter.getFiles();
tmpfiles = sortFileList(tmpfiles);
if (tmpfiles.size() <= 0) {
return;
}
// filter on dirtype
Vector<OCFile> files = new Vector<>(tmpfiles);
if (files.size() < position) {
throw new IndexOutOfBoundsException("Incorrect item selected");
}
if (files.get(position).isFolder()) {
OCFile folderToEnter = files.get(position);
startSyncFolderOperation(folderToEnter);
mParents.push(folderToEnter.getFileName());
updateDirectoryList();
}
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class ReceiveExternalFilesActivity method browseToRoot.
private void browseToRoot() {
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
mFile = root;
startSyncFolderOperation(root);
}
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();
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 cameraUploadPath = getIntent().getStringExtra(KEY_CAMERA_UPLOAD_PATH);
// The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
OCFile folder = new OCFile(cameraUploadPath);
setFile(folder);
// Account may differ from current one. We need to show the picker for this one, not current.
String accountName = getIntent().getStringExtra(KEY_CAMERA_UPLOAD_ACCOUNT);
setAccount(AccountUtils.getOwnCloudAccountByName(this, accountName));
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class OCFileListFragment method isGridViewPreferred.
/**
* Determines if user set folder to grid or list view. If folder is not set itself,
* it finds a parent that is set (at least root is set).
*
* @param file Folder to check.
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
*/
private boolean isGridViewPreferred(OCFile file) {
if (file != null) {
OCFile fileToTest = file;
OCFile parentDir;
String parentPath = null;
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
SharedPreferences setting = requireActivity().getSharedPreferences(GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE);
if (setting.contains(String.valueOf(fileToTest.getFileId()))) {
return setting.getBoolean(String.valueOf(fileToTest.getFileId()), false);
} else {
do {
if (fileToTest.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
parentPath = new File(fileToTest.getRemotePath()).getParent();
parentPath = parentPath.endsWith(File.separator) ? parentPath : parentPath + File.separator;
parentDir = storageManager.getFileByPath(parentPath);
} else {
parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);
}
while (parentDir == null) {
parentPath = new File(parentPath).getParent();
parentPath = parentPath.endsWith(File.separator) ? parentPath : parentPath + File.separator;
parentDir = storageManager.getFileByPath(parentPath);
}
fileToTest = parentDir;
} while (endWhile(parentDir, setting));
return setting.getBoolean(String.valueOf(fileToTest.getFileId()), false);
}
} else {
return false;
}
}
Aggregations