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

Commit bb572333 authored by arangelov's avatar arangelov
Browse files

Rebuild list before calling useLayoutWithDefault().

Fixes: 144080004
Test: manual
Test: atest com.android.internal.app.ResolverActivityTest
Test: atest com.android.internal.app.ChooserActivityTest
Change-Id: I2ea56dd29012eb70dcc7ecb509647ddf65778f38
parent 651fc286
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1226,9 +1226,9 @@ public class ChooserActivity extends ResolverActivity implements
    }

    @Override
    protected boolean rebuildList() {
    protected boolean postRebuildList(boolean rebuildCompleted) {
        mChooserListAdapter = (ChooserListAdapter) mAdapter;
        return rebuildListInternal();
        return postRebuildListInternal(rebuildCompleted);
    }

    @Override
+16 −10
Original line number Diff line number Diff line
@@ -325,9 +325,8 @@ public class ResolverActivity extends Activity implements
        boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction();
        mAdapter = createAdapter(this, mIntents, initialIntents, rList,
                filterLastUsed, mUseLayoutForBrowsables);
        configureContentView();

        if (rebuildList()) {
        if (configureContentView()) {
            return;
        }

@@ -1054,11 +1053,13 @@ public class ResolverActivity extends Activity implements

    /**
     * Sets up the content view.
     * @return <code>true</code> if the activity is finishing and creation should halt.
     */
    private void configureContentView() {
    private boolean configureContentView() {
        if (mAdapter == null) {
            throw new IllegalStateException("mAdapter cannot be null.");
        }
        boolean rebuildCompleted = mAdapter.rebuildList();
        if (useLayoutWithDefault()) {
            mLayoutId = R.layout.resolver_list_with_default;
        } else {
@@ -1066,21 +1067,26 @@ public class ResolverActivity extends Activity implements
        }
        setContentView(mLayoutId);
        mAdapterView = findViewById(R.id.resolver_list);
        return postRebuildList(rebuildCompleted);
    }

    /**
     * Returns true if the activity is finishing and creation should halt.
     * </p>Subclasses must call rebuildListInternal at the end of rebuildList.
     * Finishing procedures to be performed after the list has been rebuilt.
     * </p>Subclasses must call postRebuildListInternal at the end of postRebuildList.
     * @param rebuildCompleted
     * @return <code>true</code> if the activity is finishing and creation should halt.
     */
    protected boolean rebuildList() {
        return rebuildListInternal();
    protected boolean postRebuildList(boolean rebuildCompleted) {
        return postRebuildListInternal(rebuildCompleted);
    }

    /**
     * Returns true if the activity is finishing and creation should halt.
     * Finishing procedures to be performed after the list has been rebuilt.
     * @param rebuildCompleted
     * @return <code>true</code> if the activity is finishing and creation should halt.
     */
    final boolean rebuildListInternal() {
        boolean rebuildCompleted = mAdapter.rebuildList();
    final boolean postRebuildListInternal(boolean rebuildCompleted) {

        int count = mAdapter.getUnfilteredCount();

        // We only rebuild asynchronously when we have multiple elements to sort. In the case where