Glam Documentation: Usage Instructions
Glam Documentation: Usage Instructions
Glam documentation
Android Template App
Usage instructions:
On Eclipse:
Make sure that you have configured the Eclipse with Android ADT Plugin and also
installed JDK 7 and Android SDK with latest plateforms.
For detail you can visit at: http://developer.android.com/sdk/index.html
After Eclipse is fully setup, open the Eclipse, Go to Files menu then select Import->
Existing project into workspace -> Browse, then select for all the projects (Main
Template project and all the related Library files bundled in the Zip provided to
you) then click on Finish.
Sometime Eclipse may show errors about Library project missing, for that just
Right click on Project -> Properties -> Android-> Scroll down -> Remove all the lib
projects that has Red cross -> Click Apply then OK -> Reopen this window and Add
back those projects -> Click Apply then OK
All the Java bean classes are located in model package i.e. com.glam.model
You can put all the Utility classes in utils package i.e. com.glam.utils
Photoshop files:
The Photoshop files can be found in the PSD folder. They are layered - to use,
simply
open them up in your design tool of choice (i.e. Adobe Photoshop).
==========================================
Below you will find detailed source code documentation, that will help you in
using and making modifications to this template.
Do not hesitate to email at: [email protected] should you run into
any issues.
Contents
Class Checkout .......................................................................................................................................... 6
o
Class MainFragment................................................................................................................................ 25
o
Class Settings........................................................................................................................................... 32
Class SplashScreen................................................................................................................................ 33
com.glam.ui
Class Checkout
The Class Checkout is the fragment that shows the list products for checkout
and show the credit card details as well. You need to load and display actual
contents.
private
class
Field Detail
o
iList
Constructor Detail
o
Checkout
public Checkout()
Method Detail
o
onCreateView
o
o
Overrides:
onCreateView in class CustomFragment
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick in class CustomFragment
o
setupView
private void setupView(android.view.View v)
Setup the view components for this fragment. You write your code for
initializing the views, setting the adapters, touch and click listeners etc.
Parameters:
v
loadDummyData
private void loadDummyData()
Load dummy product data for displaying on the RecyclerView. You need
to write your own code for loading real products from Web-service or
API and displaying them on RecyclerView.
o
o
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater)
Overrides:
onCreateOptionsMenu
in class android.support.v4.app.Fragment
com.glam
Class CheckoutActivity
Constructor Detail
o
CheckoutActivity
public CheckoutActivity()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class CustomActivity
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam.custom
Class CustomActivity
Direct Known Subclasses:
CheckoutActivity, Home, Login, MainActivity, ProductDetail
This is a common activity that all other activities of the app can extend to
inherit the common behaviors like setting a Theme to activity.
Field Detail
o
TOUCH
public static final TouchEffect TOUCH
Apply this Constant as touch listener for views to provide alpha touch
effect. The view must have a Non-Transparent background.
Constructor Detail
o
CustomActivity
public CustomActivity()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class android.support.v7.app.ActionBarActivity
onOptionsItemSelected
Overrides:
onOptionsItemSelected
o
in class android.app.Activity
setupActionBar
protected void setupActionBar()
This method will setup the top title bar (Action bar) content and display
values. It will also setup the custom background theme for ActionBar.
You can override this method to change the behavior of ActionBar for
particular Activity
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
o
in interface android.view.View.OnClickListener
setTouchNClick
public android.view.View setTouchNClick(int id)
- the id of View
Returns:
the view
o
setClick
public android.view.View setClick(int id)
id
- the id of View
Returns:
the view
o
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam.custom
Class CustomFragment
Direct Known Subclasses:
Checkout, MainFragment, OnSale, Settings
The Class CustomFragment is the base Fragment class. You can extend your
Fragment classes with this class in case you want to apply common set of rules
for those Fragments.
Constructor Detail
o
CustomFragment
public CustomFragment()
Method Detail
o
o
o
onCreateView
public android.view.View onCreateView(android.view.LayoutInflater
inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
Overrides:
onCreateView
o
in class android.support.v4.app.Fragment
setTouchNClick
public android.view.View setTouchNClick(android.view.View v)
- the view
Returns:
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Class Data
The Class Data is simple Java bean class that holds two members only to
represent dummy data for app. You can customize or can write new bean
classes as per you needs.
Field Detail
o
texts
private java.lang.String[] texts
The texts.
o
resources
private int[] resources
The resources.
Constructor Detail
o
o
Data
public Data(java.lang.String[] texts,
int[] resources)
- the texts
resources
- the resources
Method Detail
o
getTexts
public java.lang.String[] getTexts()
setTexts
setResources
public void setResources(int[] resources)
com.glam
Class Home
The Activity Home is launched after the Splash screen. It simply show two
options for Login and Signup.
Constructor Detail
o
Home
public Home()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class CustomActivity
setupView
private void setupView()
Setup the click & other events listeners for the view components of this
screen. You can add your logic for Binding the data to TextViews and
other views as per your need.
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick
o
in class CustomActivity
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam.ui
Class LeftNavAdapter
The Adapter class for the ListView displayed in the left navigation drawer.
Field Detail
o
items
The items.
o
context
private android.content.Context context
The context.
o
selection
private int selection
The selection.
Constructor Detail
o
o
LeftNavAdapter
public LeftNavAdapter(android.content.Context context,
java.util.ArrayList<Data> items)
Parameters:
context
items
Method Detail
o
isSelection
public int isSelection()
Checks if is selection.
Returns:
the int
o
setSelection
public void setSelection(int selection)
getCount
public int getCount()
getItem
public Data getItem(int arg0)
getItemId
public long getItemId(int position)
o
o
o
getView
public android.view.View getView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
com.glam
Class Login
The Activity Login is launched after the Home screen. You need to write your
logic for actual Login. You also need to implement Facebook Login if required.
private
class
The Class PageAdapter is adapter class for ViewPager and it simply holds
a Single image view with dummy images.
Field Detail
o
pager
The pager.
o
vDots
Constructor Detail
o
Login
public Login()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class CustomActivity
setupView
private void setupView()
Setup the click & other events listeners for the view components of this
screen. You can add your logic for Binding the data to TextViews and
other views as per your need.
o
initPager
private void initPager()
setupDotbar
private void setupDotbar()
Setup the dotbar to show dots for pages of view pager with one dot as
selected to represent current page position.
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick
o
in class CustomActivity
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam
Class MainActivity
The Activity MainActivity will launched after the Login and it is the Home/Base
activity of the app which holds all the Fragments and also show the Sliding
Navigation drawer. You can write your code for displaying actual items on
Drawer layout.
Field Detail
o
drawerLayout
private android.support.v4.widget.DrawerLayout drawerLayout
drawerLeft
private android.widget.ListView drawerLeft
drawerToggle
private android.support.v7.app.ActionBarDrawerToggle drawerToggle
mActionBarAutoHideEnabled
private boolean mActionBarAutoHideEnabled
mActionBarShown
private boolean mActionBarShown
mStatusBarColorAnimator
private android.animation.ObjectAnimator mStatusBarColorAnimator
ARGB_EVALUATOR
private static final android.animation.TypeEvaluator
ARGB_EVALUATOR
mActionBarAutoHideSensivity
private int mActionBarAutoHideSensivity
mActionBarAutoHideMinY
private int mActionBarAutoHideMinY
mActionBarAutoHideSignal
private int mActionBarAutoHideSignal
toolbar
public android.support.v7.widget.Toolbar toolbar
The toolbar.
Constructor Detail
o
MainActivity
public MainActivity()
Method Detail
o
onCreate
protected void onCreate(android.os.Bundle savedInstanceState)
Overrides:
onCreate
o
in class CustomActivity
setupDrawer
private void setupDrawer()
Setup the drawer layout. This method also includes the method calls for
setting up the Left & Right side drawers.
o
o
onNavDrawerStateChanged
private void onNavDrawerStateChanged(boolean isOpen,
boolean isAnimating)
isAnimating
o
autoShowOrHideActionBar
onActionBarAutoShowOrHide
private void onActionBarAutoShowOrHide(boolean shown)
onMainContentScrolled
private void onMainContentScrolled(int currentY,
int deltaY)
Indicates that the main content has scrolled (for the purposes of
showing/hiding the action bar for the "action bar auto hide" effect).
currentY and deltaY may be exact (if the underlying view supports it) or
may be approximate indications: deltaY may be INT_MAX to mean
"scrolled forward indeterminately" and INT_MIN to mean "scrolled
backward indeterminately". currentY may be 0 to mean "somewhere
close to the start of the list" and INT_MAX to mean "we don't know, but
not at the start of the list"
Parameters:
currentY
deltaY
o
- the current y
- the delta y
initActionBarAutoHide
public void initActionBarAutoHide()
setupLeftNavDrawer
private void setupLeftNavDrawer()
Setup the left navigation drawer/slider. You can add your logic to load
the contents to be displayed on the left side drawer. It will also setup
the Header and Footer contents of left drawer. This method also apply
the Theme for components of Left drawer.
o
setupContainer
private void setupContainer(int pos)
Setup the container fragment for drawer layout. This method will setup
the grid view display of main contents. You can customize this method
as per your need to display specific content.
Parameters:
pos
onPostCreate
protected void onPostCreate(android.os.Bundle savedInstanceState)
Overrides:
onPostCreate
o
in class android.app.Activity
onConfigurationChanged
Specified by:
onConfigurationChanged
in interface android.content.ComponentCallbacks
Overrides:
onConfigurationChanged
o
in class android.support.v7.app.ActionBarActivity
onOptionsItemSelected
public boolean onOptionsItemSelected(android.view.MenuItem item)
Overrides:
onOptionsItemSelected
o
in class CustomActivity
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam.ui
Class MainFragment
The Class MainFragment is the base fragment that shows the list of various
products. You can add your code to do whatever you want related to products
for your app.
private
class
private
class
The Class PageAdapter is adapter class for ViewPager and it simply holds
a RecyclerView with dummy images.
Field Detail
o
iList
Constructor Detail
o
MainFragment
public MainFragment()
Method Detail
o
o
o
onCreateView
public android.view.View onCreateView(android.view.LayoutInflater
inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
Overrides:
onCreateView in class CustomFragment
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick in class CustomFragment
o
setupView
private void setupView(android.view.View v)
Setup the view components for this fragment. You write your code for
initializing the views, setting the adapters, touch and click listeners etc.
Parameters:
v
initPager
private void initPager(android.view.View v)
loadDummyData
private void loadDummyData()
Load dummy product data for displaying on the RecyclerView. You need
to write your own code for loading real products from Web-service or
API and displaying them on RecyclerView.
o
o
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater)
Overrides:
onCreateOptionsMenu
in class android.support.v4.app.Fragment
com.glam.ui
Class OnSale
The Class OnSale is the fragment that shows the products in GridView.
private
class
Field Detail
o
iList
private java.util.ArrayList<Data> iList
Constructor Detail
o
OnSale
public OnSale()
Method Detail
o
o
o
onCreateView
public android.view.View onCreateView(android.view.LayoutInflater
inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
Overrides:
onCreateView in class CustomFragment
o
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick in class CustomFragment
o
setupView
private void setupView(android.view.View v)
Setup the view components for this fragment. You write your code for
initializing the views, setting the adapters, touch and click listeners etc.
Parameters:
v
loadDummyData
private void loadDummyData()
Load dummy product data for displaying on the RecyclerView. You need
to write your own code for loading real products from Web-service or
API and displaying them on RecyclerView.
o
o
onCreateOptionsMenu
public void onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater)
Overrides:
onCreateOptionsMenu
in class android.support.v4.app.Fragment
com.glam
Class ProductDetail
The Activity ProductDetail is launched when user select a product item from product list or grid
views in other sections of the app. Currently it shows Dummy details of product with dummy
pics. You need to write your own code to load and display actual contents.
private
class
The Class PageAdapter is adapter class for ViewPager and it simply holds
a Single image view with dummy images.
Field Detail
o
pager
The pager.
o
vDots
private android.widget.LinearLayout vDots
Constructor Detail
o
ProductDetail
public ProductDetail()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class CustomActivity
setupView
private void setupView()
Setup the click & other events listeners for the view components of this
screen. You can add your logic for Binding the data to TextViews and
other views as per your need.
o
initPager
private void initPager()
setupDotbar
private void setupDotbar()
Setup the dotbar to show dots for pages of view pager with one dot as
selected to represent current page position.
o
onCreateOptionsMenu
Overrides:
onCreateOptionsMenu
o
in class android.app.Activity
onOptionsItemSelected
public boolean onOptionsItemSelected(android.view.MenuItem item)
Overrides:
onOptionsItemSelected
o
in class CustomActivity
getSupportFragmentManager
public android.support.v4.app.FragmentManager getSupportFragmentM
anager()
com.glam.ui
Class Settings
The Class Settings is the fragment that shows various settings options.
Constructor Detail
o
Settings
public Settings()
Method Detail
o
onCreateView
o
o
Overrides:
onCreateView
o
in class CustomFragment
onClick
public void onClick(android.view.View v)
Specified by:
onClick
in interface android.view.View.OnClickListener
Overrides:
onClick
in class CustomFragment
com.glam
Class SplashScreen
The Class SplashScreen will launched at the start of the application. It will be
displayed for 3 seconds and than finished automatically and it will also start the
next activity of app.
Field Detail
o
isRunning
Constructor Detail
o
SplashScreen
public SplashScreen()
Method Detail
o
onCreate
Overrides:
onCreate
o
in class android.app.Activity
startSplash
private void startSplash()
Starts the count down timer for 3-seconds. It simply sleeps the thread
for 3-seconds.
o
doFinish
private void doFinish()
If the app is still running than this method will start the Login activity
and finish the Splash.
o
o
onKeyDown
public boolean onKeyDown(int keyCode,
android.view.KeyEvent event)
Specified by:
onKeyDown
in interface android.view.KeyEvent.Callback
Overrides:
onKeyDown
in class android.app.Activity
com.glam.utils
Class TouchEffect
Constructor Detail
o
TouchEffect
public TouchEffect()
Method Detail
o
o
onTouch
Specified by:
onTouch
in interface android.view.View.OnTouchListener