Fix a crash when browsing empty roots.

BUG=27292682

Change-Id: I383fd359a959e86fca3f6716575027aa3b4723cf
This commit is contained in:
Ben Kwa
2016-02-24 10:11:10 -08:00
parent dd6e4c1984
commit 9b3524d839

View File

@@ -113,6 +113,11 @@ class FocusManager implements View.OnFocusChangeListener {
* Requests focus on the item that last had focus. Scrolls to that item if necessary.
*/
public void restoreLastFocus() {
if (mAdapter.getItemCount() == 0) {
// Nothing to focus.
return;
}
if (mLastFocusPosition != RecyclerView.NO_POSITION) {
// The system takes care of situations when a view is no longer on screen, etc,
focusItem(mLastFocusPosition);