Share to EffectHub.com

You can earn money or coins from your share:)

Tips: you can use Sparticle for uploading away3D effects.

Tips: you can download Sparticle for uploading effects.

Tips: The ActionScript editor is supporting Away3D, Starling, Dragonbones and Flex frameworks.

Tips: paste the web page URL then click button:)

EffectHub.com: Your Best Source for Gaming
Login    or

XlistView: A listview which can pull to refresh and load more (1)


/**

 * @file XListView.java

 * @package me.maxwin.view

 * @create 2013/5/13

 * @author youxiachai

 * @description An ListView support (a) Pull down to refresh, (b) Pull up to load more.

 * Implement IXListViewListener, and see stopRefresh() / stopLoadMore().

 * 

 */


import android.content.Context;

import android.content.SharedPreferences;

import android.os.AsyncTask;

import android.preference.PreferenceManager;

import android.util.AttributeSet;

import android.util.Log;

import android.view.MotionEvent;

import android.view.View;

import android.view.ViewTreeObserver.OnGlobalLayoutListener;

import android.view.animation.DecelerateInterpolator;

import android.widget.AbsListView;

import android.widget.AbsListView.OnScrollListener;

import android.widget.ListAdapter;

import android.widget.ListView;

import android.widget.RelativeLayout;

import android.widget.Scroller;

import android.widget.TextView;


public class XListView extends ListView implements OnScrollListener {

public static final long ONE_MINUTE = 60 * 1000;

public static final long ONE_HOUR = 60 * ONE_MINUTE;

public static final long ONE_DAY = 24 * ONE_HOUR;

public static final long ONE_MONTH = 30 * ONE_DAY;

public static final long ONE_YEAR = 12 * ONE_MONTH;

protected long lastUpdateTime;

protected float mLastY = -1; // save event y

protected Scroller mScroller; // used for scroll back

protected OnScrollListener mScrollListener; // user's scroll listener


// the interface to trigger refresh and load more.


protected IXListViewLoadMore mLoadMore;

protected IXListViewRefreshListener mOnRefresh;

private SharedPreferences preferences;

private String RefreshTimeTag="XListViewRefreshTime";

// -- header view

protected XListViewHeader mHeaderView;

// header view content, use it to calculate the Header's height. And hide it

// when disable pull refresh.

protected RelativeLayout mHeaderViewContent;

protected TextView mHeaderTimeView;

protected int mHeaderViewHeight; // header view's height

protected boolean mEnablePullRefresh = true;

protected boolean mPullRefreshing = false; // is refreashing.


// -- footer view

protected XListViewFooter mFooterView;

protected boolean mEnablePullLoad;

protected boolean mPullLoading;

protected boolean mIsFooterReady = false;


// total list items, used to detect is at the bottom of listview.

protected int mTotalItemCount;


// for mScroller, scroll back from header or footer.

protected int mScrollBack;

protected final static int SCROLLBACK_HEADER = 0;

protected final static int SCROLLBACK_FOOTER = 1;


protected final static int SCROLL_DURATION = 400; // scroll back duration

protected final static int PULL_LOAD_MORE_DELTA = 50; // when pull up >=

// 50px

// at bottom,

// trigger

// load more.

protected final static float OFFSET_RADIO = 1.8f; // support iOS like pull

// feature.


/**

* @param context

*/

public XListView(Context context) {

super(context);

initWithContext(context);

}


public XListView(Context context, AttributeSet attrs) {

super(context, attrs);

initWithContext(context);

}


public XListView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

initWithContext(context);

}


protected void initWithContext(Context context) {

mScroller = new Scroller(context, new DecelerateInterpolator());

// XListView need the scroll event, and it will dispatch the event to

// user's listener (as a proxy).

super.setOnScrollListener(this);

preferences = PreferenceManager.getDefaultSharedPreferences(context);

// init header view

mHeaderView = new XListViewHeader(context);

mHeaderViewContent = (RelativeLayout) mHeaderView

.findViewById(R.id.xlistview_header_content);

mHeaderTimeView = (TextView) mHeaderView

.findViewById(R.id.xlistview_header_time);

//mHeaderTimeView.setText(refreshUpdatedAtValue());

addHeaderView(mHeaderView);


// init footer view

mFooterView = new XListViewFooter(context);


// init header height

mHeaderView.getViewT...

You must Sign up as a member of Effecthub to view the content.

4378 views    3 comments

You must Sign up as a member of Effecthub to join the conversation.

Join Effecthub.com


Or Login with Your Email Address:

Or Sign Up with Your Email Address:
This field must contain a valid email
Password should be at least 1 character