mirror of
https://github.com/libretro/Play-.git
synced 2024-12-13 11:35:30 +00:00
Moved some functions to VirtualMachineManager to reduce class dependencies.
VirtualMachineManager shouldn't know about MainActivity.
This commit is contained in:
parent
cb23513a82
commit
8dc3e0f7f4
@ -33,8 +33,6 @@ import com.virtualapplications.play.database.GameIndexer;
|
||||
import com.virtualapplications.play.database.GameInfo;
|
||||
import com.virtualapplications.play.database.SqliteHelper.Games;
|
||||
|
||||
import static com.virtualapplications.play.VirtualMachineManager.launchDisk;
|
||||
|
||||
public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks
|
||||
{
|
||||
static Activity mActivity;
|
||||
@ -265,21 +263,6 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
((MainActivity) mActivity).clearCoverCache();
|
||||
}
|
||||
|
||||
public static boolean IsLoadableExecutableFileName(String fileName)
|
||||
{
|
||||
return fileName.toLowerCase().endsWith(".elf");
|
||||
}
|
||||
|
||||
private static boolean IsLoadableDiskImageFileName(String fileName)
|
||||
{
|
||||
|
||||
return
|
||||
fileName.toLowerCase().endsWith(".iso") ||
|
||||
fileName.toLowerCase().endsWith(".bin") ||
|
||||
fileName.toLowerCase().endsWith(".cso") ||
|
||||
fileName.toLowerCase().endsWith(".isz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationDrawerItemSelected(int position) {
|
||||
switch (position) {
|
||||
@ -474,7 +457,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
preview.setImageResource(R.drawable.boxart);
|
||||
((TextView) childview.findViewById(R.id.game_text)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (IsLoadableExecutableFileName(game.getFile().getName())) {
|
||||
} else if (VirtualMachineManager.IsLoadableExecutableFileName(game.getFile().getName())) {
|
||||
ImageView preview = (ImageView) childview.findViewById(R.id.game_icon);
|
||||
preview.setImageResource(R.drawable.boxart);
|
||||
((TextView) childview.findViewById(R.id.game_text)).setVisibility(View.VISIBLE);
|
||||
@ -518,7 +501,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
if (game.getFile().exists()){
|
||||
game.setlastplayed(mActivity);
|
||||
try {
|
||||
launchDisk(this, game.getFile());
|
||||
VirtualMachineManager.launchDisk(this, game.getFile());
|
||||
} catch (Exception e) {
|
||||
displaySimpleMessage("Error", e.getMessage());
|
||||
}
|
||||
|
@ -5,11 +5,9 @@ import android.content.Intent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.virtualapplications.play.MainActivity.IsLoadableExecutableFileName;
|
||||
|
||||
public class VirtualMachineManager
|
||||
{
|
||||
static void launchDisk(Context mContext, File game) throws Exception
|
||||
public static void launchDisk(Context mContext, File game) throws Exception
|
||||
{
|
||||
if(IsLoadableExecutableFileName(game.getPath()))
|
||||
{
|
||||
@ -22,4 +20,9 @@ public class VirtualMachineManager
|
||||
Intent intent = new Intent(mContext, EmulatorActivity.class);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
public static boolean IsLoadableExecutableFileName(String fileName)
|
||||
{
|
||||
return fileName.toLowerCase().endsWith(".elf");
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import android.util.Log;
|
||||
import com.virtualapplications.play.GameInfoStruct;
|
||||
import com.virtualapplications.play.NativeInterop;
|
||||
import com.virtualapplications.play.R;
|
||||
import com.virtualapplications.play.VirtualMachineManager;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -18,8 +19,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static com.virtualapplications.play.MainActivity.IsLoadableExecutableFileName;
|
||||
|
||||
/**
|
||||
* Based On https://github.com/LithidSoftware/android_Findex/blob/master/src/com/lithidsw/findex/utils/FileWalker.java
|
||||
*/
|
||||
@ -118,7 +117,7 @@ public class GameIndexer {
|
||||
if (!isIndexed(folderPath, f.getName())) {
|
||||
String name = f.getName();
|
||||
String serial = null;
|
||||
if (!IsLoadableExecutableFileName(f.getPath())) {
|
||||
if (!VirtualMachineManager.IsLoadableExecutableFileName(f.getPath())) {
|
||||
serial = getSerial(f);
|
||||
if (serial == null) continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user