mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
[Android] Make the FolderBrowser extend a ListFragment instead of a regular fragment. Lets us get rid of the need for an AdapterView.OnItemClickListener when handling list item clicks. Simplifies the implementation of the FolderBrowser a tiny bit.
This commit is contained in:
parent
85f067780a
commit
49fff7979b
@ -7,14 +7,13 @@
|
|||||||
package org.dolphinemu.dolphinemu.folderbrowser;
|
package org.dolphinemu.dolphinemu.folderbrowser;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.ListFragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -36,12 +35,12 @@ import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
|
|||||||
* Note that this file browser does not display files
|
* Note that this file browser does not display files
|
||||||
* or directories that are hidden
|
* or directories that are hidden
|
||||||
*/
|
*/
|
||||||
public final class FolderBrowser extends Fragment
|
public final class FolderBrowser extends ListFragment
|
||||||
{
|
{
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
private FolderBrowserAdapter adapter;
|
private FolderBrowserAdapter adapter;
|
||||||
private ListView mDrawerList;
|
private ListView mFolderBrowserList;
|
||||||
private View rootView;
|
private ListView rootView;
|
||||||
private static File currentDir = null;
|
private static File currentDir = null;
|
||||||
|
|
||||||
// Populates the FolderView with the given currDir's contents.
|
// Populates the FolderView with the given currDir's contents.
|
||||||
@ -94,9 +93,23 @@ public final class FolderBrowser extends Fragment
|
|||||||
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(m_activity, R.layout.gamelist_folderbrowser_list, dir);
|
||||||
mDrawerList = (ListView) rootView.findViewById(R.id.gamelist);
|
mFolderBrowserList = (ListView) rootView.findViewById(R.id.gamelist);
|
||||||
mDrawerList.setAdapter(adapter);
|
mFolderBrowserList.setAdapter(adapter);
|
||||||
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListItemClick(ListView lv, View v, int position, long id)
|
||||||
|
{
|
||||||
|
FolderBrowserItem item = adapter.getItem(position);
|
||||||
|
if(item.isDirectory())
|
||||||
|
{
|
||||||
|
currentDir = new File(item.getPath());
|
||||||
|
Fill(currentDir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FolderSelected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,29 +118,12 @@ public final class FolderBrowser extends Fragment
|
|||||||
if(currentDir == null)
|
if(currentDir == null)
|
||||||
currentDir = new File(Environment.getExternalStorageDirectory().getPath());
|
currentDir = new File(Environment.getExternalStorageDirectory().getPath());
|
||||||
|
|
||||||
rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
|
rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false);
|
||||||
|
|
||||||
Fill(currentDir);
|
Fill(currentDir);
|
||||||
return mDrawerList;
|
return mFolderBrowserList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
|
|
||||||
{
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
|
||||||
{
|
|
||||||
FolderBrowserItem item = adapter.getItem(position);
|
|
||||||
if(item.isDirectory())
|
|
||||||
{
|
|
||||||
currentDir = new File(item.getPath());
|
|
||||||
Fill(currentDir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FolderSelected();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity)
|
public void onAttach(Activity activity)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user