本文整理汇总了Java中com.google.cloud.backend.core.CloudEntity类的典型用法代码示例。如果您正苦于以下问题:Java CloudEntity类的具体用法?Java CloudEntity怎么用?Java CloudEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudEntity类属于com.google.cloud.backend.core包,在下文中一共展示了CloudEntity类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView != null ?
convertView : mInflater.inflate(R.layout.row_post, parent, false);
CloudEntity ce = getItem(position);
if (ce != null) {
TextView message = (TextView) view.findViewById(R.id.messageContent);
TextView signature = (TextView) view.findViewById(R.id.signature);
if (message != null) {
message.setText(ce.get("message").toString());
}
if (signature != null) {
signature.setText(getAuthor(ce) + " " + SDF.format(ce.getCreatedAt()));
}
}
return view;
}
示例2: onSendButtonPressed
import com.google.cloud.backend.core.CloudEntity; //导入依赖的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);
}
示例3: listPosts
import com.google.cloud.backend.core.CloudEntity; //导入依赖的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);
}
示例4: onContextItemSelected
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
CloudEntity selectedEntity = mPosts.get(info.position);
if (!isCloudEntityPicture(selectedEntity)) {
Toast.makeText(getBaseContext(), "This menu is not available with the item selected",
Toast.LENGTH_SHORT).show();
return false;
}
switch (item.getItemId()) {
case R.id.transform_image:
transformImage(selectedEntity);
return true;
default:
return super.onContextItemSelected(item);
}
}
示例5: getAuthor
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
/**
* Gets the author field of the CloudEntity.
*
* @param post the CloudEntity
* @return author string
*/
private String getAuthor(CloudEntity post) {
if (post.getCreatedBy() != null) {
return " " + post.getCreatedBy().replaceFirst("@.*", "");
} else {
return "<anonymous>";
}
}
示例6: onBroadcastMessageReceived
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
/**
* Method called via OnListener in {@link CloudBackendFragment}.
*/
@Override
public void onBroadcastMessageReceived(List<CloudEntity> l) {
for (CloudEntity e : l) {
String message = (String) e.get(BROADCAST_PROP_MESSAGE);
int duration = Integer.parseInt((String) e.get(BROADCAST_PROP_DURATION));
Toast.makeText(this, message, duration).show();
Log.i(Consts.TAG, "A message was recieved with content: " + message);
}
}
示例7: transformImage
import com.google.cloud.backend.core.CloudEntity; //导入依赖的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);
}
示例8: onBroadcastMessageReceived
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
/**
* Method called via OnListener in {@link com.google.cloud.backend.core.CloudBackendFragment}.
*/
@Override
public void onBroadcastMessageReceived(List<CloudEntity> l) {
for (CloudEntity e : l) {
String message = (String) e.get(BROADCAST_PROP_MESSAGE);
int duration = Integer.parseInt((String) e.get(BROADCAST_PROP_DURATION));
Toast.makeText(this, message, duration).show();
Log.i(Consts.TAG, "A message was recieved with content: " + message);
}
}
示例9: insertNewMessage
import com.google.cloud.backend.core.CloudEntity; //导入依赖的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);
}
示例10: onSendButtonPressed
import com.google.cloud.backend.core.CloudEntity; //导入依赖的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);
}
示例11: isCloudEntityPicture
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
private boolean isCloudEntityPicture(CloudEntity e) {
String entityMessage = e.get("message").toString();
return entityMessage.startsWith(GuestbookActivity.BLOB_PICTURE_MESSAGE_PREFIX +
GuestbookActivity.BLOB_PICTURE_DELIMITER);
}
示例12: PostAdapter
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
/**
* Creates a new instance of this adapter.
*
* @param context
* @param textViewResourceId
* @param objects
*/
public PostAdapter(Context context, int textViewResourceId, List<CloudEntity> objects) {
super(context, textViewResourceId, objects);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
示例13: PostAdapter
import com.google.cloud.backend.core.CloudEntity; //导入依赖的package包/类
/**
* Creates a new instance of this adapter.
*
* @param context
* @param textViewResourceId
* @param objects
*/
public PostAdapter(Context context, int textViewResourceId, List<CloudEntity> objects) {
super(context, textViewResourceId, objects);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}