Bug 918044 - Block layout requests while handling focus changes in TopSitesGridView (r=sriram)

This commit is contained in:
Lucas Rocha 2013-10-16 16:39:34 +01:00
Родитель f2a4c052ee
Коммит 3e9022b1c7
1 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -15,6 +15,7 @@ import org.mozilla.gecko.util.StringUtils;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextMenu.ContextMenuInfo;
@ -64,6 +65,11 @@ public class TopSitesGridView extends GridView {
// Context menu info.
private TopSitesGridContextMenuInfo mContextMenuInfo;
// Whether we're handling focus changes or not. This is used
// to avoid infinite re-layouts when using this GridView as
// a ListView header view (see bug 918044).
private boolean mIsHandlingFocusChange;
public TopSitesGridView(Context context) {
this(context, null);
}
@ -82,6 +88,8 @@ public class TopSitesGridView extends GridView {
mHorizontalSpacing = a.getDimensionPixelOffset(R.styleable.TopSitesGridView_android_horizontalSpacing, 0x00);
mVerticalSpacing = a.getDimensionPixelOffset(R.styleable.TopSitesGridView_android_verticalSpacing, 0x00);
a.recycle();
mIsHandlingFocusChange = false;
}
/**
@ -131,6 +139,20 @@ public class TopSitesGridView extends GridView {
mPinSiteListener = null;
}
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
mIsHandlingFocusChange = true;
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
mIsHandlingFocusChange = false;
}
@Override
public void requestLayout() {
if (!mIsHandlingFocusChange) {
super.requestLayout();
}
}
/**
* {@inheritDoc}
*/