Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 184a8cb4 authored by Pingzhi Wang's avatar Pingzhi Wang Committed by Michael Bestas
Browse files

Scrolling search results and autorotate cause crash

Activity.getCurrentFocus() can return null,
let's avoid a crash.

Bug: 111865137
Test: manual - Search in settings, scroll, rotate and scroll again.
Change-Id: I3d1437ee8dacc4dbd51f0b58df8a855b713668f0
parent 12d0b744
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -344,10 +344,12 @@ public class SearchFragment extends Fragment implements SearchView.OnQueryTextLi
        final Activity activity = getActivity();
        if (activity != null) {
            View view = activity.getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager)
                        activity.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
        }

        if (mResultsRecyclerView != null) {
            mResultsRecyclerView.requestFocus();