package com.howard.rockear.fragment;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;

import com.howard.rockear.constant.AppConstant;

/**
 * @author howard handle scroll state change
 * 
 */
public abstract class FragmentBase extends Fragment implements OnScrollListener {

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
	}

	@Override
	public void onScroll(AbsListView arg0, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int state) {
		if (state == SCROLL_STATE_TOUCH_SCROLL) {
			handleScroll();
			AppConstant.LIST_SCROLLING = true;
		}
		if (state == SCROLL_STATE_IDLE) {
			handleIdle();
			AppConstant.LIST_SCROLLING = false;
		}
		if (state == SCROLL_STATE_FLING) {
			handleFling();
			AppConstant.LIST_SCROLLING = true;
		}
	}

	public abstract void handleScroll();

	public abstract void handleIdle();

	public abstract void handleFling();

}
