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


Java Metadata类代码示例

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


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

示例1: queryFile

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
private void queryFile() {
    Query query = new Query.Builder()
            .addFilter(Filters.contains(SearchableField.TITLE, "Note.json"))
            .build();
    Drive.DriveApi.query(
            mGoogleApiClient, query).setResultCallback(result -> {
        if (!result.getStatus().isSuccess()) {
            if (BuildConfig.DEBUG)
                Log.d(TAG, "Problem while retrieving results");
            return;
        }

        Metadata metadata = result.getMetadataBuffer().get(0);
        if (BuildConfig.DEBUG)
            Log.d(TAG, "metadata.getDriveId():" + metadata.getDriveId());
        readFileFromDrive(metadata.getDriveId());
    });
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:19,代码来源:SettingsActivity.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,代码行数:33,代码来源:Querier.java

示例3: onMetaDataReceived

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
/**
 * Handles received DriveFile Metadata for comparing the newer status of the local and Drive
 * copies of the Database
 *
 * @param m the received Metadata
 */
@Override
public void onMetaDataReceived(Metadata m) {
    if (mRequestQueue.size() > 0) {

        if (mRequestQueue.peek() == COMPARE) {
            mRequestQueue.poll();

            if (compareDriveLocalNewer(m.getModifiedDate())) {
                newerStatusCallback.driveNewer();
            } else {
                newerStatusCallback.localNewer();
            }
        }
    } else {
        Log.e("Controller", "Queue size 0?...");
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:24,代码来源:DriveSyncController.java

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

示例5: onMetaDataReceived

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
/**
 * Handles received DriveFile Metadata for comparing the newer status of the local and Drive
 * copies of the Database
 * @param m the received Metadata
 */
@Override
public void onMetaDataReceived(Metadata m) {
    if (mRequestQueue.size() > 0) {

        if (mRequestQueue.peek() == COMPARE) {
            mRequestQueue.poll();

            if (compareDriveLocalNewer(m.getModifiedDate())) {
                newerStatusCallback.driveNewer();
            } else {
                newerStatusCallback.localNewer();
            }
        }
    } else {
        Log.e("Controller", "Queue size 0?...");
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:23,代码来源:DriveSyncController.java

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

示例7: readFileContent

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@DebugLog
public void readFileContent(final String file_name, final List<Metadata> remainings) {
    Query query = new Query.Builder()
            .addFilter(Filters.eq(SearchableField.TITLE, file_name))
            .build();

    app_folder_for_user.queryChildren(_parent.getClient(), query)
            .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
                @Override
                public void onResult(DriveApi.MetadataBufferResult metadataBufferResult) {
                    MetadataBuffer buffer = metadataBufferResult.getMetadataBuffer();
                    int count = buffer.getCount();
                    if (count > 0) {
                        readFileFromDrive(buffer, buffer.get(0).getDriveId());
                    } else {
                        _parent.onFileRead(null);
                    }

                    readFileContent(remainings);
                }
            });
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:23,代码来源:FileManager.java

示例8: onResult

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@Override
public void onResult(@NonNull DriveApi.MetadataBufferResult result) {
    if(!result.getStatus().isSuccess()) {
        Log.w(LOG_TAG, "Retrieving files received error");
    }
    else {
        for(Metadata data : result.getMetadataBuffer()) {
            String fileName = data.getTitle();
            if(fileName != null && fileName.equalsIgnoreCase(SAVED_DATA)) {
                mDriveId = data.getDriveId();
                break;
            }
        }
    }
    if(mDriveId!=null) {
        read();
    }
    else {
        mListener.onSyncFailed(CA.NO_DATA);
    }
    result.release();
}
 
开发者ID:zhuqianqian,项目名称:Passbook,代码行数:23,代码来源:DriveSyncService.java

示例9: onResult

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@Override
public void onResult(MetadataBufferResult result) {
	if (!result.getStatus().isSuccess()) {
		showMessage("Problem while retrieving files");
		return;
	}
	mDriveResultsAdapter.setData(result.getMetadataBuffer());
	listView.setOnItemLongClickListener(new OnItemLongClickListener() {
		@Override
		public boolean onItemLongClick(AdapterView<?> parent,
				View view, int position, long id) {
			Metadata metadata = mDriveResultsAdapter.getItem(position);
			StringBuilder sb = new StringBuilder();
			sb.append(metadata.getTitle() + "\n")
			.append(metadata.getMimeType() + "\n")
			.append(metadata.getFileSize() + "\n")
			.append(metadata.getCreatedDate() + "\n")
			.append(metadata.getModifiedDate() + "\n");
			showMessage(sb.toString());
			
			return false;
		}
	});
}
 
开发者ID:kanpol,项目名称:omni-note,代码行数:25,代码来源:DriveActivity.java

示例10: getServerItems

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@WorkerThread
@Nullable
public ArrayList<ServerItem> getServerItems(GoogleApiClient googleApiClient) {
    Log.d();
    Query query = new Query.Builder().build();
    DriveApi.MetadataBufferResult metadataBufferResult =
            Drive.DriveApi.getAppFolder(googleApiClient).queryChildren(googleApiClient, query).await(AWAIT_DELAY_SHORT, AWAIT_UNIT_SHORT);
    Status status = metadataBufferResult.getStatus();
    Log.d("status=" + status);
    if (!status.isSuccess()) {
        Log.w("Could not query app folder");
        metadataBufferResult.release();
        return null;
    }
    MetadataBuffer metadataBuffer = metadataBufferResult.getMetadataBuffer();
    int count = metadataBuffer.getCount();
    Log.d("count=" + count);
    ArrayList<ServerItem> res = new ArrayList<>(count);
    for (Metadata metadata : metadataBuffer) {
        res.add(new ServerItem(metadata));
    }
    metadataBufferResult.release();
    Log.d(res.toString());
    return res;
}
 
开发者ID:BoD,项目名称:bikey,代码行数:26,代码来源:GoogleDriveSyncManager.java

示例11: findChild

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
public static DriveId findChild(GoogleApiClient mClient, String title, DriveFolder baseFolder) {
    ArrayList<Filter> fltrs = new ArrayList<>();
    fltrs.add(Filters.eq(SearchableField.TRASHED, false));
    if (title != null) fltrs.add(Filters.eq(SearchableField.TITLE, title));
    Query qry = new Query.Builder().addFilter(Filters.and(fltrs)).build();
    DriveApi.MetadataBufferResult rslt = (baseFolder == null) ?
            Drive.DriveApi.query(mClient, qry).await() :
            baseFolder.queryChildren(mClient, qry).await();
    if (rslt.getStatus().isSuccess()) {
        MetadataBuffer mdb = null;
        try {
            mdb = rslt.getMetadataBuffer();
            if (mdb != null) {
                for (Metadata md : mdb) {
                    if (md == null) continue;
                    return md.getDriveId();      // here is the "Drive ID"
                }
            }
        } finally {
            if (mdb != null) mdb.close();
        }
    }
    return null;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:25,代码来源:GDrive.java

示例12: readRelativeDir

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
void readRelativeDir(Context context, Icons.IconType iconType, Icons.IconState state, MetadataBuffer children) {
    for (int i = 0; i < children.getCount(); ++i) {
        Metadata d = children.get(i);
        if (!d.isFolder()) {
            DriveFile file = Drive.DriveApi.getFile(mClient, d.getDriveId());
            DriveApi.ContentsResult contentsResult =
                    file.openContents(mClient, DriveFile.MODE_READ_ONLY, null).await();
            if (!contentsResult.getStatus().isSuccess()) {
                continue;
            }
            Contents r = contentsResult.getContents();
            Icons.saveIcon(context, d.getTitle(), iconType, state, r.getInputStream());
        }
    }
    children.close();
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:17,代码来源:GDriveRestoreBackupTask.java

示例13: readFile

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
private String readFile(Metadata d) {
    DriveFile file = Drive.DriveApi.getFile(mClient, d.getDriveId());
    DriveApi.ContentsResult contentsResult =
            file.openContents(mClient, DriveFile.MODE_READ_ONLY, null).await();
    if (!contentsResult.getStatus().isSuccess()) {
        return null;
    }
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(contentsResult.getContents().getInputStream()));
    StringBuilder builder = new StringBuilder();
    String line;
    String contents = null;
    try {
        while ((line = reader.readLine()) != null) {
            builder.append(line);
        }
        contents = builder.toString();
    } catch (IOException e) {
        Log.e("GDriveRestoreBackupTask", "IOException while reading from the stream", e);
    }

    file.discardContents(mClient, contentsResult.getContents()).await();
    return contents;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:25,代码来源:GDriveRestoreBackupTask.java

示例14: onMenuItemClick

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
    final Metadata item = GDriveBackupsAdapter.getItem(clickedPosition);

    switch (menuItem.getItemId()) {
        case R.id.menu_gDrive_remove: {
            gDrive.deleteBackup(item, new GDriveRemoveTask.DoneSuccess() {
                @Override
                public void done() {
                    gDrive.getListOfBackups(GDriveBackupsAdapter);
                }
            });
            return true;
        }
        case R.id.menu_gDrive_restore: {
            gDrive.restoreBackup(item.getDriveId());
            return true;
        }
    }
    return false;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:22,代码来源:GDriveFragment.java

示例15: onResult

import com.google.android.gms.drive.Metadata; //导入依赖的package包/类
@Override
public void onResult(DriveResource.MetadataResult result) {
    if (!result.getStatus().isSuccess()) {
        showMessage("Problem while trying to fetch metadata");
        return;
    }
    Metadata metadata = result.getMetadata();
    showMessage("Metadata successfully fetched. Title: " + metadata.getTitle());
}
 
开发者ID:etsy,项目名称:divertsy-client,代码行数:10,代码来源:SyncToDriveService.java


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