private UiEventHandlerLoader() {
    ClassFilter filter = new UiEventHandlerClassFilter();

    List<Class> scanPackage =
        ClassScanUtil.scanPackage(
            AspirecnCorpSocial.getContext(),
            PropertyInfo.getInstance().getString("eventBusScanPath"),
            filter);

    for (Class<IHandler<?, ?>> clazz : scanPackage) {
      if (filter.accept(clazz)) {
        Annotation annotation = clazz.getAnnotation(UIEventHandler.class);

        Class<? extends BusEvent> eventType = ((UIEventHandler) annotation).eventType();

        IHandler<?, ?> newInstance = null;
        try {
          newInstance = clazz.newInstance();
          BeanContainer.getInstance().fetchBean(newInstance);
        } catch (InstantiationException e) {
          LogUtil.e("实例化UI处理类异常", e);
        } catch (IllegalAccessException e) {
          LogUtil.e("实例化UI处理类异常", e);
        } catch (Exception e) {
          e.printStackTrace();
        }
        uiEventHandlerMap.put(eventType, newInstance);
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public Null handle(final LoginEvent loginEvent) {
    // 切换为当前登陆用户的配置文件
    ConfigPersonal.getInstance().init(loginEvent.getUsername());
    GotyeAPI apiist = GotyeAPI.getInstance();
    apiist.addListener(delegate);
    Intent login = new Intent(AspirecnCorpSocial.getContext(), GotyeService.class);
    login.setAction(GotyeService.ACTION_LOGIN);
    login.putExtra("name", loginEvent.getUsername());
    AspirecnCorpSocial.getContext().startService(login);
    //        LoginData loginData = new LoginData();
    //        loginData.setUsername(loginEvent.getUsername());
    //        loginData.setPasswd(loginEvent.getPassword());
    //
    //        if (!imNetClient.checkLogined()) {
    //            // 缓存1秒,等待系统进入主界面再抛出事件
    //
    //            SystemClock.sleep(1000);
    //
    //            notifyImModuleLoginStart();
    //
    //            imNetClient.login(loginData, new ILoginNotify() {
    //                @Override
    //                public void notify(LoginResultData arg0) {
    //
    //                    LoginRespEvent loginRespEvent = new LoginRespEvent();
    //                    int errorCode = arg0.getErrorCode();
    //
    //                    if (ErrorCode.SUCCESS.getValue() == errorCode) {
    //                        handleLoginSuccess(arg0.getLoginResp(), loginEvent);
    //                    }
    //
    //                    loginRespEvent.setRespCode(errorCode);
    //                    loginRespEvent.setMessage(arg0.getMessage());
    //                    eventListener.notifyListener(loginRespEvent);
    //                    notifyImModuleLoginResp(errorCode, arg0.getMessage());
    //
    //                }
    //            });
    //        } else {
    //            // 每次重新登陆时执行
    ////			String userId = Config.getInstance().getUserId();
    ////			ConfigPersonal.getInstance().init(userId);
    ////			getNotificationConfig();
    //            // 清理"协同办公"、"新闻中心"的过期数据
    //
    ////            UserServiceParam userServiceParam = new UserServiceParam();
    ////            userServiceParam.setServie("FindCorpService");
    ////            UserServiceResult result = (UserServiceResult)
    // OsgiServiceLoader.getInstance().getService(UserService.class).invoke(userServiceParam);
    ////            List<UserCorp> userCorps = (List<UserCorp>) result.getData();
    //            List<UserCorp> userCorps = (List<UserCorp>)
    // OsgiServiceLoader.getInstance().getService(FindCorpService.class).invoke(new Null());
    //
    //            for (UserCorp uc : userCorps) {
    //                notifyProcessModuleClearOutDatedData(uc.getCorpId());
    //                notifyNewsCenterModuleClearOutDatedData(uc.getCorpId());
    //            }
    //
    //            //通知公众号模块登录完成
    //            notifyPubAccountLoginFinish();
    //        }

    //        //通知公众号模块登录完成
    //        notifyPubAccountLoginFinish();

    //        notifyAppDefModuleChange();

    return new Null();
  }