本文整理汇总了Java中com.avos.avoscloud.SaveCallback类的典型用法代码示例。如果您正苦于以下问题:Java SaveCallback类的具体用法?Java SaveCallback怎么用?Java SaveCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SaveCallback类属于com.avos.avoscloud包,在下文中一共展示了SaveCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markAddRequestsRead
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
/**
* 标记消息为已读,标记完后会刷新未读消息数量
*/
public void markAddRequestsRead(List<AddRequest> addRequestList) {
if (addRequestList != null) {
for (AddRequest request : addRequestList) {
request.put(AddRequest.IS_READ, true);
}
AVObject.saveAllInBackground(addRequestList, new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
countUnreadRequests(null);
}
}
});
}
}
示例2: agreeAddRequest
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public void agreeAddRequest(final AddRequest addRequest, final SaveCallback saveCallback) {
addFriend(addRequest.getFromUser().getObjectId(), new SaveCallback() {
@Override
public void done(AVException e) {
if (e != null) {
if (e.getCode() == AVException.DUPLICATE_VALUE) {
addRequest.setStatus(AddRequest.STATUS_DONE);
addRequest.saveInBackground(saveCallback);
} else {
saveCallback.done(e);
}
} else {
addRequest.setStatus(AddRequest.STATUS_DONE);
addRequest.saveInBackground(saveCallback);
}
}
});
}
示例3: updateUserInfo
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
/**
* 上传用户信息,首先上传头像,上传成功后赶回头像地址,然后上传其他信息
*/
private void updateUserInfo(Bitmap avatar) {
//如果头像为空,也就是用户没有上传头像,则使用之前的头像地址
if (avatar == null) {
} else {
final AVFile avatarFile = new AVFile("user_avatar.jpeg", ImageUtil.bitmap2Bytes(avatar));
avatarFile.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
Log.i("lin", "----lin----> imgUrl" + avatarFile.getUrl());
_cardView = avatarFile.getUrl();
}
}
});
}
}
示例4: updateUserInfo
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
/**
* 上传用户信息,首先上传头像,上传成功后赶回头像地址,然后上传其他信息
*/
private void updateUserInfo(Bitmap avatar) {
//如果头像为空,也就是用户没有上传头像,则使用之前的头像地址
if (avatar == null) {
} else {
final AVFile avatarFile = new AVFile("user_avatar.jpeg", ImageUtil.bitmap2Bytes(avatar));
avatarFile.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
Log.i("lin", "----lin----> imgUrl" + avatarFile.getUrl());
imageUrl = avatarFile.getUrl();
}
}
});
}
}
示例5: initAVSDK
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
private void initAVSDK(Context context) {
Map map = this.getAppInfo();
if(map != null && map.get("appId") != null && map.get("appKey") != null) {
// 初始化应用信息
String appId = map.get("appId").toString();
String appKey = map.get("appKey").toString();
AVOSCloud.initialize(context, appId, appKey);
// 启用崩溃错误统计
AVAnalytics.enableCrashReport(context.getApplicationContext(), true);
AVOSCloud.setLastModifyEnabled(true);
AVOSCloud.setDebugLogEnabled(true);
//必须要设置默认的通知回调或者订阅一个频道,否则接收不到通知
mRNPushNotificationHelper = new RNPushNotificationHelper(this.mApplication);
PushService.setDefaultPushCallback(context.getApplicationContext(), mRNPushNotificationHelper.getMainActivityClass());
//this.subscribeChannel("public");
// 保存 installation 到服务器
AVInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(AVException e) {
String installationId = AVInstallation.getCurrentInstallation().getInstallationId();
sendRegistrationToken(installationId);
}
});
}
}
示例6: onClick
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SaveCallback saveCallback=new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
mHandler.obtainMessage(1).sendToTarget();
} else {
mHandler.obtainMessage(2).sendToTarget();
}
}
};
String advice = submitEditText.getText().toString();
AVService.createAdvice(getUserId(), advice, saveCallback);
}
示例7: onCreate
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// AVOSCloud.useAVCloudUS();//
CrashReport.initCrashReport(getApplicationContext(), "900020615", false);
// CrashReport.testJavaCrash();
AVOSCloud.initialize(this, "6vNrCi5ou4rw5sb0fx8b0J4w-gzGzoHsz", "zfuBYXx8X235VVi6O7acOM8G");
AVInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(AVException e) {
if (e == null) {
// 保存成功
String installationId = AVInstallation.getCurrentInstallation().getInstallationId();
// 关联 installationId 到用户表等操作……
} else {
// 保存失败,输出错误信息
}
}
});
PushService.setDefaultPushCallback(this, UpdateActivity.class);
}
示例8: addFriend
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
private void addFriend(String friendId) {
// String friendId = avObject.getObjectId();
AVObject object = new AVObject(Constants.TABLE_NAME_FRIEND);
object.put(Constants.KEY_FRIEND_ID, friendId);
object.put(Constants.KEY_USER_ID, userId);
object.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
Log.d(TAG, "save success!");
ToastUtil.showToastShort(FriendActivity.this, "add friend success!");
closeAddDialog();
// refresh list
queryFriends();
}
}
});
}
示例9: doSignUp
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
private void doSignUp(String username, String password, String nickname) {
AVObject userObject = new AVObject(Constants.TABLE_NAME_USER);
userObject.put(Constants.KEY_USERNAME, username);
userObject.put(Constants.KEY_PASSWORD, password);
userObject.put(Constants.KEY_NICKNAME, nickname);
userObject.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
onSignUpSuccess();
} else {
ToastUtil.showToastShort(SignUpActivity.this, "sign up failed!");
onSignUpFailed();
}
btnSignUp.setEnabled(true);
}
});
}
示例10: createOrUpdateShot
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public static void createOrUpdateShot(final String title,final String githubUrl,final String description, final String image_uri, final SaveCallback saveCallback) {
String name = System.currentTimeMillis()+"";
if (image_uri != null) {
Uri uri=Uri.parse(image_uri);
byte[] data = ImageUtils.readFile(mContext,uri);
final AVFile file = new AVFile(name, data);
file.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e != null) {
Log.d("wds",e.toString());
saveCallback.done(e);
} else {
String image_url = file.getUrl();
saveShot(title,githubUrl,description, image_url, saveCallback);
}
}
});
} else {
saveShot(title,githubUrl,description, "", saveCallback);
}
}
示例11: saveShot
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public static void saveShot(final String title,final String githubUrl,final String description,final String image_url, final SaveCallback saveCallback) {
final Shot shot = new Shot();
String avatar=AVUser.getCurrentUser().getString(UserDAO.AVATAR_URL);
String username=AVUser.getCurrentUser().getUsername();
String userId=AVUser.getCurrentUser().getObjectId();
shot.setUserID(userId);
shot.setUserAvatar(avatar);
shot.setUserName(username);
shot.setTitle(title);
shot.setGitHubUrl(githubUrl);
shot.setDescription(description);
shot.setImageURL(image_url);
// Map<String, Object> datas = new HashMap<String, Object>();
// datas.put(App.DETAIL_ID, shot.getObjectId());
// shot.setData(datas);
// 异步保存
shot.saveInBackground(saveCallback);
// AVStatus.sendStatusToFollowersInBackgroud(shot, saveCallback);
}
示例12: join
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
@Click(R.id.id_btn_join)
void join() {
AVUser user = AVUser.getCurrentUser();
final AVObject object = new AVObject("user_join");
object.put("user", user);
object.put("idea", mIdea);
object.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e == null) {
showToast("保存成功");
mIdea.increment("joinNum");
mIdea.saveInBackground();
}
}
});
}
示例13: agreeAddRequest
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public static void agreeAddRequest(final AddRequest addRequest, final SaveCallback saveCallback) {
UserService.addFriend(addRequest.getFromUser().getObjectId(), new SaveCallback() {
@Override
public void done(AVException e) {
if (e != null) {
if (e.getCode() == AVException.DUPLICATE_VALUE) {
addRequest.setStatus(AddRequest.STATUS_DONE);
addRequest.saveInBackground(saveCallback);
} else {
saveCallback.done(e);
}
} else {
addRequest.setStatus(AddRequest.STATUS_DONE);
addRequest.saveInBackground(saveCallback);
}
}
});
}
示例14: updateUserLocation
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public static void updateUserLocation() {
PreferenceMap preferenceMap = PreferenceMap.getCurUserPrefDao(DemoApplication.context);
AVGeoPoint lastLocation = preferenceMap.getLocation();
if (lastLocation != null) {
final AVUser user = AVUser.getCurrentUser();
final AVGeoPoint location = user.getAVGeoPoint("location");
if (location == null || !Utils.doubleEqual(location.getLatitude(), lastLocation.getLatitude())
|| !Utils.doubleEqual(location.getLongitude(), lastLocation.getLongitude())) {
user.put("location", lastLocation);
user.saveInBackground(new SaveCallback() {
@Override
public void done(AVException e) {
if (e != null) {
e.printStackTrace();
} else {
Log.v("lan", "lastLocation save " + user.getAVGeoPoint("location"));
}
}
});
}
}
}
示例15: addFriend
import com.avos.avoscloud.SaveCallback; //导入依赖的package包/类
public static void addFriend(String friendId, final SaveCallback saveCallback) {
AVUser user = HiTalkHelper.getInstance().getCurrentUser();
user.followInBackground(friendId, new FollowCallback() {
@Override
public void done(AVObject object, AVException e) {
if (saveCallback != null) {
saveCallback.done(e);
}
}
});
}