public void checkLogin() {
   BmobUserManager userManager = BmobUserManager.getInstance(this);
   if (userManager.getCurrentUser() == null) {
     ShowToast("ÄúµÄÕ˺ÅÒÑÔÚÆäËûÉ豸ÉϵǼ!");
     startActivity(new Intent(this, LoginActivity.class));
     finish();
   }
 }
Beispiel #2
0
 public void checkLogin() {
   // 获取当前缓存用户
   BmobUserManager userManager = BmobUserManager.getInstance(this);
   // 如果当前用户为NULL
   if (userManager.getCurrentUser() == null) {
     ShowToast("您的账号已在其他设备上登录!");
     startActivity(new Intent(this, LoginActivity.class));
     finish();
   }
 }
Beispiel #3
0
 @Override
 public void onClick(View view) {
   // 防止item错乱
   int position = Integer.parseInt(view.getTag().toString());
   switch (view.getId()) {
     case R.id.ll_praise:
       praise(position);
       break;
     case R.id.ll_share:
       share(position);
       break;
     case R.id.iv_avator:
       // 进入用户详情界面
       post = list.get(position);
       Intent intent = new Intent(context, MyDetailActivity.class);
       User user = post.getAuthor();
       String currentUserObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId();
       if (user.getObjectId().equals(currentUserObjectId)) {
         intent.putExtra("from", "me");
       } else {
         // 如果是好友。
         if (BmobDB.create(context).getContactList().contains((BmobChatUser) user)) {
           intent.putExtra("from", "friend");
         } else {
           intent.putExtra("from", "other");
         }
         intent.putExtra("target_user", post.getAuthor());
       }
       context.startActivity(intent);
     default:
       break;
   }
 }
Beispiel #4
0
  /**
   * 用于登陆或者自动登陆情况下的用户资料及好友资料的检测更新 @Title: updateUserInfos @Description: TODO
   *
   * @param
   * @return void
   * @throws
   */
  public void updateUserInfos() {
    // 更新地理位置信息
    updateUserLocation();
    // 查询该用户的好友列表(这个好友列表是去除黑名单用户的哦),目前支持的查询好友个数为100,如需修改请在调用这个方法前设置BmobConfig.LIMIT_CONTACTS即可。
    // 这里默认采取的是登陆成功之后即将好于列表存储到数据库中,并更新到当前内存中,
    userManager.queryCurrentContactList(
        new FindListener<BmobChatUser>() {

          @Override
          public void onError(int arg0, String arg1) {
            // TODO Auto-generated method stub
            if (arg0 == BmobConfig.CODE_COMMON_NONE) {
              ShowLog(arg1);
            } else {
              ShowLog("查询好友列表失败:" + arg1);
            }
          }

          @Override
          public void onSuccess(List<BmobChatUser> arg0) {
            // TODO Auto-generated method stub
            // 保存到application中方便比较
            CustomApplcation.getInstance().setContactList(CollectionUtils.list2map(arg0));
          }
        });
  }
 public MessageRecentAdapter(Context context, int textViewResourceId, List<BmobRecent> objects) {
   super(context, textViewResourceId, objects);
   inflater = LayoutInflater.from(context);
   this.mContext = context;
   mData = objects;
   bmobUserManager = BmobUserManager.getInstance(context);
 }
Beispiel #6
0
  /**
   * ���ڵ�½�����Զ���½����µ��û����ϼ��������ϵļ����� @Title: updateUserInfos @Description: TODO
   *
   * @param
   * @return void
   * @throws
   */
  public void updateUserInfos() {
    // ���µ���λ����Ϣ
    updateUserLocation();
    // ��ѯ���û��ĺ����б�(��������б���ȥ���������û���Ŷ),Ŀǰ֧�ֵIJ�ѯ���Ѹ���Ϊ100�������޸����ڵ����������ǰ����BmobConfig.LIMIT_CONTACTS���ɡ�
    // ����Ĭ�ϲ�ȡ���ǵ�½�ɹ�֮�󼴽������б�洢�����ݿ��У������µ���ǰ�ڴ���,
    userManager.queryCurrentContactList(
        new FindListener<BmobChatUser>() {

          @Override
          public void onError(int arg0, String arg1) {
            // TODO Auto-generated method stub
            if (arg0 == BmobConfig.CODE_COMMON_NONE) {
              ShowLog(arg1);
            } else {
              ShowLog("��ѯ�����б�ʧ�ܣ�" + arg1);
            }
          }

          @Override
          public void onSuccess(List<BmobChatUser> arg0) {
            // TODO Auto-generated method stub
            // ���浽application�з���Ƚ�
            CustomApplcation.getInstance().setContactList(CollectionUtils.list2map(arg0));
          }
        });
  }
Beispiel #7
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   setRetainInstance(true);
   userManager = BmobUserManager.getInstance(getActivity());
   me = App.mInstance.getCurrentUser();
   mInflater = LayoutInflater.from(getActivity());
 }
 public synchronized SharePreferenceUtil getSpUtil() {
   if (mSpUtil == null) {
     String currentId =
         BmobUserManager.getInstance(getApplicationContext()).getCurrentUserObjectId();
     String sharedName = currentId + PREFERENCE_NAME;
     mSpUtil = new SharePreferenceUtil(this, sharedName);
   }
   return mSpUtil;
 }
Beispiel #9
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   userManager = BmobUserManager.getInstance(this);
   manager = BmobChatManager.getInstance(this);
   mApplication = CustomApplcation.getInstance();
   DisplayMetrics metric = new DisplayMetrics();
   getWindowManager().getDefaultDisplay().getMetrics(metric);
   mScreenWidth = metric.widthPixels;
   mScreenHeight = metric.heightPixels;
 }
 private void init() {
   mMediaPlayer = MediaPlayer.create(this, R.raw.notify);
   mNotificationManager =
       (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);
   initImageLoader(getApplicationContext());
   // 若用户登陆过,则先从好友数据库中取出好友list存入内存中
   if (BmobUserManager.getInstance(getApplicationContext()).getCurrentUser() != null) {
     // 获取本地好友user list到内存,方便以后获取好友list
     contactList =
         CollectionUtils.list2map(BmobDB.create(getApplicationContext()).getContactList());
   }
   initBaidu();
 }
Beispiel #11
0
  public MessageAdapter(Context context, List<BmobMsg> list) {
    super(context, list);
    currentObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId();

    options =
        new DisplayImageOptions.Builder()
            //                .showImageForEmptyUri(R.drawable.ic_launcher)
            //                .showImageOnFail(R.drawable.ic_launcher)
            .resetViewBeforeLoading(true)
            .cacheOnDisc(true)
            .cacheInMemory(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300))
            .build();
  }
  /**
   * 添加好友 agressAdd @Title: agressAdd @Description: TODO
   *
   * @param @param btn_add
   * @param @param msg
   * @return void
   * @throws
   */
  private void agressAdd(final Button btn_add, final BmobInvitation msg) {
    final ProgressDialog progress = new ProgressDialog(mContext);
    progress.setMessage("正在添加...");
    progress.setCanceledOnTouchOutside(false);
    progress.show();
    try {
      // 同意添加好友
      BmobUserManager.getInstance(mContext)
          .agreeAddContact(
              msg,
              new UpdateListener() {

                @SuppressWarnings("deprecation")
                @Override
                public void onSuccess() {
                  // TODO Auto-generated method stub
                  progress.dismiss();
                  btn_add.setText("已同意");
                  btn_add.setBackgroundDrawable(null);
                  btn_add.setTextColor(
                      mContext.getResources().getColor(R.color.base_color_text_black));
                  btn_add.setEnabled(false);
                  // 保存到application中方便比较
                  CustomApplcation.getInstance()
                      .setContactList(
                          CollectionUtils.list2map(BmobDB.create(mContext).getContactList()));
                }

                @Override
                public void onFailure(int arg0, final String arg1) {
                  // TODO Auto-generated method stub
                  progress.dismiss();
                  ShowToast("添加失败: " + arg1);
                }
              });
    } catch (final Exception e) {
      progress.dismiss();
      ShowToast("添加失败: " + e.getMessage());
    }
  }
Beispiel #13
0
  /**
   * 更新用户的经纬度信息 @Title: uploadLocation @Description: TODO
   *
   * @param
   * @return void
   * @throws
   */
  public void updateUserLocation() {
    if (CustomApplcation.lastPoint != null) {
      String saveLatitude = mApplication.getLatitude();
      String saveLongtitude = mApplication.getLongtitude();
      String newLat = String.valueOf(CustomApplcation.lastPoint.getLatitude());
      String newLong = String.valueOf(CustomApplcation.lastPoint.getLongitude());
      //			ShowLog("saveLatitude ="+saveLatitude+",saveLongtitude = "+saveLongtitude);
      //			ShowLog("newLat ="+newLat+",newLong = "+newLong);
      if (!saveLatitude.equals(newLat)
          || !saveLongtitude.equals(newLong)) { // 只有位置有变化就更新当前位置,达到实时更新的目的
        User u = (User) userManager.getCurrentUser(User.class);
        final User user = new User();
        user.setLocation(CustomApplcation.lastPoint);
        user.setObjectId(u.getObjectId());
        user.update(
            this,
            new UpdateListener() {
              @Override
              public void onSuccess() {
                // TODO Auto-generated method stub
                CustomApplcation.getInstance()
                    .setLatitude(String.valueOf(user.getLocation().getLatitude()));
                CustomApplcation.getInstance()
                    .setLongtitude(String.valueOf(user.getLocation().getLongitude()));
                //						ShowLog("经纬度更新成功");
              }

              @Override
              public void onFailure(int code, String msg) {
                // TODO Auto-generated method stub
                //						ShowLog("经纬度更新 失败:"+msg);
              }
            });
      } else {
        //				ShowLog("用户位置未发生过变化");
      }
    }
  }
Beispiel #14
0
 public String getDownLoadFilePath(Context context, BmobMsg msg) {
   String accountDir =
       BmobUtils.string2MD5(BmobUserManager.getInstance(context).getCurrentUserObjectId());
   File dir =
       new File(
           BmobConfig.BMOB_VOICE_DIR
               + File.separator
               + accountDir
               + File.separator
               + msg.getBelongId());
   if (!dir.exists()) {
     dir.mkdirs();
   }
   // 在当前用户的目录下面存放录音文件
   File audioFile = new File(dir.getAbsolutePath() + File.separator + msg.getMsgTime() + ".amr");
   try {
     if (!audioFile.exists()) {
       audioFile.createNewFile();
     }
   } catch (IOException e) {
   }
   return audioFile.getAbsolutePath();
 }
Beispiel #15
0
  /**
   * �����û��ľ�γ����Ϣ @Title: uploadLocation @Description: TODO
   *
   * @param
   * @return void
   * @throws
   */
  public void updateUserLocation() {
    if (CustomApplcation.lastPoint != null) {
      String saveLatitude = mApplication.getLatitude();
      String saveLongtitude = mApplication.getLongtitude();
      String newLat = String.valueOf(CustomApplcation.lastPoint.getLatitude());
      String newLong = String.valueOf(CustomApplcation.lastPoint.getLongitude());
      //			ShowLog("saveLatitude ="+saveLatitude+",saveLongtitude = "+saveLongtitude);
      //			ShowLog("newLat ="+newLat+",newLong = "+newLong);
      if (!saveLatitude.equals(newLat)
          || !saveLongtitude.equals(newLong)) { // ֻ��λ���б仯�͸��µ�ǰλ�ã��ﵽʵʱ���µ�Ŀ��
        final User user = (User) userManager.getCurrentUser(User.class);
        user.setLocation(CustomApplcation.lastPoint);
        user.update(
            this,
            new UpdateListener() {
              @Override
              public void onSuccess() {
                // TODO Auto-generated method stub
                CustomApplcation.getInstance()
                    .setLatitude(String.valueOf(user.getLocation().getLatitude()));
                CustomApplcation.getInstance()
                    .setLongtitude(String.valueOf(user.getLocation().getLongitude()));
                //						ShowLog("��γ�ȸ��³ɹ�");
              }

              @Override
              public void onFailure(int code, String msg) {
                // TODO Auto-generated method stub
                //						ShowLog("��γ�ȸ��� ʧ��:"+msg);
              }
            });
      } else {
        //				ShowLog("�û�λ��δ�������仯");
      }
    }
  }
Beispiel #16
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   userManager = BmobUserManager.getInstance(this);
   manager = BmobChatManager.getInstance(this);
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final BmobRecent item = mData.get(position);
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.item_conversation, parent, false);
    }
    final ImageView iv_recent_avatar = ViewHolder.get(convertView, R.id.iv_recent_avatar);
    TextView tv_recent_name = ViewHolder.get(convertView, R.id.tv_recent_name);
    TextView tv_recent_msg = ViewHolder.get(convertView, R.id.tv_recent_msg);
    TextView tv_recent_time = ViewHolder.get(convertView, R.id.tv_recent_time);
    TextView tv_recent_unread = ViewHolder.get(convertView, R.id.tv_recent_unread);

    bmobUserManager.queryUserById(
        item.getTargetid(),
        new FindListener<BmobChatUser>() {
          @Override
          public void onSuccess(List<BmobChatUser> list) {
            if (!CollectionUtils.isNotNull(list)) return;
            String url = list.get(0).getAvatar();
            String avatar = url;
            if (avatar != null && !avatar.equals("")) {
              ImageLoader.getInstance()
                  .displayImage(avatar, iv_recent_avatar, ImageLoadOptions.getOptions());
            } else {
              iv_recent_avatar.setImageResource(R.mipmap.ic_launcher);
            }
          }

          @Override
          public void onError(int i, String s) {}
        });

    tv_recent_name.setText(item.getNick());
    tv_recent_time.setText(TimeUtil.getChatTime(item.getTime()));
    // 显示内容
    if (item.getType() == BmobConfig.TYPE_TEXT) {
      SpannableString spannableString =
          FaceTextUtils.toSpannableString(mContext, item.getMessage());
      tv_recent_msg.setText(spannableString);
    } else if (item.getType() == BmobConfig.TYPE_IMAGE) {
      tv_recent_msg.setText("[图片]");
    } else if (item.getType() == BmobConfig.TYPE_LOCATION) {
      String all = item.getMessage();
      if (TextUtils.isEmpty(all)) { // 位置类型的信息组装格式:地理位置&维度&经度
        String address = all.split("&")[0];
        tv_recent_msg.setText("[位置]" + address);
      }
    } else if (item.getType() == BmobConfig.TYPE_VOICE) {
      tv_recent_msg.setText("[语音]");
    }

    int num = BmobDB.create(mContext).getUnreadCount(item.getTargetid());
    if (num > 0) {
      tv_recent_unread.setVisibility(View.VISIBLE);
      tv_recent_unread.setText(num + "");
    } else {
      tv_recent_unread.setVisibility(View.GONE);
    }
    return convertView;
  }
 /** 退出登录,清空缓存数据 */
 public void logout() {
   BmobUserManager.getInstance(getApplicationContext()).logout();
   setContactList(null);
   setLatitude(null);
   setLongtitude(null);
 }
Beispiel #19
0
/** Created by XSX on 2015/10/11. */
public class PostAdapter extends CommonReclclerViewAdapter<Post> implements View.OnClickListener {

  private static final String TAG = "PostAdapter";
  private Post post;
  private LinearLayout ll_praise;
  private LinearLayout ll_share;
  private Button btn_praise;
  private Button btn_share;
  private Button btn_reply;
  private TextView tv_praise;
  private TextView tv_reply;
  private ImageView iv_avator;
  private ImageView iv_content;

  private ImageView iv_sex;

  private int position;
  private int replyCount;
  private View view;

  public PostAdapter(Context context, List<Post> list) {
    super(context, list);
  }

  @Override
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    view = LayoutInflater.from(context).inflate(R.layout.item_post, parent, false);
    view.setOnClickListener(this);
    return new MyViewHolder(view);
  }

  @Override
  public void onBindViewHolder(final MyViewHolder viewHolder, int position) {
    post = list.get(position);
    iv_avator = (ImageView) viewHolder.getView(R.id.iv_avator);
    TextView tv_author = (TextView) viewHolder.getView(R.id.tv_author);
    TextView tv_time = (TextView) viewHolder.getView(R.id.tv_time);
    TextView tv_content = (TextView) viewHolder.getView(R.id.tv_content);
    tv_praise = (TextView) viewHolder.getView(R.id.tv_praise);
    tv_reply = (TextView) viewHolder.getView(R.id.tv_reply);

    btn_praise = (Button) viewHolder.getView(R.id.btn_praise);
    btn_share = (Button) viewHolder.getView(R.id.btn_share);
    btn_reply = (Button) viewHolder.getView(R.id.btn_reply);

    ll_praise = (LinearLayout) viewHolder.getView(R.id.ll_praise);
    ll_share = (LinearLayout) viewHolder.getView(R.id.ll_share);

    iv_sex = (ImageView) viewHolder.getView(R.id.iv_sex);

    if (post.getAuthor().getSex().equals("男")) {
      iv_sex.setImageResource(R.drawable.blue_male);
    } else {
      iv_sex.setImageResource(R.drawable.red_female);
    }
    tv_praise.setTag(position);
    tv_praise.setText("赞");
    if (post.getPraiseCount() == 0) {
      tv_praise.setText("赞");
    } else {
      tv_praise.setText(post.getPraiseCount() + "");
    }
    tv_reply.setText("评论");
    BmobQuery<Reply> query = new BmobQuery<Reply>();
    query.addWhereEqualTo("post", post);
    query.count(
        context,
        Reply.class,
        new CountListener() {
          @Override
          public void onSuccess(int i) {
            if (i != 0) {
              tv_reply.setText(i + "");
            }
          }

          @Override
          public void onFailure(int i, String s) {}
        });

    iv_avator.setOnClickListener(this);
    iv_avator.setTag(position);

    ll_praise.setOnClickListener(this);
    ll_praise.setTag(position);
    ll_share.setOnClickListener(this);
    ll_share.setTag(position);

    if (post.getIsPraise()) {
      btn_praise.setBackgroundResource(R.drawable.praise_press);
    } else {
      btn_praise.setBackgroundResource(R.drawable.praise_normal);
    }

    String avatar = post.getAvator();
    if (avatar != null && !avatar.equals("")) {
      ImageLoader.getInstance().displayImage(avatar, iv_avator, ImageLoadOptions.getOptions());
    } else {
      if (post.getAuthor().getSex().equals("男")) {
        iv_avator.setImageResource(R.mipmap.male_default_icon);
      } else {
        iv_avator.setImageResource(R.mipmap.female_default_icon);
      }
    }
    // 设置时间
    long time = TimeUtil.stringToLong(post.getCreatedAt(), "yyyy-MM-dd HH:mm:ss");
    tv_time.setText(TimeUtil.getDescriptionTimeFromTimestamp(time));
    // 设置用户名
    tv_author.setText(post.getAuthor().getNick());
    // 设置文字内容
    SpannableString spannableString = FaceTextUtil.toSpannableString(context, post.getContent());
    tv_content.setText(spannableString);
    tv_content.setVisibility(View.VISIBLE);
    final List<String> imagesUrl = post.getImages();
    iv_content = (ImageView) viewHolder.getView(R.id.iv_content);
    if (imagesUrl != null && imagesUrl.size() > 0) {
      // 只取出第一张图片
      String url = imagesUrl.get(0);
      iv_content.setVisibility(View.VISIBLE);
      ImageLoader.getInstance().displayImage(url, iv_content, ImageLoadOptions.getOptions());

    } else {
      // layout_content.setVisibility(View.GONE);
      iv_content.setVisibility(View.GONE);
    }
    iv_content.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(context, ImageBrowserActivity.class);
            ArrayList<String> photos = new ArrayList<String>();
            photos.add(imagesUrl.get(0));
            intent.putStringArrayListExtra("photos", photos);
            intent.putExtra("position", 0);
            context.startActivity(intent);
          }
        });
    // 如果设置了回调,则设置点击事件
    if (mOnItemClickLitener != null) {
      view.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              int pos = viewHolder.getLayoutPosition();
              mOnItemClickLitener.onItemClick(view, pos);
            }
          });

      view.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              int pos = viewHolder.getLayoutPosition();
              mOnItemClickLitener.onItemLongClick(view, pos);
              return false;
            }
          });
    }
  }

  @Override
  public void onClick(View view) {
    // 防止item错乱
    int position = Integer.parseInt(view.getTag().toString());
    switch (view.getId()) {
      case R.id.ll_praise:
        praise(position);
        break;
      case R.id.ll_share:
        share(position);
        break;
      case R.id.iv_avator:
        // 进入用户详情界面
        post = list.get(position);
        Intent intent = new Intent(context, MyDetailActivity.class);
        User user = post.getAuthor();
        String currentUserObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId();
        if (user.getObjectId().equals(currentUserObjectId)) {
          intent.putExtra("from", "me");
        } else {
          // 如果是好友。
          if (BmobDB.create(context).getContactList().contains((BmobChatUser) user)) {
            intent.putExtra("from", "friend");
          } else {
            intent.putExtra("from", "other");
          }
          intent.putExtra("target_user", post.getAuthor());
        }
        context.startActivity(intent);
      default:
        break;
    }
  }

  /**
   * 分享功能
   *
   * @param position
   */
  public void share(int position) {
    post = list.get(position);
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_SUBJECT, "Share");
    intent.putExtra(Intent.EXTRA_TEXT, "发现有趣事物,快来看吧! (分享自samer)");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(Intent.createChooser(intent, "发现有趣事物,快来看吧 (分享自samer)"));
  }

  private List<User> praiseUsers;
  /** 查询出所有赞了的人 */
  public void queryAllPrasieUsers() {
    BmobQuery<User> query = new BmobQuery<User>();
    // likes是Post表中的字段,用来存储所有喜欢该帖子的用户
    query.addWhereRelatedTo("likes", new BmobPointer(post));
    query.findObjects(
        context,
        new FindListener<User>() {
          @Override
          public void onSuccess(List<User> object) {
            for (User user : object) {
              Log.i(TAG, "user="******"currentUser="******"praiseCount");
      tv_praise.setText("" + (count + 1));
      //            if(!praiseUsers.contains(currentUser)){
      //               //判断当前user是否赞过
      //                Log.i(TAG, "当前用户有赞过,取消赞");
      //                //赞过,要取消赞
      //                post.increment("praiseCount", -1);
      //                BmobRelation relation=new BmobRelation();
      //                relation.remove(currentUser);
      //                post.setLikes(relation);
      //                //取消赞之后判断赞的数量
      //                if(post.getPraiseCount()==0){
      //                    btn_praise.setBackgroundResource(R.drawable.praise_normal);
      //                    tv_praise.setText("赞");
      //                    post.setIsPraise(false);
      //                }else{
      //                    btn_praise.setBackgroundResource(R.drawable.praise_press);
      //                    tv_praise.setText("" + post.getPraiseCount());
      //                }
      //            }else{
      //                //当前用户没有赞过,点赞
      //                Log.i(TAG, "当前用户没有赞过,点赞");
      //                btn_praise.setBackgroundResource(R.drawable.praise_press);
      //                post.increment("praiseCount");
      //                tv_praise.setText("" + post.getPraiseCount());
      //                BmobRelation relation=new BmobRelation();
      //                //将点赞的人添加到集合中
      //                relation.add(currentUser);
      //                post.setLikes(relation);
      //            }
    } else {
      Log.i(TAG, "无赞,点赞");
      post.increment("praiseCount");
      tv_praise.setText("" + (count + 1));
      btn_praise.setBackgroundResource(R.drawable.praise_press);
      post.setIsPraise(true);
      //            BmobRelation relation=new BmobRelation();
      //            //将点赞的人添加到集合中
      //            relation.add(currentUser);
      //            post.setLikes(relation);
    }

    post.update(
        context,
        new UpdateListener() {
          @Override
          public void onFailure(int arg0, String arg1) {}

          @Override
          public void onSuccess() {
            // 查找出更新后的内容,否则界面不会改变
            BmobQuery<Post> query = new BmobQuery<Post>();
            query.addWhereEqualTo("objectId", post.getObjectId());
            query.addQueryKeys("praiseCount");
            query.findObjects(
                context,
                new FindListener<Post>() {
                  @Override
                  public void onSuccess(List<Post> list) {
                    post.setPraiseCount(list.get(0).getPraiseCount());
                    notifyItemChanged(position, null);
                  }

                  @Override
                  public void onError(int i, String s) {}
                });
          }
        });
  }
}