Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #145 from lioncash/split-about-activity

[Android] Split the AboutFragmentItem and InfoFragmentAdapter into their own class files.
  • Loading branch information...
commit 8863eb06710b741aca73a577d28846b27d7a7498 2 parents e05eca7 + 53ed005
Pierre Bourdon authored
82  Source/Android/src/org/dolphinemu/dolphinemu/about/AboutActivity.java
... ...
@@ -1,3 +1,9 @@
  1
+/**
  2
+ * Copyright 2014 Dolphin Emulator Project
  3
+ * Licensed under GPLv2
  4
+ * Refer to the license.txt file included.
  5
+ */
  6
+
1 7
 package org.dolphinemu.dolphinemu.about;
2 8
 
3 9
 import org.dolphinemu.dolphinemu.R;
@@ -10,17 +16,10 @@
10 16
 import android.app.Fragment;
11 17
 import android.app.FragmentManager;
12 18
 import android.app.FragmentTransaction;
13  
-import android.content.Context;
14 19
 import android.os.Bundle;
15 20
 import android.support.v13.app.FragmentPagerAdapter;
16 21
 import android.support.v4.view.ViewPager;
17  
-import android.view.LayoutInflater;
18  
-import android.view.View;
19  
-import android.view.ViewGroup;
20  
-import android.widget.ArrayAdapter;
21  
-import android.widget.TextView;
22 22
 
23  
-import java.util.List;
24 23
 
25 24
 /**
26 25
  * Activity for the about menu, which displays info
@@ -31,75 +30,6 @@
31 30
 	private ViewPager viewPager;
32 31
 	private final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
33 32
 
34  
-	// Represents an item in the multiple About fragments.
35  
-	public static final class AboutFragmentItem
36  
-	{
37  
-		private final String title;
38  
-		private final String subtitle;
39  
-
40  
-		public AboutFragmentItem(String title, String subtitle)
41  
-		{
42  
-			this.title = title;
43  
-			this.subtitle = subtitle;
44  
-		}
45  
-
46  
-		public String getTitle()
47  
-		{
48  
-			return title;
49  
-		}
50  
-
51  
-		public String getSubTitle()
52  
-		{
53  
-			return subtitle;
54  
-		}
55  
-	}
56  
-
57  
-	// The adapter that manages the displaying of items in multiple About fragments.
58  
-	public static final class InfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
59  
-	{
60  
-		private final int id;
61  
-		private final List<AboutFragmentItem> items;
62  
-
63  
-		public InfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
64  
-		{
65  
-			super(ctx, id, items);
66  
-
67  
-			this.id = id;
68  
-			this.items = items;
69  
-		}
70  
-
71  
-		@Override
72  
-		public AboutFragmentItem getItem(int index)
73  
-		{
74  
-			return items.get(index);
75  
-		}
76  
-
77  
-		@Override
78  
-		public View getView(int position, View convertView, ViewGroup parent)
79  
-		{
80  
-			if (convertView == null)
81  
-			{
82  
-				LayoutInflater vi = LayoutInflater.from(getContext());
83  
-				convertView = vi.inflate(id, parent, false);
84  
-			}
85  
-
86  
-			final AboutFragmentItem item = items.get(position);
87  
-			if (item != null)
88  
-			{
89  
-				TextView title    = (TextView) convertView.findViewById(R.id.AboutItemTitle);
90  
-				TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
91  
-
92  
-				if (title != null)
93  
-					title.setText(item.getTitle());
94  
-
95  
-				if (subtitle != null)
96  
-					subtitle.setText(item.getSubTitle());
97  
-			}
98  
-
99  
-			return convertView;
100  
-		}
101  
-	}
102  
-
103 33
 	@Override
104 34
 	protected void onCreate(Bundle savedInstanceState)
105 35
 	{
49  Source/Android/src/org/dolphinemu/dolphinemu/about/AboutFragmentItem.java
... ...
@@ -0,0 +1,49 @@
  1
+/**
  2
+ * Copyright 2014 Dolphin Emulator Project
  3
+ * Licensed under GPLv2
  4
+ * Refer to the license.txt file included.
  5
+ */
  6
+
  7
+package org.dolphinemu.dolphinemu.about;
  8
+
  9
+/**
  10
+ * Represents an item within an info
  11
+ * {@list Fragment} in the About menu.
  12
+ */
  13
+final class AboutFragmentItem
  14
+{
  15
+	private final String title;
  16
+	private final String subtitle;
  17
+
  18
+	/**
  19
+	 * Constructor
  20
+	 * 
  21
+	 * @param title    The title of this item.
  22
+	 * @param subtitle The subtitle for this item.
  23
+	 */
  24
+	public AboutFragmentItem(String title, String subtitle)
  25
+	{
  26
+		this.title = title;
  27
+		this.subtitle = subtitle;
  28
+	}
  29
+
  30
+	/**
  31
+	 * Gets the title of this item.
  32
+	 * 
  33
+	 * @return the title of this item.
  34
+	 */
  35
+	public String getTitle()
  36
+	{
  37
+		return title;
  38
+	}
  39
+
  40
+	/**
  41
+	 * Gets the subtitle of this item.
  42
+	 * 
  43
+	 * @return the subtitle of this item.
  44
+	 */
  45
+	public String getSubTitle()
  46
+	{
  47
+		return subtitle;
  48
+	}
  49
+}
67  Source/Android/src/org/dolphinemu/dolphinemu/about/AboutInfoFragmentAdapter.java
... ...
@@ -0,0 +1,67 @@
  1
+/**
  2
+ * Copyright 2014 Dolphin Emulator Project
  3
+ * Licensed under GPLv2
  4
+ * Refer to the license.txt file included.
  5
+ */
  6
+
  7
+package org.dolphinemu.dolphinemu.about;
  8
+
  9
+import java.util.List;
  10
+
  11
+import org.dolphinemu.dolphinemu.R;
  12
+
  13
+import android.content.Context;
  14
+import android.view.LayoutInflater;
  15
+import android.view.View;
  16
+import android.view.ViewGroup;
  17
+import android.widget.ArrayAdapter;
  18
+import android.widget.TextView;
  19
+
  20
+/**
  21
+ * {@link ArrayAdapter} subclass specifically for the
  22
+ * information fragments within the about menu.
  23
+ */
  24
+final class AboutInfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
  25
+{
  26
+	private final int id;
  27
+	private final List<AboutFragmentItem> items;
  28
+
  29
+	public AboutInfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
  30
+	{
  31
+		super(ctx, id, items);
  32
+
  33
+		this.id = id;
  34
+		this.items = items;
  35
+	}
  36
+
  37
+	@Override
  38
+	public AboutFragmentItem getItem(int index)
  39
+	{
  40
+		return items.get(index);
  41
+	}
  42
+
  43
+	@Override
  44
+	public View getView(int position, View convertView, ViewGroup parent)
  45
+	{
  46
+		if (convertView == null)
  47
+		{
  48
+			LayoutInflater vi = LayoutInflater.from(getContext());
  49
+			convertView = vi.inflate(id, parent, false);
  50
+		}
  51
+
  52
+		final AboutFragmentItem item = items.get(position);
  53
+		if (item != null)
  54
+		{
  55
+			TextView title    = (TextView) convertView.findViewById(R.id.AboutItemTitle);
  56
+			TextView subtitle = (TextView) convertView.findViewById(R.id.AboutItemSubTitle);
  57
+
  58
+			if (title != null)
  59
+				title.setText(item.getTitle());
  60
+
  61
+			if (subtitle != null)
  62
+				subtitle.setText(item.getSubTitle());
  63
+		}
  64
+
  65
+		return convertView;
  66
+	}
  67
+}
11  Source/Android/src/org/dolphinemu/dolphinemu/about/CPUInfoFragment.java
... ...
@@ -1,10 +1,15 @@
  1
+/**
  2
+ * Copyright 2014 Dolphin Emulator Project
  3
+ * Licensed under GPLv2
  4
+ * Refer to the license.txt file included.
  5
+ */
  6
+
1 7
 package org.dolphinemu.dolphinemu.about;
2 8
 
3 9
 import java.util.ArrayList;
4 10
 import java.util.List;
5 11
 
6 12
 import org.dolphinemu.dolphinemu.R;
7  
-import org.dolphinemu.dolphinemu.about.AboutActivity.AboutFragmentItem;
8 13
 import org.dolphinemu.dolphinemu.utils.CPUHelper;
9 14
 
10 15
 import android.app.ListFragment;
@@ -25,7 +30,7 @@
25 30
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
26 31
 	{
27 32
 		ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
28  
-		List<AboutActivity.AboutFragmentItem> items = new ArrayList<AboutActivity.AboutFragmentItem>();
  33
+		List<AboutFragmentItem> items = new ArrayList<AboutFragmentItem>();
29 34
 
30 35
 		CPUHelper cpuHelper = new CPUHelper(getActivity());
31 36
 
@@ -39,7 +44,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
39 44
 		if (CPUHelper.isARM())
40 45
 			items.add(new AboutFragmentItem(getString(R.string.cpu_implementer), cpuHelper.getImplementer()));
41 46
 
42  
-		AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, items);
  47
+		AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, items);
43 48
 		rootView.setAdapter(adapter);
44 49
 
45 50
 		return rootView;
6  Source/Android/src/org/dolphinemu/dolphinemu/about/DolphinInfoFragment.java
... ...
@@ -1,5 +1,5 @@
1 1
 /**
2  
- * Copyright 2013 Dolphin Emulator Project
  2
+ * Copyright 2014 Dolphin Emulator Project
3 3
  * Licensed under GPLv2
4 4
  * Refer to the license.txt file included.
5 5
  */
@@ -18,8 +18,6 @@
18 18
 
19 19
 import org.dolphinemu.dolphinemu.NativeLibrary;
20 20
 import org.dolphinemu.dolphinemu.R;
21  
-import org.dolphinemu.dolphinemu.about.AboutActivity.AboutFragmentItem;
22  
-import org.dolphinemu.dolphinemu.about.AboutActivity.InfoFragmentAdapter;
23 21
 import org.dolphinemu.dolphinemu.utils.EGLHelper;
24 22
 
25 23
 /**
@@ -41,7 +39,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
41 39
 		Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), eglHelper.supportsGLES3() ? yes : no));
42 40
 		Input.add(new AboutFragmentItem(getString(R.string.supports_neon),  NativeLibrary.SupportsNEON() ? yes : no));
43 41
 
44  
-		InfoFragmentAdapter adapter = new InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
  42
+		AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
45 43
 		rootView.setAdapter(adapter);
46 44
 		rootView.setEnabled(false);  // Makes the list view non-clickable.
47 45
 
10  Source/Android/src/org/dolphinemu/dolphinemu/about/GLES2InfoFragment.java
... ...
@@ -1,5 +1,5 @@
1 1
 /**
2  
- * Copyright 2013 Dolphin Emulator Project
  2
+ * Copyright 2014 Dolphin Emulator Project
3 3
  * Licensed under GPLv2
4 4
  * Refer to the license.txt file included.
5 5
  */
@@ -57,12 +57,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
57 57
 		final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
58 58
 
59 59
 		ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
60  
-		List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
  60
+		List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
61 61
 
62 62
 		for (Limit limit : Limits)
63 63
 		{
64 64
 			Log.i("GLES2InfoFragment", "Getting enum " + limit.name);
65  
-			Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
  65
+			Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
66 66
 		}
67 67
 
68 68
 		// Get extensions manually
@@ -72,9 +72,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
72 72
 		{
73 73
 			extensionsBuilder.append(extension).append('\n');
74 74
 		}
75  
-		Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 2.0 Extensions", extensionsBuilder.toString()));
  75
+		Input.add(new AboutFragmentItem("OpenGL ES 2.0 Extensions", extensionsBuilder.toString()));
76 76
 
77  
-		AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
  77
+		AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
78 78
 		rootView.setAdapter(adapter);
79 79
 
80 80
 		return rootView;
10  Source/Android/src/org/dolphinemu/dolphinemu/about/GLES3InfoFragment.java
... ...
@@ -1,5 +1,5 @@
1 1
 /**
2  
- * Copyright 2013 Dolphin Emulator Project
  2
+ * Copyright 2014 Dolphin Emulator Project
3 3
  * Licensed under GPLv2
4 4
  * Refer to the license.txt file included.
5 5
  */
@@ -89,12 +89,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
89 89
 		final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES3_BIT_KHR);
90 90
 
91 91
 		ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
92  
-		List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
  92
+		List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
93 93
 
94 94
 		for (Limit limit : Limits)
95 95
 		{
96 96
 			Log.i("GLES3InfoFragment", "Getting enum " + limit.name);
97  
-			Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
  97
+			Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
98 98
 		}
99 99
 
100 100
 		// Get extensions manually
@@ -104,9 +104,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
104 104
 		{
105 105
 			extensionsBuilder.append(eglHelper.glGetStringi(GLES30.GL_EXTENSIONS, i)).append('\n');
106 106
 		}
107  
-		Input.add(new AboutActivity.AboutFragmentItem("OpenGL ES 3.0 Extensions", extensionsBuilder.toString()));
  107
+		Input.add(new AboutFragmentItem("OpenGL ES 3.0 Extensions", extensionsBuilder.toString()));
108 108
 
109  
-		AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
  109
+		AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
110 110
 		rootView.setAdapter(adapter);
111 111
 
112 112
 		return rootView;
10  Source/Android/src/org/dolphinemu/dolphinemu/about/GLInfoFragment.java
... ...
@@ -1,5 +1,5 @@
1 1
 /**
2  
- * Copyright 2013 Dolphin Emulator Project
  2
+ * Copyright 2014 Dolphin Emulator Project
3 3
  * Licensed under GPLv2
4 4
  * Refer to the license.txt file included.
5 5
  */
@@ -44,12 +44,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
44 44
 		final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_BIT);
45 45
 
46 46
 		ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
47  
-		List<AboutActivity.AboutFragmentItem> Input = new ArrayList<AboutActivity.AboutFragmentItem>();
  47
+		List<AboutFragmentItem> Input = new ArrayList<AboutFragmentItem>();
48 48
 
49 49
 		for (Limit limit : Limits)
50 50
 		{
51 51
 			Log.i("GLInfoFragment", "Getting enum " + limit.name);
52  
-			Input.add(new AboutActivity.AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
  52
+			Input.add(new AboutFragmentItem(limit.name, limit.GetValue(eglHelper)));
53 53
 		}
54 54
 
55 55
 		// Get extensions manually
@@ -59,9 +59,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
59 59
 		{
60 60
 			extensionsBuilder.append(eglHelper.glGetStringi(GL10.GL_EXTENSIONS, i)).append('\n');
61 61
 		}
62  
-		Input.add(new AboutActivity.AboutFragmentItem("OpenGL Extensions", extensionsBuilder.toString()));
  62
+		Input.add(new AboutFragmentItem("OpenGL Extensions", extensionsBuilder.toString()));
63 63
 
64  
-		AboutActivity.InfoFragmentAdapter adapter = new AboutActivity.InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
  64
+		AboutInfoFragmentAdapter adapter = new AboutInfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
65 65
 		rootView.setAdapter(adapter);
66 66
 
67 67
 		return rootView;
6  Source/Android/src/org/dolphinemu/dolphinemu/about/Limit.java
... ...
@@ -1,3 +1,9 @@
  1
+/**
  2
+ * Copyright 2014 Dolphin Emulator Project
  3
+ * Licensed under GPLv2
  4
+ * Refer to the license.txt file included.
  5
+ */
  6
+
1 7
 package org.dolphinemu.dolphinemu.about;
2 8
 
3 9
 import org.dolphinemu.dolphinemu.utils.EGLHelper;

0 notes on commit 8863eb0

Please sign in to comment.
Something went wrong with that request. Please try again.