mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1203122 - Current tab is not selected in tab tray on gingerbread devices; r=mcomella
This commit is contained in:
parent
614172ce7a
commit
f9531b73f3
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -314,6 +315,7 @@ public class Tabs implements GeckoEventListener {
|
||||
*
|
||||
* @return the selected tab, or null if no tabs exist
|
||||
*/
|
||||
@Nullable
|
||||
public Tab getSelectedTab() {
|
||||
return mSelectedTab;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import java.util.List;
|
||||
class TabsGridLayout extends GridView
|
||||
implements TabsLayout,
|
||||
Tabs.OnTabsChangedListener {
|
||||
|
||||
private static final String LOGTAG = "Gecko" + TabsGridLayout.class.getSimpleName();
|
||||
|
||||
public static final int ANIM_DELAY_MULTIPLE_MS = 20;
|
||||
@ -266,15 +267,26 @@ class TabsGridLayout extends GridView
|
||||
*
|
||||
* @param selected position of the selected tab
|
||||
*/
|
||||
private void updateSelectedStyle(int selected) {
|
||||
for (int i = 0; i < tabsAdapter.getCount(); i++) {
|
||||
// setItemChecked doesn't exist until API 11, despite what the API docs say!
|
||||
if (AppConstants.Versions.feature11Plus) {
|
||||
setItemChecked(i, (i == selected));
|
||||
} else {
|
||||
setSelection(i);
|
||||
private void updateSelectedStyle(final int selected) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final int displayCount = getChildCount();
|
||||
|
||||
for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition(); i++) {
|
||||
final Tab tab = tabsAdapter.getItem(i);
|
||||
final boolean checked = displayCount == 1 || i == selected;
|
||||
final View tabView = getViewForTab(tab);
|
||||
if (tabView != null) {
|
||||
((TabsLayoutItemView) tabView).setChecked(checked);
|
||||
}
|
||||
// setItemChecked doesn't exist until API 11, despite what the API docs say!
|
||||
if (AppConstants.Versions.feature11Plus) {
|
||||
setItemChecked(i, checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshTabsData() {
|
||||
|
@ -5,21 +5,16 @@
|
||||
package org.mozilla.gecko.tabs;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.widget.TabThumbnailWrapper;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
@ -136,6 +131,8 @@ public class TabsLayoutItemView extends LinearLayout
|
||||
|
||||
mTabId = tab.getId();
|
||||
|
||||
setChecked(Tabs.getInstance().isSelectedTab(tab));
|
||||
|
||||
Drawable thumbnailImage = tab.getThumbnail();
|
||||
mThumbnail.setImageDrawable(thumbnailImage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user