mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 06:35:39 +00:00
[Android] Open drawer if there isn't anything in the game list, instead of on first run.
This commit is contained in:
parent
970661a0c5
commit
143d2eccb4
@ -10,17 +10,13 @@ import android.os.Bundle;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.ActionBarDrawerToggle;
|
import android.support.v4.app.ActionBarDrawerToggle;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +24,8 @@ import java.util.List;
|
|||||||
* Licensed under GPLv2
|
* Licensed under GPLv2
|
||||||
* Refer to the license.txt file included.
|
* 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};
|
enum keyTypes {TYPE_STRING, TYPE_BOOL};
|
||||||
|
|
||||||
@ -37,90 +34,19 @@ public class GameListActivity extends Activity {
|
|||||||
private SideMenuAdapter mDrawerAdapter;
|
private SideMenuAdapter mDrawerAdapter;
|
||||||
private ListView mDrawerList;
|
private ListView mDrawerList;
|
||||||
|
|
||||||
private static GameListActivity me;
|
private static GameListActivity mMe;
|
||||||
|
|
||||||
public static class GameListFragment extends Fragment {
|
// Called from the game list fragment
|
||||||
private ListView mMainList;
|
public void onZeroFiles()
|
||||||
private GameListAdapter mGameAdapter;
|
{
|
||||||
|
mDrawerLayout.openDrawer(mDrawerList);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.gamelist_activity);
|
setContentView(R.layout.gamelist_activity);
|
||||||
me = this;
|
mMe = this;
|
||||||
|
|
||||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
mDrawerList = (ListView) findViewById(R.id.left_drawer);
|
mDrawerList = (ListView) findViewById(R.id.left_drawer);
|
||||||
@ -152,16 +78,6 @@ public class GameListActivity extends Activity {
|
|||||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||||
|
|
||||||
recreateFragment();
|
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()
|
private void recreateFragment()
|
||||||
@ -181,23 +97,23 @@ public class GameListActivity extends Activity {
|
|||||||
switch(o.getID())
|
switch(o.getID())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Toast.makeText(me, "Loading up the browser", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show();
|
||||||
Intent ListIntent = new Intent(me, FolderBrowser.class);
|
Intent ListIntent = new Intent(mMe, FolderBrowser.class);
|
||||||
startActivityForResult(ListIntent, 1);
|
startActivityForResult(ListIntent, 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Toast.makeText(me, "Loading up settings", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show();
|
||||||
Intent SettingIntent = new Intent(me, PrefsActivity.class);
|
Intent SettingIntent = new Intent(mMe, PrefsActivity.class);
|
||||||
startActivityForResult(SettingIntent, 2);
|
startActivityForResult(SettingIntent, 2);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Toast.makeText(me, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
|
||||||
Intent ConfigIntent = new Intent(me, InputConfigActivity.class);
|
Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class);
|
||||||
startActivityForResult(ConfigIntent, 3);
|
startActivityForResult(ConfigIntent, 3);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
Toast.makeText(me, "Loading up About", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show();
|
||||||
Intent AboutIntent = new Intent(me, AboutActivity.class);
|
Intent AboutIntent = new Intent(mMe, AboutActivity.class);
|
||||||
startActivityForResult(AboutIntent, 3);
|
startActivityForResult(AboutIntent, 3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user