package com.droideve.apps.dealify.helper;

import android.widget.AbsListView;

public abstract class OnScrollObserver implements AbsListView.OnScrollListener {

    int last = 0;
    boolean control = true;

    public abstract void onScrollUp();

    public abstract void onScrollDown();

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
    }

    @Override
    public void onScroll(AbsListView view, int current, int visibles, int total) {
        if (current < last && !control) {
            onScrollUp();
            control = true;
        } else if (current > last && control) {
            onScrollDown();
            control = false;
        }

        last = current;
    }
}
