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


Java Metadata.isTrashed方法代码示例

本文整理汇总了Java中com.google.android.gms.drive.Metadata.isTrashed方法的典型用法代码示例。如果您正苦于以下问题:Java Metadata.isTrashed方法的具体用法?Java Metadata.isTrashed怎么用?Java Metadata.isTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.drive.Metadata的用法示例。


在下文中一共展示了Metadata.isTrashed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResult

import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
 * Handles the result of the query. If the results are nonzero, passes up the {@link Metadata}
 * out of the result one at a time through {@link QuerierResultCallback#onQuerierResult(Metadata)}
 * with the {@link QuerierResultCallback} registered in ths {@link Querier}. If the results are
 * null, calls {@link QuerierResultCallback#onNoQuerierResult()}
 *
 * @param result the result of the query
 */
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        Log.e("Querier", "Problem while retrieving files");
        return;
    }

    // Get the metadata buffer
    MetadataBuffer buffer = result.getMetadataBuffer();

    // Check for file dne
    if (buffer.getCount() == 0) {
        // Call null result callback
        callback.onNoQuerierResult();
    }

    // Get the metadata
    for (Metadata m : buffer) {
        if (m.isInAppFolder() && !m.isTrashed()) {
            callback.onQuerierResult(m);
            break;
        }
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:33,代码来源:Querier.java

示例2: onResult

import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
 * Handles the result of the query. If the results are nonzero, passes up the {@link Metadata}
 * out of the result one at a time through {@link QuerierResultCallback#onQuerierResult(Metadata)}
 * with the {@link QuerierResultCallback} registered in ths {@link Querier}. If the results are
 * null, calls {@link QuerierResultCallback#onNoQuerierResult()}
 * @param result the result of the query
 */
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        Log.e("Querier", "Problem while retrieving files");
        return;
    }

    // Get the metadata buffer
    MetadataBuffer buffer = result.getMetadataBuffer();

    // Check for file dne
    if (buffer.getCount() == 0) {
        // Call null result callback
        callback.onNoQuerierResult();
    }

    // Get the metadata
    for (Metadata m : buffer) {
        if (m.isInAppFolder() && !m.isTrashed()) {
            callback.onQuerierResult(m);
            break;
        }
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:32,代码来源:Querier.java

示例3: 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

示例4: 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

示例5: 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

示例6: getOrCreateDriveFolder

import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
 * search on a particualr folder or root
 */
public static DriveId getOrCreateDriveFolder(GoogleApiClient mGoogleApiClient,DriveId baseFolderId, String targetFolder) throws ImportExportException {
    DriveFolder baseFolder=null;
    if (baseFolderId!=null) {
        baseFolder=Drive.DriveApi.getFolder(mGoogleApiClient, baseFolderId);
        //DriveResource.MetadataResult r = baseFolder.getMetadata(mGoogleApiClient).await();
    }
    if (baseFolder==null) {
        baseFolder=Drive.DriveApi.getRootFolder(mGoogleApiClient);
    }

    DriveId folder = null;
    if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
        Query query = new Query.Builder()
                .addFilter(Filters.eq(SearchableField.TITLE, targetFolder))
                .addFilter(Filters.eq(SearchableField.TRASHED, false))
                .addFilter(Filters.eq(SearchableField.MIME_TYPE, "application/vnd.google-apps.folder"))
                .build();
        // fire the query
        DriveApi.MetadataBufferResult rslt =baseFolder.queryChildren(mGoogleApiClient,query).await();
        //DriveApi.MetadataBufferResult rslt = Drive.DriveApi.query(mGoogleApiClient, query).await();
        if (rslt.getStatus().isSuccess()) {
            MetadataBuffer mdb = null;
            try {
                mdb = rslt.getMetadataBuffer();

                for (Metadata md : mdb) {
                    if (md == null || !md.isDataValid() || md.isTrashed()) continue;
                    //   md.getTitle(), md.getDriveId(), ....
                    if (md.getTitle().equals(targetFolder)) {
                        folder = md.getDriveId();
                    }
                }
            } finally {
                if (mdb != null) mdb.close();
            }
        }
        //if not found create it
        if (folder == null) {
            MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                    .setTitle(targetFolder).build();
            DriveFolder.DriveFolderResult rslt2 = baseFolder.createFolder(mGoogleApiClient, changeSet).await();
            folder = rslt2.getDriveFolder().getDriveId();
        }
        return folder;
    } else {
        throw new ImportExportException(R.string.gdocs_connection_failed);
    }
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:52,代码来源:ApiClientAsyncTask.java

示例7: 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

示例8: 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.isTrashed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。