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

Commit 4858f5fd authored by Josh Gargus's avatar Josh Gargus Committed by Android (Google) Code Review
Browse files

Merge "Don't request a layout during layout." into jb-dev

parents 2828c48c 73042e8f
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.contacts.ContactLoader;
import com.android.contacts.detail.ContactDetailPhotoSetter;
import com.android.contacts.util.MoreMath;
import com.android.contacts.util.PhoneCapabilityTester;
import com.android.contacts.util.SchedulingUtils;

import android.content.Context;
import android.content.res.Resources;
@@ -203,11 +204,19 @@ public class ContactDetailTabCarousel extends HorizontalScrollView implements On
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        if (mScrollToCurrentTab) {

        // Defer this stuff until after the layout has finished.  This is because
        // updateAlphaLayers() ultimately results in another layout request, and
        // the framework currently can't handle this safely.
        if (!mScrollToCurrentTab) return;
        mScrollToCurrentTab = false;
        SchedulingUtils.doAfterLayout(this, new Runnable() {
            @Override
            public void run() {
                scrollTo(mCurrentTab == TAB_INDEX_ABOUT ? 0 : mAllowedHorizontalScrollLength, 0);
                updateAlphaLayers();
            }
        });
    }

    /** When clicked, selects the corresponding tab. */