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

Commit ae5ed3a4 authored by Ivan Chiang's avatar Ivan Chiang Committed by Android (Google) Code Review
Browse files

Merge "Update Storage's rootInfo when open the drawer"

parents 9febe073 2f1f223e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.drawerlayout.widget.DrawerLayout.DrawerListener;
import androidx.legacy.app.ActionBarDrawerToggle;

import com.android.documentsui.base.Display;
import com.android.documentsui.base.Providers;

/**
 * A facade over the various pieces comprising "roots fragment in a Drawer".
@@ -201,6 +202,9 @@ public abstract class DrawerController implements DrawerListener {
        @Override
        public void onDrawerOpened(View drawerView) {
            mToggle.onDrawerOpened(drawerView);
            // Update the information for Storage's root
            DocumentsApplication.getProvidersCache(drawerView.getContext()).updateAuthorityAsync(
                    Providers.AUTHORITY_STORAGE);
        }

        @Override
+19 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.documentsui.base.BooleanConsumer;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.Events;
import com.android.documentsui.base.Providers;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
import com.android.documentsui.base.State;
@@ -246,9 +247,21 @@ public class RootsFragment extends Fragment {
                final String excludePackage = excludeSelf ? activity.getCallingPackage() : null;
                List<Item> sortedItems = sortLoadResult(roots, excludePackage, handlerAppIntent,
                        DocumentsApplication.getProvidersCache(getContext()));

                // Get the first visible position and offset
                final int firstPosition = mList.getFirstVisiblePosition();
                View firstChild = mList.getChildAt(0);
                final int offset =
                        firstChild != null ? firstChild.getTop() - mList.getPaddingTop() : 0;
                final int oriItemCount = mAdapter != null ? mAdapter.getCount() : 0;
                mAdapter = new RootsAdapter(activity, sortedItems, mDragListener);
                mList.setAdapter(mAdapter);

                // recover the position.
                if (oriItemCount == mAdapter.getCount()) {
                    mList.setSelectionFromTop(firstPosition, offset);
                }

                mInjector.shortcutsUpdater.accept(roots);
                mInjector.appsRowManager.updateList(mApplicationItemList);
                mInjector.appsRowManager.updateView(activity);
@@ -421,6 +434,12 @@ public class RootsFragment extends Fragment {
    @Override
    public void onResume() {
        super.onResume();
        final Context context = getActivity();
        // Update the information for Storage's root
        if (context != null) {
            DocumentsApplication.getProvidersCache(context).updateAuthorityAsync(
                    Providers.AUTHORITY_STORAGE);
        }
        onDisplayStateChanged();
    }