Search in sources :

Example 6 with GalleryFragment

use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.

the class GallerySearchTask method doInBackground.

@Override
protected GallerySearchTask.Result doInBackground(Void... voids) {
    if (photoFragmentWeakReference.get() == null) {
        return new Result(false, false, -1);
    }
    GalleryFragment photoFragment = photoFragmentWeakReference.get();
    if (isCancelled()) {
        return new Result(false, false, -1);
    } else {
        OCCapability ocCapability = storageManager.getCapability(user.getAccountName());
        SearchRemoteOperation searchRemoteOperation = new SearchRemoteOperation("", SearchRemoteOperation.SearchType.GALLERY_SEARCH, false, ocCapability);
        searchRemoteOperation.setLimit(limit);
        searchRemoteOperation.setStartDate(startDate);
        searchRemoteOperation.setEndDate(endDate);
        if (photoFragment.getContext() != null) {
            Log_OC.d(this, "Start gallery search with " + new Date(startDate * 1000L) + " - " + new Date(endDate * 1000L) + " with limit: " + limit);
            RemoteOperationResult result = searchRemoteOperation.execute(user.toPlatformAccount(), photoFragment.getContext());
            boolean emptySearch = parseMedia(startDate, endDate, result.getData());
            long lastTimeStamp = findLastTimestamp(result.getData());
            photoFragment.getAdapter().showAllGalleryItems(storageManager);
            return new Result(result.isSuccess(), emptySearch, lastTimeStamp);
        } else {
            return new Result(false, false, -1);
        }
    }
}
Also used : GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SearchRemoteOperation(com.owncloud.android.lib.resources.files.SearchRemoteOperation) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) Date(java.util.Date) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Example 7 with GalleryFragment

use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.

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) {
    if (!operation.isInBackground()) {
        DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
    }
    if (result.isSuccess()) {
        OCFile removedFile = operation.getFile();
        tryStopPlaying(removedFile);
        Fragment leftFragment = getLeftFragment();
        // check if file is still available, if so do nothing
        boolean fileAvailable = getStorageManager().fileExists(removedFile.getFileId());
        if (leftFragment instanceof FileFragment && !fileAvailable && removedFile.equals(((FileFragment) leftFragment).getFile())) {
            if (leftFragment instanceof PreviewMediaFragment) {
                ((PreviewMediaFragment) leftFragment).stopPreview(true);
            }
            setFile(getStorageManager().getFileById(removedFile.getParentId()));
            cleanSecondFragment();
        }
        OCFile parentFile = getStorageManager().getFileById(removedFile.getParentId());
        if (parentFile != null && parentFile.equals(getCurrentDir())) {
            updateListOfFilesFragment(false);
        } else if (getLeftFragment() instanceof GalleryFragment) {
            ((GalleryFragment) getLeftFragment()).onRefresh();
        }
        supportInvalidateOptionsMenu();
    } else {
        if (result.isSslRecoverableException()) {
            mLastSslUntrustedServerResult = result;
            showUntrustedCertDialog(mLastSslUntrustedServerResult);
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Aggregations

GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)7 OCFile (com.owncloud.android.datamodel.OCFile)3 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)3 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)3 Fragment (androidx.fragment.app.Fragment)2 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)2 SearchEvent (com.owncloud.android.ui.events.SearchEvent)2 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)2 FileFragment (com.owncloud.android.ui.fragment.FileFragment)2 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)2 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)2 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)2 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)2 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)2 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)2 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 User (com.nextcloud.client.account.User)1