示例#1
0
  /*
   * List of expressions in GDL 1. guide definition pre-conditions 2.
   * archetype binding predicates 3. rule when statements 4. rule then
   * statements
   */
  private void bindExpressions(Guide guide) throws Exception {
    List<String> preConditions = guide.getDefinition().getPreConditions();

    guide.getDefinition().setPreConditionExpressions(parseExpressions(preConditions));

    GuideDefinition definition = guide.getDefinition();
    if (definition.getArchetypeBindings() != null) {
      Collection<ArchetypeBinding> bindings = definition.getArchetypeBindings();
      for (ArchetypeBinding binding : bindings) {
        binding.setPredicateStatements(parseExpressions(binding.getPredicates()));
      }
      if (definition.getRules() != null) {
        Collection<Rule> rules = definition.getRules().values();
        for (Rule rule : rules) {
          rule.setWhenStatements(parseExpressions(rule.getWhen()));
          rule.setThenStatements(toAssignments(parseExpressions(rule.getThen())));
        }
      }
    }
  }
  public KeyguardViewHostManager(
      Context context,
      KeyguardViewHost host,
      SkylightHost skylight,
      LockPatternUtils lockPatternUtils,
      ViewMediatorCallback callback) {

    OtaUtils.checkRomOta(context);

    initVersionName(context);

    mContext = context;
    mKeyguardViewHost = host;
    mSkylightHost = skylight;
    mLockPatternUtils = lockPatternUtils;
    HKAgent.startStatisticThread(context.getApplicationContext());
    DataStatistics.getInstance().onInit(context.getApplicationContext());
    registerReceivers();
    sInstance = this;
    setViewMediatorCallback(callback);
    initKeyguard(callback);
    // GIONEE <Amigo_Keyguard> gexiufeng <2015-06-18> modify [1/2] begin: show haokan in power saver
    // mode.
    // Common.setPowerSaverMode(getPowerSaverMode() == 2);
    Common.setPowerSaverMode(false);
    // GIONEE <Amigo_Keyguard> gexiufeng <2015-06-18> modify [1/2] end: show haokan in power saver
    // mode.

    initHorizontalListView();
    mKeyguardWallpaperManager = new KeyguardWallpaperManager();
    mKeyguardWallpaperManager.setKeyguardListView(mKeyguardListView);
    mKeyguardWallpaperManager.setWallpaperContainer(mContainer);
    mKeyguardWallpaperManager.setViewMediatorCallback(callback);
    mKeyguardWallpaperManager.init(mContext);
    UIController.getInstance().setmViewMediatorCallback(callback);

    mKeyguardViewHost.setConfigChangeCallback(mConfigChangeCallback);
    isSuppotFinger = isSupportFingerPrint();
    if (isSuppotFinger) {
      mFingerIdentifyManager = new FingerIdentifyManager(context);
    }

    // GIONEE <Amigo_Keyguard> gexiufeng <2015-06-18> modify [2/2] begin: show haokan in power saver
    // mode.
    initPowerSaverObserver();
    // GIONEE <Amigo_Keyguard> gexiufeng <2015-06-18> modify [2/2] end: show haokan in power saver
    // mode.

    DebugLog.d(TAG, "isSuppotFinger....isSuppotFinger=" + isSuppotFinger);

    Guide.init(context);
    onBootCompleted();
  }
示例#3
0
  /** Guide parsing */
  public static Guide parseGuide(String json) throws JSONException {
    JSONObject jGuide = new JSONObject(json);
    JSONArray jSteps = jGuide.getJSONArray("steps");
    JSONArray jTools = jGuide.getJSONArray("tools");
    JSONArray jParts = jGuide.getJSONArray("parts");
    JSONObject jAuthor = jGuide.getJSONObject("author");
    Guide guide = new Guide(jGuide.getInt("guideid"));

    guide.setTitle(jGuide.getString("title"));
    guide.setTopic(jGuide.getString("category"));
    guide.setSubject(jGuide.getString("subject"));
    guide.setAuthor(jAuthor.getString("username"));
    guide.setTimeRequired(jGuide.getString("time_required"));
    guide.setDifficulty(jGuide.getString("difficulty"));
    guide.setIntroductionRaw(jGuide.getString("introduction_raw"));
    guide.setIntroductionRendered(jGuide.getString("introduction_rendered"));
    guide.setIntroImage(parseImage(jGuide, "image"));
    guide.setSummary(jGuide.isNull("summary") ? "" : jGuide.getString("summary"));
    guide.setRevisionid(jGuide.getInt("revisionid"));
    guide.setPublic(jGuide.getBoolean("public"));
    guide.setType(jGuide.getString("type"));
    guide.setPatrolThreshold(jGuide.getInt("patrol_threshold"));

    if (jGuide.has("can_edit")) {
      guide.setCanEdit(jGuide.getBoolean("can_edit"));
    }

    for (int i = 0; i < jSteps.length(); i++) {
      guide.addStep(parseStep(jSteps.getJSONObject(i), i + 1));
    }

    for (int i = 0; i < jTools.length(); i++) {
      guide.addTool(parseTool(jTools.getJSONObject(i)));
    }

    for (int i = 0; i < jParts.length(); i++) {
      guide.addPart(parsePart(jParts.getJSONObject(i)));
    }

    return guide;
  }