diff options
| author | Lioncash <mathew1800@gmail.com> | 2013-08-29 12:40:35 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2013-08-29 12:40:35 -0400 |
| commit | 8fd2c32ba65be8338be171dee744839adce95dd7 (patch) | |
| tree | b3d27f8f7ae793f898c014fd75109c0e7fa037dc /Source/Android | |
| parent | 93ed4adb025928c913fb3c01f1c3b0567330b9e3 (diff) | |
[Android] Decouple the About fragment from the FolderBrowserAdapter. Now it uses its own independent adapter (I have no idea why this wasn't done in the first place).
Diffstat (limited to 'Source/Android')
| -rw-r--r-- | Source/Android/res/layout/about_layout.xml | 7 | ||||
| -rw-r--r-- | Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java | 91 |
2 files changed, 87 insertions, 11 deletions
diff --git a/Source/Android/res/layout/about_layout.xml b/Source/Android/res/layout/about_layout.xml index c282fc0369..390d7d0de9 100644 --- a/Source/Android/res/layout/about_layout.xml +++ b/Source/Android/res/layout/about_layout.xml @@ -2,10 +2,11 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" - android:orientation="vertical" > + android:orientation="vertical" + android:padding="6dp"> <TextView - android:id="@+id/FolderTitle" + android:id="@+id/AboutItemTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dip" @@ -14,7 +15,7 @@ android:textStyle="bold" /> <TextView - android:id="@+id/FolderSubTitle" + android:id="@+id/AboutItemSubTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" /> diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java index c65cd6135a..325c5ce4d8 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -8,25 +8,28 @@ package org.dolphinemu.dolphinemu; import android.app.Activity; import android.app.Fragment; +import android.content.Context; import android.os.Bundle; 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.ArrayList; import java.util.List; -import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowserAdapter; -import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowserItem; import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment; - +/** + * Represents the about screen. + */ public final class AboutFragment extends Fragment { private static Activity m_activity; private ListView mMainList; - private FolderBrowserAdapter adapter; + private AboutFragmentAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) @@ -37,11 +40,11 @@ public final class AboutFragment extends Fragment String yes = getString(R.string.yes); String no = getString(R.string.no); - List<FolderBrowserItem> Input = new ArrayList<FolderBrowserItem>(); - Input.add(new FolderBrowserItem(getString(R.string.build_revision), NativeLibrary.GetVersionString(), "")); - Input.add(new FolderBrowserItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no, "")); + List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>(); + Input.add(new AboutFragmentItem(getString(R.string.build_revision), NativeLibrary.GetVersionString())); + Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no)); - adapter = new FolderBrowserAdapter(m_activity, R.layout.about_layout, Input); + adapter = new AboutFragmentAdapter(m_activity, R.layout.about_layout, Input); mMainList.setAdapter(adapter); return mMainList; @@ -55,4 +58,76 @@ public final class AboutFragment extends Fragment // Cache the activity instance. m_activity = activity; } + + // Represents an item in the AboutFragment. + private static final class AboutFragmentItem + { + private final String title; + private final String subtitle; + + public AboutFragmentItem(String title, String subtitle) + { + this.title = title; + this.subtitle = subtitle; + } + + public String getTitle() + { + return title; + } + + public String getSubTitle() + { + return subtitle; + } + } + + // The adapter that manages the displaying of items in this AboutFragment. + private static class AboutFragmentAdapter extends ArrayAdapter<AboutFragmentItem> + { + private final Context ctx; + private final int id; + private final List<AboutFragmentItem> items; + + public AboutFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items) + { + super(ctx, id, items); + + this.ctx = ctx; + this.id = id; + this.items = items; + } + + @Override + public AboutFragmentItem getItem(int index) + { + return items.get(index); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) + { + View v = convertView; + if (v == null) + { + LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = 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); + + if (title != null) + title.setText(item.getTitle()); + + if (subtitle != null) + subtitle.setText(item.getSubTitle()); + } + + return v; + } + } } |
