[Android] Simplify the AboutFragmentAdapter a little bit.

- Removes an unnecessary variable.
- Shortens the LayoutInflater usage.
- Gets rid of an unnecessary override of onAttach.
This commit is contained in:
Lioncash 2013-11-15 17:19:09 -05:00
parent 8c7d1afd5f
commit 483a28f34a
1 changed files with 7 additions and 20 deletions

View File

@ -6,7 +6,6 @@
package org.dolphinemu.dolphinemu; package org.dolphinemu.dolphinemu;
import android.app.Activity;
import android.app.ListFragment; import android.app.ListFragment;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
@ -27,8 +26,6 @@ import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment;
*/ */
public final class AboutFragment extends ListFragment public final class AboutFragment extends ListFragment
{ {
private static Activity m_activity;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
@ -43,22 +40,13 @@ public final class AboutFragment extends ListFragment
Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no)); Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no));
Input.add(new AboutFragmentItem(getString(R.string.supports_neon), NativeLibrary.SupportsNEON() ? yes : no)); Input.add(new AboutFragmentItem(getString(R.string.supports_neon), NativeLibrary.SupportsNEON() ? yes : no));
AboutFragmentAdapter adapter = new AboutFragmentAdapter(m_activity, R.layout.about_layout, Input); AboutFragmentAdapter adapter = new AboutFragmentAdapter(getActivity(), R.layout.about_layout, Input);
mMainList.setAdapter(adapter); mMainList.setAdapter(adapter);
mMainList.setEnabled(false); // Makes the list view non-clickable. mMainList.setEnabled(false); // Makes the list view non-clickable.
return mMainList; return mMainList;
} }
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
// Cache the activity instance.
m_activity = activity;
}
// Represents an item in the AboutFragment. // Represents an item in the AboutFragment.
private static final class AboutFragmentItem private static final class AboutFragmentItem
{ {
@ -107,18 +95,17 @@ public final class AboutFragment extends ListFragment
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent)
{ {
View v = convertView; if (convertView == null)
if (v == null)
{ {
LayoutInflater vi = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater vi = LayoutInflater.from(ctx);
v = vi.inflate(id, parent, false); convertView = vi.inflate(id, parent, false);
} }
final AboutFragmentItem item = items.get(position); final AboutFragmentItem item = items.get(position);
if (item != null) if (item != null)
{ {
TextView title = (TextView) v.findViewById(R.id.AboutItemTitle); TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) v.findViewById(R.id.AboutItemSubTitle); TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
if (title != null) if (title != null)
title.setText(item.getTitle()); title.setText(item.getTitle());
@ -127,7 +114,7 @@ public final class AboutFragment extends ListFragment
subtitle.setText(item.getSubTitle()); subtitle.setText(item.getSubTitle());
} }
return v; return convertView;
} }
} }
} }