summaryrefslogtreecommitdiff
path: root/Source/Android/src
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2013-06-24 12:16:59 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2013-06-24 12:17:31 -0500
commit143d2eccb49b700ccd00dfa229b03d1d1a51533c (patch)
treefc0cb256d82ca6afa12b943f130a4ef4e5668b68 /Source/Android/src
parent970661a0c5fc0c1ad481e0498dbe0320a704ed20 (diff)
[Android] Open drawer if there isn't anything in the game list, instead of on first run.
Diffstat (limited to 'Source/Android/src')
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java116
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java121
2 files changed, 137 insertions, 100 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
index 25d3adb9fb..41b0ecfd9c 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
@@ -10,17 +10,13 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
-import java.io.File;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
@@ -28,7 +24,8 @@ import java.util.List;
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
-public class GameListActivity extends Activity {
+public class GameListActivity extends Activity
+ implements GameListFragment.OnGameListZeroListener{
enum keyTypes {TYPE_STRING, TYPE_BOOL};
@@ -37,90 +34,19 @@ public class GameListActivity extends Activity {
private SideMenuAdapter mDrawerAdapter;
private ListView mDrawerList;
- private static GameListActivity me;
+ private static GameListActivity mMe;
- public static class GameListFragment extends Fragment {
- private ListView mMainList;
- private GameListAdapter mGameAdapter;
-
- public GameListFragment() {
- // Empty constructor required for fragment subclasses
- }
- private void Fill()
- {
- List<GameListItem>fls = new ArrayList<GameListItem>();
- String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
- int intDirectories = Integer.parseInt(Directories);
- for (int a = 0; a < intDirectories; ++a)
- {
- String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(a), "");
- File currentDir = new File(BrowseDir);
- File[]dirs = currentDir.listFiles();
- try
- {
- for(File ff: dirs)
- {
- if (ff.getName().charAt(0) != '.')
- if(!ff.isDirectory())
- if (ff.getName().toLowerCase().contains(".gcm") ||
- ff.getName().toLowerCase().contains(".iso") ||
- ff.getName().toLowerCase().contains(".wbfs") ||
- ff.getName().toLowerCase().contains(".gcz") ||
- ff.getName().toLowerCase().contains(".dol") ||
- ff.getName().toLowerCase().contains(".elf") ||
- ff.getName().toLowerCase().contains(".dff"))
- fls.add(new GameListItem(me.getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
- }
- }
- catch(Exception ignored)
- {
- }
- }
- Collections.sort(fls);
-
- mGameAdapter = new GameListAdapter(me, R.layout.gamelist_layout, fls);
- mMainList.setAdapter(mGameAdapter);
- }
-
- @Override
- 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);
- mMainList.setOnItemClickListener(mGameItemClickListener);
-
- Fill();
-
- return mMainList;
- }
- private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
- {
- public void onItemClick(AdapterView<?> parent, View view, int position, long id)
- {
- GameListItem o = mGameAdapter.getItem(position);
- if(!(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")))
- {
- onFileClick(o.getPath());
- }
- }
- };
- private void onFileClick(String o)
- {
- Toast.makeText(me, "File Clicked: " + o, Toast.LENGTH_SHORT).show();
-
- Intent intent = new Intent();
- intent.putExtra("Select", o);
- me.setResult(Activity.RESULT_OK, intent);
-
- me.finish();
- }
+ // Called from the game list fragment
+ public void onZeroFiles()
+ {
+ mDrawerLayout.openDrawer(mDrawerList);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gamelist_activity);
- me = this;
+ mMe = this;
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
@@ -152,16 +78,6 @@ public class GameListActivity extends Activity {
mDrawerLayout.setDrawerListener(mDrawerToggle);
recreateFragment();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- boolean bFirstRun = prefs.getBoolean("FirstRun", true);
- if (bFirstRun)
- {
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("FirstRun", false);
- editor.commit();
- mDrawerLayout.openDrawer(mDrawerList);
- }
}
private void recreateFragment()
@@ -181,23 +97,23 @@ public class GameListActivity extends Activity {
switch(o.getID())
{
case 0:
- Toast.makeText(me, "Loading up the browser", Toast.LENGTH_SHORT).show();
- Intent ListIntent = new Intent(me, FolderBrowser.class);
+ Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show();
+ Intent ListIntent = new Intent(mMe, FolderBrowser.class);
startActivityForResult(ListIntent, 1);
break;
case 1:
- Toast.makeText(me, "Loading up settings", Toast.LENGTH_SHORT).show();
- Intent SettingIntent = new Intent(me, PrefsActivity.class);
+ Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show();
+ Intent SettingIntent = new Intent(mMe, PrefsActivity.class);
startActivityForResult(SettingIntent, 2);
break;
case 2:
- Toast.makeText(me, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
- Intent ConfigIntent = new Intent(me, InputConfigActivity.class);
+ Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
+ Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class);
startActivityForResult(ConfigIntent, 3);
break;
case 3:
- Toast.makeText(me, "Loading up About", Toast.LENGTH_SHORT).show();
- Intent AboutIntent = new Intent(me, AboutActivity.class);
+ Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show();
+ Intent AboutIntent = new Intent(mMe, AboutActivity.class);
startActivityForResult(AboutIntent, 3);
break;
default:
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java
new file mode 100644
index 0000000000..4d2e0d4236
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java
@@ -0,0 +1,121 @@
+package org.dolphinemu.dolphinemu;
+
+import android.app.Activity;
+import android.app.Fragment;
+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;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Copyright 2013 Dolphin Emulator Project
+ * Licensed under GPLv2
+ * Refer to the license.txt file included.
+ */
+public class GameListFragment extends Fragment
+{
+ private ListView mMainList;
+ private GameListAdapter mGameAdapter;
+ private static GameListActivity mMe;
+ OnGameListZeroListener mCallback;
+
+ public interface OnGameListZeroListener {
+ public void onZeroFiles();
+ }
+
+ public GameListFragment() {
+ // Empty constructor required for fragment subclasses
+ }
+ private void Fill()
+ {
+ List<GameListItem> fls = new ArrayList<GameListItem>();
+ String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
+ int intDirectories = Integer.parseInt(Directories);
+ for (int a = 0; a < intDirectories; ++a)
+ {
+ String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(a), "");
+ File currentDir = new File(BrowseDir);
+ File[]dirs = currentDir.listFiles();
+ try
+ {
+ for(File ff: dirs)
+ {
+ if (ff.getName().charAt(0) != '.')
+ if(!ff.isDirectory())
+ if (ff.getName().toLowerCase().contains(".gcm") ||
+ ff.getName().toLowerCase().contains(".iso") ||
+ ff.getName().toLowerCase().contains(".wbfs") ||
+ ff.getName().toLowerCase().contains(".gcz") ||
+ ff.getName().toLowerCase().contains(".dol") ||
+ ff.getName().toLowerCase().contains(".elf") ||
+ ff.getName().toLowerCase().contains(".dff"))
+ fls.add(new GameListItem(mMe.getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
+ }
+ }
+ catch(Exception ignored)
+ {
+ }
+ }
+ Collections.sort(fls);
+
+ mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
+ mMainList.setAdapter(mGameAdapter);
+ if (fls.size() == 0)
+ mCallback.onZeroFiles();
+ }
+
+ @Override
+ 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);
+ mMainList.setOnItemClickListener(mGameItemClickListener);
+
+ Fill();
+
+ return mMainList;
+ }
+ private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
+ {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
+ {
+ GameListItem o = mGameAdapter.getItem(position);
+ if(!(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")))
+ {
+ onFileClick(o.getPath());
+ }
+ }
+ };
+ private void onFileClick(String o)
+ {
+ Toast.makeText(mMe, "File Clicked: " + o, Toast.LENGTH_SHORT).show();
+
+ Intent intent = new Intent();
+ intent.putExtra("Select", o);
+ mMe.setResult(Activity.RESULT_OK, intent);
+ mMe.finish();
+ }
+ @Override
+ 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 {
+ mCallback = (OnGameListZeroListener) activity;
+ mMe = (GameListActivity) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()
+ + " must implement OnGameListZeroListener");
+ }
+ }
+} \ No newline at end of file