Loading src/com/android/documentsui/BaseActivity.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -176,7 +176,7 @@ public abstract class BaseActivity @Override @Override public void onSearchChanged(@Nullable String query) { public void onSearchChanged(@Nullable String query) { if (query != null) { if (query != null) { SearchFragment.dismissFragment(getSupportFragmentManager()); SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager()); } } if (mSearchManager.isSearching()) { if (mSearchManager.isSearching()) { Loading Loading @@ -232,7 +232,7 @@ public abstract class BaseActivity SearchFragment.showFragment(getSupportFragmentManager(), SearchFragment.showFragment(getSupportFragmentManager(), mSearchManager.getSearchViewText()); mSearchManager.getSearchViewText()); } else { } else { SearchFragment.dismissFragment(getSupportFragmentManager()); SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager()); } } } } Loading src/com/android/documentsui/queries/SearchFragment.java +22 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,9 @@ package com.android.documentsui.queries; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; Loading Loading @@ -71,10 +74,16 @@ public class SearchFragment extends Fragment{ ft.commitNow(); ft.commitNow(); } } public static void dismissFragment(FragmentManager fm) { /** * Posts the dismissal of the dialog to the next frame of the main looper thread. This method * should be used in cases where the user is still searching, since it can avoid other elements * from flashing for a frame when they are reacting to the same state change (e.g. * http://b/153094528). */ public static void dismissFragmentNextFrame(FragmentManager fm) { SearchFragment fragment = get(fm); SearchFragment fragment = get(fm); if (fragment != null) { if (fragment != null) { fragment.dismiss(); fragment.dismissNextFrame(); } } } } Loading Loading @@ -152,7 +161,7 @@ public class SearchFragment extends Fragment{ mSearchViewManager.setHistorySearch(); mSearchViewManager.setHistorySearch(); mSearchViewManager.setCurrentSearch(item); mSearchViewManager.setCurrentSearch(item); mSearchViewManager.restoreSearch(true); mSearchViewManager.restoreSearch(true); dismiss(); dismissNextFrame(); } } private void dismiss() { private void dismiss() { Loading @@ -175,6 +184,16 @@ public class SearchFragment extends Fragment{ } } } } /** * Posts the dismissal of the dialog to the next frame of the main looper thread. This method * should be used in cases where the user is still searching, since it can avoid other elements * from flashing for a frame when they are reacting to the same state change (e.g. * http://b/153094528). */ private void dismissNextFrame() { new Handler(Looper.getMainLooper()).post(this::dismiss); } private class HistoryListAdapter extends ArrayAdapter<String> { private class HistoryListAdapter extends ArrayAdapter<String> { public HistoryListAdapter(Context context, List<String> list) { public HistoryListAdapter(Context context, List<String> list) { Loading Loading
src/com/android/documentsui/BaseActivity.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -176,7 +176,7 @@ public abstract class BaseActivity @Override @Override public void onSearchChanged(@Nullable String query) { public void onSearchChanged(@Nullable String query) { if (query != null) { if (query != null) { SearchFragment.dismissFragment(getSupportFragmentManager()); SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager()); } } if (mSearchManager.isSearching()) { if (mSearchManager.isSearching()) { Loading Loading @@ -232,7 +232,7 @@ public abstract class BaseActivity SearchFragment.showFragment(getSupportFragmentManager(), SearchFragment.showFragment(getSupportFragmentManager(), mSearchManager.getSearchViewText()); mSearchManager.getSearchViewText()); } else { } else { SearchFragment.dismissFragment(getSupportFragmentManager()); SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager()); } } } } Loading
src/com/android/documentsui/queries/SearchFragment.java +22 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,9 @@ package com.android.documentsui.queries; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.View; import android.view.View; Loading Loading @@ -71,10 +74,16 @@ public class SearchFragment extends Fragment{ ft.commitNow(); ft.commitNow(); } } public static void dismissFragment(FragmentManager fm) { /** * Posts the dismissal of the dialog to the next frame of the main looper thread. This method * should be used in cases where the user is still searching, since it can avoid other elements * from flashing for a frame when they are reacting to the same state change (e.g. * http://b/153094528). */ public static void dismissFragmentNextFrame(FragmentManager fm) { SearchFragment fragment = get(fm); SearchFragment fragment = get(fm); if (fragment != null) { if (fragment != null) { fragment.dismiss(); fragment.dismissNextFrame(); } } } } Loading Loading @@ -152,7 +161,7 @@ public class SearchFragment extends Fragment{ mSearchViewManager.setHistorySearch(); mSearchViewManager.setHistorySearch(); mSearchViewManager.setCurrentSearch(item); mSearchViewManager.setCurrentSearch(item); mSearchViewManager.restoreSearch(true); mSearchViewManager.restoreSearch(true); dismiss(); dismissNextFrame(); } } private void dismiss() { private void dismiss() { Loading @@ -175,6 +184,16 @@ public class SearchFragment extends Fragment{ } } } } /** * Posts the dismissal of the dialog to the next frame of the main looper thread. This method * should be used in cases where the user is still searching, since it can avoid other elements * from flashing for a frame when they are reacting to the same state change (e.g. * http://b/153094528). */ private void dismissNextFrame() { new Handler(Looper.getMainLooper()).post(this::dismiss); } private class HistoryListAdapter extends ArrayAdapter<String> { private class HistoryListAdapter extends ArrayAdapter<String> { public HistoryListAdapter(Context context, List<String> list) { public HistoryListAdapter(Context context, List<String> list) { Loading