mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-16 12:58:33 +02: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:
@ -27,7 +27,7 @@ import org.dolphinemu.dolphinemu.R;
|
|||||||
*/
|
*/
|
||||||
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||||
{
|
{
|
||||||
private final Context c;
|
private final Context context;
|
||||||
private final int id;
|
private final int id;
|
||||||
private final List<FolderBrowserItem> items;
|
private final List<FolderBrowserItem> items;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
|||||||
{
|
{
|
||||||
super(context, resourceId, objects);
|
super(context, resourceId, objects);
|
||||||
|
|
||||||
this.c = context;
|
this.context = context;
|
||||||
this.id = resourceId;
|
this.id = resourceId;
|
||||||
this.items = objects;
|
this.items = objects;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
|||||||
View v = convertView;
|
View v = convertView;
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater vi = LayoutInflater.from(context);
|
||||||
v = vi.inflate(id, parent, false);
|
v = vi.inflate(id, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
|||||||
if(subtitle != null)
|
if(subtitle != null)
|
||||||
{
|
{
|
||||||
// Remove the subtitle for all folders, except for the parent directory folder.
|
// 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);
|
subtitle.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import org.dolphinemu.dolphinemu.R;
|
|||||||
*/
|
*/
|
||||||
public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||||
{
|
{
|
||||||
private final Context c;
|
private final Context context;
|
||||||
private final int id;
|
private final int id;
|
||||||
private final List<GameListItem>items;
|
private final List<GameListItem>items;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
|||||||
{
|
{
|
||||||
super(context, resourceId, objects);
|
super(context, resourceId, objects);
|
||||||
|
|
||||||
this.c = context;
|
this.context = context;
|
||||||
this.id = resourceId;
|
this.id = resourceId;
|
||||||
this.items = objects;
|
this.items = objects;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
|||||||
View v = convertView;
|
View v = convertView;
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater vi = LayoutInflater.from(context);
|
||||||
v = vi.inflate(id, parent, false);
|
v = vi.inflate(id, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
|||||||
if (icon != null)
|
if (icon != null)
|
||||||
{
|
{
|
||||||
icon.setImageBitmap(item.getImage());
|
icon.setImageBitmap(item.getImage());
|
||||||
icon.getLayoutParams().width = (int) ((860 / c.getResources().getDisplayMetrics().density) + 0.5);
|
icon.getLayoutParams().width = (int) ((860 / context.getResources().getDisplayMetrics().density) + 0.5);
|
||||||
icon.getLayoutParams().height = (int)((340 / c.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.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -24,16 +25,24 @@ import org.dolphinemu.dolphinemu.R;
|
|||||||
*/
|
*/
|
||||||
public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
|
public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
|
||||||
{
|
{
|
||||||
private final Context c;
|
private final Context context;
|
||||||
private final int id;
|
private final int id;
|
||||||
private final List<SideMenuItem>items;
|
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);
|
super(context, resourceId, objects);
|
||||||
c = context;
|
|
||||||
id = textViewResourceId;
|
this.context = context;
|
||||||
items = objects;
|
this.id = resourceId;
|
||||||
|
this.items = objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +57,7 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
|
|||||||
View v = convertView;
|
View v = convertView;
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater vi = LayoutInflater.from(context);
|
||||||
v = vi.inflate(id, null);
|
v = vi.inflate(id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user