Tag: load more

Load more, loaders

https://stackoverflow.com/questions/44491406/how-to-load-more-items-to-the-listview-with-a-loadermanager
http://blog.iamsuleiman.com/android-pagination-tutorial-getting-started-recyclerview/
https://stackoverflow.com/questions/26579764/loaders-with-paginated-listview
http://www.androiddesignpatterns.com/2012/07/understanding-loadermanager.html
http://android.amberfog.com/?p=296
https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView
https://stackoverflow.com/questions/12583419/implement-endless-scroll-on-listview
https://stackoverflow.com/questions/1080811/android-endless-list
https://medium.com/google-developers/making-loading-data-on-android-lifecycle-aware-897e12760832
http://www.vogella.com/tutorials/AndroidBackgroundProcessing/article.html
https://stackoverflow.com/questions/39825125/android-recyclerview-cursorloader-contentprovider-load-more#40017905

Search books

Hello. I have just updated my educational Search books app.

I implemented settings fragment to setup order by setting.

I added setOnKeyListener – if user taps on Enter button, it will work as Search button.

searchEditText.setOnKeyListener(new EditText.OnKeyListener() {
	public boolean onKey(View v, int keyCode, KeyEvent event) {
		// If the event is a key-down event on the "enter" button
		if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
				(keyCode == KeyEvent.KEYCODE_ENTER)) {
			// Perform action on key press
			// Clear the adapter of previous book data
			mAdapter.clear();
			String search = searchEditText.getText().toString();
			loadMore(search);
			return true;
		}
		return false;
	}
});

I added setOnScrollListener to load more data.

// Create an OnScrollListener
bookListView.setOnScrollListener(new AbsListView.OnScrollListener() {

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		int threshold = 1;
		int count = bookListView.getCount();

		if (scrollState == SCROLL_STATE_IDLE) {
			if (bookListView.getLastVisiblePosition() >= count - threshold) {
				// loadMore
				String search = searchEditText.getText().toString();
				startIndex += 10;
				loadMore(search);
			}
		}
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
		//
	}
});