コード例 #1
0
  protected void handleRegionDetected(String detectedRegion) {
    if (RegionUtil.getInstance().isLegalRegion(detectedRegion)) {
      RegionUtil.getInstance().setTargetRegion(detectedRegion);
    }

    postModelEvent(ICommonConstants.EVENT_MODEL_CHECK_REGION);
  }
コード例 #2
0
  protected void checkRegionChange() {
    final String region = RegionUtil.getInstance().getTargetRegion();
    if (RegionUtil.getInstance().isRegionSupported(region)
        && RegionUtil.getInstance().isNewRegion(region)) {
      RegionResSwitcher regionSwitcher =
          new RegionResSwitcher(
              new RegionResSwitcher.IRegionResSwitcherListener() {
                public void onRegionSwitched(String message, int resultType) {
                  if (resultType == RegionResSwitcher.SUCCESS_FROM_SERVER) {
                    RegionUtil.getInstance().setCurrentRegion(region);
                    RegionUtil.getInstance().clearTargetRegion(region);
                    postModelEvent(ICommonConstants.EVENT_MODEL_SWITCHING_SUCC_FROM_SERVER);
                  } else if (resultType == RegionResSwitcher.FAIL) {
                    postModelEvent(ICommonConstants.EVENT_MODEL_SWITCHING_FAIL);
                  }
                }
              });

      int resultType = regionSwitcher.switchRegion(region);
      if (resultType == RegionResSwitcher.SUCCESS_FROM_CACHE) {
        RegionUtil.getInstance().setCurrentRegion(region);
        RegionUtil.getInstance().clearTargetRegion(region);
        postModelEvent(ICommonConstants.EVENT_MODEL_CONTINUE);
      } else if (resultType == RegionResSwitcher.SUCCESS_FROM_SERVER) {
        postModelEvent(ICommonConstants.EVENT_MODEL_SWITCHING_REGION);
      }
    } else {
      RegionUtil.getInstance().clearTargetRegion(region);
      postModelEvent(ICommonConstants.EVENT_MODEL_CONTINUE);
    }
  }