mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-25 15:41:11 +00:00
[Android] Simplify LayoutInflater retrieval within GameListAdapter, FolderBrowserAdapter, and SideMenuAdapter.
Also added Javadoc to SideMenuAdapter. Gave the context variables a full spelling as well.
This commit is contained in:
parent
4e08a6cc8d
commit
8dfc752780
@ -27,7 +27,7 @@ import org.dolphinemu.dolphinemu.R;
|
||||
*/
|
||||
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||
{
|
||||
private final Context c;
|
||||
private final Context context;
|
||||
private final int id;
|
||||
private final List<FolderBrowserItem> items;
|
||||
|
||||
@ -42,7 +42,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||
{
|
||||
super(context, resourceId, objects);
|
||||
|
||||
this.c = context;
|
||||
this.context = context;
|
||||
this.id = resourceId;
|
||||
this.items = objects;
|
||||
}
|
||||
@ -59,7 +59,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||
View v = convertView;
|
||||
if (v == null)
|
||||
{
|
||||
LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater vi = LayoutInflater.from(context);
|
||||
v = vi.inflate(id, parent, false);
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||
if(subtitle != null)
|
||||
{
|
||||
// Remove the subtitle for all folders, except for the parent directory folder.
|
||||
if (item.isDirectory() && !item.getSubtitle().equals(c.getString(R.string.parent_directory)))
|
||||
if (item.isDirectory() && !item.getSubtitle().equals(context.getString(R.string.parent_directory)))
|
||||
{
|
||||
subtitle.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import org.dolphinemu.dolphinemu.R;
|
||||
*/
|
||||
public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||
{
|
||||
private final Context c;
|
||||
private final Context context;
|
||||
private final int id;
|
||||
private final List<GameListItem>items;
|
||||
|
||||
@ -41,7 +41,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||
{
|
||||
super(context, resourceId, objects);
|
||||
|
||||
this.c = context;
|
||||
this.context = context;
|
||||
this.id = resourceId;
|
||||
this.items = objects;
|
||||
}
|
||||
@ -58,7 +58,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||
View v = convertView;
|
||||
if (v == null)
|
||||
{
|
||||
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater vi = LayoutInflater.from(context);
|
||||
v = vi.inflate(id, parent, false);
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||
if (icon != null)
|
||||
{
|
||||
icon.setImageBitmap(item.getImage());
|
||||
icon.getLayoutParams().width = (int) ((860 / c.getResources().getDisplayMetrics().density) + 0.5);
|
||||
icon.getLayoutParams().height = (int)((340 / c.getResources().getDisplayMetrics().density) + 0.5);
|
||||
icon.getLayoutParams().width = (int) ((860 / context.getResources().getDisplayMetrics().density) + 0.5);
|
||||
icon.getLayoutParams().height = (int)((340 / context.getResources().getDisplayMetrics().density) + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
@ -24,16 +25,24 @@ import org.dolphinemu.dolphinemu.R;
|
||||
*/
|
||||
public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
|
||||
{
|
||||
private final Context c;
|
||||
private final Context context;
|
||||
private final int id;
|
||||
private final List<SideMenuItem>items;
|
||||
|
||||
public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects)
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param resourceId The resource ID for a layout file containing a layout to use when instantiating views.
|
||||
* @param objects The objects to represent in the {@link ListView}.
|
||||
*/
|
||||
public SideMenuAdapter(Context context, int resourceId, List<SideMenuItem> objects)
|
||||
{
|
||||
super(context, textViewResourceId, objects);
|
||||
c = context;
|
||||
id = textViewResourceId;
|
||||
items = objects;
|
||||
super(context, resourceId, objects);
|
||||
|
||||
this.context = context;
|
||||
this.id = resourceId;
|
||||
this.items = objects;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +57,7 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
|
||||
View v = convertView;
|
||||
if (v == null)
|
||||
{
|
||||
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
LayoutInflater vi = LayoutInflater.from(context);
|
||||
v = vi.inflate(id, null);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user