Skip to content

Commit

Permalink
[Android] Make the GameListFragment extend a ListFragment instead of …
Browse files Browse the repository at this point in the history
…a Fragment. This allows us to simplify behavior a little by eliminating the need for an AdapterView. Now we just override "onListClick" and achieve the same result.
  • Loading branch information
lioncash committed Oct 2, 2013
1 parent 16fb0b0 commit cd6a863
Showing 1 changed file with 12 additions and 18 deletions.
Expand Up @@ -7,13 +7,12 @@
package org.dolphinemu.dolphinemu.gamelist;

import android.app.Activity;
import android.app.Fragment;
import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

Expand All @@ -31,9 +30,9 @@


/**
* The {@link Fragment} responsible for displaying the game list.
* The {@link ListFragment} responsible for displaying the game list.
*/
public final class GameListFragment extends Fragment
public final class GameListFragment extends ListFragment
{
private ListView mMainList;
private GameListAdapter mGameAdapter;
Expand All @@ -60,7 +59,7 @@ public interface OnGameListZeroListener
*/
public GameListAdapter getAdapter()
{
return mGameAdapter;
return mGameAdapter;
}

private void Fill()
Expand Down Expand Up @@ -110,28 +109,23 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
{
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist);
mMainList.setOnItemClickListener(mGameItemClickListener);

Fill();

return mMainList;
}

private final AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()

@Override
public void onListItemClick(ListView listView, View view, int position, long id)
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
GameListItem item = mGameAdapter.getItem(position);
onFileClick(item.getPath());
}
};
GameListItem item = mGameAdapter.getItem(position);

private void onFileClick(String o)
{
Toast.makeText(mMe, String.format(getString(R.string.file_clicked), o), Toast.LENGTH_SHORT).show();
// Show a toast indicating which game was clicked.
Toast.makeText(mMe, String.format(getString(R.string.file_clicked), item.getPath()), Toast.LENGTH_SHORT).show();

// Start the emulation activity and send the path of the clicked ROM to it.
Intent intent = new Intent(mMe, EmulationActivity.class);
intent.putExtra("SelectedGame", o);
intent.putExtra("SelectedGame", item.getPath());
mMe.startActivity(intent);
}

Expand Down

0 comments on commit cd6a863

Please sign in to comment.