Generic cleanup and simplifications.

Just some really generic things that simplify existing code among other things.
This commit is contained in:
Lioncash 2013-09-27 00:13:37 -04:00
parent 14c3892208
commit be32d28dcd
5 changed files with 19 additions and 24 deletions

View File

@ -22,14 +22,14 @@ public class DirectoryActivity extends Activity implements
public String path;
public boolean parentIsBack;
public BackStackItem(String aPath, boolean aParentIsBack) {
path = aPath;
parentIsBack = aParentIsBack;
public BackStackItem(String path, boolean parentIsBack) {
this.path = path;
this.parentIsBack = parentIsBack;
}
private BackStackItem(Parcel aIn) {
path = aIn.readString();
parentIsBack = aIn.readInt() != 0;
private BackStackItem(Parcel in) {
this.path = in.readString();
this.parentIsBack = in.readInt() != 0;
}
public int describeContents() {
@ -87,7 +87,7 @@ public class DirectoryActivity extends Activity implements
backStack = savedInstanceState.getParcelableArrayList("BACKSTACK");
}
if (backStack == null || backStack.size() == 0) {
if (backStack == null || backStack.isEmpty()) {
backStack = new ArrayList<BackStackItem>();
String startPath = (startDirectory == null || startDirectory.isEmpty()) ? Environment
.getExternalStorageDirectory().getPath() : startDirectory;
@ -112,7 +112,7 @@ public class DirectoryActivity extends Activity implements
editor.commit();
}
Intent intent = new Intent();
Intent intent = new Intent();
intent.putExtra("PATH", path);
setResult(RESULT_OK, intent);
finish();

View File

@ -360,7 +360,7 @@ public final class MainMenuActivity extends PreferenceActivity {
// Refactor this entire mess and make this usable for per-core config
if (android.os.Build.VERSION.SDK_INT >= 17 &&
prefs.getBoolean("audio_latency_auto", true) == true) {
prefs.getBoolean("audio_latency_auto", true)) {
int buffersize = getLowLatencyBufferSize();
boolean lowLatency = hasLowLatencyAudio();
@ -475,11 +475,11 @@ public final class MainMenuActivity extends PreferenceActivity {
.getApplicationInfo().dataDir + "/retroarch-history.txt");
for (int i = 1; i <= 4; i++) {
final String btns[] = { "up", "down", "left", "right", "a", "b",
final String[] btns = { "up", "down", "left", "right", "a", "b",
"x", "y", "start", "select", "l", "r", "l2", "r2", "l3",
"r3" };
for (String b : btns) {
String p = "input_player" + String.valueOf(i) + "_" + b
String p = "input_player" + i + "_" + b
+ "_btn";
config.setInt(p, prefs.getInt(p, 0));
}
@ -493,8 +493,7 @@ public final class MainMenuActivity extends PreferenceActivity {
}
private byte[] loadAsset(String asset) throws IOException {
String path = asset;
InputStream stream = getAssets().open(path);
InputStream stream = getAssets().open(asset);
int len = stream.available();
byte[] buf = new byte[len];
stream.read(buf, 0, len);
@ -544,8 +543,7 @@ public final class MainMenuActivity extends PreferenceActivity {
try {
String dataDir = getApplicationInfo().dataDir;
File cacheVersion = new File(dataDir, ".cacheversion");
if (cacheVersion != null && cacheVersion.isFile()
&& cacheVersion.canRead() && cacheVersion.canWrite()) {
if (cacheVersion.isFile() && cacheVersion.canRead() && cacheVersion.canWrite()) {
DataInputStream cacheStream = new DataInputStream(
new FileInputStream(cacheVersion));
@ -803,7 +801,7 @@ public final class MainMenuActivity extends PreferenceActivity {
public void startActivity(Intent intent) {
if (intent.getComponent().getClassName()
.equals("org.retroarch.browser.ROMActivity")) {
if (new File(libretro_path).isDirectory() == false) {
if (!new File(libretro_path).isDirectory()) {
super.startActivityForResult(intent, ACTIVITY_LOAD_ROM);
} else {
Toast.makeText(this,

View File

@ -8,10 +8,10 @@ import android.graphics.drawable.Drawable;
final class ModuleWrapper implements IconAdapterItem {
public final File file;
private ConfigFile config;
private final ConfigFile config;
public ModuleWrapper(Context aContext, File aFile, ConfigFile config) throws IOException {
file = aFile;
public ModuleWrapper(Context context, File file, ConfigFile config) throws IOException {
this.file = file;
this.config = config;
}

View File

@ -5,9 +5,6 @@ import android.os.Bundle;
import android.widget.Toast;
public final class RetroActivity extends NativeActivity {
public RetroActivity() {
super();
}
@Override
public void onCreate(Bundle savedInstance) {

View File

@ -29,7 +29,7 @@ public final class SeekbarPreference extends DialogPreference implements SeekBar
seek_value = getPersistedFloat(1.0f);
int prog = (int) (seek_value * 100);
bar.setProgress(prog);
text.setText(String.valueOf(prog) + "%");
text.setText(prog + "%");
bar.setOnSeekBarChangeListener(this);
return view;
}
@ -46,7 +46,7 @@ public final class SeekbarPreference extends DialogPreference implements SeekBar
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
seek_value = (float) progress / 100.0f;
text.setText(String.valueOf((int)(seek_value * 100)) + "%");
text.setText((int) (seek_value * 100) + "%");
}
@Override