[Android] Get rid of some unnecessary onAttach overrides in AboutFragment, VideoSettingsFragment, and FolderBrowser. These can just be replaced with calls to getActivity().

This commit is contained in:
Lioncash 2013-11-14 10:45:45 -05:00
parent 1942d79c5b
commit f15a0c17d0
3 changed files with 7 additions and 40 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.video.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)
{ {
@ -42,22 +39,13 @@ public final class AboutFragment extends ListFragment
Input.add(new AboutFragmentItem(getString(R.string.build_revision), NativeLibrary.GetVersionString())); Input.add(new AboutFragmentItem(getString(R.string.build_revision), NativeLibrary.GetVersionString()));
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));
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
{ {

View File

@ -6,7 +6,6 @@
package org.dolphinemu.dolphinemu.folderbrowser; package org.dolphinemu.dolphinemu.folderbrowser;
import android.app.Activity;
import android.app.ListFragment; import android.app.ListFragment;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
@ -37,7 +36,6 @@ import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
*/ */
public final class FolderBrowser extends ListFragment public final class FolderBrowser extends ListFragment
{ {
private Activity m_activity;
private FolderBrowserAdapter adapter; private FolderBrowserAdapter adapter;
private ListView mFolderBrowserList; private ListView mFolderBrowserList;
private ListView rootView; private ListView rootView;
@ -46,7 +44,9 @@ public final class FolderBrowser extends ListFragment
// Populates the FolderView with the given currDir's contents. // Populates the FolderView with the given currDir's contents.
private void Fill(File currDir) private void Fill(File currDir)
{ {
m_activity.setTitle(String.format(getString(R.string.current_dir), currDir.getName())); // Change the activity title to reflect the current directory the FolderBrowser is in.
getActivity().setTitle(String.format(getString(R.string.current_dir), currDir.getName()));
File[] dirs = currDir.listFiles(); File[] dirs = currDir.listFiles();
List<FolderBrowserItem> dir = new ArrayList<FolderBrowserItem>(); List<FolderBrowserItem> dir = new ArrayList<FolderBrowserItem>();
List<FolderBrowserItem> fls = new ArrayList<FolderBrowserItem>(); List<FolderBrowserItem> fls = new ArrayList<FolderBrowserItem>();
@ -96,7 +96,7 @@ public final class FolderBrowser extends ListFragment
if (!currDir.getPath().equalsIgnoreCase("/")) if (!currDir.getPath().equalsIgnoreCase("/"))
dir.add(0, new FolderBrowserItem("..", getString(R.string.parent_directory), currDir.getParent())); dir.add(0, new FolderBrowserItem("..", getString(R.string.parent_directory), currDir.getParent()));
adapter = new FolderBrowserAdapter(m_activity, R.layout.gamelist_folderbrowser_list, dir); adapter = new FolderBrowserAdapter(getActivity(), R.layout.gamelist_folderbrowser_list, dir);
mFolderBrowserList = (ListView) rootView.findViewById(R.id.gamelist); mFolderBrowserList = (ListView) rootView.findViewById(R.id.gamelist);
mFolderBrowserList.setAdapter(adapter); mFolderBrowserList.setAdapter(adapter);
} }
@ -128,16 +128,6 @@ public final class FolderBrowser extends ListFragment
return mFolderBrowserList; return mFolderBrowserList;
} }
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
// Cache the activity instance.
m_activity = activity;
}
private void FolderSelected() private void FolderSelected()
{ {
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
@ -168,6 +158,6 @@ public final class FolderBrowser extends ListFragment
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), currentDir.getPath()); NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), currentDir.getPath());
} }
((GameListActivity)m_activity).SwitchPage(0); ((GameListActivity)getActivity()).SwitchPage(0);
} }
} }

View File

@ -6,7 +6,6 @@
package org.dolphinemu.dolphinemu.settings.video; package org.dolphinemu.dolphinemu.settings.video;
import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
@ -28,7 +27,6 @@ public final class VideoSettingsFragment extends PreferenceFragment
public static String m_GLVendor; public static String m_GLVendor;
public static String m_GLRenderer; public static String m_GLRenderer;
public static String m_GLExtensions; public static String m_GLExtensions;
private Activity m_activity;
/** /**
* Class which provides a means to retrieve various * Class which provides a means to retrieve various
@ -225,7 +223,7 @@ public final class VideoSettingsFragment extends PreferenceFragment
// denotes the placement on the UI. So if more elements are // denotes the placement on the UI. So if more elements are
// added to the video settings, these may need to change. // added to the video settings, these may need to change.
// //
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(m_activity); final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
final PreferenceScreen mainScreen = getPreferenceScreen(); final PreferenceScreen mainScreen = getPreferenceScreen();
if (videoBackends.getValue().equals("Software Renderer")) if (videoBackends.getValue().equals("Software Renderer"))
@ -266,13 +264,4 @@ public final class VideoSettingsFragment extends PreferenceFragment
} }
}); });
} }
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
// Cache the activity instance.
m_activity = activity;
}
} }