Android Open Source - StikkyHeader Stikky Header Builder






From Project

Back to project page StikkyHeader.

License

The source code is released under:

Apache License

If you think the Android project StikkyHeader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.carlom.stikkyheader.core;
/*  w w  w.j ava 2 s.  c  om*/

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListView;

import it.carlom.stikkyheader.core.animator.HeaderStikkyAnimator;

public class StikkyHeaderBuilder {

    private final Context mContext;
    private final ListView mListView;

    private View mHeader;
    private int mMinHeight = 0;
    private HeaderAnimator mAnimator;

    private StikkyHeaderBuilder(final ListView listView) {
        mListView = listView;
        mContext = listView.getContext();
        mMinHeight = 0;
    }

    public static StikkyHeaderBuilder stickTo(final ListView listView) {
        return new StikkyHeaderBuilder(listView);
    }

    public StikkyHeaderBuilder addHeader(final View header, final FrameLayout containerListView) {

        mHeader = header;
        containerListView.addView(header);

        return this;
    }

    public StikkyHeaderBuilder addHeader(final int resLayout, final FrameLayout containerListView) {

        mHeader = LayoutInflater.from(mContext).inflate(resLayout, containerListView, false);
        containerListView.addView(mHeader);

        return this;
    }

    public StikkyHeaderBuilder setHeader(final View header) {

        mHeader = header;

        return this;
    }

    public StikkyHeaderBuilder minHeightHeaderRes(final int resDimension) {
        mMinHeight = mContext.getResources().getDimensionPixelSize(resDimension);
        return this;
    }

    public StikkyHeaderBuilder minHeightHeaderPixel(final int minHeight) {
        mMinHeight = minHeight;
        return this;
    }

    public StikkyHeaderBuilder animator(final HeaderAnimator animator) {
        mAnimator = animator;
        return this;
    }

    public StikkyHeader build() {

        //if the animator has not been set, the default one is used
        if (mAnimator == null) {
            mAnimator = new HeaderStikkyAnimator();
        }

        return new StikkyHeader(mContext, mListView, mHeader, mMinHeight, mAnimator);
    }

}




Java Source Code List

it.carlom.stickyheader.example.MainActivity.java
it.carlom.stickyheader.example.animator.IO2014HeaderAnimator.java
it.carlom.stickyheader.example.animator.IconActionBarAnimator.java
it.carlom.stickyheader.example.fragment.ActionBarImageFragment.java
it.carlom.stickyheader.example.fragment.FadeOutInterpolatedFragment.java
it.carlom.stickyheader.example.fragment.IO2014HeaderFragment.java
it.carlom.stickyheader.example.fragment.MainFragment.java
it.carlom.stickyheader.example.fragment.ParallaxStikkyFragment.java
it.carlom.stickyheader.example.fragment.SimpleStikkyFragment.java
it.carlom.stikkyheader.core.HeaderAnimator.java
it.carlom.stikkyheader.core.StikkyHeaderBuilder.java
it.carlom.stikkyheader.core.StikkyHeader.java
it.carlom.stikkyheader.core.animator.AnimatorBuilder.java
it.carlom.stikkyheader.core.animator.BaseStickyHeaderAnimator.java
it.carlom.stikkyheader.core.animator.HeaderStikkyAnimator.java