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

Commit 0f60e357 authored by Zemiao Zhu's avatar Zemiao Zhu Committed by Automerger Merge Worker
Browse files

Merge "Revert "Post SearchFragment dismissal to the next frame when user is...

Merge "Revert "Post SearchFragment dismissal to the next frame when user is searching"" into rvc-dev am: 0b814377 am: 18a425d4

Change-Id: I27ce0ef3b39d6ae4b86f9dc6c7c29178eb13b8f5
parents bb392cb6 18a425d4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public abstract class BaseActivity
            @Override
            public void onSearchChanged(@Nullable String query) {
                if (query != null) {
                    SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager());
                    SearchFragment.dismissFragment(getSupportFragmentManager());
                }

                if (mSearchManager.isSearching()) {
@@ -232,7 +232,7 @@ public abstract class BaseActivity
                    SearchFragment.showFragment(getSupportFragmentManager(),
                            mSearchManager.getSearchViewText());
                } else {
                    SearchFragment.dismissFragmentNextFrame(getSupportFragmentManager());
                    SearchFragment.dismissFragment(getSupportFragmentManager());
                }
            }

+3 −22
Original line number Diff line number Diff line
@@ -19,9 +19,6 @@ package com.android.documentsui.queries;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -74,16 +71,10 @@ public class SearchFragment extends Fragment{
        ft.commitNow();
    }

    /**
     * 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) {
    public static void dismissFragment(FragmentManager fm) {
        SearchFragment fragment = get(fm);
        if (fragment != null) {
            fragment.dismissNextFrame();
            fragment.dismiss();
        }
    }

@@ -161,7 +152,7 @@ public class SearchFragment extends Fragment{
        mSearchViewManager.setHistorySearch();
        mSearchViewManager.setCurrentSearch(item);
        mSearchViewManager.restoreSearch(true);
        dismissNextFrame();
        dismiss();
    }

    private void dismiss() {
@@ -184,16 +175,6 @@ 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> {

        public HistoryListAdapter(Context context, List<String> list) {