Пример #1
0
  private boolean commitValue() throws ElementFailureException {
    try {
      Utils.runCommand(command + " \"" + lastEdit.toString() + '"');
      String result = getLiveValue();

      if (!result.equals(getStoredValue())) Utils.db.setValue(command, result);

      try {
        stored = Integer.parseInt(result);
      } catch (NumberFormatException ignored) {
        stored = result;
      }

      lastLive = lastEdit = stored;
      textView.setText(lastLive.toString());
      if (editText != null && editText.getParent() != null)
        if (((LinearLayout) editText.getParent()).findViewById(tv_id) == textView)
          editText.setText(lastLive.toString());
      valueCheck();

      return true;
    } catch (Exception e) {
      throw new ElementFailureException(this, e);
    }
  }
Пример #2
0
 /** ActionValueClient methods */
 @Override
 public String getLiveValue() throws ElementFailureException {
   try {
     String value = Utils.runCommand(command);
     try {
       lastLive = Integer.parseInt(value);
     } catch (NumberFormatException ignored) {
       lastLive = value;
     }
     return value;
   } catch (Exception e) {
     throw new ElementFailureException(this, e);
   }
 }
Пример #3
0
  @Override
  public View getView() throws ElementFailureException {
    if (elementView != null) return elementView;

    LinearLayout v =
        (LinearLayout)
            LayoutInflater.from(Utils.mainActivity)
                .inflate(R.layout.template_livelabel, this.layout, false);

    assert v != null;
    elementView = v;

    /** Nesting another element's view in our own for title and description. */
    LinearLayout descriptionFrame = (LinearLayout) v.findViewById(R.id.SLiveLabel_descriptionFrame);

    if (titleObj != null) {
      TextView titleView = (TextView) titleObj.getView();
      titleView.setBackground(null);
      descriptionFrame.addView(titleView);
    }

    if (descriptionObj != null) descriptionFrame.addView(descriptionObj.getView());

    liveLabel = (TextView) v.findViewById(R.id.SLiveLabel_textView);

    if (style != null) {
      if (style.contains("bold") && style.contains("italic")) {
        liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD_ITALIC);
        return v;
      }

      if (style.contains("bold")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD);

      if (style.contains("italic")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.ITALIC);
    }

    try {
      liveLabel.setText(Utils.runCommand(command).replace("@n", "\n"));
    } catch (Exception e) {
      throw new ElementFailureException(this, e);
    }

    return v;
  }