當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。