Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] General cleanup. Add more documentation.
Remove some accidental changes that slipped through. Don't want to have input settings in the settings menu just yet.
  • Loading branch information
lioncash committed Aug 22, 2013
1 parent 951bbcd commit 41c25d0
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 70 deletions.
Expand Up @@ -23,17 +23,8 @@
public final class AboutFragment extends Fragment
{
private static Activity m_activity;

private ListView mMainList;

private FolderBrowserAdapter adapter;
boolean Configuring = false;
boolean firstEvent = true;

public AboutFragment()
{
// Empty constructor required for fragment subclasses
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Expand Down
Expand Up @@ -4,12 +4,20 @@
import android.view.SurfaceHolder;
import android.view.SurfaceView;

/**
* The surface that rendering is done to.
*/
public final class NativeGLSurfaceView extends SurfaceView
{
private static Thread myRun;
private static boolean Running = false;
private static boolean Created = false;

/**
* Constructor.
*
* @param context The current {@link Context}.
*/
public NativeGLSurfaceView(Context context)
{
super(context);
Expand Down
Expand Up @@ -19,6 +19,19 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;

/**
* A basic folder browser {@link Fragment} that allows
* the user to select ISOs/ROMs for playing within the
* emulator.
* <p>
* Any valid ISO/ROM selected in this will be added to
* the game list for easy browsing the next time the
* application is used.
* <p>
* Note that invalid items will be shown in the color red. <br/>
* Also note that this file browser does not display files
* or directories that are hidden
*/
public final class FolderBrowser extends Fragment
{
private Activity m_activity;
Expand Down Expand Up @@ -69,7 +82,7 @@ else if (invalidExts.contains(entryName.toLowerCase().substring(entryName.lastIn
}
catch (Exception ex)
{
Log.d("EXCEPTION", ex.toString());
Log.e("Exception-FolderBrowser", ex.toString());
}
}

Expand Down Expand Up @@ -136,6 +149,8 @@ public void onAttach(Activity activity)
+ " must implement OnGameListZeroListener");
}
}


private void FolderSelected()
{
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
Expand Down
Expand Up @@ -12,6 +12,12 @@

import org.dolphinemu.dolphinemu.R;

/**
* The {@link ArrayAdapter} that backs the file browser.
* <p>
* This is responsible for correctly handling the display
* of the items for the UI.
*/
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{
private final Context c;
Expand All @@ -26,6 +32,7 @@ public FolderBrowserAdapter(Context context, int textViewResourceId, List<Folder
items = objects;
}

@Override
public FolderBrowserItem getItem(int i)
{
return items.get(i);
Expand Down
@@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/

package org.dolphinemu.dolphinemu.gamelist;

import android.app.Activity;
Expand Down Expand Up @@ -26,9 +32,8 @@
import org.dolphinemu.dolphinemu.sidemenu.SideMenuItem;

/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The activity that implements all of the functions
* for the game list.
*/
public final class GameListActivity extends Activity
implements GameListFragment.OnGameListZeroListener
Expand All @@ -40,8 +45,24 @@ public final class GameListActivity extends Activity
private DrawerLayout mDrawerLayout;
private SideMenuAdapter mDrawerAdapter;
private ListView mDrawerList;

/**
* Interface defining methods which handle
* the binding of specific key presses within
* the input mapping settings.
*/
public interface OnGameConfigListener
{
boolean onMotionEvent(MotionEvent event);
boolean onKeyEvent(KeyEvent event);
}

// Called from the game list fragment
/**
* Called from the {@link GameListFragment}.
* <p>
* This is called when there are no games
* currently present within the game list.
*/
public void onZeroFiles()
{
mDrawerLayout.openDrawer(mDrawerList);
Expand Down Expand Up @@ -100,6 +121,12 @@ private void recreateFragment()
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}

/**
* Switches to the {@link Fragment} represented
* by the given ID number.
*
* @param toPage the number representing the {@link Fragment} to switch to.l
*/
public void SwitchPage(int toPage)
{
if (mCurFragmentNum == toPage)
Expand Down Expand Up @@ -194,11 +221,11 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
SwitchPage(o.getID());
}
};

/**
* When using the ActionBarDrawerToggle, you must call it during
* onPostCreate() and onConfigurationChanged()...
*/

@Override
protected void onPostCreate(Bundle savedInstanceState)
{
Expand Down Expand Up @@ -235,17 +262,12 @@ public boolean onOptionsItemSelected(MenuItem item)
return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed()
{
SwitchPage(0);
}

public interface OnGameConfigListener
{
public boolean onMotionEvent(MotionEvent event);
public boolean onKeyEvent(KeyEvent event);
}

// Gets move(triggers, joystick) events
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event)
Expand Down
@@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/

package org.dolphinemu.dolphinemu.gamelist;

import android.content.Context;
Expand All @@ -12,6 +18,11 @@

import org.dolphinemu.dolphinemu.R;

/**
* The adapter backing the game list.
* <p>
* Responsible for handling each game list item individually.
*/
public final class GameListAdapter extends ArrayAdapter<GameListItem>
{
private final Context c;
Expand All @@ -26,6 +37,7 @@ public GameListAdapter(Context context, int textViewResourceId, List<GameListIte
items = objects;
}

@Override
public GameListItem getItem(int i)
{
return items.get(i);
Expand Down
@@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/

package org.dolphinemu.dolphinemu.gamelist;

import android.app.Activity;
Expand All @@ -22,26 +28,28 @@
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;


/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The {@link Fragment} responsible for displaying the game list.
*/
public final class GameListFragment extends Fragment
{
private ListView mMainList;
private GameListAdapter mGameAdapter;
private static GameListActivity mMe;
OnGameListZeroListener mCallback;
private OnGameListZeroListener mCallback;

/**
* Interface that defines how to handle the case
* when there are zero game.
*/
public interface OnGameListZeroListener
{
public void onZeroFiles();
}

public GameListFragment()
{
// Empty constructor required for fragment subclasses
/**
* This is called when there are no games
* currently present within the game list.
*/
void onZeroFiles();
}

private void Fill()
Expand Down Expand Up @@ -97,8 +105,11 @@ private void Fill()

mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
mMainList.setAdapter(mGameAdapter);
if (fls.size() == 0)

if (fls.isEmpty())
{
mCallback.onZeroFiles();
}
}

@Override
Expand Down
@@ -1,15 +1,25 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/

package org.dolphinemu.dolphinemu.gamelist;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import org.dolphinemu.dolphinemu.NativeLibrary;

/**
* Represents an item in the game list.
*/
public final class GameListItem implements Comparable<GameListItem>
{
private String name;
Expand All @@ -18,6 +28,15 @@ public final class GameListItem implements Comparable<GameListItem>
private final boolean isValid;
private Bitmap image;

/**
* Constructor.
*
* @param ctx The current {@link Context}
* @param name The name of this GameListItem.
* @param data The subtitle for this GameListItem
* @param path The file path for the game represented by this GameListItem.
* @param isValid Whether or not the emulator can handle this file.
*/
public GameListItem(Context ctx, String name, String data, String path, boolean isValid)
{
this.name = name;
Expand All @@ -44,8 +63,7 @@ public GameListItem(Context ctx, String name, String data, String path, boolean
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("Exception-GameListItem", e.toString());
}
}
else
Expand All @@ -57,26 +75,51 @@ public GameListItem(Context ctx, String name, String data, String path, boolean
}
}

/**
* Gets the name of this GameListItem.
*
* @return the name of this GameListItem.
*/
public String getName()
{
return name;
}

/**
* Gets the subtitle of this GameListItem.
*
* @return the subtitle of this GameListItem.
*/
public String getData()
{
return data;
}

/**
* Gets the file path of the game represented by this GameListItem.
*
* @return the file path of the game represented by this GameListItem.
*/
public String getPath()
{
return path;
}

/**
* Gets the image data for this game as a {@link Bitmap}.
*
* @return the image data for this game as a {@link Bitmap}.
*/
public Bitmap getImage()
{
return image;
}

/**
* Gets whether or not the emulator can handle this GameListItem.
*
* @return true, if this GameListItem can be handled by the emulator; false, otherwise.
*/
public boolean isValid()
{
return isValid;
Expand Down

0 comments on commit 41c25d0

Please sign in to comment.