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


Java DriveFolder类代码示例

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


DriveFolder类属于com.google.android.gms.drive包,在下文中一共展示了DriveFolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createEmptyDriveFile

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
/**
 * Create an empty file with the given {@code fileName} and {@code mimeType}.
 *
 * @return {@link DriveId} of the specific file.
 */
private DriveId createEmptyDriveFile(String fileName, String mimeType) {
    DriveApi.DriveContentsResult result =
            Drive.DriveApi.newDriveContents(mGoogleApiClient).await();

    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle(fileName)
            .setMimeType(mimeType)
            .setStarred(true)
            .build();

    // Create a new file with the given changeSet in the AppData folder.
    DriveFolder.DriveFileResult driveFileResult = Drive.DriveApi.getAppFolder(mGoogleApiClient)
            .createFile(mGoogleApiClient, changeSet, result.getDriveContents())
            .await();
    return driveFileResult.getDriveFile().getDriveId();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:22,代码来源:DriveHelper.java

示例2: commitToNewFile

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
/**
 * Creates a new file and adds the {@link DriveContents} passed to this method.
 * @return Returns a boolean stating the success of this operation
 */
private boolean commitToNewFile(DriveContents driveContents) {
    DebugLog.logMethod();
    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle("CouponsTrackerData.txt")
            .setMimeType("text/plain")
            .build();

    DriveFolder.DriveFileResult driveFileResult = Drive.DriveApi
            .getAppFolder(getGoogleApiClient())
            .createFile(getGoogleApiClient(), changeSet, driveContents)
            .await();
    DebugLog.logMessage("DriveFileResult: statusCode - " + driveFileResult.getStatus().getStatusCode()
            + ", statusMessage: " + driveFileResult.getStatus().getStatusMessage());
    return driveFileResult.getStatus().isSuccess();
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:20,代码来源:ExportToDriveService.java

示例3: onResult

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
@Override
public void onResult(@NonNull final DriveApi.DriveContentsResult driveContentsResult) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            DriveFolder appFolder = Drive.DriveApi.getAppFolder(mGoogleApiClient);
            MetadataChangeSet set = new MetadataChangeSet.Builder().setTitle(getString(R.string.drive_file_name)).setMimeType(getString(R.string.drive_file_mimetype)).build();
            appFolder.createFile(mGoogleApiClient, set, driveContentsResult.getDriveContents()).setResultCallback(new ResultCallback<DriveFolder.DriveFileResult>() {
                @Override
                public void onResult(@NonNull DriveFolder.DriveFileResult driveFileResult) {
                    driveFileResult.getDriveFile().open(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(writeDriveCallback);
                    loadingView.setVisibility(View.GONE);
                }
            });
        }
    }).start();
}
 
开发者ID:JeanBarriere,项目名称:Note,代码行数:18,代码来源:MainActivity.java

示例4: showGDriveFolderSelector

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
private static void showGDriveFolderSelector(Activity activity) {
    if (activity == null)
        return;

    OpenFileActivityBuilder openFileActivityBuilder = Drive.DriveApi
            .newOpenFileActivityBuilder();

    if (openFileActivityBuilder != null) {
        IntentSender intentSender = openFileActivityBuilder.setActivityTitle(AndiCar.getAppResources().getString(R.string.pref_secure_backup_gdrive_folder_selector_title))
                .setSelectionFilter(Filters.eq(SearchableField.MIME_TYPE, DriveFolder.MIME_TYPE))
                .build(mGoogleApiClient);
        try {
            activity.startIntentSenderForResult(
                    intentSender, ConstantValues.REQUEST_OPEN_DRIVE_FOLDER, null, 0, 0, 0);
        }
        catch (IntentSender.SendIntentException e) {
            Log.i("AndiCar", "Failed to launch file chooser.");
        }
    }
    else {
        Toast.makeText(activity, "Unable to open folder selector!", Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:24,代码来源:PreferenceActivity.java

示例5: getRootFolderId

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
public String getRootFolderId(boolean create) throws Exception {
    if (!TextUtils.isEmpty(rootId))
        return rootId;
    Log.d(TAG, "Looking for Uoccin folder...");
    FileList files = service.files().list().setQ("mimeType = '" + DriveFolder.MIME_TYPE +
        "' and title = '" + FOLDER + "' and trashed = false").execute();
    if (files != null && !files.isEmpty() && files.getItems().size() > 0) {
        Log.d(TAG, "Uoccin folder found");
        rootId = files.getItems().get(0).getId();
    } else if (create) {
        Log.i(TAG, "Creating Uoccin folder...");
        File body = new File();
        body.setTitle(FOLDER);
        body.setMimeType(DriveFolder.MIME_TYPE);
        rootId = service.files().insert(body).execute().getId();
    } else
        Log.w(TAG, "Uoccin folder NOT found");
    return rootId;
}
 
开发者ID:tarzasai,项目名称:Uoccin,代码行数:20,代码来源:GSA.java

示例6: getDeviceFolderId

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
public String getDeviceFolderId(boolean create) throws Exception {
    if (!TextUtils.isEmpty(deviceId))
        return deviceId;
    if (!TextUtils.isEmpty(getRootFolderId(create))) {
        Log.d(TAG, "Looking for device folder...");
        String dfName = "device." + session.driveDeviceID();
        ChildList children = service.children().list(rootId).setQ("mimeType = '" +
            DriveFolder.MIME_TYPE + "' and title = '" + dfName + "' and trashed = false").execute();
        if (children != null && !children.isEmpty() && children.getItems().size() > 0) {
            Log.d(TAG, "Device folder found");
            deviceId = children.getItems().get(0).getId();
        } else if (create) {
            Log.i(TAG, "Creating device folder...");
            File body = new File();
            body.setTitle(dfName);
            body.setMimeType(DriveFolder.MIME_TYPE);
            body.setParents(Arrays.asList(new ParentReference().setId(rootId)));
            deviceId = service.files().insert(body).execute().getId();
        } else
            Log.w(TAG, "Device folder NOT found");
    }
    return deviceId;
}
 
开发者ID:tarzasai,项目名称:Uoccin,代码行数:24,代码来源:GSA.java

示例7: getOtherFoldersIds

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
public List<String> getOtherFoldersIds() throws Exception {
    getDeviceFolderId(true); // required
    Log.d(TAG, "Looking for other devices folders...");
    List<String> res = new ArrayList<String>();
    ChildList children;
    Children.List request = service.children().list(rootId).setQ("mimeType = '" +
        DriveFolder.MIME_TYPE + "' and title contains 'device.' and trashed = false");
    do {
        try {
            children = request.execute();
            for (ChildReference child : children.getItems())
                if (!deviceId.equals(child.getId()))
                    res.add(child.getId());
            request.setPageToken(children.getNextPageToken());
        } catch (Exception err) {
            Log.e(TAG, "getDeviceFolders", err);
            request.setPageToken(null);
        }
    } while (request.getPageToken() != null && request.getPageToken().length() > 0);
    return res;
}
 
开发者ID:tarzasai,项目名称:Uoccin,代码行数:22,代码来源:GSA.java

示例8: deleteFolder

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
public Observable<Void> deleteFolder(final String folderName) {
	return Observable.defer(new Func0<Observable<Void>>() {
		@Override
		public Observable<Void> call() {
			GoogleApiClient client = googleApiClientManager.getGoogleApiClient();

			// find folder drive id
			DriveFolder appFolder = getAppRootFolder();
			MetadataBuffer queryResult = appFolder.queryChildren(
					client,
					new Query.Builder().addFilter(Filters.eq(SearchableField.TITLE, folderName)).build())
					.await().getMetadataBuffer();
			if (queryResult.getCount() == 0) throw new IllegalArgumentException("no folder with name " + folderName);
			DriveId folderId = queryResult.get(0).getDriveId();

			// delete folder
			DriveFile folder = Drive.DriveApi.getFile(client, folderId);
			folder.delete(client).await();
			return Observable.just(null);
		}
	});
}
 
开发者ID:FauDroids,项目名称:BabyFace,代码行数:23,代码来源:GoogleDriveManager.java

示例9: initializeFolderView

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
/**
 * Initializes the folder view after the given task completes.
 *
 * @return Task which resolves after the view has been initialized
 */
private Task<Void> initializeFolderView() {
    Task<DriveFolder> folderTask;
    if (mNavigationPath.isEmpty()) {
        folderTask = mDriveResourceClient.getRootFolder();
    } else {
        folderTask = Tasks.forResult(mNavigationPath.peek().asDriveFolder());
    }
    Task<Void> initFolderTask = folderTask.continueWith(new Continuation<DriveFolder, Void>() {
        @Override
        public Void then(@NonNull Task<DriveFolder> task) throws Exception {
            DriveId id = task.getResult().getDriveId();
            if (mNavigationPath.isEmpty()) {
                mNavigationPath.push(id);
            }
            return null;
        }
    });
    return updateUiAfterTask(initFolderTask);
}
 
开发者ID:googledrive,项目名称:android-trash,代码行数:25,代码来源:MainActivity.java

示例10: createFile

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
private void createFile() {
    setUiInteractionsEnabled(false);

    int fileCount = mFileFolderAdapter.getCount();

    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                                          .setTitle("sample file " + (fileCount + 1))
                                          .setMimeType("text/plain")
                                          .build();

    DriveFolder driveFolder = mNavigationPath.peek().asDriveFolder();

    Task<DriveFile> createFileTask =
            mDriveResourceClient.createFile(driveFolder, changeSet, null);
    Task<Void> updateTask = updateUiAfterTask(createFileTask);
    handleTaskError(updateTask, R.string.unexpected_error);
}
 
开发者ID:googledrive,项目名称:android-trash,代码行数:18,代码来源:MainActivity.java

示例11: createFolder

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
private void createFolder() {
    setUiInteractionsEnabled(false);

    int fileCount = mFileFolderAdapter.getCount();

    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                                          .setTitle("sample folder " + (fileCount + 1))
                                          .build();

    DriveFolder driveFolder = mNavigationPath.peek().asDriveFolder();

    Task<DriveFolder> createFolderTask =
            mDriveResourceClient.createFolder(driveFolder, changeSet);
    Task<Void> updateTask = updateUiAfterTask(createFolderTask);
    handleTaskError(updateTask, R.string.unexpected_error);
}
 
开发者ID:googledrive,项目名称:android-trash,代码行数:17,代码来源:MainActivity.java

示例12: createAmiiboFolder

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
@DebugLog
private void createAmiiboFolder() {
    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle(AMIIBO_FOLDER).build();

    Drive.DriveApi.getRootFolder(_parent.getClient())
            .createFolder(_parent.getClient(), changeSet)
            .setResultCallback(new ResultCallback<DriveFolder.DriveFolderResult>() {
                @Override
                public void onResult(DriveFolder.DriveFolderResult driveFolderResult) {
                    if (driveFolderResult.getStatus().isSuccess()) {
                        app_folder_for_user = driveFolderResult.getDriveFolder();
                        listFiles();
                    } else {
                        app_folder_for_user = null;
                        _parent.onPushFinished();
                    }
                }
            });
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:21,代码来源:FileManager.java

示例13: onResult

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
@Override
public void onResult(DriveFolder.DriveFileResult result) {
    progress.setProgress(progress.getCurrentProgress() + 1);
    if (!result.getStatus().isSuccess()) {
        errors += 1;
        return;
    }

    if (progress.getCurrentProgress() == progress.getMaxProgress()) {

        new AlertDialogWrapper.Builder(SettingsBackup.this)
                .setTitle(R.string.backup_success)
                .setPositiveButton(R.string.btn_close, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).show();
    }
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:21,代码来源:SettingsBackup.java

示例14: onResult

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
@Override
        public void onResult(DriveFolder.DriveFileResult result) {
            mConnectionRequested = false; // for testing
            if (!result.getStatus().isSuccess()) {
                showMessage("Error while trying to create the file");
                return;
            }
            DriveId driveId = result.getDriveFile().getDriveId();
            showMessage("Created file: " + driveId);
            if (LDebug.ON) Log.d(LOG_TAG, "XXX Created file: " + driveId);
            DriveFile file = driveId.asDriveFile();
            file.addChangeSubscription(getGoogleApiClient());

            if (LDebug.ON) Log.d(LOG_TAG, "XXX resource ID file: "
                    + result.getDriveFile().getDriveId().getResourceId()); // returns null

//            result.getDriveFile().getMetadata().isCanceled();
        }
 
开发者ID:rickshory,项目名称:VegNabAS,代码行数:19,代码来源:MainVNActivity.java

示例15: onNewContents

import com.google.android.gms.drive.DriveFolder; //导入依赖的package包/类
public void onNewContents(DriveApi.DriveContentsResult result)
{
    if (!result.getStatus().isSuccess())
    {
        Toast.makeText(App.getAppContext(), "Error while trying to create new file contents", Toast.LENGTH_SHORT).show();
        return;
    }

    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle("Finanvita " + DateUtils.formatDateTime(App.getAppContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR))
            .setMimeType("application/json")
            .setStarred(false).build();

    Drive.DriveApi.getRootFolder(client).createFile(client, changeSet, result.getDriveContents()).setResultCallback(new ResultCallback<DriveFolder.DriveFileResult>() {
        @Override
        public void onResult(DriveFolder.DriveFileResult driveFileResult) {
            onCreateFile(driveFileResult);
        }
    });
}
 
开发者ID:kimkha,项目名称:Finanvita,代码行数:21,代码来源:YourDataActivity.java


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