com.avos.avoscloud.AVUser Java Examples
The following examples show how to use
com.avos.avoscloud.AVUser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MySpaceFragment.java From LoveTalkClient with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.avatarLayout) { Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(intent, IMAGE_PICK_REQUEST); } else if (id == R.id.logout) { ChatService.closeSession(); AVUser.logOut(); getActivity().finish(); } else if (id == R.id.sexLayout) { showSexChooseDialog(); } }
Example #2
Source File: QuestionDataRepository.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override public void addQuestion(String title, String des, final SaveCallback callback) { Question question = new Question(); question.setTitle(title); question.setDescription(des); User user = AVUser.getCurrentUser(User.class); question.setUser(user); question.saveInBackground(new com.avos.avoscloud.SaveCallback() { @Override public void done(AVException e) { if (e == null) { callback.onSaveSuccess(); } else { callback.onSaveFailed(e.getLocalizedMessage()); } } }); }
Example #3
Source File: SplashActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override protected void init() { super.init(); //设置状态栏颜色为透明色 setStatusBarTransparent(); //获取当前用户 User currentUser = AVUser.getCurrentUser(User.class); //如果当前用户为null,说明用户没有登陆 if (currentUser == null) { //延时跳转到登陆界面 navigateToLoginActivity(); } else { //延时跳转到主界面 navigateToMainActivity(); } //Activity 转场动画,淡入淡出 overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }
Example #4
Source File: CommentDataRepository.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override public void sendComment(Answer answer, String replayTo, String commentString, final SaveCallback callback) { Comment comment = new Comment(); User user = AVUser.getCurrentUser(User.class); comment.setContent(commentString); answer.addCommentCount(); comment.setAnswer(answer); comment.setUser(user); comment.saveInBackground(new com.avos.avoscloud.SaveCallback() { @Override public void done(AVException e) { if (e == null) { callback.onSaveSuccess(); } else { callback.onSaveFailed(e.getLocalizedMessage()); } } }); }
Example #5
Source File: MeetAdapter.java From LoveTalkClient with Apache License 2.0 | 6 votes |
@Override public Object getItem(int position) { // TODO Auto-generated method stub final Map<String, Object> item = new HashMap<String, Object>(); AVUser user = (AVUser) MeetList.get(position).get("user"); String name = user.getUsername(); AVFile avatar = user.getAVFile("avatar"); String avatarUrl = getAvatarUrl(user); String times = MeetList.get(position).get("times").toString(); times = "相遇" + times + "次"; item.put("name", name); item.put("avatar", avatarUrl); item.put("times", times); return item; }
Example #6
Source File: AnswerDataRepository.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override public void addAnswerToQuestion(String answerString, final Question question, final SaveCallback callback) { Answer answer = new Answer(); answer.setAnswer(answerString); User currentUser = AVUser.getCurrentUser(User.class); answer.setUser(currentUser);//设置回答者 Question dependent = getQuestionWithoutData(question.getObjectId()); answer.setQuestion(dependent);//设置回答的问题 answer.saveInBackground(new com.avos.avoscloud.SaveCallback() { @Override public void done(AVException e) { if (e == null) { question.addAnswerCount();//增加问题的回答计数 callback.onSaveSuccess(); } else { callback.onSaveFailed(e.getLocalizedMessage()); } } }); }
Example #7
Source File: MeetingInfo.java From LoveTalkClient with Apache License 2.0 | 6 votes |
public static void addMeeting(AVObject meetinfo) { AVUser adduser = meetinfo.getAVUser("YourUser"); String username = adduser.getUsername(); for (HashMap<String, Object> meet : list) { AVUser user = (AVUser) meet.get("user"); String name = user.getUsername(); if (name.equals(username)) { int times = Integer.valueOf(meet.get("times").toString()); meet.put("times", times + 1); return; } } HashMap<String, Object> newuser = new HashMap<String, Object>(); newuser.put("user", adduser); newuser.put("times", 1); list.add(newuser); }
Example #8
Source File: PersonalCenterHeaderVH.java From PlayTogether with Apache License 2.0 | 6 votes |
@Override public void bindData(Object object) { User user = ((PersonalCenterHomeBean) object).getUser(); mTvDetailDesc.setText(user.getDetailDesc()); String genderTrend = Constant.GENDER_ALL; if (!"".equals(user.getGenderTrend())) genderTrend = user.getGenderTrend(); mTvGenderTrend.setText(genderTrend); mTvFavoriteActivity.setText(user.getFavoriteActivity()); //如果当前展示用户为本人,不显示聊天按钮 if (user.getObjectId().equals(AVUser.getCurrentUser().getObjectId())) { mBtnChat.setVisibility(View.GONE); } else { mBtnChat.setVisibility(View.VISIBLE); } }
Example #9
Source File: NewFriendActivity.java From LoveTalkClient with Apache License 2.0 | 6 votes |
private void refresh() { new MyAsyncTask(mContext) { List<AddRequest> subAddRequests; @Override protected void doInBack() throws Exception { subAddRequests = AddRequestService.findAddRequests(); } @Override protected void onSucceed() { AVUser user = AVUser.getCurrentUser(); String id = user.getObjectId(); PreferenceMap preferenceMap = new PreferenceMap(context, id); preferenceMap.setAddRequestN(subAddRequests.size()); adapter.addAll(subAddRequests); } }.execute(); }
Example #10
Source File: InvitationCategoryController.java From PlayTogether with Apache License 2.0 | 6 votes |
/** * 保存用户的位置 * * @param longitude * @param latitude */ public void updateLocation(double longitude, double latitude) { User user = AVUser.getCurrentUser(User.class); // Logger.e(user.getLocation()+""); user.setLocation(new AVGeoPoint(latitude, longitude)); mUserBll.updateLocation(user) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<Void>() { @Override public void call(Void aVoid) { // Logger.e("更新定位成功"); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { // Logger.e("更新定位失败:" + throwable.getMessage()); } }); }
Example #11
Source File: ChatUtils.java From LoveTalkClient with Apache License 2.0 | 6 votes |
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")); } } }); } } }
Example #12
Source File: LoginActivity.java From LoveTalkClient with Apache License 2.0 | 6 votes |
private void login() { final String email = enterLogin.getText().toString(); final String pwd = enterPassword.getText().toString(); new MyAsyncTask(this) { @Override protected void doInBack() throws Exception { // TODO Auto-generated method stub AVUser.logIn(email, pwd); } @Override protected void onSucceed() { Utils.toast("登录成功"); Utils.goActivity(context, HomeActivity.class); } }.execute(); }
Example #13
Source File: User.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
public static void getUser(final LoadCallback<User> loadCallback, String objectId) { AVQuery<User> userAVQuery = AVQuery.getQuery(User.class); userAVQuery.whereEqualTo(AVUser.OBJECT_ID, objectId); userAVQuery.findInBackground(new FindCallback<User>() { @Override public void done(List<User> list, AVException e) { if (e == null) { loadCallback.onLoadSuccess(list); } else { loadCallback.onLoadFailed(e.getLocalizedMessage()); } } }); }
Example #14
Source File: ContactFragment.java From LoveTalkClient with Apache License 2.0 | 6 votes |
private void deleteFriend(final AVUser user) { new MyAsyncTask(context) { @Override protected void doInBack() throws Exception { // TODO Auto-generated method stub AVUser curUser = AVUser.getCurrentUser(); CloudService.removeFriendForBoth(curUser, user); } @Override protected void onSucceed() { Utils.toast("删除成功"); userAdapter.remove(user); } }; }
Example #15
Source File: ContactFragment.java From LoveTalkClient with Apache License 2.0 | 6 votes |
public void refresh() { new MyAsyncTask(context, true) { boolean haveAddRequest; List<AVUser> friends; @Override protected void doInBack() throws Exception { // TODO Auto-generated method stub haveAddRequest = AddRequestService.hasAddRequest(); friends = UserService.findFriends(); } @Override protected void onSucceed() { setAddRequestTipsAndListView(haveAddRequest, friends); } }.execute(); // }
Example #16
Source File: ContactFragment.java From LoveTalkClient with Apache License 2.0 | 6 votes |
private void fillFriendsData(List<AVUser> datas) { friends.clear(); int total = datas.size(); for (int i = 0; i < total; i++) { AVUser user = datas.get(i); AVUser sortUser = new AVUser(); sortUser.put("avatar", user.getAVFile("avatar")); sortUser.setUsername(user.getUsername()); sortUser.setObjectId(user.getObjectId()); String username = sortUser.getUsername(); if (username != null) { String pinyin = CharacterParser.getPingYin(user.getUsername()); String sortString = pinyin.substring(0, 1).toUpperCase(); if (sortString.matches("[A-Z]")) { Log.d("lan", sortString.toUpperCase()); } else { Log.d("lan", "#"); } } else { Log.d("lan", "#"); } friends.add(sortUser); } Collections.sort(friends, pinyinComparator); }
Example #17
Source File: ChatHomeActivity.java From PlayTogether with Apache License 2.0 | 6 votes |
@Override public void afterCreate() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.setTitle(""); User me = AVUser.getCurrentUser(User.class); if (me == null) { Toast.makeText(this, "请先进行登录,", Toast.LENGTH_SHORT).show(); finish(); } //初始化用户信息 mTvUsername.setText(me.getUsername()); AVFile avAvatar = me.getAvatar(); if (avAvatar != null) PicassoUtils.displayFitImage(this, Uri.parse(avAvatar.getThumbnailUrl(true, Constant .AVATAR_WIDTH, Constant.AVATAR_HEIGHT)), mIvAvatar, null); //初始化事件 initEvent(); //初始化viewpager initViewPagerAndTabLayout(); }
Example #18
Source File: ChatActivity.java From LoveTalkClient with Apache License 2.0 | 6 votes |
public void initData(Intent intent) { mCurUser = AVUser.getCurrentUser(); mDbHelper = new DBHelper(ctx, "chat.db", 1); int roomTypeInt = intent.getIntExtra(ROOM_TYPE, RoomType.Single.getValue()); roomType = RoomType.fromInt(roomTypeInt); msgSize = PAGE_SIZE; if (roomType == RoomType.Single) { String chatUserId = intent.getStringExtra(CHAT_USER_ID); chatUser = DemoApplication.lookupUser(chatUserId); if (chatUser != null) { ChatService.withUserToWatch(chatUser, true); msgAgent = new MsgAgent(roomType, chatUser.getObjectId()); } else { Log.d("test1", chatUserId); } } else { // String groupId = intent.getStringExtra(GROUP_ID); // Session session = ChatService.getSession(); // group = session.getGroup(groupId); // chatGroup = App.lookupChatGroup(groupId); // msgAgent = new MsgAgent(roomType, groupId); } }
Example #19
Source File: UserBll.java From PlayTogether with Apache License 2.0 | 6 votes |
/** * 检查 指定friend 是否已经是我的好友 */ public Observable<String> checkIfIsFriend(final String friend) { return Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(Subscriber<? super String> subscriber) { List<User> friends = AVUser.getCurrentUser(User.class).getFriends(); if (!friends.isEmpty()) { for (User user : friends) { if (user.getUsername().equals(friend)) { subscriber.onError(new Exception(friend + " 已是你的好友")); break; } } } subscriber.onNext(friend); } }); }
Example #20
Source File: UserBll.java From PlayTogether with Apache License 2.0 | 6 votes |
public Observable<User> addFriend(final User friend) { return Observable.create(new Observable.OnSubscribe<User>() { @Override public void call(Subscriber<? super User> subscriber) { User me = AVUser.getCurrentUser(User.class); List<User> friendList = me.getFriends(); friendList.addAll(Arrays.asList(friend)); me.setFriends(friendList); try { me.save(); subscriber.onNext(friend); } catch (AVException e) { subscriber.onError(e); e.printStackTrace(); } } }); }
Example #21
Source File: UserBll.java From PlayTogether with Apache License 2.0 | 6 votes |
public Observable<User> registerUser(final User user) { return Observable.create(new Observable.OnSubscribe<User>() { @Override public void call(Subscriber<? super User> subscriber) { try { AVUser avUser = new AVUser(); avUser.setUsername(user.getUsername()); avUser.setPassword(user.getPassword()); avUser.put(User.FIELD_GENDER, user.getGender()); avUser.signUp(); //注册成功 subscriber.onNext(user); } catch (AVException e) { e.printStackTrace(); subscriber.onError(e); } } }); }
Example #22
Source File: ShareArticleActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
private void publishArticle() { String title = mArticleTitle.getText().toString().trim(); if (title.length() == 0) { Snackbar.make(mScrollView, getString(R.string.title_not_null), Snackbar.LENGTH_SHORT).show(); return; } if (mTag == -1) { Snackbar.make(mScrollView, getString(R.string.tag_not_null), Snackbar.LENGTH_SHORT).show(); return; } Article article = new Article(); article.setTitle(title); String desc = mArticleDescription.getText().toString().trim(); article.setDesc(desc); article.setUrl(mArticleUrl.getText().toString()); article.setTag(mTag); User user = AVUser.getCurrentUser(User.class); article.setUser(user); mArticleDataSource.saveArticle(article, new SaveCallback() { @Override public void onSaveSuccess() { Snackbar.make(mScrollView, getString(R.string.publish_success), Snackbar.LENGTH_SHORT).show(); } @Override public void onSaveFailed(String errorMsg) { Snackbar.make(mScrollView, getString(R.string.publish_failed), Snackbar.LENGTH_SHORT).show(); } }); }
Example #23
Source File: ArticleDetailActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.favour) public void onViewClicked() { isFavoured = !isFavoured; mFavour.setSelected(isFavoured); User user = AVUser.getCurrentUser(User.class); if (isFavoured) { UserArticleFavourMap.buildFavourMap(user, mArticle); } else { UserArticleFavourMap.breakFavourMap(user, mArticle); } }
Example #24
Source File: UserBll.java From PlayTogether with Apache License 2.0 | 5 votes |
public Observable<String> uploadAvatar(final String path) { return Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(Subscriber<? super String> subscriber) { File file = new File(path); try { //对头像进行压缩 Bitmap bitmap = FileUtils.compressImage(path, Constant.UPLOAD_AVATAR_WIDTH, Constant .UPLOAD_AVATAR_HEIGHT); ByteArrayOutputStream os = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 60, os); AVFile avatar = new AVFile(System.currentTimeMillis() + "", os.toByteArray()); avatar.addMetaData("width", bitmap.getWidth()); avatar.addMetaData("height", bitmap.getHeight()); avatar.save(); User user = AVUser.getCurrentUser(User.class); user.setAvatar(avatar); user.save(); subscriber.onNext(path); } catch (Exception e) { e.printStackTrace(); subscriber.onError(e); } } }); }
Example #25
Source File: AddRequestService.java From LoveTalkClient with Apache License 2.0 | 5 votes |
public static void createAddRequest(AVUser toUser) throws Exception { AVUser curUser = AVUser.getCurrentUser(); AVQuery<AddRequest> q = AVObject.getQuery(AddRequest.class); q.whereEqualTo(AddRequest.FROM_USER, curUser); q.whereEqualTo(AddRequest.TO_USER, toUser); q.whereEqualTo(AddRequest.STATUS, AddRequest.STATUS_WAIT); int count = 0; try { count = q.count(); } catch (AVException e) { e.printStackTrace(); if (e.getCode() == AVException.OBJECT_NOT_FOUND) { count = 0; } else { throw e; } } if (count > 0) { throw new Exception(DemoApplication.context.getString(R.string.contact_alreadyCreateAddRequest)); } else { AddRequest add = new AddRequest(); add.setFromUser(curUser); add.setToUser(toUser); add.setStatus(AddRequest.STATUS_WAIT); add.save(); } }
Example #26
Source File: MySpaceFragment.java From LoveTalkClient with Apache License 2.0 | 5 votes |
public String getAvatarUrl(AVUser user) { AVFile avatar = user.getAVFile("avatar"); if (avatar != null) { return avatar.getUrl(); } else { return null; } }
Example #27
Source File: AnswerDetailActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
private void initViews() { User user = AVUser.getCurrentUser(User.class); if (user.isLikedAnswer(mAnswer.getObjectId())) { isUp = true; mThumbUp.setColorFilter(getResources().getColor(R.color.colorPrimary)); } mQuestionTitle.setText(mAnswer.getQuestion().getTitle()); mAnswerText.setText(mAnswer.getContent()); mPublishDate.setText(DateUtils.getDateTimeFormat(mAnswer.getCreatedAt())); }
Example #28
Source File: AddFriendActivity.java From LoveTalkClient with Apache License 2.0 | 5 votes |
private static List<String> getFriendIds() { List<AVUser> friends = DemoApplication.context.getFriends(); List<String> ids = new ArrayList<String>(); for (AVUser friend : friends) { ids.add(friend.getObjectId()); } return ids; }
Example #29
Source File: SettingsActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
private void logout() { new AlertDialog.Builder(this).setTitle(R.string.logout) .setMessage(R.string.confirm_logout) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AVUser.logOut(); navigateTo(LoginActivity.class); EventBus.getDefault().post(new LogoutEvent()); } }).show(); }
Example #30
Source File: FriendListFragment.java From PlayTogether with Apache License 2.0 | 5 votes |
@Override public void afterViewCreated(View view) { EventBus.getDefault().register(this); //初始化 recyclerview mRvFriendList.setLayoutManager(mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); mController.getFriends(AVUser.getCurrentUser(User.class).getUsername()); }