当前位置: 首页>>代码示例>>Java>>正文


Java Metadata.isTrashable方法代码示例

本文整理汇总了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]
}
 
开发者ID:googledrive,项目名称:android-trash,代码行数:24,代码来源:MainActivity.java

示例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;
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:35,代码来源:TBDrive.java

示例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;
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:36,代码来源:TBDrive.java

示例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();
       	}
       }
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:58,代码来源:TBDrive.java

示例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();
       	}            
       }
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:53,代码来源:TBDrive.java


注:本文中的com.google.android.gms.drive.Metadata.isTrashable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。