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

Commit ca6da00f authored by Craig Mautner's avatar Craig Mautner
Browse files

Don't load views before onResume called.

Views were being kicked off when RecentsTaskLoader was being started
from BaseStatusBar.toggleRecentsActivity. Then RecentTasksLoader called
RecentsPanelView.onTasksLoaded which invalidated the Adapter and loaded
the item views. All this before window manager had determined that the
Activity should be rotated and providing a new Configuration.

This fix waits for the Activity to resume before allowing the Adapter
to be invalidated.

Fixes bug 7138698.

Change-Id: I0df67ff2e07a0e0b69cc3b52e9843f90ce763704
parent 55552094
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ public class RecentsActivity extends Activity {
    @Override
    public void onResume() {
        mForeground = true;
        if (mRecentsPanel != null) {
            mRecentsPanel.refreshViews();
        }
        super.onResume();
    }

@@ -186,4 +189,7 @@ public class RecentsActivity extends Activity {
        }
    }

    boolean isForeground() {
        return mForeground;
    }
}
+11 −9
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.app.ActivityOptions;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -67,7 +66,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        StatusBarPanel, Animator.AnimatorListener {
    static final String TAG = "RecentsPanelView";
    static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
    private Context mContext;
    private PopupMenu mPopup;
    private View mRecentsScrim;
    private View mRecentsNoApps;
@@ -203,7 +201,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener

    public RecentsPanelView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
        updateValuesFromResources();

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecentsPanelView,
@@ -374,7 +371,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
    protected void onFinishInflate() {
        super.onFinishInflate();

        mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mRecentsContainer = (ViewGroup) findViewById(R.id.recents_container);
        mStatusBarTouchProxy = (StatusBarTouchProxy) findViewById(R.id.status_bar_touch_proxy);
        mListAdapter = new TaskDescriptionAdapter(mContext);
@@ -508,6 +504,12 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        }
    }

    public void refreshViews() {
        mListAdapter.notifyDataSetInvalidated();
        updateUiElements();
        showIfReady();
    }

    public void refreshRecentTasksList() {
        refreshRecentTasksList(null, false);
    }
@@ -530,12 +532,12 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        } else {
            mRecentTaskDescriptions.addAll(tasks);
        }
        mListAdapter.notifyDataSetInvalidated();
        updateUiElements(getResources().getConfiguration());
        showIfReady();
        if (((RecentsActivity)mContext).isForeground()) {
            refreshViews();
        }
    }

    private void updateUiElements(Configuration config) {
    private void updateUiElements() {
        final int items = mRecentTaskDescriptions.size();

        mRecentsContainer.setVisibility(items > 0 ? View.VISIBLE : View.GONE);