PagedHeadListView

Additional

Language
Java
Version
N/A
Created
Aug 14, 2014
Updated
Nov 13, 2014 (Retired)
Owner
Jorge Castillo (JorgeCastilloPrz)
Contributor
Jorge Castillo (JorgeCastilloPrz)
1
Activity
Badge
Generate
Download
Source code

Blurb

Usage

In order to make it work, you will need to use PagedHeadListView class into your Android code. Please, don't forget to add the aditional xmlns:pagedheadlistview="http://schemas.android.com/apk/res-auto" namespace to it.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:pagedheadlistview="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.jorgecastilloprz.pagedheadlistview.PagedHeadListView
        android:id="@+id/pagedHeadListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        pagedheadlistview:headerHeight="@dimen/header_height"
        pagedheadlistview:indicatorType="bottomAligned"
        pagedheadlistview:disableVerticalTouchOnHeader="true"
        pagedheadlistview:indicatorBgColor="@color/material_green"
        pagedheadlistview:indicatorColor="@color/material_light_green" />

</RelativeLayout>

In your java code, use PagedHeadListView like this:

mPagedHeadList = (PagedHeadListView) rootView.findViewById(R.id.pagedHeadListView);

mPagedHeadList.addFragmentToHeader(new FirstHeaderFragment());
mPagedHeadList.addFragmentToHeader(new SecondHeaderFragment());
mPagedHeadList.addFragmentToHeader(new ThirdHeaderFragment());
mPagedHeadList.addFragmentToHeader(new FourthHeaderFragment());
mPagedHeadList.addFragmentToHeader(new FifthHeaderFragment());

mPagedHeadList.setHeaderOffScreenPageLimit(4);
mPagedHeadList.setHeaderPageTransformer(PageTransformerTypes.FLIP);

ArrayList<String> mockItemList = new ArrayList<String>();

for (int i = 0; i < 50; i++)
    mockItemList.add(getResources().getString(R.string.mock_item) + " " + (i+1));

MockListAdapter mockListAdapter = new MockListAdapter(getActivity(), R.layout.mock_list_item, mockItemList);
mPagedHeadList.setAdapter(mockListAdapter);

For being able to listen to header page change events, use setOnHeaderPageChangeListener which needs a ViewPager.OnPageChangeListener item as an argument.

Following methods are avaiable to setup the pager programatically:

//Types vaiable: DEPTH, ZOOMOUT, ROTATE, SCALE, FLIP, ACCORDION.
mPagedHeadListView.setHeaderPageTransformer(PageTransformerTypes pageTransformerType);

//This is a mapping for normal setPageTransformer from Android support ViewPager.
mPagedHeadListView.setHeaderPageTransformer(boolean reverseDrawingOrder, ViewPager.PageTransformer customPageTransformer);

//Dynamic mode to set header's view height. (Always in pixels)
mPagedHeadListView.setHeaderHeight(500);
mPagedHeadListView.setHeaderHeight(getResources().getDimensionPixelSize(R.dimen.header_height_test));

//For the user to be able to listen for header ViewPager events.
mPagedHeadListView.setOnHeaderPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener);

mPagedHeadListView.setHeaderOffScreenPageLimit(int offScreenPageLimit);

mPagedHeadListView.setIndicatorBgColor(int indicatorBgColor);
mPagedHeadListView.setIndicatorColor(int indicatorColor);

//If you want to disable vertical touch on header programatically.
mPagedHeadListView.disableVerticalTouchOnHeader();

mPagedHeadList.setIndicatorBgColor(getResources().getColor(R.color.material_green));
mPagedHeadList.setIndicatorColor(getResources().getColor(R.color.material_light_green));

Import PagedHeadListView dependency

Add the next code to your build.gradle project dependencies:

dependencies {
    compile 'com.github.jorgecastilloprz:pagedheadlistview:1.0.0@aar'
}

Set the mavenCentral repo into the external build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

If you are using Maven, use the following code:

<dependency>
  <groupId>com.github.jorgecastilloprz</groupId>
  <artifactId>pagedheadlistview</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

TODO - AT WORK

  • Give the users the possibility to extend AbstractPagedHeadIndicator class to develop their own indicators. A new setter will be added for it when i get sure that it is fully supported.

Developer

License

Copyright 2014 Jorge Castillo Pérez

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.