Java 类com.facebook.litho.LithoView 实例源码

项目:screenshot-tests-for-android    文件:LithoHierarchyPlugin.java   
@Override
public void putHierarchy(LayoutHierarchyDumper dumper, JSONObject root, Object obj, Point offset)
    throws JSONException {
  if (!accept(obj)) {
    return;
  }

  if (obj instanceof LithoView) {
    LithoView lithoView = (LithoView) obj;
    DebugComponent debugComponent = DebugComponent.getRootInstance(lithoView);
    if (debugComponent == null) {
      return;
    }
    final int offsetLeft = LayoutHierarchyDumper.getViewLeft(lithoView);
    final int offsetTop = LayoutHierarchyDumper.getViewTop(lithoView);
    offset.offset(offsetLeft, offsetTop);
    dumpHierarchy(dumper, root, debugComponent, offset);
    offset.offset(-offsetLeft, -offsetTop);
  } else {
    dumpHierarchy(dumper, root, (DebugComponent) obj, offset);
  }
}
项目:screenshot-tests-for-android    文件:LithoAttributePlugin.java   
@Override
public void putAttributes(JSONObject node, Object obj, Point offset) throws JSONException {
  final DebugComponent debugComponent;
  if (obj instanceof LithoView) {
    ((LithoView) obj).rebind();
    debugComponent = DebugComponent.getRootInstance((LithoView) obj);
    if (debugComponent == null) {
      return;
    }
  } else {
    debugComponent = (DebugComponent) obj;

    // Since we're dealing with a pure component, we cant rely on the default required
    // attributes to be added, so we add them here
    Rect bounds = debugComponent.getBoundsInLithoView();
    putRequired(
        node,
        debugComponent.getComponent().getClass().getName(),
        offset.x + bounds.left,
        offset.y + bounds.top,
        bounds.width(),
        bounds.height());
  }
}
项目:litho-glide    文件:DemoActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Demos.initialize(this);

  final String demoName = (String) getIntent().getSerializableExtra("demoName");

  setContentView(
      LithoView.create(
          this,
          Demos.getComponent(demoName)));
}
项目:litho-glide    文件:DemoListActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  Demos.initialize(this);

  setContentView(
      LithoView.create(
          this,
          DemoListComponent.create(new ComponentContext(this))
              .build()));
}
项目:litho-picasso    文件:DemoActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Demos.initialize(this);

  final String demoName = (String) getIntent().getSerializableExtra("demoName");

  setContentView(
      LithoView.create(
          this,
          Demos.getComponent(demoName)));
}
项目:litho-picasso    文件:DemoListActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  Demos.initialize(this);

  setContentView(
      LithoView.create(
          this,
          DemoListComponent.create(new ComponentContext(this))
              .build()));
}
项目:WideEyes    文件:SplashActivity.java   
@Override
public void initData() {
    final ComponentContext c = new ComponentContext(this);

    final LithoView lithoView = LithoView.create(
            this /* context */,
            Text.create(c)
                    .text("Hello, World!")
                    .textSizeDip(50)
                    .build());

    setContentView(lithoView);

}
项目:screenshot-tests-for-android    文件:ExampleScreenshotTest.java   
@Test
public void testDefault() {
  Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
  LayoutInflater inflater = LayoutInflater.from(targetContext);
  LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);

  view.setComponent(Example.create(view.getComponentContext()).build());

  ViewHelpers.setupView(view).setExactWidthDp(300).layout();
  Screenshot.snap(view).record();
}
项目:screenshot-tests-for-android    文件:ImageRowScreenshotTest.java   
@Test
public void testDefault() {
  Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
  LayoutInflater inflater = LayoutInflater.from(targetContext);
  LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);

  view.setComponent(ImageRow.create(view.getComponentContext()).build());

  ViewHelpers.setupView(view).setExactWidthDp(300).layout();
  Screenshot.snap(view).record();
}
项目:screenshot-tests-for-android    文件:LithoHierarchyPlugin.java   
@Override
public boolean accept(Object obj) {
  return obj instanceof LithoView || obj instanceof DebugComponent;
}
项目:screenshot-tests-for-android    文件:LithoAttributePlugin.java   
@Override
public boolean accept(Object obj) {
  return obj instanceof LithoView || obj instanceof DebugComponent;
}
项目:screenshot-tests-for-android    文件:LithoHierarchyPluginTest.java   
@Test
public void testAcceptsLithoView() throws Exception {
  LithoView lithoView = new LithoView(InstrumentationRegistry.getTargetContext());
  assertEquals(true, LithoHierarchyPlugin.getInstance().accept(lithoView));
}
项目:screenshot-tests-for-android    文件:LithoAttributePluginTest.java   
@Test
public void testAcceptsLithoView() throws Exception {
  LithoView lithoView = new LithoView(InstrumentationRegistry.getTargetContext());
  assertEquals(true, LithoAttributePlugin.getInstance().accept(lithoView));
}