@Override
  protected void initData() {

    if (RongContext.getInstance() != null) RongContext.getInstance().getEventBus().register(this);

    if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) {
      RongIM.getInstance()
          .getRongIMClient()
          .getConversationNotificationStatus(
              getConversationType(),
              getTargetId(),
              new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {

                @Override
                public void onSuccess(
                    final Conversation.ConversationNotificationStatus notificationStatus) {

                  if (notificationStatus != null) {
                    setSwitchBtnStatus(
                        notificationStatus
                                == Conversation.ConversationNotificationStatus.DO_NOT_DISTURB
                            ? false
                            : true);
                  }
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {

                  setSwitchBtnStatus(!getSwitchBtnStatus());
                }
              });
    }
  }
    @Override
    public void run() {
      RLog.d(this, "AttachRunnable", "insert image and save to db, uri = " + mUri);
      final ImageMessage content = ImageMessage.obtain(mUri, mUri);
      if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) ;
      RongIM.getInstance()
          .getRongIMClient()
          .insertMessage(
              getCurrentConversation().getConversationType(),
              getCurrentConversation().getTargetId(),
              null,
              content,
              new RongIMClient.ResultCallback<Message>() {
                @Override
                public void onSuccess(Message message) {
                  RLog.d(this, "AttachRunnable", "onSuccess insert image");
                  message.setSentStatus(Message.SentStatus.SENDING);
                  RongIM.getInstance()
                      .getRongIMClient()
                      .setMessageSentStatus(
                          message.getMessageId(), Message.SentStatus.SENDING, null);
                  getContext().executorBackground(new UploadRunnable(message));
                }

                @Override
                public void onError(RongIMClient.ErrorCode e) {
                  RLog.d(this, "AttachRunnable", "onError insert image, error = " + e);
                }
              });
    }
    @Override
    public void run() {

      // 封装image类型的IM消息
      final ImageMessage content = ImageMessage.obtain(mUri, mUri);

      if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null)
        RongIM.getInstance()
            .getRongIMClient()
            .sendImageMessage(
                getCurrentConversation().getConversationType(),
                getCurrentConversation().getTargetId(),
                content,
                null,
                null,
                new RongIMClient.SendImageMessageCallback() {
                  @Override
                  public void onAttached(Message message) {}

                  @Override
                  public void onError(Message message, RongIMClient.ErrorCode errorCode) {}

                  @Override
                  public void onSuccess(Message message) {}

                  @Override
                  public void onProgress(Message message, int i) {}
                });
    }
Пример #4
0
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    RongIM.getInstance()
        .init(this, Const.APP_KEY, R.drawable.ic_launcher); // 只执行一次,中间字符串,写private Key(开发环境的)

    String token = Const.TOKEN; // 用网页调试生成现成的token

    RongIM.connect(
        token,
        new RongIMClient.ConnectCallback() // 工程中只调用一次,如果断线,由融云SDK自动启重连
        {

          @Override
          public void onError(ErrorCode arg0) {
            // TODO Auto-generated method stub
            Log.d("Connect:", "Login Failed " + arg0.getValue());
          }

          @Override
          public void onSuccess(String arg0) {
            // TODO Auto-generated method stub
            Log.d("Connect:", "Login Success " + arg0);
          }
        });
  }
Пример #5
0
  @Override
  public void onCreate() {

    super.onCreate();
    /** IMKit SDK调用第一步 初始化 context上下文 */
    RongIM.init(this);
    /** d 融云SDK事件监听处理 */
    RongCloudEvent.init(this);

    DemoContext.init(this);

    // 注册消息类型的时候判断当前的进程是否在主进程
    if ("io.rong.app".equals(getCurProcessName(getApplicationContext()))) {
      try {
        // 注册自定义消息,注册完消息后可以收到自定义消息
        RongIM.registerMessageType(DeAgreedFriendRequestMessage.class);
        // 注册消息模板,注册完消息模板可以在会话列表上展示
        RongIM.registerMessageTemplate(new DeContactNotificationMessageProvider());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    // Crash 日志
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(this));
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent;

    RongContext.getInstance().getEventBus().register(this);

    if (getActivity() != null) {

      intent = getActivity().getIntent();

      if (intent.getData() != null) {

        mConversationType =
            Conversation.ConversationType.valueOf(
                intent.getData().getLastPathSegment().toUpperCase());

        mTargetId = intent.getData().getQueryParameter("targetId");
      }
    }
    mAdapter = new RongConversationAddMemberAdapter(getActivity());
    mAdapter.setDeleteIconListener(this);

    if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) {
      initData();
    }
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.add_black:
        if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) {
          RongIM.getInstance()
              .addToBlacklist(
                  userId,
                  new RongIM.OperationCallback() {

                    @Override
                    public void onError(ErrorCode errorCode) {
                      Log.e(
                          TAG, "-------addToBlacklist onError----------:" + errorCode.getMessage());
                      Log.e(TAG, "-------addToBlacklist onError---------:" + errorCode.getValue());
                    }

                    @Override
                    public void onSuccess() {
                      Log.e(TAG, "-------添加到黑名单--------:");

                      Message msg = Message.obtain();
                      msg.what = 1;
                      mHandler.sendMessage(msg);
                    }
                  });
        } else {
          WinToast.toast(this, R.string.network_not);
        }
        break;
      case R.id.remove_black:
        if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) {
          RongIM.getInstance()
              .removeFromBlacklist(
                  userId,
                  new RongIM.OperationCallback() {

                    @Override
                    public void onError(ErrorCode errorCode) {
                      Log.e(TAG, "------- removeFromBlacklist onError-------:" + errorCode);
                    }

                    @Override
                    public void onSuccess() {
                      Log.e(TAG, "-------被移除黑名单-------:");
                      Message msg = Message.obtain();
                      msg.what = 2;
                      mHandler.sendMessage(msg);
                    }
                  });
        } else {
          WinToast.toast(this, R.string.network_not);
        }
        break;
      default:
        break;
    }
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Bundle bundle = getIntent().getExtras();
   Log.i("yifan", "get intent, test is : " + bundle.getString("test"));
   if (RongIM.getInstance() != null) {
     RongIM.getInstance().startConversationList(this);
   }
   finish();
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.de_ac_main);
   RongIM.getInstance().enableNewComingMessageIcon(true);
   RongIM.getInstance().enableUnreadMessageIcon(true);
   initView();
   initData();
   getPushMessage();
 }
Пример #10
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.customer_chat:
       if (RongIM.getInstance() != null)
         // KEFU146001495753714 正式  KEFU145930951497220 测试
         RongIM.getInstance()
             .startCustomerServiceChat(getActivity(), "KEFU146001495753714", "在线客服", null);
       break;
   }
 }
Пример #11
0
  /**
   * 连接融云服务器
   *
   * @param c
   * @param token 用户令牌
   */
  public static void ConnectRongYun(final Context c, String token) {
    RongYunFrindsManager.getInstance(c);
    if (c.getApplicationInfo()
        .packageName
        .equals(App.getCurrentPidName(c.getApplicationContext()))) {
      RongIM.connect(
          token,
          new ConnectCallback() {

            @Override
            public void onTokenIncorrect() {
              // TODO Auto-generated method stub
              Toast.makeText(c.getApplicationContext(), "获取令牌失败", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(ErrorCode arg0) {
              // TODO Auto-generated method stub
              Toast.makeText(c.getApplicationContext(), "服务器故障,请稍候重试", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onSuccess(String arg0) {
              // TODO Auto-generated method stub
              Toast.makeText(c.getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show();
            }
          });
    }
  }
    @Override
    public void run() {
      mLock = new CountDownLatch(1);
      RLog.d(this, "UploadRunnable", "sendImageMessage");
      RongIM.getInstance()
          .getRongIMClient()
          .sendImageMessage(
              msg,
              null,
              null,
              new RongIMClient.SendImageMessageCallback() {
                @Override
                public void onAttached(Message message) {
                  mLock.countDown();
                }

                @Override
                public void onError(Message message, RongIMClient.ErrorCode code) {
                  mLock.countDown();
                }

                @Override
                public void onSuccess(Message message) {
                  mLock.countDown();
                }

                @Override
                public void onProgress(Message message, int progress) {}
              });
      try {
        mLock.await();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
Пример #13
0
  public static void setConverstionNotif(
      final Context context,
      Conversation.ConversationType conversationType,
      String targetId,
      boolean state) {
    Conversation.ConversationNotificationStatus cns;
    if (state) {
      cns = Conversation.ConversationNotificationStatus.DO_NOT_DISTURB;
    } else {
      cns = Conversation.ConversationNotificationStatus.NOTIFY;
    }
    RongIM.getInstance()
        .setConversationNotificationStatus(
            conversationType,
            targetId,
            cns,
            new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {
              @Override
              public void onSuccess(
                  Conversation.ConversationNotificationStatus conversationNotificationStatus) {
                if (conversationNotificationStatus
                    == Conversation.ConversationNotificationStatus.DO_NOT_DISTURB) {
                  //                    NToast.shortToast(context, "设置免打扰成功");
                } else if (conversationNotificationStatus
                    == Conversation.ConversationNotificationStatus.NOTIFY) {
                  //                    NToast.shortToast(context, "取消免打扰成功");
                }
              }

              @Override
              public void onError(RongIMClient.ErrorCode errorCode) {
                NToast.shortToast(context, "设置失败");
              }
            });
  }
  private void initData() {
    if (mConversationType.equals(Conversation.ConversationType.DISCUSSION)) {
      RongIM.getInstance()
          .getRongIMClient()
          .getDiscussion(
              mTargetId,
              new RongIMClient.ResultCallback<Discussion>() {
                @Override
                public void onSuccess(Discussion discussion) {
                  mIdList = discussion.getMemberIdList();
                  mAdapter.setCreatorId(discussion.getCreatorId());
                  Message msg = new Message();
                  msg.what = PREPARE_LIST;
                  msg.obj = mIdList;
                  getHandler().sendMessage(msg);
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {
                  getHandler().sendEmptyMessage(SHOW_TOAST);
                }
              });
    } else if (mConversationType.equals(Conversation.ConversationType.PRIVATE)) {
      mIdList.add(mTargetId);
      Message msg = new Message();
      msg.what = PREPARE_LIST;
      msg.obj = mIdList;
      getHandler().sendMessage(msg);
    }
  }
    @Override
    public View getViewForRow(View convertView, ViewGroup parent, int section, int row) {
      View view = null;
      if (section == 0) {
        if (AccountService.instance().isLogin()) {
          MineHeaderView headerView = MineHeaderView.create(getActivity());
          Account account = AccountService.instance().account();
          headerView.getAvartaIv().setImageUrl(account.getAvatar());
          headerView.getNameTv().setText(account.getNickName());
          headerView.getAgeTv().setText(account.getMobile());
          view = headerView;

        } else {
          view =
              LayoutInflater.from(getActivity())
                  .inflate(R.layout.layout_mine_header_not_login, null);
          view.findViewById(R.id.login_btn)
              .setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      Intent intent =
                          new Intent(Intent.ACTION_VIEW, Uri.parse("sgteacher://login"));
                      startActivity(intent);
                    }
                  });
        }

      } else {
        SimpleListItem simpleListItem = SimpleListItem.create(getActivity());
        simpleListItem.setShowArrow(true);
        if (section == 1) {
          if (row == 0) {
            simpleListItem.setTitle("成为助教");
            simpleListItem.setIcon(R.drawable.ic_mine_order);
          }
        } else if (section == 2) {
          if (row == 0) {
            simpleListItem.setTitle("系统消息");
            simpleListItem.setIcon(R.drawable.ic_mine_feedback);
            int unreadSys =
                RongIM.getInstance()
                    .getRongIMClient()
                    .getUnreadCount(Conversation.ConversationType.SYSTEM);
            if (unreadSys > 0) {
              simpleListItem.getDotView().setVisibility(View.VISIBLE);
            } else {
              simpleListItem.getDotView().setVisibility(View.GONE);
            }

          } else {
            simpleListItem.setTitle("关于我们");
            simpleListItem.setIcon(R.drawable.ic_mine_setting);
          }
        }
        view = simpleListItem;
      }
      return view;
    }
Пример #16
0
  private void conectionRongYun() {

    //        APIManager.getInstance(this).getRongyunToken(new Response.ErrorListener() {
    //            @Override
    //            public void onErrorResponse(VolleyError error) {
    //                hideProgressDialog();
    //                showException(error);
    //            }
    //        }, new Response.Listener<RequestResult<?>>() {
    //            @Override
    //            public void onResponse(RequestResult<?> response) {
    //                if (response.code==RequestResult.RESULT_SUCESS) {
    Log.e("TOKEN", "==" + mLoginUser.rongcloudToken);
    try {
      //
      // mLoginUser.rongcloudToken="FHGRf2wRDyokcR1o/HiLdM2yq+hfEluLjZ78E1qo4hGoJtlXfHETWOBzWjJmmabX2UDBRYDylpE0F1hw19xVFA==";
      RongIM.connect(
          mLoginUser.rongcloudToken,
          new RongIMClient.ConnectCallback() {

            @Override
            public void onSuccess(String s) {
              // 此处处理连接成功。
              Log.e("Connect:", "Login successfully." + s);
              //                    hideProgressDialog();
              SettingsManager.saveLoginUser(mLoginUser);
              SettingsManager.setPhone(mLoginUser.phone);
              SettingsManager.setRememberPwd(isSelect, mPasswordStr);
              goToMainActivity();
              new Thread() {
                @Override
                public void run() {
                  RongCloudProvidersListener.getInstance().setOtherListener();
                  //                            getFriends();

                }
              }.start();
            }

            @Override
            public void onError(ErrorCode errorCode) {
              hideProgressDialog();
              //                    ToastUtil.show(getMyApplication(), "融云服务器连接失败");
              //                                showException(error);
              // 此处处理连接错误。
              Log.e("Connect:", "Login failed.==" + errorCode);
              SettingsManager.saveLoginUser(mLoginUser);
              SettingsManager.setPhone(mLoginUser.phone);
              SettingsManager.setRememberPwd(isSelect, mPasswordStr);
              goToMainActivity();
            }
          });
    } catch (Exception e) {
      e.printStackTrace();
    }
    //                }
  }
  @Override
  protected void toggleSwitch(boolean toggle) {

    if (getConversationType() != null && !TextUtils.isEmpty(getTargetId())) {
      RongIM.getInstance()
          .getRongIMClient()
          .setConversationToTop(getConversationType(), getTargetId(), toggle, null);
    }
  }
  @Override
  protected void toggleSwitch(boolean toggle) {

    Conversation.ConversationNotificationStatus status;

    if (toggle) {
      status = Conversation.ConversationNotificationStatus.NOTIFY;
    } else {
      status = Conversation.ConversationNotificationStatus.DO_NOT_DISTURB;
    }

    if (getConversationType() != null
        && !TextUtils.isEmpty(getTargetId())
        && RongIM.getInstance() != null
        && RongIM.getInstance().getRongIMClient() != null) {

      RongIM.getInstance()
          .getRongIMClient()
          .setConversationNotificationStatus(
              getConversationType(),
              getTargetId(),
              status,
              new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {

                @Override
                public void onSuccess(Conversation.ConversationNotificationStatus status) {
                  RLog.i(this, "SetConversationNotificationFragment", "onSuccess--");
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {
                  setSwitchBtnStatus(!getSwitchBtnStatus());
                  // Toast.makeText(getActivity(),
                  // getString(R.string.rc_setting_conversation_notify_fail),
                  // Toast.LENGTH_SHORT).show();
                }
              });

    } else {
      RLog.e(this, "SetConversationNotificationFragment", "Arguments is null");
    }
  }
  @Override
  protected void initData() {
    mAddBlack.setOnClickListener(this);
    mRemoveBlack.setOnClickListener(this);
    if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) {
      if (userId.equals(LoginActivity.mUserID)) {
        mUserInfo.setVisibility(View.GONE);
      } else {
        RongIM.getInstance()
            .getBlacklistStatus(
                userId,
                new RongIM.GetUserBlacklistCallback() {

                  @Override
                  public void onError(ErrorCode errorCode) {
                    Log.e(
                        TAG,
                        "-------getBlacklistStatus onError---------:"
                            + errorCode.getMessage()
                            + ",:"
                            + errorCode.getValue());
                    mUserInfo.setText(errorCode + "");
                  }

                  @Override
                  public void onSuccess(RongIMClient.BlacklistStatus status) {
                    Log.e(TAG, "-------getBlacklistStatus onSuccess---------:" + status);
                    if (status == RongIMClient.BlacklistStatus.NOT_EXIT_BLACK_LIST) {
                      mUserInfo.setText(title);

                      mAddBlack.setVisibility(View.VISIBLE);
                    } else if (status == RongIMClient.BlacklistStatus.EXIT_BLACK_LIST) {
                      mUserInfo.setText(title + "已被加入黑名单,无法收到此用户消息");
                      mRemoveBlack.setVisibility(View.VISIBLE);
                    }
                  }
                });
      }
    } else {
      WinToast.toast(UserInfoActivity.this, R.string.network_not);
    }
  }
  private void refreshDot() {
    int unreadGroup =
        RongIM.getInstance()
            .getRongIMClient()
            .getUnreadCount(
                Conversation.ConversationType.PRIVATE, Conversation.ConversationType.GROUP);
    if (unreadGroup > 0) {
      groupDot.setVisibility(View.VISIBLE);
    } else {
      groupDot.setVisibility(View.GONE);
    }

    int unreadSys =
        RongIM.getInstance().getRongIMClient().getUnreadCount(Conversation.ConversationType.SYSTEM);
    if (unreadSys > 0) {
      mineDot.setVisibility(View.VISIBLE);
    } else {
      mineDot.setVisibility(View.GONE);
    }
  }
  /**
   * 收到push消息后做重连,重新连接融云
   *
   * @param token
   */
  private void reconnect(String token) {

    mDialog = new LoadingDialog(this);
    mDialog.setCancelable(false);
    mDialog.setText("正在连接中...");
    mDialog.show();

    try {
      RongIM.connect(
          token,
          new RongIMClient.ConnectCallback() {

            @Override
            public void onTokenIncorrect() {}

            @Override
            public void onSuccess(String userId) {
              mHandler.post(
                  new Runnable() {
                    @Override
                    public void run() {
                      mDialog.dismiss();
                      Intent intent = getIntent();
                      if (intent != null) {
                        enterFragment(intent);
                      }
                    }
                  });
            }

            @Override
            public void onError(RongIMClient.ErrorCode e) {
              mHandler.post(
                  new Runnable() {
                    @Override
                    public void run() {
                      mDialog.dismiss();
                    }
                  });
            }
          });
    } catch (Exception e) {
      mHandler.post(
          new Runnable() {
            @Override
            public void run() {
              mDialog.dismiss();
            }
          });
      e.printStackTrace();
    }
  }
Пример #22
0
  @Override
  public void onCreate() {
    super.onCreate();
    JPushInterface.setDebugMode(true);
    JPushInterface.init(this);
    RongIM.init(this, "pvxdm17jx5lmr", R.drawable.mineral_logo);
    if (SettingUtil.getInstance(getApplicationContext())
        .getValue(SettingUtil.KEY_ACCEPT_PUSH_NOTIFICATION, true)) {
      JPushInterface.resumePush(getApplicationContext());

    } else {
      JPushInterface.stopPush(getApplicationContext());
    }
  }
  @Override
  protected void initData() {

    if (RongContext.getInstance() != null) RongContext.getInstance().getEventBus().register(this);

    if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) {
      RongIM.getInstance()
          .getRongIMClient()
          .getConversation(
              getConversationType(),
              getTargetId(),
              new RongIMClient.ResultCallback<Conversation>() {

                @Override
                public void onSuccess(final Conversation conversation) {
                  if (conversation != null) setSwitchBtnStatus(conversation.isTop());
                }

                @Override
                public void onError(RongIMClient.ErrorCode e) {}
              });
    }
  }
  @Override
  public void onStatusChange(final RealTimeLocationConstant.RealTimeLocationStatus status) {
    Log.e(TAG, "onStatusChange:---" + status);
    currentLocationStatus = status;

    EventBus.getDefault().post(status);

    if (status
        == RealTimeLocationConstant.RealTimeLocationStatus.RC_REAL_TIME_LOCATION_STATUS_IDLE) {
      hideRealTimeBar();

      RealTimeLocationConstant.RealTimeLocationErrorCode errorCode =
          RongIMClient.getInstance().getRealTimeLocation(mConversationType, targetId);

      if (errorCode
          == RealTimeLocationConstant.RealTimeLocationErrorCode.RC_REAL_TIME_LOCATION_SUCCESS) {
        RongIM.getInstance()
            .getRongIMClient()
            .insertMessage(
                mConversationType,
                targetId,
                RongIM.getInstance().getRongIMClient().getCurrentUserId(),
                InformationNotificationMessage.obtain("位置共享已结束"));
      }
    } else if (status
        == RealTimeLocationConstant.RealTimeLocationStatus
            .RC_REAL_TIME_LOCATION_STATUS_OUTGOING) { // 发自定义消息
      showRealTimeLocationBar(status);
    } else if (status
        == RealTimeLocationConstant.RealTimeLocationStatus.RC_REAL_TIME_LOCATION_STATUS_INCOMING) {
      showRealTimeLocationBar(status);
    } else if (status
        == RealTimeLocationConstant.RealTimeLocationStatus.RC_REAL_TIME_LOCATION_STATUS_CONNECTED) {
      showRealTimeLocationBar(status);
    }
  }
Пример #25
0
  public static void setConversationTop(
      final Context context,
      Conversation.ConversationType conversationType,
      String targetId,
      boolean state) {
    if (!TextUtils.isEmpty(targetId) && RongIM.getInstance() != null) {
      RongIM.getInstance()
          .setConversationToTop(
              conversationType,
              targetId,
              state,
              new RongIMClient.ResultCallback<Boolean>() {
                @Override
                public void onSuccess(Boolean aBoolean) {
                  //                    NToast.shortToast(context, "设置成功");
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {
                  NToast.shortToast(context, "设置失败");
                }
              });
    }
  }
  private void getMyGroupApiSuccess(Object obj) {
    if (obj instanceof Groups) {
      final Groups groups = (Groups) obj;

      if (groups.getCode() == 200) {
        List<Group> grouplist = new ArrayList<>();
        if (groups.getResult() != null) {
          for (int i = 0; i < groups.getResult().size(); i++) {

            String id = groups.getResult().get(i).getId();
            String name = groups.getResult().get(i).getName();
            if (groups.getResult().get(i).getPortrait() != null) {
              Uri uri = Uri.parse(groups.getResult().get(i).getPortrait());
              grouplist.add(new Group(id, name, uri));
            } else {
              grouplist.add(new Group(id, name, null));
            }
          }
          HashMap<String, Group> groupM = new HashMap<String, Group>();
          for (int i = 0; i < grouplist.size(); i++) {
            groupM.put(groups.getResult().get(i).getId(), grouplist.get(i));
            Log.e("login", "------get Group id---------" + groups.getResult().get(i).getId());
          }

          if (DemoContext.getInstance() != null) DemoContext.getInstance().setGroupMap(groupM);

          if (grouplist.size() > 0)
            RongIM.getInstance()
                .getRongIMClient()
                .syncGroup(
                    grouplist,
                    new RongIMClient.OperationCallback() {
                      @Override
                      public void onSuccess() {
                        Log.e(TAG, "---syncGroup-onSuccess---");
                      }

                      @Override
                      public void onError(RongIMClient.ErrorCode errorCode) {
                        Log.e(TAG, "---syncGroup-onError---");
                      }
                    });
        }
      } else {
        //                    WinToast.toast(this, groups.getCode());
      }
    }
  }
  private void getMyGroupApiSuccess(Object obj) {
    if (obj instanceof Groups) {
      final Groups groups = (Groups) obj;

      if (groups.getCode() == 200) {
        List<Group> grouplist = new ArrayList<Group>();
        if (groups.getResult() != null) {
          for (int i = 0; i < groups.getResult().size(); i++) {

            String id = groups.getResult().get(i).getId();
            String name = groups.getResult().get(i).getName();
            if (groups.getResult().get(i).getPortrait() != null) {
              Uri uri = Uri.parse(groups.getResult().get(i).getPortrait());
              grouplist.add(new Group(id, name, uri));
            } else {
              grouplist.add(new Group(id, name, null));
            }
          }
          HashMap<String, Group> groupM = new HashMap<String, Group>();
          for (int i = 0; i < grouplist.size(); i++) {
            groupM.put(groups.getResult().get(i).getId(), grouplist.get(i));
          }
          if (DemoContext.getInstance() != null) DemoContext.getInstance().setGroupMap(groupM);

          Intent in = new Intent();
          in.setAction(MainActivity.ACTION_DMEO_GROUP_MESSAGE);
          sendBroadcast(in);

          if (grouplist.size() > 0)
            RongIM.getInstance()
                .getRongIMClient()
                .syncGroup(
                    grouplist,
                    new RongIMClient.OperationCallback() {
                      @Override
                      public void onSuccess() {
                        Log.e(TAG, "---syncGroup-onSuccess---");
                      }

                      @Override
                      public void onError(RongIMClient.ErrorCode errorCode) {
                        Log.e(TAG, "---syncGroup-onError---");
                      }
                    });
        }
      }
    }
  }
Пример #28
0
  @Override
  public void onCreate() {
    mAppApplication = this;
    super.onCreate();

    /**
     * OnCreate 会被多个进程重入,这段保护代码,确保只有您需要使用 RongIM 的进程和 Push 进程执行了 init。 io.rong.push 为融云 push
     * 进程名称,不可修改。
     */
    if (getApplicationInfo().packageName.equals(getCurProcessName(getApplicationContext()))
        || "io.rong.push".equals(getCurProcessName(getApplicationContext()))) {

      /** IMKit SDK调用第一步 初始化 */
      RongIM.init(this);
    }
  }
Пример #29
0
 private void startDoubleChatroom(Context context, String chatroomId1, String chatroomId2) {
   if (TextUtils.isEmpty(chatroomId1) && TextUtils.isEmpty(chatroomId2)) {
     NToast.shortToast(context, "chatroom ids is null");
     return;
   }
   if (RongIM.getInstance()
       .getCurrentConnectionStatus()
       .equals(RongIMClient.ConnectionStatusListener.ConnectionStatus.DISCONNECTED)) {
     NToast.shortToast(context, "please connection");
     return;
   }
   Intent intent = new Intent(context, DoubleChatRoomActivity.class);
   intent.putExtra("chatroomId1", chatroomId1);
   intent.putExtra("chatroomId2", chatroomId2);
   startActivity(intent);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_root);

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
    tabHost.addTab(
        tabHost
            .newTabSpec("manager")
            .setIndicator(createTabItem("课程管理", R.drawable.ic_tab_manager)),
        CourseManagerFragment.class,
        null);

    View groupTabItem = createTabItem("学生群组", R.drawable.ic_tab_group);
    groupDot = groupTabItem.findViewById(R.id.dot);
    tabHost.addTab(
        tabHost.newTabSpec("chatlist").setIndicator(groupTabItem), ChatListFragment.class, null);
    tabHost.addTab(
        tabHost
            .newTabSpec("material")
            .setIndicator(createTabItem("教材教具", R.drawable.ic_tab_material)),
        TeachMaterialFragment.class,
        null);

    View mineTabItem = createTabItem("我的", R.drawable.ic_tab_mine);
    mineDot = mineTabItem.findViewById(R.id.dot);
    tabHost.addTab(tabHost.newTabSpec("mine").setIndicator(mineTabItem), MineFragment.class, null);

    tabHost.setOnTabChangedListener(this);

    // Umeng
    MobclickAgent.updateOnlineConfig(this);
    UmengUpdateAgent.silentUpdate(this);

    // RongCloud
    doRCIMConnect(3);

    isFirstLogin = Boolean.valueOf(getIntent().getData().getQueryParameter("isFirstLogin"));
    if (isFirstLogin) {
      startActivity("sgteacher://applyteacher?fromLogin=true");
    }

    RongIM.setOnReceiveMessageListener(this);

    setSwipeBackEnable(false);
  }