Search in sources :

Example 21 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by owncloud.

the class PreviewImageFragment method onFileMetadataChanged.

@Override
public void onFileMetadataChanged() {
    FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
    if (storageManager != null) {
        setFile(storageManager.getFileByPath(getFile().getRemotePath()));
    }
    getActivity().invalidateOptionsMenu();
}
Also used : FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 22 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by owncloud.

the class FileDetailFragment method updateFileDetails.

/**
     * Updates the view with all relevant details about that file.
     *
     * @param forcedTransferring Flag signaling if the file should be considered as downloading or uploading,
     *                     although {@link FileDownloaderBinder#isDownloading(Account, OCFile)}  and
     *                     {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
     * @param refresh      If 'true', try to refresh the whole file from the database
     */
private void updateFileDetails(boolean forcedTransferring, boolean refresh) {
    if (readyToShow()) {
        FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
        if (refresh && storageManager != null) {
            setFile(storageManager.getFileByPath(getFile().getRemotePath()));
        }
        OCFile file = getFile();
        // set file details
        setFilename(file.getFileName());
        setFiletype(file);
        setFilesize(file.getFileLength());
        setTimeModified(file.getModificationTimestamp());
        // configure UI for depending upon local state of the file
        FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
        if (forcedTransferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file))) {
            setButtonsForTransferring();
        } else if (file.isDown()) {
            setButtonsForDown();
        } else {
            // TODO load default preview image; when the local file is removed, the preview
            // remains there
            setButtonsForRemote();
        }
    }
    getView().invalidate();
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDownloaderBinder(com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder) FileUploaderBinder(com.owncloud.android.files.services.FileUploader.FileUploaderBinder) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 23 with FileDataStorageManager

use of com.owncloud.android.datamodel.FileDataStorageManager in project android by owncloud.

the class OCFileListFragment method listDirectory.

/**
     * Lists the given directory on the view. When the input parameter is null,
     * it will either refresh the last known directory. list the root
     * if there never was a directory.
     *
     * @param directory File to be listed
     */
public void listDirectory(OCFile directory) /*, boolean onlyOnDevice*/
{
    FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
    if (storageManager != null) {
        // Check input parameters for null
        if (directory == null) {
            if (mFile != null) {
                directory = mFile;
            } else {
                directory = storageManager.getFileByPath("/");
                // no files, wait for sync
                if (directory == null)
                    return;
            }
        }
        // If that's not a directory -> List its parent
        if (!directory.isFolder()) {
            Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
            directory = storageManager.getFileById(directory.getParentId());
        }
        // TODO Enable when "On Device" is recovered ?
        mAdapter.swapDirectory(directory, storageManager);
        if (mFile == null || !mFile.equals(directory)) {
            mCurrentListView.setSelection(0);
        }
        mFile = directory;
        updateLayout();
    }
}
Also used : FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Aggregations

FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)23 OCFile (com.owncloud.android.datamodel.OCFile)9 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)6 Account (android.accounts.Account)4 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)4 AccountsException (android.accounts.AccountsException)2 Intent (android.content.Intent)2 File (java.io.File)2 IOException (java.io.IOException)2 ContentResolver (android.content.ContentResolver)1 SharedPreferences (android.content.SharedPreferences)1 MatrixCursor (android.database.MatrixCursor)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 Pair (android.support.v4.util.Pair)1 ScrollingMovementMethod (android.text.method.ScrollingMovementMethod)1 Pair (android.util.Pair)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1