use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.
the class FileDisplayActivity method cancelTransference.
/**
* Request stopping the upload/download operation in progress over the given {@link OCFile} file.
*
* @param file {@link OCFile} file which operation are wanted to be cancel
*/
public void cancelTransference(OCFile file) {
getFileOperationsHelper().cancelTransference(file);
if (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(file.getRemotePath())) {
mWaitingToPreview = null;
}
if (mWaitingToSend != null && mWaitingToSend.getRemotePath().equals(file.getRemotePath())) {
mWaitingToSend = null;
}
refreshListOfFilesFragment(false);
FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && file.equals(secondFragment.getFile())) {
if (!file.fileExists()) {
cleanSecondFragment();
} else {
secondFragment.onSyncEvent(FileDownloader.getDownloadFinishMessage(), false, null);
}
}
invalidateOptionsMenu();
}
use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.
the class FileDisplayActivity method onSynchronizeFileOperationFinish.
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) {
if (operation.transferWasRequested()) {
// this block is probably useless duy
OCFile syncedFile = operation.getLocalFile();
refreshListOfFilesFragment(false);
FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && syncedFile.equals(secondFragment.getFile())) {
secondFragment.onSyncEvent(FileDownloader.getDownloadAddedMessage(), false, null);
invalidateOptionsMenu();
}
} else if (getSecondFragment() == null) {
showSnackMessage(ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
}
}
/// no matter if sync was right or not - if there was no transfer and the file is down, OPEN it
boolean waitedForPreview = (mWaitingToPreview != null && mWaitingToPreview.equals(operation.getLocalFile()) && mWaitingToPreview.isDown());
if (!operation.transferWasRequested() & waitedForPreview) {
getFileOperationsHelper().openFile(mWaitingToPreview);
mWaitingToPreview = null;
}
}
use of com.owncloud.android.ui.fragment.FileFragment in project android by owncloud.
the class FileDisplayActivity method onRemoveFileOperationFinish.
/**
* Updates the view associated to the activity after the finish of an operation trying to
* remove a file.
*
* @param operation Removal operation performed.
* @param result Result of the removal.
*/
private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
showSnackMessage(ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
if (result.isSuccess()) {
OCFile removedFile = operation.getFile();
FileFragment second = getSecondFragment();
if (second != null && removedFile.equals(second.getFile())) {
if (second instanceof PreviewAudioFragment) {
((PreviewAudioFragment) second).stopPreview();
} else if (second instanceof PreviewVideoFragment) {
((PreviewVideoFragment) second).stopPreview();
}
setFile(getStorageManager().getFileById(removedFile.getParentId()));
cleanSecondFragment();
}
if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) {
refreshListOfFilesFragment(true);
}
invalidateOptionsMenu();
} else {
if (result.isSslRecoverableException()) {
mLastSslUntrustedServerResult = result;
showUntrustedCertDialog(mLastSslUntrustedServerResult);
}
}
}
use of com.owncloud.android.ui.fragment.FileFragment in project android by nextcloud.
the class FileDisplayActivity method onResume.
@Override
protected void onResume() {
Log_OC.v(TAG, "onResume() start");
super.onResume();
// Instead of onPostCreate, starting the loading in onResume for children fragments
Fragment leftFragment = getLeftFragment();
// Listen for sync messages
if (!(leftFragment instanceof OCFileListFragment) || !((OCFileListFragment) leftFragment).isSearchFragment()) {
IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
}
if (!(leftFragment instanceof OCFileListFragment)) {
if (leftFragment instanceof FileFragment) {
super.updateActionBarTitleAndHomeButton(((FileFragment) leftFragment).getFile());
}
return;
}
OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
ocFileListFragment.setLoading(mSyncInProgress);
syncAndUpdateFolder(false);
OCFile startFile = null;
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
startFile = getIntent().getParcelableExtra(EXTRA_FILE);
setFile(startFile);
}
// refresh list of files
if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
searchView.setQuery(searchQuery, false);
} else if (!ocFileListFragment.isSearchFragment() && startFile == null) {
updateListOfFilesFragment(false);
ocFileListFragment.registerFabListener();
} else {
ocFileListFragment.listDirectory(startFile, false, false);
updateActionBarTitleAndHomeButton(startFile);
}
// Listen for upload messages
IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
mUploadFinishReceiver = new UploadFinishReceiver();
localBroadcastManager.registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
// Listen for download messages
IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
mDownloadFinishReceiver = new DownloadFinishReceiver();
localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
// setup drawer
menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
if (menuItemId == -1) {
if (MainApp.isOnlyOnDevice()) {
setDrawerMenuItemChecked(R.id.nav_on_device);
setupToolbar();
} else {
setDrawerMenuItemChecked(R.id.nav_all_files);
setupHomeSearchToolbarWithSortAndListButtons();
}
} else {
if (menuItemId == R.id.nav_all_files) {
setupHomeSearchToolbarWithSortAndListButtons();
} else {
setupToolbar();
}
setDrawerMenuItemChecked(menuItemId);
}
if (ocFileListFragment instanceof GalleryFragment) {
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
}
Log_OC.v(TAG, "onResume() end");
}
use of com.owncloud.android.ui.fragment.FileFragment in project android by nextcloud.
the class PreviewImagePagerAdapter method updateFile.
public void updateFile(int position, OCFile file) {
FileFragment fragmentToUpdate = mCachedFragments.get(position);
if (fragmentToUpdate != null) {
mObsoleteFragments.add(fragmentToUpdate);
}
mObsoletePositions.add(position);
mImageFiles.set(position, file);
}
Aggregations