Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Simplify the AboutFragmentAdapter a little bit.
- Removes an unnecessary variable.
- Shortens the LayoutInflater usage.
- Gets rid of an unnecessary override of onAttach.
  • Loading branch information
lioncash committed Nov 15, 2013
1 parent 8c7d1af commit 483a28f
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
Expand Up @@ -6,7 +6,6 @@

package org.dolphinemu.dolphinemu;

import android.app.Activity;
import android.app.ListFragment;
import android.content.Context;
import android.os.Bundle;
Expand All @@ -27,8 +26,6 @@
*/
public final class AboutFragment extends ListFragment
{
private static Activity m_activity;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
Expand All @@ -43,22 +40,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
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));

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.setEnabled(false); // Makes the list view non-clickable.

return mMainList;
}

@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);

// Cache the activity instance.
m_activity = activity;
}

// Represents an item in the AboutFragment.
private static final class AboutFragmentItem
{
Expand Down Expand Up @@ -107,18 +95,17 @@ public AboutFragmentItem getItem(int index)
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
if (convertView == null)
{
LayoutInflater vi = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, parent, false);
LayoutInflater vi = LayoutInflater.from(ctx);
convertView = vi.inflate(id, parent, false);
}

final AboutFragmentItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) v.findViewById(R.id.AboutItemSubTitle);
TextView title = (TextView) convertView.findViewById(R.id.AboutItemTitle);
TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);

if (title != null)
title.setText(item.getTitle());
Expand All @@ -127,7 +114,7 @@ public View getView(int position, View convertView, ViewGroup parent)
subtitle.setText(item.getSubTitle());
}

return v;
return convertView;
}
}
}

0 comments on commit 483a28f

Please sign in to comment.