// Path: src/com/nilhcem/frcndict/core/Log.java
// public final class Log {
// 
// 	private static final boolean LOG_ERROR = Config.LOGLEVEL > 0;
// 	private static final boolean LOG_WARN = Config.LOGLEVEL > 1;
// 	private static final boolean LOG_INFO = Config.LOGLEVEL > 2;
// 	private static final boolean LOG_DEBUG = Config.LOGLEVEL > 3;
// 
// 	private Log() {
// 		throw new UnsupportedOperationException();
// 	}
// 
// 	public static void d(String tag, String msgFormat, Object... args) {
// 		if (LOG_DEBUG) {
// 			try {
// 				android.util.Log.d(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.d(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void w(String tag, String msgFormat, Object... args) {
// 		if (LOG_WARN) {
// 			try {
// 				android.util.Log.w(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.w(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void i(String tag, String msgFormat, Object... args) {
// 		if (LOG_INFO) {
// 			try {
// 				android.util.Log.i(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.i(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void e(String tag, Throwable t) {
// 		if (LOG_ERROR) {
// 			android.util.Log.e(tag, "", t);
// 		}
// 	}
// 
// 	public static void e(String tag, String msgFormat, Object... args) {
// 		if (LOG_ERROR) {
// 			try {
// 				android.util.Log.e(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.e(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void e(String tag, Throwable t, String msgFormat, Object... args) {
// 		if (LOG_ERROR) {
// 			try {
// 				android.util.Log.e(tag, String.format(Locale.US, msgFormat, args), t);
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.e(tag, msgFormat, t);
// 			}
// 		}
// 	}
// }


import java.util.Observable;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import com.nilhcem.frcndict.core.Log;
package com.nilhcem.frcndict.core.list;




public final class EndlessScrollListener extends Observable implements OnScrollListener {

	private int mCurrentPage; // Current loaded "page" of data
	private int mPreviousTotal; // Total nb of items in the dataset.
	private boolean mLoading; // True if we are still waiting for the last set of data to load.

	public EndlessScrollListener() {
		super();
		reset();
	}

	// called every time the list is scrolled to check if the latest element of the list is visible, to run a special operation
	@Override
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
		if (mLoading && (totalItemCount > mPreviousTotal)) {
			// If the dataset count has changed, it has finished loading
			mLoading = false;
			mPreviousTotal = totalItemCount;
			mCurrentPage++;
		}
		// If it isn't currently loading, we check to see if we need to reload more data.
		if (!mLoading && totalItemCount > 0 && ((firstVisibleItem + visibleItemCount) == totalItemCount)) {
// Path: src/com/nilhcem/frcndict/core/Log.java
// public final class Log {
// 
// 	private static final boolean LOG_ERROR = Config.LOGLEVEL > 0;
// 	private static final boolean LOG_WARN = Config.LOGLEVEL > 1;
// 	private static final boolean LOG_INFO = Config.LOGLEVEL > 2;
// 	private static final boolean LOG_DEBUG = Config.LOGLEVEL > 3;
// 
// 	private Log() {
// 		throw new UnsupportedOperationException();
// 	}
// 
// 	public static void d(String tag, String msgFormat, Object... args) {
// 		if (LOG_DEBUG) {
// 			try {
// 				android.util.Log.d(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.d(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void w(String tag, String msgFormat, Object... args) {
// 		if (LOG_WARN) {
// 			try {
// 				android.util.Log.w(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.w(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void i(String tag, String msgFormat, Object... args) {
// 		if (LOG_INFO) {
// 			try {
// 				android.util.Log.i(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.i(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void e(String tag, Throwable t) {
// 		if (LOG_ERROR) {
// 			android.util.Log.e(tag, "", t);
// 		}
// 	}
// 
// 	public static void e(String tag, String msgFormat, Object... args) {
// 		if (LOG_ERROR) {
// 			try {
// 				android.util.Log.e(tag, String.format(Locale.US, msgFormat, args));
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.e(tag, msgFormat);
// 			}
// 		}
// 	}
// 
// 	public static void e(String tag, Throwable t, String msgFormat, Object... args) {
// 		if (LOG_ERROR) {
// 			try {
// 				android.util.Log.e(tag, String.format(Locale.US, msgFormat, args), t);
// 			} catch (NullPointerException e) {
// 				// Do nothing
// 			} catch (IllegalFormatException e) {
// 				android.util.Log.e(tag, msgFormat, t);
// 			}
// 		}
// 	}
// }


// Path: src/com/nilhcem/frcndict/core/list/EndlessScrollListener.java
import java.util.Observable;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import com.nilhcem.frcndict.core.Log;

package com.nilhcem.frcndict.core.list;




public final class EndlessScrollListener extends Observable implements OnScrollListener {

	private int mCurrentPage; // Current loaded "page" of data
	private int mPreviousTotal; // Total nb of items in the dataset.
	private boolean mLoading; // True if we are still waiting for the last set of data to load.

	public EndlessScrollListener() {
		super();
		reset();
	}

	// called every time the list is scrolled to check if the latest element of the list is visible, to run a special operation
	@Override
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
		if (mLoading && (totalItemCount > mPreviousTotal)) {
			// If the dataset count has changed, it has finished loading
			mLoading = false;
			mPreviousTotal = totalItemCount;
			mCurrentPage++;
		}
		// If it isn't currently loading, we check to see if we need to reload more data.
		if (!mLoading && totalItemCount > 0 && ((firstVisibleItem + visibleItemCount) == totalItemCount)) {
			Log.d(EndlessScrollListener.class.getSimpleName(), "[End of scroll] Load more data");