本文整理汇总了Java中com.google.android.gms.drive.Metadata.isTrashable方法的典型用法代码示例。如果您正苦于以下问题:Java Metadata.isTrashable方法的具体用法?Java Metadata.isTrashable怎么用?Java Metadata.isTrashable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.drive.Metadata
的用法示例。
在下文中一共展示了Metadata.isTrashable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toggleTrashStatus
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Trashes or untrashes the given item.
*
* @param metadata Item to (un)trash
*/
private void toggleTrashStatus(Metadata metadata) {
// [START trash]
if (!metadata.isTrashable()) {
showMessage(R.string.trashable_error);
return;
}
DriveResource driveResource = metadata.getDriveId().asDriveResource();
Task<Void> toggleTrashTask;
if (metadata.isTrashed()) {
toggleTrashTask = mDriveResourceClient.untrash(driveResource);
} else {
toggleTrashTask = mDriveResourceClient.trash(driveResource);
}
toggleTrashTask = updateUiAfterTask(toggleTrashTask);
handleTaskError(toggleTrashTask, R.string.unexpected_error);
// [END trash]
}
示例2: sync_trashFile
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Trashes a file.
*
* @param driveFile The Drive file
* @param driveFileMetaData The Drive file metadata, see {@link Metadata}
* @returns Boolean. TRUE if file is trashed ok, otherwise FALSE.
*/
public boolean sync_trashFile(final DriveFile driveFile, final Metadata driveFileMetaData) throws TBDriveException {
boolean res = false;
//If a DriveResource is a folder it will only be trashable if all of its children
//are also accessible to this app.
if (driveFileMetaData.isTrashable()) {
if (!driveFileMetaData.isTrashed()) {
Status status = driveFile.trash(mGoogleApiClient).await();
if (!status.isSuccess()) {
Log.e(TAG, "Problem trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
throw new TBDriveException("Problem trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
}else{
res = true;
}
} else {
Log.e(TAG, "The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is already in trash.");
throw new TBDriveException("The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is already in trash.");
}
} else {
Log.e(TAG, "Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
throw new TBDriveException("Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
}
return res;
}
示例3: sync_untrashFile
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Un-Trashes a file.
*
* @param driveFile The Drive file
* @param driveFileMetaData The Drive file metadata, see {@link Metadata}
* @returns Boolean. TRUE if file is un-trashed ok, otherwise FALSE.
*/
public boolean sync_untrashFile(final DriveFile driveFile, final Metadata driveFileMetaData)
throws TBDriveException {
boolean res = false;
//If a DriveResource is a folder it will only be trashable if
//all of its children are also accessible to this app.
if (driveFileMetaData.isTrashable()) {
if (driveFileMetaData.isTrashed()) {
Status status = driveFile.untrash(mGoogleApiClient).await();
if (!status.isSuccess()) {
Log.e(TAG, "Problem untrashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
throw new TBDriveException("Problem untrashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
} else {
res = true;
}
} else {
Log.e(TAG, "The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is not in the trash.");
throw new TBDriveException("The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is not in the trash.");
}
} else {
Log.e(TAG, "Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
throw new TBDriveException("Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
}
return res;
}
示例4: async_trashFile
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Trashes a file.
*
* @param driveFile The Drive file
* @param driveFileMetaData The Drive file metadata, see {@link Metadata}
* @param callback See {@link TBDriveTrashOpCallback}
*/
public void async_trashFile(final DriveFile driveFile, final Metadata driveFileMetaData,
final TBDriveTrashOpCallback callback) {
/**
* Callback when call to trash or untrash is complete.
*/
final ResultCallback<Status> trashStatusCallback =
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (!status.isSuccess()) {
Log.e(TAG, "Problem trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_TRASH);
callback.setErrorMessage(ERROR_FILE_TRASH_STRING);
callback.setErrorDetails(status.getStatus().getStatusMessage());
callback.run();
}
return;
}
if(callback!=null) {
callback.setStatus(status);
callback.run();
}
}
};
//If a DriveResource is a folder it will only be trashable if all of its children
//are also accessible to this app.
if (driveFileMetaData.isTrashable()) {
if (!driveFileMetaData.isTrashed()) {
driveFile.trash(mGoogleApiClient).setResultCallback(trashStatusCallback);
} else {
Log.e(TAG, "The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is already in trash.");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_TRASH_ALREADY_TRASHED);
callback.setErrorMessage(ERROR_FILE_TRASH_ALREADY_TRASHED_STRING);
callback.run();
}
}
} else {
Log.e(TAG, "Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_TRASH_PERMISSION);
callback.setErrorMessage(ERROR_FILE_TRASH_PERMISSION_STRING);
callback.run();
}
}
}
示例5: async_untrashFile
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Un-Trashes a file.
*
* @param driveFile The Drive file
* @param driveFileMetaData The Drive file metadata, see {@link Metadata}
* @param callback See {@link TBDriveTrashOpCallback}
*/
public void async_untrashFile(final DriveFile driveFile, final Metadata driveFileMetaData,
final TBDriveTrashOpCallback callback) {
/**
* Callback when call to trash or untrash is complete.
*/
final ResultCallback<Status> trashStatusCallback =
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (!status.isSuccess()) {
Log.e(TAG, "Problem untrashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " [" + status.getStatusMessage() + "].");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_UNTRASH);
callback.setErrorMessage(ERROR_FILE_UNTRASH_STRING);
callback.setErrorDetails(status.getStatus().getStatusMessage());
callback.run();
}
return;
}
}
};
//If a DriveResource is a folder it will only be trashable if all of its children
//are also accessible to this app.
if (driveFileMetaData.isTrashable()) {
if (driveFileMetaData.isTrashed()) {
driveFile.untrash(mGoogleApiClient).setResultCallback(trashStatusCallback);
} else {
Log.e(TAG, "The file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + " is not in the trash.");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_TRASH_NOT_IN_TRASH);
callback.setErrorMessage(ERROR_FILE_TRASH_NOT_IN_TRASH_STRING);
callback.run();
}
}
} else {
Log.e(TAG, "Error trashing the file '" + driveFileMetaData.getTitle() + "' with DriveId: " + driveFile.getDriveId() + ", resource is not owned by the user or is in the AppFolder.");
if(callback!=null) {
callback.setErrorCode(ERROR_FILE_TRASH_PERMISSION);
callback.setErrorMessage(ERROR_FILE_TRASH_PERMISSION_STRING);
callback.run();
}
}
}