本文整理汇总了Java中com.google.cloud.backend.core.CloudCallbackHandler类的典型用法代码示例。如果您正苦于以下问题:Java CloudCallbackHandler类的具体用法?Java CloudCallbackHandler怎么用?Java CloudCallbackHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudCallbackHandler类属于com.google.cloud.backend.core包,在下文中一共展示了CloudCallbackHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSendButtonPressed
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
/**
* onClick method.
*/
public void onSendButtonPressed(View view) {
// create a CloudEntity with the new post
CloudEntity newPost = new CloudEntity("Guestbook");
newPost.put("message", Integer.toString(testint) );
testint ++;
// create a response handler that will receive the result or an error
CloudCallbackHandler<CloudEntity> handler = new CloudCallbackHandler<CloudEntity>() {
@Override
public void onComplete(final CloudEntity result) {
mPosts.add(0, result);
updateGuestbookView();
mSendBtn.setEnabled(true);
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
// execute the insertion with the handler
mProcessingFragment.getCloudBackend().insert(newPost, handler);
mSendBtn.setEnabled(true);
}
示例2: listPosts
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
/**
* Retrieves the list of all posts from the backend and updates the UI. For
* demonstration in this sample, the query that is executed is:
* "SELECT * FROM Guestbook ORDER BY _createdAt DESC LIMIT 50" This query
* will be re-executed when matching entity is updated.
*/
private void listPosts() {
// create a response handler that will receive the result or an error
CloudCallbackHandler<List<CloudEntity>> handler =
new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
mAnnounceTxt.setText(R.string.announce_success);
mPosts = results;
animateArrival();
updateGuestbookView();
}
@Override
public void onError(IOException exception) {
mAnnounceTxt.setText(R.string.announce_fail);
animateArrival();
handleEndpointException(exception);
}
};
// execute the query with the handler
mProcessingFragment.getCloudBackend().listByKind(
"Guestbook", CloudEntity.PROP_CREATED_AT, Order.DESC, 50,
Scope.FUTURE_AND_PAST, handler);
}
示例3: transformImage
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
private void transformImage(CloudEntity selectedEntity) {
String entityMessage = selectedEntity.get("message").toString();
CloudCallbackHandler<BlobAccess> handlerForProcessImage = new CloudCallbackHandler<BlobAccess>() {
@Override
public void onComplete(final BlobAccess blobAccessResult) {
Toast.makeText(getBaseContext(), "Uploading the transformed image", Toast.LENGTH_SHORT).show();
String pictureMesage = BLOB_PICTURE_MESSAGE_PREFIX + BLOB_PICTURE_DELIMITER
+ blobAccessResult.getAccessUrl();
insertNewMessage(pictureMesage);
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
BucketAndObjectName bucketAndObjectName = parsePictureMessageToBucketAndObject(entityMessage);
CloudBackend.ImageTransformationParam param = new CloudBackend.ImageTransformationParam();
param.bucketName = bucketAndObjectName.bucketName;
param.objectName = bucketAndObjectName.objectName;
param.accessModeForTransformedImage = "PUBLIC_READ";
Toast.makeText(getBaseContext(), "Transforming the image", Toast.LENGTH_SHORT).show();
findViewById(R.id.progress_horizontal).setVisibility(View.VISIBLE);
mProcessingFragment.getCloudBackend().transformImage(param, handlerForProcessImage);
}
示例4: insertNewMessage
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
private void insertNewMessage(String message) {
// create a CloudEntity with the new post
CloudEntity newPost = new CloudEntity("Guestbook");
newPost.put("message", message);
// create a response handler that will receive the result or an error
CloudCallbackHandler<CloudEntity> handler = new CloudCallbackHandler<CloudEntity>() {
@Override
public void onComplete(final CloudEntity result) {
mPosts.add(0, result);
updateGuestbookView();
mMessageTxt.setText("");
mMessageTxt.setEnabled(true);
mSendBtn.setEnabled(true);
findViewById(R.id.progress_horizontal).setVisibility(View.GONE);
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
findViewById(R.id.progress_horizontal).setVisibility(View.VISIBLE);
// execute the insertion with the handler
mProcessingFragment.getCloudBackend().insert(newPost, handler);
mMessageTxt.setEnabled(false);
mSendBtn.setEnabled(false);
}
示例5: onSendButtonPressed
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
/**
* onClick method.
*/
public void onSendButtonPressed(View view) {
// create a CloudEntity with the new post
CloudEntity newPost = new CloudEntity("Guestbook");
newPost.put("message", mMessageTxt.getText().toString());
// create a response handler that will receive the result or an error
CloudCallbackHandler<CloudEntity> handler = new CloudCallbackHandler<CloudEntity>() {
@Override
public void onComplete(final CloudEntity result) {
mPosts.add(0, result);
updateGuestbookView();
mMessageTxt.setText("");
mMessageTxt.setEnabled(true);
mSendBtn.setEnabled(true);
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
// execute the insertion with the handler
mProcessingFragment.getCloudBackend().insert(newPost, handler);
mMessageTxt.setEnabled(false);
mSendBtn.setEnabled(false);
}
示例6: uploadSelectedPicture
import com.google.cloud.backend.core.CloudCallbackHandler; //导入依赖的package包/类
/**
* Uploads the selected image to Google Cloud Storage.
*
* @param data The intent with which the image was selected.
*/
private void uploadSelectedPicture(Intent data) {
Uri selectedImageUri = data.getData();
final InputStream uploadInputStream = getInputStreamFromUri(selectedImageUri);
if (uploadInputStream == null) {
Toast.makeText(getApplicationContext(), "Failed to load the image", Toast.LENGTH_LONG).show();
return;
}
final CloudBackend.BlobAccessParam blobAccessParam = new CloudBackend.BlobAccessParam();
blobAccessParam.bucketName = Consts.PROJECT_ID;
blobAccessParam.objectName = String.valueOf("cloudguestbook-picture-" + System.currentTimeMillis());
blobAccessParam.accessMode = "PUBLIC_READ";
blobAccessParam.contentType = "";
// create a response handler that will receive the result or an error
CloudCallbackHandler<BlobAccess> handlerForBlobUpload = new CloudCallbackHandler<BlobAccess>() {
@Override
public void onComplete(final BlobAccess blobAccessResult) {
CloudBackend.BlobUploadParam uploadParam = new CloudBackend.BlobUploadParam();
uploadParam.blobAccess = blobAccessResult;
uploadParam.inputStream = uploadInputStream;
uploadParam.blobAccessParam = blobAccessParam;
mProcessingFragment.getCloudBackend().uploadBlob(uploadParam, new CloudCallbackHandler<Boolean>() {
@Override
public void onComplete(Boolean booleanResult) {
String message = booleanResult ? "Upload completed " : "Failed to upload";
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
if (booleanResult) {
String pictureMesage = BLOB_PICTURE_MESSAGE_PREFIX + BLOB_PICTURE_DELIMITER
+ blobAccessResult.getAccessUrl();
insertNewMessage(pictureMesage);
}
}
});
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
findViewById(R.id.progress_horizontal).setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(), "Uploading the image", Toast.LENGTH_LONG).show();
mProcessingFragment.getCloudBackend().getBlobUploadUrl(blobAccessParam, handlerForBlobUpload);
}