[Android] Clean up for things only being done halfway.
Changing from a collection to an array back to a collection was just adding a lot of unnecessary overhead. This removes that pointless process and adds the previous changes to the second activity for handling controllers.
This commit is contained in:
parent
f7a651f2a7
commit
6da7b865d9
|
@ -57,14 +57,6 @@ public class FileUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
public File[] listFilesAsArray(File directory, FilenameFilter[] filter,
|
||||
int recurse) {
|
||||
Collection<File> files = listFiles(directory, filter, recurse);
|
||||
|
||||
File[] arr = new File[files.size()];
|
||||
return files.toArray(arr);
|
||||
}
|
||||
|
||||
public Collection<File> listFiles(File directory, FilenameFilter[] filter,
|
||||
int recurse) {
|
||||
|
||||
|
@ -96,7 +88,7 @@ public class FileUtils {
|
|||
File dir = new File(MainActivity.home_directory);
|
||||
SimpleDateFormat s = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String timestamp = s.format(new Date());
|
||||
File f = new File(dir.getPath(), timestamp+".jpeg");
|
||||
File f = new File(dir.getAbsolutePath(), timestamp+".jpeg");
|
||||
FileOutputStream out = new FileOutputStream(f);
|
||||
savePixels(0, 0, w, h, gl).compress(Bitmap.CompressFormat.JPEG, 100, out);
|
||||
out.close();
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -171,7 +172,6 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
@Override
|
||||
protected List<File> doInBackground(String... paths) {
|
||||
final List<File> tFileList = new ArrayList<File>();
|
||||
File storage = new File(paths[0]);
|
||||
Resources resources = parentActivity.getResources();
|
||||
// array of valid image file extensions
|
||||
|
@ -197,9 +197,8 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
|
||||
FileUtils fileUtils = new FileUtils();
|
||||
File[] allMatchingFiles = fileUtils.listFilesAsArray(storage, filter, 1);
|
||||
Collections.addAll(tFileList, allMatchingFiles);
|
||||
return tFileList;
|
||||
Collection<File> files = fileUtils.listFiles(storage, filter, 1);
|
||||
return (List<File>) files;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -343,14 +343,14 @@ public class GL2JNINative extends NativeActivity {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
|
||||
&& event.getSource() != Gamepad.Xperia_Touchpad) {
|
||||
|
||||
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
|
||||
int playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
|
||||
playerNum = pad.deviceDescriptor_PlayerNum
|
||||
.get(pad.deviceId_deviceDescriptor.get(event.getDeviceId()));
|
||||
} else {
|
||||
playerNum = -1;
|
||||
}
|
||||
if (playerNum == null || playerNum == -1) {
|
||||
if (playerNum == -1) {
|
||||
return false;
|
||||
}
|
||||
if (!pad.compat[playerNum]) {
|
||||
|
@ -416,8 +416,8 @@ public class GL2JNINative extends NativeActivity {
|
|||
|
||||
}
|
||||
|
||||
boolean handle_key(Integer playerNum, int kc, boolean down) {
|
||||
if (playerNum == null || playerNum == -1)
|
||||
boolean handle_key(int playerNum, int kc, boolean down) {
|
||||
if (playerNum == -1)
|
||||
return false;
|
||||
if (kc == pad.getSelectButtonCode()) {
|
||||
return false;
|
||||
|
@ -473,8 +473,8 @@ public class GL2JNINative extends NativeActivity {
|
|||
}
|
||||
|
||||
public boolean OnNativeKeyPress(int device, int keyCode, int action, int metaState) {
|
||||
Integer playerNum = pad.playerNumX.get(device);
|
||||
if (playerNum != null && playerNum != -1) {
|
||||
int playerNum = pad.playerNumX.get(device);
|
||||
if (playerNum != -1) {
|
||||
String id = pad.portId[playerNum];
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1)) {
|
||||
|
@ -504,8 +504,8 @@ public class GL2JNINative extends NativeActivity {
|
|||
public boolean OnNativeMotion(int device, int source, int action, int x, int y, boolean newEvent) {
|
||||
if (newEvent && source == Gamepad.Xperia_Touchpad) {
|
||||
// Source is Xperia Play touchpad
|
||||
Integer playerNum = pad.playerNumX.get(device);
|
||||
if (playerNum != null && playerNum != -1) {
|
||||
int playerNum = pad.playerNumX.get(device);
|
||||
if (playerNum != -1) {
|
||||
Log.d("reidc", playerNum + " - " + device + ": " + source);
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
x = 0;
|
||||
|
|
Loading…
Reference in New Issue