Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] General formatting clean-up.
Made some class variables final, since they should convey that they cannot be changed after the first assignment.
Made the formatting consistent between files.
  • Loading branch information
lioncash committed Aug 14, 2013
1 parent 6f1612d commit 94397a4
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 147 deletions.
21 changes: 14 additions & 7 deletions Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
Expand Up @@ -16,7 +16,8 @@
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
public final class AboutFragment extends Fragment {
public final class AboutFragment extends Fragment
{
private static Activity m_activity;

private ListView mMainList;
Expand All @@ -25,13 +26,14 @@ public final class AboutFragment extends Fragment {
boolean Configuring = false;
boolean firstEvent = true;

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist);

Expand All @@ -47,15 +49,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

return mMainList;
}

@Override
public void onAttach(Activity activity) {
public void onAttach(Activity activity)
{
super.onAttach(activity);

// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
try
{
m_activity = activity;
} catch (ClassCastException e) {
}
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
Expand Down
36 changes: 25 additions & 11 deletions Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
Expand Up @@ -25,24 +25,32 @@
private float screenWidth;
private float screenHeight;

private void CopyAsset(String asset, String output) {
private void CopyAsset(String asset, String output)
{
InputStream in = null;
OutputStream out = null;
try {

try
{
in = getAssets().open(asset);
out = new FileOutputStream(output);
copyFile(in, out);
in.close();
out.close();
} catch(IOException e) {
}
catch(IOException e)
{
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e);
}
}

private void copyFile(InputStream in, OutputStream out) throws IOException {
private void copyFile(InputStream in, OutputStream out) throws IOException
{
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){

while((read = in.read(buffer)) != -1)
{
out.write(buffer, 0, read);
}
}
Expand All @@ -54,13 +62,15 @@ public void onStop()
if (Running)
NativeLibrary.StopEmulation();
}

@Override
public void onPause()
{
super.onPause();
if (Running)
NativeLibrary.PauseEmulation();
}

@Override
public void onResume()
{
Expand All @@ -71,7 +81,8 @@ public void onResume()

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if (savedInstanceState == null)
{
Expand Down Expand Up @@ -158,7 +169,8 @@ public boolean onTouchEvent(MotionEvent event)

// Gets button presses
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
public boolean dispatchKeyEvent(KeyEvent event)
{
int action = 0;

// Special catch for the back key
Expand All @@ -180,7 +192,8 @@ public boolean dispatchKeyEvent(KeyEvent event) {

if (Running)
{
switch (event.getAction()) {
switch (event.getAction())
{
case KeyEvent.ACTION_DOWN:
action = 0;
break;
Expand All @@ -198,8 +211,10 @@ public boolean dispatchKeyEvent(KeyEvent event) {
}

@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running) {
public boolean dispatchGenericMotionEvent(MotionEvent event)
{
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running)
{
return super.dispatchGenericMotionEvent(event);
}

Expand All @@ -213,5 +228,4 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {

return true;
}

}
17 changes: 11 additions & 6 deletions Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
Expand Up @@ -14,7 +14,8 @@
import java.io.File;
import java.util.*;

public final class FolderBrowser extends Fragment {
public final class FolderBrowser extends Fragment
{
private Activity m_activity;
private FolderBrowserAdapter adapter;
private ListView mDrawerList;
Expand Down Expand Up @@ -77,9 +78,9 @@ else if (invalidExts.contains(entryName.toLowerCase().substring(entryName.lastIn
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if(currentDir == null)
currentDir = new File(Environment.getExternalStorageDirectory().getPath());
Expand Down Expand Up @@ -111,14 +112,18 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
};

@Override
public void onAttach(Activity activity) {
public void onAttach(Activity activity)
{
super.onAttach(activity);

// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
try
{
m_activity = activity;
} catch (ClassCastException e) {
}
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
Expand Down
@@ -1,7 +1,6 @@
package org.dolphinemu.dolphinemu;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -11,13 +10,14 @@

import java.util.List;

public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>{
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{
private final Context c;
private final int id;
private final List<FolderBrowserItem> items;

private Context c;
private int id;
private List<FolderBrowserItem> items;

public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects) {
public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects)
{
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
Expand Down

0 comments on commit 94397a4

Please sign in to comment.