示例#1
0
  /**
   * @param options
   * @param data
   * @param path
   * @param uri
   * @param resource
   * @return
   */
  public static Bitmap decodeMuilt(
      BitmapFactory.Options options, byte[] data, String path, Uri uri, int resource) {
    try {

      if (!checkByteArray(data) && TextUtils.isEmpty(path) && uri == null && resource <= 0) {
        return null;
      }

      if (checkByteArray(data)) {
        return BitmapFactory.decodeByteArray(data, 0, data.length, options);
      }

      if (uri != null) {
        InputStream inputStream =
            CCPAppManager.getContext().getContentResolver().openInputStream(uri);
        Bitmap localBitmap = BitmapFactory.decodeStream(inputStream, null, options);
        inputStream.close();
        return localBitmap;
      }

      if (resource > 0) {
        return BitmapFactory.decodeResource(
            CCPAppManager.getContext().getResources(), resource, options);
      }
      return BitmapFactory.decodeFile(path, options);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 /**
  * 更新群组成员
  *
  * @param groupId
  * @param members
  */
 public static void insertGroupMembers(String groupId, String[] members) {
   if (TextUtils.isEmpty(groupId) || members == null || members.length <= 0) {
     return;
   }
   for (String member : members) {
     ECGroupMember groupMember = new ECGroupMember();
     groupMember.setBelong(groupId);
     groupMember.setVoipAccount(member);
     if (CCPAppManager.getClientUser() != null
         && CCPAppManager.getClientUser().getUserId().equals(member)) {
       groupMember.setRole(1);
     } else {
       groupMember.setRole(3);
     }
     groupMember.setTel(member);
     insertGroupMember(groupMember);
   }
 }
 public static Cursor getGroupMembersByCursorExceptSelf(String groupId) {
   String selfVoip = CCPAppManager.getUserId();
   String sql =
       "select voipaccount ,contacts.username ,contacts.remark ,role ,isban from group_members ,contacts  where group_members.voipaccount  != '"
           + selfVoip
           + "'   and group_id ='"
           + groupId
           + "' and contacts.contact_id = group_members.voipaccount order by role";
   return getInstance().sqliteDB().rawQuery(sql, null);
 }
  /**
   * 创建私有群组
   *
   * @param member
   */
  public static void doCreateGroup(
      final String[] member, final ECGroupManager.OnInviteJoinGroupListener l) {
    // 构建群组参数
    ECGroup group = new ECGroup();
    // 设置群组名称
    group.setName(CCPAppManager.getClientUser().getUserId() + PRICATE_CHATROOM);
    // 设置群组公告
    group.setDeclare("");
    // 设置群组类型,如:临时群组(100人)
    group.setGroupType(0);
    // 设置群组验证权限,如:需要身份验证2
    group.setPermission(ECGroup.Permission.NEED_AUTH);
    // 设置群组创建者(可以不设置,服务器默认接口调用者为创建者)
    group.setOwner(CCPAppManager.getClientUser().getUserId());

    getGroupManager();
    getInstance()
        .mGroupManager
        .createGroup(
            group,
            new ECGroupManager.OnCreateGroupListener() {

              @Override
              public void onCreateGroupComplete(ECError error, ECGroup group) {
                if (getInstance().isSuccess(error)) {
                  if (group.getName() != null && group.getName().endsWith(PRICATE_CHATROOM)) {
                    ArrayList<String> contactName = ContactSqlManager.getContactName(member);
                    String chatroomName = DemoUtils.listToString(contactName, ",");
                    group.setName(chatroomName);
                  }
                  GroupSqlManager.insertGroup(group, true, false, false);
                  GroupMemberService.inviteMembers(
                      group.getGroupId(), "", ECGroupManager.InvitationMode.FORCE_PULL, member, l);
                  return;
                }
                onErrorCallback(error.errorCode, "创建群组失败");
              }
            });
  }
示例#5
0
 public static boolean saveImage(String url, String ext) {
   if (TextUtils.isEmpty(url)) {
     return false;
   }
   String filePath = url;
   File dir = new File(FileAccessor.APPS_ROOT_DIR, "ECDemo_IM");
   if (!dir.exists()) dir.mkdirs();
   long timeMillis = System.currentTimeMillis();
   int result =
       FileUtils.copyFile(
           dir.getAbsolutePath(),
           "ecexport" + timeMillis,
           ext,
           FileUtils.readFlieToByte(filePath, 0, FileUtils.decodeFileLength(filePath)));
   if (result == 0) {
     ExportImgUtil.refreshingMediaScanner(
         CCPAppManager.getContext(), "ecexport" + timeMillis + ext);
     ToastUtil.showMessage("图片已保存至" + dir.getAbsolutePath(), Toast.LENGTH_LONG);
     return false;
   }
   ToastUtil.showMessage("图片保存失败");
   return true;
 }
示例#6
0
 public static boolean checkUpdater(String serVer) {
   String version = CCPAppManager.getVersion();
   return compareVersion(version, serVer) == -1;
 }
示例#7
0
  public boolean isChatToSelf(String sessionId) {

    String userId = CCPAppManager.getUserId();
    return sessionId != null && (sessionId.equalsIgnoreCase(userId) ? true : false);
  }