findLastVisibleItemPosition returns -1 with the following sequence:
onViewCreated() { recyclerView.setAdapter(adapter = new Adapter()); adapter.updateContent(List<Content>); // will call notifyItemRangeChanged post(new Runnable() { run() { layoutManager.getLastVisibleItem(); // == -1 (using runnable or not) } } }
It seems that the views of the children are not yet ready. Using a tree viewer in RecyclerView seems to solve the problem, but what is the best approach to get the last visible item after setting the adapter contents right after creation?
android android-recyclerview android-adapter
mbmc Aug 25 '15 at 0:15 2015-08-25 00:15
source share