本文整理汇总了Java中cn.bmob.v3.datatype.BmobRelation.add方法的典型用法代码示例。如果您正苦于以下问题:Java BmobRelation.add方法的具体用法?Java BmobRelation.add怎么用?Java BmobRelation.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.bmob.v3.datatype.BmobRelation
的用法示例。
在下文中一共展示了BmobRelation.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveNewFriendToServer
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
/**
* 在服务器上关联该好友
*
* @param user 用户实体
* @param currentId 现在的登录用户ID
* @param updateListener 跟新回调
*/
private void saveNewFriendToServer(User user, String currentId, UpdateListener updateListener) {
if (getCurrentUser() != null && currentId.equals(getCurrentUserObjectId())) {
User currentUser = new User();
currentUser.setObjectId(currentId);
BmobRelation relation = new BmobRelation();
relation.add(user);
currentUser.setContacts(relation);
currentUser.update(CustomApplication.getInstance(), updateListener
);
} else {
LogUtil.e("toId:" + currentId);
if (getCurrentUser() != null) {
LogUtil.e("现在的UID:" + getCurrentUserObjectId());
}
// 不是当前用户的情况下
LogUtil.e("不是当前的用户,不在服务器上关联该好友");
updateListener.onFailure(0, "不是当前的用户,不在服务器上关联该好友");
}
}
示例2: toCollect
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void toCollect() {
BmobRelation relation = new BmobRelation();
// 将当前用户添加到MActivity表中的collect字段中,表名当前用户收藏了该活动内容
relation.add(BmobUser.getCurrentUser(User.class));
article.setCollect(relation);
if (article.getCollectIdList() != null) {
collectIdList = article.getCollectIdList();
}
collectIdList.add(user.getObjectId());
article.setCollectIdList(collectIdList);
article.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
Log.e(TAG, "收藏成功");
ivCollect.setImageResource(R.drawable.ic_favorite_orange_500_24dp);
isCollect = true;
} else {
Log.e(TAG, "收藏失败" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例3: toCollect
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void toCollect() {
BmobRelation relation = new BmobRelation();
// 将当前用户添加到MActivity表中的collect字段中,表名当前用户收藏了该活动内容
relation.add(BmobUser.getCurrentUser(User.class));
mactivity.setCollect(relation);
if (mactivity.getCollectIdList() != null) {
collectIdList = mactivity.getCollectIdList();
}
collectIdList.add(BmobUser.getCurrentUser(User.class).getObjectId());
mactivity.setCollectIdList(collectIdList);
mactivity.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
Log.e(TAG, "收藏成功");
ivCollect.setImageResource(R.drawable.ic_favorite_orange_500_24dp);
isCollect = true;
} else {
Log.e(TAG, "收藏失败" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例4: startFollowRequest
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void startFollowRequest(User user, final RequestListener<String> listener) {
final User currentUser = BmobUser.getCurrentUser(User.class);
BmobRelation relation = new BmobRelation();
relation.add(user);
currentUser.setFollowPerson(relation);
currentUser.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
listener.success(null);
} else {
listener.error(ErrMsgFactory.errMSG(e.getErrorCode()));
}
}
});
}
示例5: startLikeRequest
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void startLikeRequest(Post post, final RequestListener<String> listener) {
final User user = BmobUser.getCurrentUser(User.class);
//将当前用户添加到Post表中的likes字段值中,表明当前用户喜欢该帖子
BmobRelation relation = new BmobRelation();
//将当前用户添加到多对多关联中
relation.add(user);
//多对多关联指向`post`的`likes`字段
post.setLikes(relation);
post.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
listener.success("收藏成功");
} else {
listener.error(ErrMsgFactory.errMSG(e.getErrorCode()));
}
}
});
}
示例6: startLikeRequest
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void startLikeRequest(Post post, final RequestListener<String> listener) {
final User user = BmobUser.getCurrentUser(User.class);
//将当前用户添加到Post表中的likes字段值中,表明当前用户喜欢该帖子
BmobRelation relation = new BmobRelation();
//将当前用户添加到多对多关联中
relation.add(user);
//多对多关联指向`post`的`likes`字段
post.setLikes(relation);
post.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
listener.success(null);
} else {
listener.error(ErrMsgFactory.errMSG(e.getErrorCode()));
}
}
});
}
示例7: buildAndAddFriend
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void buildAndAddFriend() {
UserSoicalInfo userSoicalInfo = new UserSoicalInfo();
RunUser runUser = BmobUser.getCurrentUser(RunUser.class);
userSoicalInfo.setRunner(runUser);//一对一关系
BmobRelation relation = new BmobRelation();
relation.add(mFriRunner);
userSoicalInfo.setFriends(relation);
userSoicalInfo.save(new SaveListener<String>() {
@Override
public void done(String arg0, BmobException e) {
// TODO Auto-generated method stub
if(e==null){
Log.i(MainActivity.TAG, "add friend ok");
Toast.makeText(getApplicationContext(), "add friend ok", Toast.LENGTH_SHORT).show();
}else{
Log.i(MainActivity.TAG, "add friend fail err="+e.getMessage());
Toast.makeText(getApplicationContext(), "add friend fail", Toast.LENGTH_SHORT).show();
}
}
});
}
示例8: addFriend
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void addFriend(UserSoicalInfo userSoicalInfo){
BmobRelation relation = new BmobRelation();
relation.add(mFriRunner);
userSoicalInfo.setFriends(relation);
userSoicalInfo.update(new UpdateListener() {
@Override
public void done(BmobException e) {
// TODO Auto-generated method stub
if(e==null){
Log.i(MainActivity.TAG, "update soicalFri ok");
}else{
Log.i(MainActivity.TAG, "update soicalFri fail");
}
}
});
}
示例9: addBlackRelation
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void addBlackRelation(User user, UpdateListener listener) {
User currentUser = new User();
currentUser.setObjectId(getCurrentUserObjectId());
BmobRelation relation = new BmobRelation();
relation.add(user);
currentUser.setBlack(relation);
currentUser.update(CustomApplication.getInstance(), listener);
}
示例10: toFocus
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void toFocus() {
// 将动态作者的ID添加
if (user.getFocusIds() != null) {
focusId = user.getFocusIds();
}
BmobRelation relation = new BmobRelation();
relation.add(dynamicAuthor);
user.setFocus(relation);
focusId.add(dynamicAuthor.getObjectId());
user.setFocusIds(focusId);
user.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
tvFocus.setText("已关注");
isFocus = true;
String nums = tvFan.getText().toString();
Integer num = Integer.valueOf(nums);
Integer numshow = num + 1;
tvFan.setText(numshow.toString());
} else {
showToast("关注失败" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例11: toLike
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void toLike() {
BmobRelation relation = new BmobRelation();
// 将当前用户添加到MActivity表中的like字段值中,表名当前用户喜欢这个帖子
relation.add(BmobUser.getCurrentUser(User.class));
article.setLike(relation);
// 添加当前用户的ID
if (article.getLikeIdList() != null) {
likeIdList = article.getLikeIdList();
}
likeIdList.add(user.getObjectId());
article.setLikeIdList(likeIdList);
article.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
//queryLikes();
tvLikeNum.setText("赞("+likeIdList.size()+")");
ivLike.setImageResource(R.drawable.ic_thumb_up_orange_500_24dp);
isLike = true;
} else {
showToast("设置点赞失败" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例12: join
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
/**
* 具体的报名逻辑
*/
private void join() {
BmobRelation relation = new BmobRelation();
relation.add(BmobUser.getCurrentUser(User.class));
mactivity.setJoin(relation);
// 添加当前用户的ID
if (mactivity.getJoinIdList() != null) {
joinIdList = mactivity.getJoinIdList();
}
joinIdList.add(BmobUser.getCurrentUser(User.class).getObjectId());
mactivity.setJoinIdList(joinIdList);
mactivity.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
showToast("报名成功,请及时参加");
btnJoin.setText(R.string.joined);
btnJoin.setBackground(getResources().getDrawable(R.color.unused));
btnJoin.setClickable(false);
tvFlag.setText(R.string.joined);
} else {
showToast("报名失败,请稍后重试" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例13: toLike
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void toLike() {
BmobRelation relation = new BmobRelation();
// 将当前用户添加到MActivity表中的like字段值中,表名当前用户喜欢这个帖子
relation.add(BmobUser.getCurrentUser(User.class));
mactivity.setLike(relation);
// 添加当前用户的ID
if (mactivity.getLikeIdList() != null) {
likeIdList = mactivity.getLikeIdList();
}
likeIdList.add(BmobUser.getCurrentUser(User.class).getObjectId());
mactivity.setLikeIdList(likeIdList);
mactivity.update(new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
tvLikeNum.setText("赞(" + likeIdList.size() + ")");
ivLike.setImageResource(R.drawable.ic_thumb_up_orange_500_24dp);
isLike = true;
} else {
showToast("设置点赞失败" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例14: onClickFav
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void onClickFav(View v, DianDi DianDi) {
// TODO Auto-generated method stub
User user = BmobUser.getCurrentUser(mContext, User.class);
if (user != null && user.getSessionToken() != null) {
BmobRelation favRelaton = new BmobRelation();
DianDi.setMyFav(!DianDi.getMyFav());
if (DianDi.getMyFav()) {
((ImageView) v).setImageResource(R.drawable.ic_action_fav_choose);
favRelaton.add(DianDi);
ShowToast("收藏成功。");
} else {
((ImageView) v).setImageResource(R.drawable.ic_action_fav_normal);
favRelaton.remove(DianDi);
ShowToast("取消收藏。");
}
user.setFavorite(favRelaton);
user.update(mContext, new UpdateListener() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
L.i(TAG, "收藏成功。");
//try get fav to see if fav success
// getMyFavourite();
}
@Override
public void onFailure(int arg0, String arg1) {
// TODO Auto-generated method stub
L.i(TAG, "收藏失败。请检查网络~");
ShowToast("收藏失败。请检查网络~" + arg0);
}
});
}
}
示例15: onClickFav
import cn.bmob.v3.datatype.BmobRelation; //导入方法依赖的package包/类
private void onClickFav(View v) {
// TODO Auto-generated method stub
User user = BmobUser.getCurrentUser(this, User.class);
if (user != null && user.getSessionToken() != null) {
BmobRelation favRelaton = new BmobRelation();
mDianDi.setMyFav(!mDianDi.getMyFav());
if (mDianDi.getMyFav()) {
((ImageView) v).setImageResource(R.drawable.ic_action_fav_choose);
favRelaton.add(mDianDi);
ShowToast("收藏成功。");
} else {
((ImageView) v).setImageResource(R.drawable.ic_action_fav_normal);
favRelaton.remove(mDianDi);
ShowToast("取消收藏。");
}
user.setFavorite(favRelaton);
user.update(this, new UpdateListener() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
L.i(TAG, "收藏成功。");
ShowToast("收藏成功。");
//try get fav to see if fav success
// getMyFavourite();
}
@Override
public void onFailure(int arg0, String arg1) {
// TODO Auto-generated method stub
L.i(TAG, "收藏失败。请检查网络~");
ShowToast("收藏失败。请检查网络~" + arg0);
}
});
} else {
//前往登录注册界面
ShowToast("收藏前请先登录。");
Intent intent = new Intent();
intent.setClass(this, LoginActivity.class);
startActivityForResult(intent, Constant.SAVE_FAVOURITE);
}
}