예제 #1
0
  /**
   * 同步群组信息
   *
   * @param groupId
   */
  public static void syncGroupInfo(final String groupId) {
    ECGroupManager groupManager = SDKCoreHelper.getECGroupManager();
    if (groupManager == null) {
      return;
    }
    groupManager.getGroupDetail(
        groupId,
        new ECGroupManager.OnGetGroupDetailListener() {

          @Override
          public void onGetGroupDetailComplete(ECError error, ECGroup group) {
            if (getInstance().isSuccess(error)) {
              if (group == null) {
                return;
              }

              GroupSqlManager.updateGroup(group);
              if (getInstance().mCallback != null) {
                getInstance().mCallback.onSyncGroupInfo(groupId);
              }
              return;
            }
            onErrorCallback(error.errorCode, "同步群组信息失败");
          }
        });
  }
예제 #2
0
  /** 开始网络同步群组列表信息 */
  @SuppressWarnings("deprecation")
  public static void syncGroup(Callback callback) {
    getInstance().mGroupManager = SDKCoreHelper.getECGroupManager();
    if (getInstance().mGroupManager == null || getInstance().isSync) {
      LogUtil.e(TAG, "SDK not ready or isSync " + getInstance().isSync);
      return;
    }
    getInstance().isSync = true;
    getInstance().mCallback = callback;

    getInstance()
        .mGroupManager
        .queryOwnGroups(
            Target.GROUP,
            new ECGroupManager.OnQueryOwnGroupsListener() {

              @Override
              public void onQueryOwnGroupsComplete(ECError error, List<ECGroup> groups) {
                if (getInstance().isSuccess(error)) {
                  if (groups == null || groups.isEmpty()) {
                    GroupSqlManager.delALLGroup();
                  } else {
                    LogUtil.d(TAG, "[syncGroup] groups size :" + groups.size());
                    List<String> allGroupIdByJoin = GroupSqlManager.getAllGroupIdBy(true);
                    ArrayList<String> ids = new ArrayList<String>();
                    for (ECGroup group : groups) {
                      ids.add(group.getGroupId());
                    }

                    // 查找不是我的群组
                    if (!allGroupIdByJoin.isEmpty()) {
                      for (String id : allGroupIdByJoin) {
                        if (ids.contains(id)) {
                          continue;
                        }
                        // 不是我的群组
                        GroupSqlManager.updateUNJoin(id);
                      }
                    }
                    GroupSqlManager.insertGroupInfos(groups, 1);
                  }
                  getInstance().isSync = false;
                  // 更新公共所有群组
                  // syncPublicGroups();
                  if (getInstance().mCallback != null) {
                    getInstance().mCallback.onSyncGroup();
                  }
                  if (CCPAppManager.getContext() != null) {
                    CCPAppManager.getContext().sendBroadcast(new Intent((ACTION_SYNC_GROUP)));
                  }
                  return;
                }
                onErrorCallback(error.errorCode, "同步群组失败");
              }
            });
  }
예제 #3
0
 private GroupService() {
   mGroupManager = SDKCoreHelper.getECGroupManager();
   countGroups();
 }
예제 #4
0
 private static void getGroupManager() {
   getInstance().mGroupManager = SDKCoreHelper.getECGroupManager();
 }