/** 登陆 */
 public void login() {
   String username = setUsername.getText().toString();
   String password = setPassword.getText().toString();
   if (TextUtils.isEmpty(username) || TextUtils.isEmpty(password)) return;
   if (AVUser.getCurrentUser() != null) {
     showLoadingDialog("当前用户为:" + AVUser.getCurrentUser().getUsername() + "\n正在切换用户...");
   } else {
     showLoadingDialog("正在登陆...");
   }
   AVUser.logInInBackground(
       username,
       password,
       new LogInCallback<AVUser>() {
         @Override
         public void done(AVUser u, AVException e) {
           if (e == null) {
             Utils.showToast(UserActivity.this, "登陆成功");
             User user = AVUser.getCurrentUser(User.class);
             textView.setText(
                 "Username:"******"\n"
                     + "DisplayName:"
                     + user.getDisplayName()
                     + "\n");
             Log.i("Session-token", user.getUsername() + user.getSessionToken());
           } else {
             textView.setText(e.getMessage());
           }
           cancelLoadingDialog();
         }
       });
 }
Beispiel #2
0
 private void getFromCloud() {
   try {
     groups = new ArrayList<>();
     AVUser user = AVUser.getCurrentUser();
     JSONArray array = user.getJSONArray("groups");
     if (array != null) {
       for (int i = 0; i < array.length(); i++) {
         JSONObject object = array.getJSONObject(i);
         WrapGroup wrapGroup = new WrapGroup();
         Group group = new Group();
         group.setWidth(236);
         group.setHeight(354);
         group.setImageurl(object.getString("imageurl"));
         group.setTitle(object.getString("title"));
         group.setUrl(object.getString("url"));
         wrapGroup.setGroup(group);
         wrapGroup.setIscollected(true);
         wrapGroup.setDate(new Date().getTime());
         wrapGroup.setGroupid(object.getString("groupid"));
         groups.add(wrapGroup);
       }
       saveDb(groups);
       mAdapter.replaceWith(groups);
       showSnackBar("云端同步成功");
     }
   } catch (JSONException e) {
     e.printStackTrace();
     KLog.e(e);
   }
 }
Beispiel #3
0
 private void saveToCloud() {
   try {
     JSONArray array = new JSONArray();
     for (WrapGroup group : groups) {
       JSONObject object = new JSONObject();
       object.put("groupid", group.getGroupid());
       object.put("title", group.getGroup().getTitle());
       object.put("imageurl", group.getGroup().getImageurl());
       object.put("url", group.getGroup().getUrl());
       array.put(object);
     }
     AVUser user = AVUser.getCurrentUser();
     user.put("groups", array);
     user.saveInBackground(
         new SaveCallback() {
           @Override
           public void done(AVException e) {
             if (e == null) {
               showSnackBar("云端同步完成");
             }
           }
         });
   } catch (JSONException e) {
     e.printStackTrace();
     KLog.e(e);
   }
 }
 /** 设置手机号,等待验证码(注册时可用,重置手机号往往应该先验证一下当前的(主动发送一次验证码到当前手机号)) */
 public void setMobile() {
   final String mobile = setMobilePhone.getText().toString();
   User user = AVUser.getCurrentUser(User.class);
   if (TextUtils.isEmpty(mobile)
       || mobile.length() != 11
       || user == null
       || !user.isAuthenticated()) return;
   showLoadingDialog("设置手机号...");
   user.setMobilePhoneNumber(mobile); // 先设置手机号
   user.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) {
             AVUser.requestMobilePhoneVerifyInBackground(
                 mobile,
                 new RequestMobileCodeCallback() {
                   @Override
                   public void done(AVException e) {
                     if (e == null) {
                       Utils.showToast(UserActivity.this, "已发送验证码短信,请验证!");
                     } else {
                       textView.setText(e.getMessage());
                     }
                     cancelLoadingDialog();
                   }
                 });
           } else {
             textView.setText(e.getMessage());
             cancelLoadingDialog();
           }
         }
       });
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.action_collect:
        showToast("收藏");
        AVUser user = AVUser.getCurrentUser();
        final AVObject collect = new AVObject("user_collect");
        collect.put("user", user);
        collect.put("event", mDream);
        collect.saveInBackground(
            new SaveCallback() {
              @Override
              public void done(AVException e) {
                if (e == null) {
                  showToast("收藏成功");
                  mDream.increment("collectNum");
                  mDream.saveInBackground();
                }
              }
            });
        break;

      case R.id.action_share:
        showToast("分享");
        break;
      case android.R.id.home:
        finish();
        break;
    }

    return super.onOptionsItemSelected(item);
  }
Beispiel #6
0
 public static void launch(Activity fromActivity) {
   ChatManager chatManager = ChatManager.getInstance();
   chatManager.setupManagerWithUserId(AVUser.getCurrentUser().getObjectId());
   chatManager.openClient(null);
   Intent intent = new Intent(fromActivity, MainActivity.class);
   fromActivity.startActivity(intent);
 }
 public void inflatData() {
   AVUser currentUser = AVUser.getCurrentUser();
   if (currentUser != null) {
     profile_image.setImageResource(R.drawable.user_profile);
     loginStatus.setText(currentUser.getUsername());
   }
 }
  /** 修改email(API上说的开启邮箱验证不知道怎么开???) */
  public void updEmail() {
    String email = setEmail.getText().toString();
    AVUser currentUser = AVUser.getCurrentUser();
    if (TextUtils.isEmpty(email) || currentUser == null || !currentUser.isAuthenticated()) return;
    showLoadingDialog("修改邮箱...");

    currentUser.setEmail(email);
    currentUser.saveInBackground(saveCallback);
  }
  public static void saveAvatar(String path) throws IOException, AVException {
    AVUser user = AVUser.getCurrentUser();
    final AVFile file = AVFile.withAbsoluteLocalPath(user.getUsername(), path);
    file.save();
    user.put(User.AVATAR, file);

    user.save();
    user.fetch();
  }
 public static void updateUserInfo() {
   AVUser user = AVUser.getCurrentUser();
   if (user != null) {
     AVInstallation installation = AVInstallation.getCurrentInstallation();
     if (installation != null) {
       user.put(User.INSTALLATION, installation);
       user.saveInBackground();
     }
   }
 }
 public static void removeFriend(String friendId, final SaveCallback saveCallback) {
   AVUser user = AVUser.getCurrentUser();
   user.unfollowInBackground(
       friendId,
       new FollowCallback() {
         @Override
         public void done(AVObject object, AVException e) {
           saveCallback.done(e);
         }
       });
 }
 /** 注销 */
 public void logout() {
   if (AVUser.getCurrentUser() != null) {
     showLoadingDialog("当前用户为:" + AVUser.getCurrentUser().getUsername() + "\n正在注销用户...");
   } else {
     Utils.showToast(UserActivity.this, "当前无用户登陆"); // 无用户登陆时注销也不会错
     return;
   }
   AVUser.logOut(); // 直接注销,清除缓存
   Utils.showToast(UserActivity.this, "注销成功");
   //        AVUser.logOutInBackground(new LogOutCallback() {
   //            @Override
   //            public void done(AVException e) {
   //                if (e == null) {//注销成功后currentUser为null
   //                    Utils.showToast(UserActivity.this, "注销成功");
   //                } else {
   //                    textView.setText(e.getMessage());
   //                }
   //                dismissLoadingDialog();
   //            }
   //        });
 }
 public static void findFriendsWithCachePolicy(
     AVQuery.CachePolicy cachePolicy, FindCallback<AVUser> findCallback) {
   AVUser curUser = AVUser.getCurrentUser();
   AVQuery<AVUser> q = null;
   try {
     q = curUser.followeeQuery(AVUser.class);
   } catch (Exception e) {
     throw new NullPointerException();
   }
   q.setCachePolicy(cachePolicy);
   q.include("followee");
   q.findInBackground(findCallback);
 }
 public static List<AVUser> searchUser(String searchName, int skip) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.whereContains(User.USERNAME, searchName);
   q.limit(Constant.PAGE_SIZE);
   q.skip(skip);
   AVUser user = AVUser.getCurrentUser();
   List<String> friendIds = new ArrayList<String>(CacheService.getFriendIds());
   friendIds.add(user.getObjectId());
   q.whereNotContainedIn(Constant.OBJECT_ID, friendIds);
   q.orderByDescending(Constant.UPDATED_AT);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   List<AVUser> users = q.find();
   CacheService.registerUsers(users);
   return users;
 }
Beispiel #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    initView();

    initLocation();

    updateNearByQuan();

    CacheService.registerUser(AVUser.getCurrentUser());

    // initTestData();
  }
 @Click(R.id.id_btn_follow)
 void follow() {
   AVUser user = AVUser.getCurrentUser();
   AVRelation<AVObject> relation = user.getRelation("follow");
   relation.add(mDream.getAVUser("user"));
   user.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) {
             showToast("关注成功");
           }
         }
       });
 }
 /** 验证手机号 */
 public void signMobile() {
   String code = setCode.getText().toString();
   AVUser user = AVUser.getCurrentUser();
   if (TextUtils.isEmpty(code) || user == null || !user.isAuthenticated()) return;
   showLoadingDialog("正在验证手机号");
   AVUser.verifyMobilePhoneInBackground(
       code,
       new AVMobilePhoneVerifyCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) {
             Utils.showToast(UserActivity.this, "手机号验证成功!");
           } else {
             textView.setText(e.getMessage());
           }
           cancelLoadingDialog();
         }
       });
 }
  @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("dream", mDream);
    object.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(AVException e) {
            if (e == null) {
              showToast("保存成功");
              mDream.increment("joinNum");
              mDream.saveInBackground();
            }
          }
        });
  }
 /** 重置密码(通过邮箱验证,会先检验邮箱正确与否),往往在忘记密码时候使用,所以无需注销 */
 public void resetPwd() {
   final String email = setEmail.getText().toString();
   AVUser currentUser = AVUser.getCurrentUser();
   if (TextUtils.isEmpty(email) || currentUser == null || !currentUser.isAuthenticated()) return;
   showLoadingDialog("重置密码中...");
   AVUser.requestPasswordResetInBackground(
       email,
       new RequestPasswordResetCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) {
             Utils.showToast(UserActivity.this, "重置密码成功,请去" + email + "邮箱验证");
           } else {
             textView.setText(e.getMessage());
           }
           cancelLoadingDialog();
         }
       });
 }
 /** 手动更改密码,更改后自动重新登陆即可同步session-token */
 public void updPassword() {
   final String password = setPassword.getText().toString();
   final AVUser currentUser = AVUser.getCurrentUser();
   if (TextUtils.isEmpty(password) || currentUser == null || !currentUser.isAuthenticated())
     return;
   showLoadingDialog("正在修改密码...");
   currentUser.setPassword(password); // 修改完密码后session-token会失效(再去修改用户信息时异常),重新登陆(重置了session-token)
   currentUser.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) { // 修改成功
             cancelLoadingDialog();
             showLoadingDialog("正在重新登陆");
             AVUser.logInInBackground(
                 currentUser.getUsername(),
                 password,
                 new LogInCallback<User>() {
                   @Override
                   public void done(User newUser, AVException e) {
                     if (e == null) {
                       Utils.showToast(UserActivity.this, "重新登陆成功");
                       textView.setText(
                           "Username:"******"\n"
                               + "DisplayName:"
                               + newUser.getDisplayName()
                               + "\n");
                     } else {
                       textView.setText(e.getMessage());
                     }
                     cancelLoadingDialog();
                   }
                 },
                 User.class);
           } else {
             textView.setText(e.getMessage());
             cancelLoadingDialog();
           }
         }
       });
 }
  /** 更新用户名(login和signUp得到的user是授权的) */
  public void updUsername() {
    AVUser user = AVUser.getCurrentUser();
    String usernmae = setUsername.getText().toString();
    if (TextUtils.isEmpty(usernmae)) return;
    if (user == null) {
      Utils.showToast(this, "当前无登陆用户");
      return;
    }
    if (!user.isAuthenticated()) {
      Utils.showToast(this, "当前登陆用户无授权,请重新登录");
      return;
    }
    showLoadingDialog("正在更改username");
    user.setUsername(usernmae); // 自己的用户信息登陆后可以修改
    user.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(AVException e) {
            if (e == null) {
              textView.setText("保存成功");
            } else {
              textView.setText(e.getMessage());
            }
            AVUser user1 = AVUser.getCurrentUser();
            if (user1 != null) {
              Log.i("Session-token", user1.getUsername() + user1.getSessionToken());
            }
            cancelLoadingDialog();
          }
        });

    // 查询得到的user都是没有授权的
    /*ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.getInBackground("WXIMPuEaUZ", new GetCallback<ParseUser>() {
        @Override
        public void done(ParseUser object, ParseException e) {
            if (object != null) {
                object.setUsername("李某某");
                object.saveInBackground(saveCallback);
            }
        }
    });*/
  }
  private void initData() {

    String friendUsername = getIntent().getStringExtra("username");
    mUsername.setText(friendUsername);
    mUserAcount.setText(getIntent().getStringExtra("email"));

    switch (getIntent().getStringExtra("gender")) {
      case "男":
        mGender.setImageDrawable(getResources().getDrawable(R.drawable.user_boy));
        break;

      case "女":
        mGender.setImageDrawable(getResources().getDrawable(R.drawable.user_girl));
        break;
    }

    // 用户头像(大图)
    AVQuery<AVObject> queryAvater = new AVQuery<AVObject>("Gender");
    queryAvater.whereEqualTo("username", friendUsername);
    queryAvater.findInBackground(findGenderCallback(this, mAvatar));

    AVQuery<AVObject> query = new AVQuery<AVObject>("UserInformation");
    query.whereEqualTo("username", friendUsername);
    query.findInBackground(
        new FindCallback<AVObject>() {
          public void done(List<AVObject> avObjects, AVException e) {
            if (e == null) {
              Message msg = new Message();
              msg.what = 1;
              msg.obj = avObjects;
              mFriendHandler.sendMessage(msg);
            } else {
              // Toast.makeText(AlterActivity.this, "请检查网络!",
              // Toast.LENGTH_LONG).show();
            }
          }
        });

    // 查找好友距离
    findLocation(AVUser.getCurrentUser().getUsername(), friendUsername);
  }
 // 上传头像
 private void upLoadUserAvatar(final MaterialDialog progressDialog) {
   mAVService.upLoadUserAvatar(
       AVUser.getCurrentUser().getUsername(),
       mAvaterUrl,
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           progressDialog.setContent("注册成功!");
           new Handler()
               .postDelayed(
                   new Runnable() {
                     @Override
                     public void run() {
                       Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
                       startActivity(mainIntent);
                       AppManager.getAppManager().finishActivity(LoginActivity.class);
                       RegisterActivity.this.finish();
                     }
                   },
                   1000);
         }
       });
 }
Beispiel #24
0
 public static boolean isLogin() {
   return AVUser.getCurrentUser() != null;
 }
@SuppressLint("NewApi")
public class ChatmsgsListViewAdapter extends BaseAdapter {

  private Context mContext;
  private List<MessageChatBean> chatmsgsList;
  private SimpleDateFormat sd;

  private int mMaxItemWidth; // item最大宽度
  private int mMinItemWidth; // item最小宽度

  // TODO 暂时只测试4种状态 ,但是要进一步判断消息发送的方向
  private final int TYPE_COUNT = 20;
  private UserDao userDao;
  // 拿本地的 user
  private AVUser currentUser = AVUser.getCurrentUser();
  Handler handler;
  // 网络相关
  private ObjUser user = null;
  FinalBitmap finalBitmap;
  BitmapUtils bitmapUtils = null;
  Bitmap loadBitmap;
  int photoW, photoH;

  public ChatmsgsListViewAdapter(
      Context context, List<MessageChatBean> chatmsgsList, Handler handler) {
    this.mContext = context;
    this.chatmsgsList = chatmsgsList;
    this.handler = handler;

    mMaxItemWidth = DisplayUtils.getWindowWidth(mContext) - DensityUtil.dip2px(mContext, 110);
    mMinItemWidth = DensityUtil.dip2px(mContext, 44);

    if (currentUser != null) {
      user = AVUser.cast(currentUser, ObjUser.class);
    }

    MyApplication app = (MyApplication) context.getApplicationContext();
    finalBitmap = app.getFinalBitmap();
    bitmapUtils = new BitmapUtils(context.getApplicationContext());
    userDao = new UserDao(context);
    loadBitmap =
        BitmapFactory.decodeResource(
            mContext.getResources(), R.drawable.mine_likelist_profile_default);
  }

  /**
   * 消息状态 style 10 我发的文本消息 12接收的文本消息 11 我发的图片的消息 13接收的图片消息 3新人加入消息 4普通通知消息 活动咨询反馈通知消息 消息发送方向 14
   * 自己加入和踢出提醒
   */
  @Override
  public int getItemViewType(int position) {

    // TODO Auto-generated method stub
    return chatmsgsList != null ? chatmsgsList.get(position).getTypeMsg() : -1;
  }

  /** */
  @Override
  public int getViewTypeCount() {
    // TODO Auto-generated method stub
    return TYPE_COUNT;
  }

  @Override
  public int getCount() {
    // TODO Auto-generated method stub
    // return newsList.size();
    return chatmsgsList.size();
  }

  @Override
  public Object getItem(int position) {
    // TODO Auto-generated method stub
    return chatmsgsList.get(position);
  }

  @Override
  public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    final ViewHolder holder;
    final MessageChatBean item = chatmsgsList.get(position);
    com.meetu.common.Log.e("chatListsize", "size" + chatmsgsList.size());
    com.meetu.common.Log.e("getTypeMsg", "" + item.getTypeMsg());
    if (convertView == null) {
      holder = new ViewHolder();
      switch (item.getTypeMsg()) {
        case Constants.SHOW_SEND_TYPE_TEXT:
          convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_item_text_right, null);
          holder.content = (TextView) convertView.findViewById(R.id.content_chat_item_right_tv);
          holder.time = (TextView) convertView.findViewById(R.id.time_chat_item_right_tv);
          holder.timeLayout =
              (RelativeLayout) convertView.findViewById(R.id.time_chat_item_right_rl);
          holder.userHeadPhoto =
              (ImageView) convertView.findViewById(R.id.userHead_chat_item_right_img);
          holder.userName = (TextView) convertView.findViewById(R.id.userName_chat_item_tv);
          holder.failPhoto = (ImageView) convertView.findViewById(R.id.fail_chat_item_text_img);
          holder.resentLayout =
              (RelativeLayout) convertView.findViewById(R.id.fail_chat_item_text_right_rl);
          holder.progressMsg = (ProgressBar) convertView.findViewById(R.id.progressBar_msg);
          break;
          // TODO 1 暂时没有此类型 未知原因出现此类型 待解决

        case Constants.SHOW_RECEIVE_TYPE_TEXT:
          convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_item_text_left, null);
          holder.content = (TextView) convertView.findViewById(R.id.content_chat_item_left_tv);
          holder.time = (TextView) convertView.findViewById(R.id.time_chat_item_left_tv);
          holder.timeLayout =
              (RelativeLayout) convertView.findViewById(R.id.time_chat_item_left_rl);

          holder.userHeadPhoto =
              (ImageView) convertView.findViewById(R.id.userHead_chat_item_left_img);
          holder.userName = (TextView) convertView.findViewById(R.id.userName_chat_item_left_tv);
          holder.failPhoto = (ImageView) convertView.findViewById(R.id.fail_chat_item_text_left);
          holder.resentLayout =
              (RelativeLayout) convertView.findViewById(R.id.fail_chat_item_text_right_rl);
          holder.progressMsg = (ProgressBar) convertView.findViewById(R.id.progressBar_msg);
          break;
        case Constants.SHOW_SEND_TYPE_IMG:
          convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_item_photo_right, null);
          holder.photo = (ImageView) convertView.findViewById(R.id.photo_chat_item_right_img);
          holder.time = (TextView) convertView.findViewById(R.id.time_photochat_item_right_tv);
          holder.timeLayout =
              (RelativeLayout) convertView.findViewById(R.id.time_photochat_item_right_rl);
          holder.userHeadPhoto =
              (ImageView) convertView.findViewById(R.id.userHead_chat_item_photo_right_img);
          holder.userName =
              (TextView) convertView.findViewById(R.id.userName_chat_item_photo_right_tv);
          holder.failPhoto =
              (ImageView) convertView.findViewById(R.id.fail_chat_item_text_photo__right_img);
          holder.resentLayout =
              (RelativeLayout) convertView.findViewById(R.id.fail_chat_item_photo_right_rl);
          holder.progressMsg = (ProgressBar) convertView.findViewById(R.id.progressBar_msg);
          break;
        case Constants.SHOW_RECEIVE_TYPE_IMG:
          convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_item_photo_left, null);
          holder.photo = (ImageView) convertView.findViewById(R.id.photo_chat_item_left_img);
          holder.time = (TextView) convertView.findViewById(R.id.time_photochat_item_left_tv);
          holder.timeLayout =
              (RelativeLayout) convertView.findViewById(R.id.time_photochat_item_left_rl);

          holder.userHeadPhoto =
              (ImageView) convertView.findViewById(R.id.userHead_chat_item_photo_left_img);
          holder.userName =
              (TextView) convertView.findViewById(R.id.userNamechat_item_photo_left_tv);
          holder.failPhoto =
              (ImageView) convertView.findViewById(R.id.fail_chat_item_text_photo__left_img);
          holder.resentLayout =
              (RelativeLayout) convertView.findViewById(R.id.fail_chat_item_photo_left_rl);
          holder.progressMsg = (ProgressBar) convertView.findViewById(R.id.progressBar_msg);
          //	holder.leftPhotoUp=(ImageView)
          // convertView.findViewById(R.id.photo_up_chat_item_left_img);

          break;

        case Constants.SHOW_MEMBER_ADD:
          convertView =
              LayoutInflater.from(mContext).inflate(R.layout.chat_item_newjoin_remind, null);
          holder.userHeadPhoto = (ImageView) convertView.findViewById(R.id.msg_photo_img);
          holder.userSchool =
              (TextView) convertView.findViewById(R.id.content_chat_item_newjoin_tv);
          holder.userName = (TextView) convertView.findViewById(R.id.name_chat_item_newjoin_tv);
          holder.sexImg = (ImageView) convertView.findViewById(R.id.sex_icon_imv);
          holder.time = (TextView) convertView.findViewById(R.id.time_chat_item_newjoin_tv);
          holder.allItem = (LinearLayout) convertView.findViewById(R.id.all_card_item_newjoin_ll);
          break;
        case Constants.SHOW_SELF_ADD:
        case Constants.SHOW_SELF_KICK:
          convertView = LayoutInflater.from(mContext).inflate(R.layout.chat_my_join_or_exit, null);
          holder.time = (TextView) convertView.findViewById(R.id.time_my_join_or_exit_remind_tv);
          holder.content =
              (TextView) convertView.findViewById(R.id.content_my_join_or_exit_remind_tv);
          break;
        default:
          break;
      }
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    switch (item.getTypeMsg()) {
      case Constants.SHOW_SEND_TYPE_TEXT:
      case Constants.SHOW_RECEIVE_TYPE_TEXT:
        if (item.getStatusMsg() == Constants.STATUES_FAILED) {
          holder.failPhoto.setVisibility(View.VISIBLE);
          holder.progressMsg.setVisibility(View.GONE);
          holder.resentLayout.setVisibility(View.VISIBLE);
        } else {
          holder.resentLayout.setVisibility(View.GONE);
        }
        holder.resentLayout.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                holder.failPhoto.setVisibility(View.GONE);
                holder.progressMsg.setVisibility(View.VISIBLE);
                Message msg = new Message();
                msg.what = 3;
                msg.obj = item;
                handler.sendMessage(msg);
              }
            });
        SpannableString spannableString =
            ChatGroupActivity.getExpressionString(mContext, item.getMsgText());
        holder.content.setMaxWidth(mMaxItemWidth);
        holder.content.setMinWidth(mMinItemWidth);
        holder.content.setText(spannableString);
        if (item.getIsShowTime() == 1) {
          Date date = new Date(item.getSendTimeStamp());
          sd = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
          String string = sd.format(date);
          holder.time.setText(string);
          holder.timeLayout.setVisibility(View.VISIBLE);
        }
        if (item.getIsShowTime() == 0) {
          holder.timeLayout.setVisibility(View.GONE);
        }
        holder.userHeadPhoto.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(mContext, UserPagerActivity.class);
                intent.putExtra("userId", item.getIdClient());
                mContext.startActivity(intent);
              }
            });

        if (item.getIdClient() != null && !("").equals(item.getIdClient())) {
          if (user.getObjectId().equals(item.getIdClient())) {
            holder.userName.setText("" + user.getNameNick());
            // log.e("zcq", "是我自己发的消息");
            if (user.getProfileClip() != null) {
              // log.e("zcq", "是我自己发的消息");
              finalBitmap.display(
                  holder.userHeadPhoto,
                  user.getProfileClip()
                      .getThumbnailUrl(
                          true, DensityUtil.dip2px(mContext, 40), DensityUtil.dip2px(mContext, 40)),
                  loadBitmap);
            }
          } else {

            ArrayList<UserBean> list = userDao.queryUser(item.getIdClient());
            if (null != list && list.size() > 0) {

              if (!list.get(0).getProfileClip().equals("")) {
                finalBitmap.display(holder.userHeadPhoto, list.get(0).getProfileClip(), loadBitmap);
              }
              holder.userName.setText("" + list.get(0).getNameNick());

            } else {
              ObjUserWrap.getObjUser(
                  item.getIdClient(),
                  new ObjUserInfoCallback() {

                    @Override
                    public void callback(ObjUser objuser, AVException e) {
                      // TODO Auto-generated method stub
                      if (e == null) {
                        userDao.insertOrReplaceUser(objuser);
                        ArrayList<UserBean> list2 = userDao.queryUser(item.getIdClient());
                        if (null != list2 && list2.size() > 0) {
                          if (!list2.get(0).getProfileClip().equals("")) {
                            finalBitmap.display(
                                holder.userHeadPhoto, list2.get(0).getProfileClip(), loadBitmap);
                          }
                          holder.userName.setText("" + list2.get(0).getNameNick());
                        }
                      }
                    }
                  });
            }
          }
        }
        break;

      case Constants.SHOW_SEND_TYPE_IMG:
        if (item.getStatusMsg() == Constants.STATUES_FAILED) {
          holder.failPhoto.setVisibility(View.VISIBLE);
          holder.progressMsg.setVisibility(View.GONE);
          holder.resentLayout.setVisibility(View.VISIBLE);
        } else {
          holder.resentLayout.setVisibility(View.GONE);
        }
        holder.resentLayout.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                holder.failPhoto.setVisibility(View.GONE);
                holder.progressMsg.setVisibility(View.VISIBLE);
                Message msg = new Message();
                msg.what = 4;
                msg.obj = item;
                handler.sendMessage(msg);
              }
            });
        if (item.getFileUrl() != null && !item.getFileUrl().equals("")) {
          //	finalBitmap.display(holder.photo, item.getImgMsgImageUrl());
          bitmapUtils.display(
              holder.photo,
              item.getFileUrl(),
              new BitmapLoadCallBack<ImageView>() {

                @Override
                public void onLoadCompleted(
                    ImageView imageView,
                    String arg1,
                    Bitmap bitmap,
                    BitmapDisplayConfig arg3,
                    BitmapLoadFrom arg4) {

                  bitmap = BitmapCut.toRoundCorner(bitmap, DensityUtil.dip2px(mContext, 10));

                  holder.photo.setImageBitmap(bitmap);
                }

                @Override
                public void onLoadFailed(ImageView arg0, String arg1, Drawable arg2) {
                  // TODO Auto-generated method stub

                }
              });
        }

        if (item.getIsShowTime() == 1) {
          Date date = new Date(item.getSendTimeStamp());
          sd = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
          String string = sd.format(date);
          holder.time.setText(string);
          holder.timeLayout.setVisibility(View.VISIBLE);
        }
        if (item.getIsShowTime() == 0) {
          holder.timeLayout.setVisibility(View.GONE);
        }

        holder.userHeadPhoto.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(mContext, UserPagerActivity.class);
                intent.putExtra("userId", item.getIdClient());
                mContext.startActivity(intent);
              }
            });

        if (user.getObjectId().equals(item.getIdClient())) {
          holder.userName.setText("" + user.getNameNick());
          if (user.getProfileClip() != null) {
            finalBitmap.display(
                holder.userHeadPhoto,
                user.getProfileClip()
                    .getThumbnailUrl(
                        true, DensityUtil.dip2px(mContext, 40), DensityUtil.dip2px(mContext, 40)),
                loadBitmap);
          }
        }

        break;
      case Constants.SHOW_RECEIVE_TYPE_IMG:
        if (item.getStatusMsg() == Constants.STATUES_FAILED) {
          holder.resentLayout.setVisibility(View.VISIBLE);
        } else {
          holder.resentLayout.setVisibility(View.GONE);
        }
        if (item.getFileUrl() != null && !item.getFileUrl().equals("")) {
          bitmapUtils.display(
              holder.photo,
              item.getFileUrl(),
              new BitmapLoadCallBack<ImageView>() {

                @Override
                public void onLoadCompleted(
                    ImageView imageView,
                    String arg1,
                    Bitmap bitmap,
                    BitmapDisplayConfig arg3,
                    BitmapLoadFrom arg4) {

                  bitmap = BitmapCut.toRoundCorner(bitmap, DensityUtil.dip2px(mContext, 10));

                  holder.photo.setImageBitmap(bitmap);
                }

                @Override
                public void onLoadFailed(ImageView arg0, String arg1, Drawable arg2) {
                  // TODO Auto-generated method stub

                }
              });
          //			finalBitmap.display(holder.photo, item.getImgMsgImageUrl());

          // 计算图片 比例 大小
          /*			if(item.getImgMsgImageWidth()>item.getImgMsgImageHeight()){
          	if(item.getImgMsgImageWidth()<DensityUtil.dip2px(mContext, 160)){
          		photoW=item.getImgMsgImageWidth();
          		photoH=item.getImgMsgImageHeight();
          	}else{
          		photoW=DensityUtil.dip2px(mContext, 160);
          		photoH=(int)((double)item.getImgMsgImageHeight()/((double)((double)item.getImgMsgImageWidth()/(double)photoW)));
          	}

          }else{
          	if(item.getImgMsgImageHeight()<DensityUtil.dip2px(mContext, 160)){
          		photoW=item.getImgMsgImageWidth();
          		photoH=item.getImgMsgImageHeight();
          	}else{
          		photoH=DensityUtil.dip2px(mContext, 160);
          		photoW=(int)((double)item.getImgMsgImageWidth()/((double)((double)item.getImgMsgImageHeight()/(double)photoH)));
          	}

          }*/
        }

        //			RelativeLayout.LayoutParams params= (LayoutParams)
        // holder.leftPhotoUp.getLayoutParams();
        //			params.width=photoW;
        //			params.height=photoH;
        //			holder.leftPhotoUp.setLayoutParams(params);
        //			log.e("image wh==",
        // "photoW=="+photoW+"photoH=="+photoH+"w=="+item.getImgMsgImageWidth()+"
        // h=="+item.getImgMsgImageHeight());
        //			finalBitmap.display(holder.photo, item.getImgMsgImageUrl(), photoW, photoH);

        if (item.getIsShowTime() == 1) {
          Date date = new Date(item.getSendTimeStamp());
          sd = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
          String string = sd.format(date);
          // log.e(""+date+", "+sd.format(date)+", time=="+item.getSendTimeStamp());
          holder.time.setText(string);
          holder.timeLayout.setVisibility(View.VISIBLE);
        }
        if (item.getIsShowTime() == 0) {
          holder.timeLayout.setVisibility(View.GONE);
        }

        holder.userHeadPhoto.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(mContext, UserPagerActivity.class);
                intent.putExtra("userId", item.getIdClient());
                mContext.startActivity(intent);
              }
            });
        if (item.getIdClient() != null && !("").equals(item.getIdClient())) {
          ArrayList<UserBean> list = userDao.queryUser(item.getIdClient());
          if (null != list && list.size() > 0) {

            if (!list.get(0).getProfileClip().equals("")) {
              finalBitmap.display(holder.userHeadPhoto, list.get(0).getProfileClip(), loadBitmap);
            }
            holder.userName.setText("" + list.get(0).getNameNick());

          } else {
            ObjUserWrap.getObjUser(
                item.getIdClient(),
                new ObjUserInfoCallback() {

                  @Override
                  public void callback(ObjUser objuser, AVException e) {
                    // TODO Auto-generated method stub
                    if (e == null) {
                      userDao.insertOrReplaceUser(objuser);
                      ArrayList<UserBean> list2 = userDao.queryUser(item.getIdClient());
                      if (null != list2 && list2.size() > 0) {
                        if (!list2.get(0).getProfileClip().equals("")) {
                          finalBitmap.display(
                              holder.userHeadPhoto, list2.get(0).getProfileClip(), loadBitmap);
                        }
                        holder.userName.setText("" + list2.get(0).getNameNick());
                      }
                    }
                  }
                });
          }
        }

        break;

      case Constants.SHOW_MEMBER_ADD:
        // TODO 设置他人头像 需要封装个方法。多处使用
        try {

          holder.time.setText(
              com.meetu.cloud.utils.DateUtils.getFormattedTimeInterval(item.getSendTimeStamp()));

          if (item.getIdOperated() != null && !("").equals(item.getIdOperated())) {

            holder.allItem.setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    Intent intent = new Intent(mContext, UserPagerActivity.class);
                    intent.putExtra("userId", item.getIdOperated());
                    mContext.startActivity(intent);
                  }
                });

            ArrayList<UserBean> list = userDao.queryUser(item.getIdOperated());
            if (null != list && list.size() > 0) {

              if (!list.get(0).getProfileClip().equals("")) {
                finalBitmap.display(holder.userHeadPhoto, list.get(0).getProfileClip(), loadBitmap);
              }
              holder.userName.setText("" + list.get(0).getNameNick());
              holder.userSchool.setText("" + list.get(0).getSchool());
              if (list.get(0).getGender() == 2) {
                holder.sexImg.setImageResource(R.drawable.acty_joinlist_img_female);
              }
            } else {
              ObjUserWrap.getObjUser(
                  item.getIdOperated(),
                  new ObjUserInfoCallback() {

                    @Override
                    public void callback(ObjUser objuser, AVException e) {
                      // TODO Auto-generated method stub
                      if (e == null) {
                        userDao.insertOrReplaceUser(objuser);
                        ArrayList<UserBean> list2 = userDao.queryUser(item.getIdOperated());
                        if (null != list2 && list2.size() > 0) {
                          if (!list2.get(0).getProfileClip().equals("")) {
                            finalBitmap.display(
                                holder.userHeadPhoto, list2.get(0).getProfileClip(), loadBitmap);
                          }
                          holder.userName.setText("" + list2.get(0).getNameNick());
                          holder.userSchool.setText("" + list2.get(0).getSchool());
                          if (list2.get(0).getGender() == 2) {
                            holder.sexImg.setImageResource(R.drawable.acty_joinlist_img_female);
                          }
                        }
                      }
                    }
                  });
            }
          }
        } catch (Exception e) {
          log.e("zcq 新人加入异常", e);
        }

        break;
      case Constants.SHOW_SELF_KICK:
      case Constants.SHOW_SELF_ADD:
        // 自己 加入和退出的状态提醒
        holder.content.setText("" + item.getMsgText());
        holder.time.setText(
            ""
                + com.meetu.cloud.utils.DateUtils.getFormattedTimeInterval(
                    Long.valueOf(item.getSendTimeStamp())));
        break;
    }

    return convertView;
  }

  private class ViewHolder {
    private TextView content;
    private ImageView photo;
    private ImageView sexImg;
    private TextView time;
    private RelativeLayout timeLayout;
    private TextView userSchool;
    private ImageView userHeadPhoto;
    private TextView userName;
    private ImageView failPhoto;
    private ProgressBar progressMsg;
    private RelativeLayout resentLayout;
    private ImageView leftPhotoUp;
    private LinearLayout allItem;
  }
}