dump ( )源码实例Demo

android.view.inputmethod.EditorInfo#dump ( )源码实例Demo

下面列出了android.view.inputmethod.EditorInfo#dump ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 365browser   文件: ImeUtils.java
/**
 * @param editorInfo The EditorInfo
 * @return Debug string for the given {@EditorInfo}.
 */
static String getEditorInfoDebugString(EditorInfo editorInfo) {
    StringBuilder builder = new StringBuilder();
    StringBuilderPrinter printer = new StringBuilderPrinter(builder);
    editorInfo.dump(printer, "");
    return builder.toString();
}
 
源代码2 项目: android-test   文件: HumanReadables.java
/**
 * Transforms an arbitrary view into a string with (hopefully) enough debug info.
 *
 * @param v nullable view
 * @return a string for human consumption.
 */
public static String describe(View v) {
  if (null == v) {
    return "null";
  }
  ToStringHelper helper = MoreObjects.toStringHelper(v).add("id", v.getId());
  if (v.getId() != -1 && v.getResources() != null && !isViewIdGenerated(v.getId())) {
    try {
      helper.add("res-name", v.getResources().getResourceEntryName(v.getId()));
    } catch (Resources.NotFoundException ignore) {
      // Do nothing.
    }
  }
  if (null != v.getContentDescription()) {
    helper.add("desc", v.getContentDescription());
  }

  switch (v.getVisibility()) {
    case View.GONE:
      helper.add("visibility", "GONE");
      break;
    case View.INVISIBLE:
      helper.add("visibility", "INVISIBLE");
      break;
    case View.VISIBLE:
      helper.add("visibility", "VISIBLE");
      break;
    default:
      helper.add("visibility", v.getVisibility());
  }

  helper
      .add("width", v.getWidth())
      .add("height", v.getHeight())
      .add("has-focus", v.hasFocus())
      .add("has-focusable", v.hasFocusable())
      .add("has-window-focus", v.hasWindowFocus())
      .add("is-clickable", v.isClickable())
      .add("is-enabled", v.isEnabled())
      .add("is-focused", v.isFocused())
      .add("is-focusable", v.isFocusable())
      .add("is-layout-requested", v.isLayoutRequested())
      .add("is-selected", v.isSelected())
      .add("layout-params", v.getLayoutParams())
      .add("tag", v.getTag());

  if (null != v.getRootView()) {
    // pretty much only true in unit-tests.
    helper.add("root-is-layout-requested", v.getRootView().isLayoutRequested());
  }

  EditorInfo ei = new EditorInfo();
  InputConnection ic = v.onCreateInputConnection(ei);
  boolean hasInputConnection = ic != null;
  helper.add("has-input-connection", hasInputConnection);
  if (hasInputConnection) {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    Printer p = new StringBuilderPrinter(sb);
    ei.dump(p, "");
    sb.append("]");
    helper.add("editor-info", sb.toString().replace("\n", " "));
  }

  if (Build.VERSION.SDK_INT > 10) {
    helper.add("x", v.getX()).add("y", v.getY());
  }

  if (v instanceof TextView) {
    innerDescribe((TextView) v, helper);
  }
  if (v instanceof Checkable) {
    innerDescribe((Checkable) v, helper);
  }
  if (v instanceof ViewGroup) {
    innerDescribe((ViewGroup) v, helper);
  }
  return helper.toString();
}