use of com.owncloud.android.lib.resources.activities.models.RichObject in project android by nextcloud.
the class ActivitiesListActivity method onActivityClicked.
@Override
public void onActivityClicked(RichObject richObject) {
String path = FileUtils.PATH_SEPARATOR + richObject.getPath();
runOnUiThread(new Runnable() {
@Override
public void run() {
swipeEmptyListRefreshLayout.setVisibility(View.VISIBLE);
swipeListRefreshLayout.setVisibility(View.GONE);
setLoadingMessage();
}
});
updateTask = new AsyncTask<String, Object, OCFile>() {
@Override
protected OCFile doInBackground(String... path) {
OCFile ocFile = null;
// always update file as it could be an old state saved in database
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(path[0]);
RemoteOperationResult resultRemoteFileOp = operation.execute(ownCloudClient);
if (resultRemoteFileOp.isSuccess()) {
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) resultRemoteFileOp.getData().get(0));
ocFile = getStorageManager().saveFileWithParent(temp, getBaseContext());
if (ocFile.isFolder()) {
// perform folder synchronization
RemoteOperation synchFolderOp = new RefreshFolderOperation(ocFile, System.currentTimeMillis(), false, getFileOperationsHelper().isSharedSupported(), true, getStorageManager(), getAccount(), getApplicationContext());
synchFolderOp.execute(ownCloudClient);
}
}
return ocFile;
}
@Override
protected void onPostExecute(OCFile ocFile) {
if (!isCancelled()) {
if (ocFile == null) {
Toast.makeText(getBaseContext(), R.string.file_not_found, Toast.LENGTH_LONG).show();
swipeEmptyListRefreshLayout.setVisibility(View.GONE);
swipeListRefreshLayout.setVisibility(View.VISIBLE);
dismissLoadingDialog();
} else {
Intent showDetailsIntent;
if (PreviewImageFragment.canBePreviewed(ocFile)) {
showDetailsIntent = new Intent(getBaseContext(), PreviewImageActivity.class);
} else {
showDetailsIntent = new Intent(getBaseContext(), FileDisplayActivity.class);
}
showDetailsIntent.putExtra(EXTRA_FILE, ocFile);
showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(showDetailsIntent);
}
}
}
};
updateTask.execute(path);
}
Aggregations