Skip to content

Instantly share code, notes, and snippets.

View ckdevrel's full-sized avatar

Chandrasekar Kuppusamy ckdevrel

View GitHub Profile
<global id="srcOut" value="${srcDir}/${slashedPackageName(packageName)}" />
<global id="srcOutPackage" value="${srcDir}" />
<global id="resOut" value="${resDir}" />
<parameter
id=”isFragment”
name=”Need Fragment code instead of Activitiy?”
type=”boolean”
default=”false”
help=”If true, the fragment code will be created instead of Activity”/>
<parameter
id=”isFragment”
name=”Need Fragment code instead of Activitiy?”
type=”boolean”
default=”false”
help=”If true, the fragment code will be created instead of Activity”/>
<parameter
id="activityClass"
name="Activity Name"
type="string" constraints="class|unique|nonempty"
visibility="!isFragment" //This view will be shown only if fragment checkbox is false
suggest="${layoutToActivity(layoutActivityName)}"
default="RecyclerViewActivity"
help="The name of the activity class to create"/>
<parameter
id="className"
name="Fragment Class Name"
type="string"
constraints="class|unique|nonempty"
visibility="isFragment" //This view will be shown only if fragment checkbox is true
default="RecyclerViewFragment"
help="The name of the fragment class to create"/>
<#if isFragment>
<instantiate from="src/app_package/RecyclerFragment.java.ftl"
to="${escapeXmlAttribute(srcOut)}/${className}.java" />
<instantiate from="res/layout/fragment_recycler_view.xml.ftl"
to="${escapeXmlAttribute(resOut)}/layout/${fragmentName}.xml" />
<#else>
<instantiate from="src/app_package/RecyclerActivity.java.ftl"
to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" />
<#if features == 'banner'>
<#include "YOUR_LAYOUT_FOR_BANNER_RECYCLERVIEW.xml.ftl"/>
<#elseif features == 'section'>
<#include "YOUR_LAYOUT_FOR_SECTION_RECYCLERVIEW.xml.ftl"/>
<#else>
<#include "YOUR_DEFAULT_LAYOUT_TO_REMAINING_RECYCLERVIEW_STYLES.xml.ftl"/></#if>
<#if layoutmanager == 'grid'>
GridLayoutManager layoutManager = new GridLayoutManager(${activityClass}.this, 2);
recyclerView.addItemDecoration(new GridMarginDecoration(${activityClass}.this, 2, 2, 2, 2));
<#else>
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
</#if>
recyclerView.setLayoutManager(layoutManager);

Simple RecyclerView (List & Grid)

VERTICAL:

HORIZONTAL:

@ckdevrel
ckdevrel / index.js
Last active October 31, 2017 17:59
import React from 'react';
import { Text, AppRegistry } from 'react-native';
const App = () => (
<Text>Hello Component!</Text>
);
AppRegistry.registerComponent('ComponentDemo', () => App);