Search in sources :

Example 1 with ComponentsGetter

use of com.owncloud.android.ui.activity.ComponentsGetter in project android by nextcloud.

the class RemoveFileDialogFragment method onConfirmation.

/**
 * Performs the removal of the target file, both locally and in the server.
 */
@Override
public void onConfirmation(String callerTag) {
    ComponentsGetter cg = (ComponentsGetter) getActivity();
    FileDataStorageManager storageManager = cg.getStorageManager();
    if (storageManager.getFileById(mTargetFile.getFileId()) != null) {
        ArrayList<OCFile> list = new ArrayList<>();
        list.add(mTargetFile);
        cg.getFileOperationsHelper().removeFiles(list, false);
    }
}
Also used : ComponentsGetter(com.owncloud.android.ui.activity.ComponentsGetter) OCFile(com.owncloud.android.datamodel.OCFile) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) ArrayList(java.util.ArrayList)

Example 2 with ComponentsGetter

use of com.owncloud.android.ui.activity.ComponentsGetter in project android by nextcloud.

the class RemoveFilesDialogFragment method onCancel.

/**
 * Performs the removal of the local copy of the target file
 */
@Override
public void onCancel(String callerTag) {
    ComponentsGetter cg = (ComponentsGetter) getActivity();
    cg.getFileOperationsHelper().removeFiles(mTargetFiles, true);
}
Also used : ComponentsGetter(com.owncloud.android.ui.activity.ComponentsGetter)

Example 3 with ComponentsGetter

use of com.owncloud.android.ui.activity.ComponentsGetter in project android by owncloud.

the class RemoveFilesDialogFragment method onConfirmation.

/**
 * Performs the removal of the target file, both locally and in the server.
 */
@Override
public void onConfirmation(String callerTag) {
    ComponentsGetter cg = (ComponentsGetter) getActivity();
    cg.getFileOperationsHelper().removeFiles(mTargetFiles, false);
}
Also used : ComponentsGetter(com.owncloud.android.ui.activity.ComponentsGetter)

Example 4 with ComponentsGetter

use of com.owncloud.android.ui.activity.ComponentsGetter in project android by owncloud.

the class RemoveFilesDialogFragment method onCancel.

/**
 * Performs the removal of the local copy of the target file
 */
@Override
public void onCancel(String callerTag) {
    ComponentsGetter cg = (ComponentsGetter) getActivity();
    cg.getFileOperationsHelper().removeFiles(mTargetFiles, true);
}
Also used : ComponentsGetter(com.owncloud.android.ui.activity.ComponentsGetter)

Example 5 with ComponentsGetter

use of com.owncloud.android.ui.activity.ComponentsGetter in project android by nextcloud.

the class RemoveFileDialogFragment method onCancel.

/**
 * Performs the removal of the local copy of the target file
 */
@Override
public void onCancel(String callerTag) {
    ComponentsGetter cg = (ComponentsGetter) getActivity();
    ArrayList<OCFile> list = new ArrayList<>();
    list.add(mTargetFile);
    cg.getFileOperationsHelper().removeFiles(list, true);
    FileDataStorageManager storageManager = cg.getStorageManager();
    boolean containsFavorite = false;
    if (mTargetFile.isFolder()) {
        List<OCFile> files = storageManager.getFolderContent(mTargetFile, false);
        for (OCFile file : files) {
            containsFavorite = file.isAvailableOffline() || containsFavorite;
            if (containsFavorite) {
                break;
            }
        }
    }
    // or is a folder and contains favorite
    if (mTargetFile.isAvailableOffline() || containsFavorite) {
        OCFile folder = null;
        if (mTargetFile.isFolder()) {
            folder = mTargetFile;
        } else {
            folder = storageManager.getFileById(mTargetFile.getParentId());
        }
        folder.setEtag("");
        storageManager.saveFile(folder);
    }
}
Also used : ComponentsGetter(com.owncloud.android.ui.activity.ComponentsGetter) OCFile(com.owncloud.android.datamodel.OCFile) ArrayList(java.util.ArrayList) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Aggregations

ComponentsGetter (com.owncloud.android.ui.activity.ComponentsGetter)8 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)3 OCFile (com.owncloud.android.datamodel.OCFile)2 ArrayList (java.util.ArrayList)2 Account (android.accounts.Account)1 LinearLayout (android.widget.LinearLayout)1 ProgressBar (android.widget.ProgressBar)1 RelativeLayout (android.widget.RelativeLayout)1 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)1 TransferProgressController (com.owncloud.android.ui.controller.TransferProgressController)1