@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop String title, @Prop RecyclerBinder recyclerBinder) { return Column.create(c) .child( Text.create(c) .text(title) .glyphWarming(true) .textSizeSp(16) .withLayout() .paddingDip(TOP, 8) .paddingDip(BOTTOM, 4) .heightDip(44) ) .paddingDip(LEFT, 8) .paddingDip(RIGHT, 8) .child( Recycler.create(c) .hasFixedSize(true) .binder(recyclerBinder) ) .build(); }
public static void initialize(Context context) { final ComponentContext c = new ComponentContext(context); final RecyclerBinder glideRecyclerBinder = new RecyclerBinder( c, 4.0f, new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)); DataModel.populateBinderWithSampleDataForGlide(glideRecyclerBinder, c); demoModels = new LinkedHashMap<>(); demoModels.put( "Lithography - Picasso", LithographyRootComponent.create(c) .recyclerBinder(glideRecyclerBinder) .build()); demoModels.put("Playground", PlaygroundComponent.create(c).build()); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_repos); bindViews(this); componentContext = new ComponentContext(this); recyclerBinder = new RecyclerBinder( componentContext, 4.0f, new LinearLayoutInfo(this, OrientationHelper.VERTICAL, false)); sRefresh.setOnRefreshListener(() -> store.dispatch(HomeAction.REFRESH)); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop RecyclerBinder binder) { return Recycler.create(c) .binder(binder) .withLayout().flexShrink(0) .testKey(MAIN_SCREEN) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final ArtistDatum artist, @Prop final RecyclerBinder binder) { return Column.create(c) .child(Column.create(c) .child(artist.getImages().length == 1 ? getImageComponent(c, artist) : getRecyclerComponent(c, binder)) .child(TitleComponent.create(c).title(artist.getName())) .child(ActionsComponent.create(c))) .child(FooterComponent.create(c).text(artist.getBiography())) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final ArtistDatum artist, @Prop final RecyclerBinder binder) { return Column.create(c) .flexShrink(0) .alignContent(YogaAlign.FLEX_START) .paddingDip(VERTICAL, 8) .paddingDip(HORIZONTAL, 16) .child(Card.create(c) .content(FeedItemComponent.create(c).artist(artist).binder(binder))) .build(); }
public static void populateBinderWithSampleDataForGlide(RecyclerBinder recyclerBinder, ComponentContext c) { final Datum[] dataModels = SampleDataForGlide(); for (Datum datum : dataModels) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(datum.createComponent(c)).isSticky(datum instanceof Decade); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
@Override public Component createComponent(ComponentContext c) { final RecyclerBinder imageRecyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.HORIZONTAL, false)).build(c); for (String image : images) { ComponentRenderInfo.Builder imageComponentInfoBuilder = ComponentRenderInfo.create(); imageComponentInfoBuilder.component( GlideSingleImageComponent.create(c).image(image).aspectRatio(2).build()); imageRecyclerBinder.insertItemAt(imageRecyclerBinder.getItemCount(), imageComponentInfoBuilder.build()); } return FeedItemCard.create(c).artist(this).binder(imageRecyclerBinder).build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c, @Prop final RecyclerBinder recyclerBinder) { return Recycler.create(c) .binder(recyclerBinder) .flexShrink(0) .paddingDip(YogaEdge.TOP, 8) .testKey(MAIN_SCREEN) .buildWithLayout(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c) { final RecyclerBinder recyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)).build(c); Demos.addAllToBinder(recyclerBinder, c); return Recycler.create(c) .binder(recyclerBinder) .flexShrink(0) .testKey(MAIN_SCREEN) .buildWithLayout(); }
public static void initialize(Context context) { final ComponentContext c = new ComponentContext(context); final RecyclerBinder glideRecyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)).build(c); DataModel.populateBinderWithSampleDataForGlide(glideRecyclerBinder, c); demoModels = new LinkedHashMap<>(); demoModels.put("Lithography - Glide", LithographyRootComponent.create(c).recyclerBinder(glideRecyclerBinder).build()); demoModels.put("Playground", PlaygroundComponent.create(c).build()); }
public static void addAllToBinder(RecyclerBinder recyclerBinder, ComponentContext c) { for (String name : demoModels.keySet()) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(DemoListItemComponent.create(c).name(name).build()); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
public static void populateBinderWithSampleDataForGlide( RecyclerBinder recyclerBinder, ComponentContext c) { final Datum[] dataModels = SampleDataForGlide(); for (Datum datum : dataModels) { ComponentInfo.Builder componentInfoBuilder = ComponentInfo.create(); componentInfoBuilder .component(datum.createComponent(c)) .isSticky(datum instanceof Decade); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
@Override public Component createComponent(ComponentContext c) { final RecyclerBinder imageRecyclerBinder = new RecyclerBinder(c, 4.0f, new LinearLayoutInfo(c, OrientationHelper.HORIZONTAL, false)); for (String image : images) { ComponentInfo.Builder imageComponentInfoBuilder = ComponentInfo.create(); imageComponentInfoBuilder.component( PicassoSingleImageComponent.create(c).image(image).fit(true).build()); imageRecyclerBinder.insertItemAt(imageRecyclerBinder.getItemCount(), imageComponentInfoBuilder.build()); } return FeedItemCard.create(c).artist(this).binder(imageRecyclerBinder).build(); }
@OnCreateLayout static ComponentLayout onCreateLayout( ComponentContext c, @Prop final RecyclerBinder recyclerBinder) { return Recycler.create(c) .binder(recyclerBinder) .withLayout().flexShrink(0) .paddingDip(YogaEdge.TOP, 8) .testKey(MAIN_SCREEN) .build(); }
@OnCreateLayout static ComponentLayout onCreateLayout(ComponentContext c) { final RecyclerBinder recyclerBinder = new RecyclerBinder( c, 4.0f, new LinearLayoutInfo(c, OrientationHelper.VERTICAL, false)); Demos.addAllToBinder(recyclerBinder, c); return Recycler.create(c) .binder(recyclerBinder) .withLayout().flexShrink(0) .testKey(MAIN_SCREEN) .build(); }
public static void addAllToBinder(RecyclerBinder recyclerBinder, ComponentContext c) { for (String name : demoModels.keySet()) { ComponentInfo.Builder componentInfoBuilder = ComponentInfo.create(); componentInfoBuilder.component( DemoListItemComponent.create(c) .name(name) .build()); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
private void renderContent(List<HomeSection> sections) { sRefresh.setRefreshing(false); ComponentInfo.Builder componentInfoBuilder; for (HomeSection section : sections) { componentInfoBuilder = ComponentInfo.create(); if (section instanceof SingleBannerSection) { componentInfoBuilder .component( SingleBannerComponent .create(componentContext) .payload((SingleBannerSection) section) .key(((SingleBannerSection) section).title()) .build() ); } else if (section instanceof TripleBannerSection) { componentInfoBuilder .component( TripleBannersComponent.create(componentContext) .payload((TripleBannerSection) section) .key(((TripleBannerSection) section).title()) .build() ); } else if (section instanceof ProductSlideSection) { final RecyclerBinder productSlideBinder = new RecyclerBinder(componentContext, 4.0f, new LinearLayoutInfo(this, OrientationHelper.HORIZONTAL, false)); for (Product product : ((ProductSlideSection) section).products()) { componentInfoBuilder = ComponentInfo.create(); componentInfoBuilder .component( ProductComponent.create(componentContext) .product(product) .key(product.id()) .build() ); productSlideBinder.insertItemAt(productSlideBinder.getItemCount(), componentInfoBuilder.build()); } componentInfoBuilder = ComponentInfo.create(); componentInfoBuilder .component( ProductSlideComponent.create(componentContext) .title(((ProductSlideSection) section).title()) .recyclerBinder(productSlideBinder) .key(((ProductSlideSection) section).title()) .build() ); } recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } ltView.setComponent( HomeListComponent .create(componentContext) .binder(recyclerBinder) .build() ); }
private static ComponentLayout.Builder getRecyclerComponent(ComponentContext c, RecyclerBinder binder) { return Recycler.create(c).binder(binder).withLayout().flexShrink(0).aspectRatio(2); }