diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowser.java index 63a4f2bbd7..8aa561376a 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowser.java @@ -6,7 +6,6 @@ package org.dolphinemu.dolphinemu.folderbrowser; -import android.app.Activity; import android.app.ListFragment; import android.os.Bundle; import android.os.Environment; @@ -37,16 +36,18 @@ import org.dolphinemu.dolphinemu.gamelist.GameListActivity; */ public final class FolderBrowser extends ListFragment { - private Activity m_activity; private FolderBrowserAdapter adapter; - private ListView mFolderBrowserList; - private ListView rootView; private static File currentDir = null; // Populates the FolderView with the given currDir's contents. private void Fill(File currDir) { - m_activity.setTitle(String.format(getString(R.string.current_dir), currDir.getName())); + // Clear the adapter of previous items. + adapter.clear(); + + // Set the activity title to the current directory the FolderBrowser is in. + getActivity().setTitle(String.format(getString(R.string.current_dir), currDir.getName())); + File[] dirs = currDir.listFiles(); List dir = new ArrayList(); List fls = new ArrayList(); @@ -96,9 +97,9 @@ public final class FolderBrowser extends ListFragment if (!currDir.getPath().equalsIgnoreCase("/")) dir.add(0, new FolderBrowserItem("..", getString(R.string.parent_directory), currDir.getParent())); - adapter = new FolderBrowserAdapter(m_activity, R.layout.gamelist_folderbrowser_list_item, dir); - mFolderBrowserList = (ListView) rootView.findViewById(R.id.gamelist); - mFolderBrowserList.setAdapter(adapter); + // Add the items to the adapter and notify the adapter users of its new contents. + adapter.addAll(dir); + adapter.notifyDataSetChanged(); } @Override @@ -122,22 +123,14 @@ public final class FolderBrowser extends ListFragment if(currentDir == null) currentDir = new File(Environment.getExternalStorageDirectory().getPath()); - rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false); + ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false); + adapter = new FolderBrowserAdapter(getActivity(), R.layout.gamelist_folderbrowser_list_item); + rootView.setAdapter(adapter); Fill(currentDir); - return mFolderBrowserList; + return rootView; } - @Override - public void onAttach(Activity activity) - { - super.onAttach(activity); - - // Cache the activity instance. - m_activity = activity; - } - - private void FolderSelected() { String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); @@ -168,6 +161,6 @@ public final class FolderBrowser extends ListFragment NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), currentDir.getPath()); } - ((GameListActivity)m_activity).SwitchPage(0); + ((GameListActivity)getActivity()).SwitchPage(0); } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowserAdapter.java index a9dc002733..f97799e6e4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/folderbrowser/FolderBrowserAdapter.java @@ -6,15 +6,12 @@ package org.dolphinemu.dolphinemu.folderbrowser; -import java.util.List; - import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; import org.dolphinemu.dolphinemu.R; @@ -40,7 +37,6 @@ public final class FolderBrowserAdapter extends ArrayAdapter private final Context context; private final int id; - private final List items; private ViewHolder viewHolder; /** @@ -48,21 +44,13 @@ public final class FolderBrowserAdapter extends ArrayAdapter * * @param context The current {@link Context}. * @param resourceId The resource ID for a layout file containing a layout to use when instantiating views. - * @param objects The objects to represent in the {@link ListView}. */ - public FolderBrowserAdapter(Context context, int resourceId, List objects) + public FolderBrowserAdapter(Context context, int resourceId) { - super(context, resourceId, objects); + super(context, resourceId); this.context = context; this.id = resourceId; - this.items = objects; - } - - @Override - public FolderBrowserItem getItem(int i) - { - return items.get(i); } @Override @@ -85,7 +73,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter viewHolder = (ViewHolder) convertView.getTag(); } - final FolderBrowserItem item = items.get(position); + final FolderBrowserItem item = getItem(position); if (item != null) { if (viewHolder.title != null)