[Android] Get rid of some unnecessary variables in the getView() methods of some adapters.

Directly referencing convertView is fine.
This commit is contained in:
Lioncash 2013-11-15 16:31:52 -05:00
parent 0e415467c4
commit d3731d0827
3 changed files with 16 additions and 19 deletions

View file

@ -56,19 +56,18 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(context);
v = vi.inflate(id, parent, false);
convertView = vi.inflate(id, parent, false);
}
final FolderBrowserItem item = items.get(position);
if (item != null)
{
ImageView icon = (ImageView) v.findViewById(R.id.ListItemIcon);
TextView title = (TextView) v.findViewById(R.id.ListItemTitle);
TextView subtitle = (TextView) v.findViewById(R.id.ListItemSubTitle);
ImageView icon = (ImageView) convertView.findViewById(R.id.ListItemIcon);
TextView title = (TextView) convertView.findViewById(R.id.ListItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.ListItemSubTitle);
if(title != null)
{
@ -100,6 +99,6 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
}
}
}
return v;
return convertView;
}
}

View file

@ -55,19 +55,18 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(context);
v = vi.inflate(id, parent, false);
convertView = vi.inflate(id, parent, false);
}
final GameListItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.ListItemTitle);
TextView subtitle = (TextView) v.findViewById(R.id.ListItemSubTitle);
ImageView icon = (ImageView) v.findViewById(R.id.ListItemIcon);
TextView title = (TextView) convertView.findViewById(R.id.ListItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.ListItemSubTitle);
ImageView icon = (ImageView) convertView.findViewById(R.id.ListItemIcon);
if (title != null)
title.setText(item.getName());
@ -83,7 +82,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
}
}
return v;
return convertView;
}
}

View file

@ -54,23 +54,22 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
if (convertView == null)
{
LayoutInflater vi = LayoutInflater.from(context);
v = vi.inflate(id, null);
convertView = vi.inflate(id, null);
}
final SideMenuItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
TextView title = (TextView) convertView.findViewById(R.id.SideMenuTitle);
if (title != null)
title.setText(item.getName());
}
return v;
return convertView;
}
}