Bug 1075576 - Change the TabsLayoutAdapter API to use TabsLayoutItemView instead of the generic View (r=lucasr)

This commit is contained in:
Martyn Haigh 2014-10-02 15:39:26 +01:00
Родитель 49612ba0d9
Коммит c6ab7dc50c
3 изменённых файлов: 13 добавлений и 14 удалений

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

@ -88,17 +88,16 @@ class TabsGridLayout extends GridView
} }
@Override @Override
View newView(int position, ViewGroup parent) { TabsLayoutItemView newView(int position, ViewGroup parent) {
final TabsLayoutItemView item = (TabsLayoutItemView) super.newView(position, parent); final TabsLayoutItemView item = super.newView(position, parent);
item.setOnClickListener(mSelectClickListener); item.setOnClickListener(mSelectClickListener);
item.setCloseOnClickListener(mCloseClickListener); item.setCloseOnClickListener(mCloseClickListener);
return item; return item;
} }
@Override @Override
public void bindView(View view, Tab tab) { public void bindView(TabsLayoutItemView view, Tab tab) {
super.bindView(view, tab); super.bindView(view, tab);
((TabsLayoutItemView) view).close.setVisibility(View.VISIBLE);
// If we're recycling this view, there's a chance it was transformed during // If we're recycling this view, there's a chance it was transformed during
// the close animation. Remove any of those properties. // the close animation. Remove any of those properties.

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

@ -70,23 +70,23 @@ public class TabsLayoutAdapter extends BaseAdapter {
} }
@Override @Override
final public View getView(int position, View convertView, ViewGroup parent) { final public TabsLayoutItemView getView(int position, View convertView, ViewGroup parent) {
final View view; final TabsLayoutItemView view;
if (convertView == null) { if (convertView == null) {
view = newView(position, parent); view = newView(position, parent);
} else { } else {
view = convertView; view = (TabsLayoutItemView) convertView;
} }
final Tab tab = mTabs.get(position); final Tab tab = mTabs.get(position);
bindView(view, tab); bindView(view, tab);
return view; return view;
} }
View newView(int position, ViewGroup parent) { TabsLayoutItemView newView(int position, ViewGroup parent) {
return mInflater.inflate(R.layout.tabs_layout_item_view, parent, false); return (TabsLayoutItemView) mInflater.inflate(R.layout.tabs_layout_item_view, parent, false);
} }
void bindView(View view, Tab tab) { void bindView(TabsLayoutItemView view, Tab tab) {
((TabsLayoutItemView) view).assignValues(tab); view.assignValues(tab);
} }
} }

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

@ -104,8 +104,8 @@ class TabsListLayout extends TwoWayView
} }
@Override @Override
public View newView(int position, ViewGroup parent) { public TabsLayoutItemView newView(int position, ViewGroup parent) {
TabsLayoutItemView item = (TabsLayoutItemView) super.newView(position, parent); TabsLayoutItemView item = super.newView(position, parent);
item.setCloseOnClickListener(mCloseOnClickListener); item.setCloseOnClickListener(mCloseOnClickListener);
@ -113,7 +113,7 @@ class TabsListLayout extends TwoWayView
} }
@Override @Override
public void bindView(View view, Tab tab) { public void bindView(TabsLayoutItemView view, Tab tab) {
super.bindView(view, tab); super.bindView(view, tab);
// If we're recycling this view, there's a chance it was transformed during // If we're recycling this view, there's a chance it was transformed during