[Android] Kill off unnecessary getString calls.

This commit is contained in:
Lioncash 2014-03-06 04:28:47 -05:00
parent 08d40fe44f
commit e9891118f7
6 changed files with 40 additions and 51 deletions

View File

@ -119,7 +119,7 @@ public class AboutFragment extends Fragment {
handler = new Handler();
try {
InputStream file = parentActivity.getAssets().open("build");
InputStream file = getResources().getAssets().open("build");
if (file != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(file));
@ -137,10 +137,10 @@ public class AboutFragment extends Fragment {
.getPackageInfo(parentActivity.getPackageName(), 0).versionCode;
TextView version = (TextView) getView().findViewById(
R.id.revision_text);
String revision = parentActivity.getString(R.string.revision_text,
String revision = getString(R.string.revision_text,
versionName, String.valueOf(versionCode));
if (!buildId.isEmpty()) {
revision = parentActivity.getString(R.string.revision_text,
revision = getString(R.string.revision_text,
versionName, buildId.substring(0,7));
}
version.setText(revision);
@ -148,17 +148,15 @@ public class AboutFragment extends Fragment {
e.printStackTrace();
}
TextView website = (TextView) getView().findViewById(
R.id.site_text);
TextView website = (TextView) getView().findViewById(R.id.site_text);
Linkify.addLinks(website, Linkify.ALL);
slidingGithub = (SlidingDrawer) getView().findViewById(
R.id.slidingGithub);
slidingGithub = (SlidingDrawer) getView().findViewById(R.id.slidingGithub);
if (MainActivity.debugUser) {
slidingGithub.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onDrawerOpened() {
String git = parentActivity.getString(R.string.git_api);
String git = getString(R.string.git_api);
retrieveGitTask queryGithub = new retrieveGitTask();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
queryGithub.executeOnExecutor(
@ -297,8 +295,7 @@ public class AboutFragment extends Fragment {
}
}
private JSONArray getContent(String urlString) throws IOException,
JSONException {
private JSONArray getContent(String urlString) throws IOException, JSONException {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(urlString);

View File

@ -19,7 +19,6 @@ import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@ -172,9 +171,9 @@ public class FileBrowser extends Fragment {
@Override
protected List<File> doInBackground(String... paths) {
File storage = new File(paths[0]);
Resources resources = parentActivity.getResources();
// array of valid image file extensions
String[] mediaTypes = resources.getStringArray(R.array.images);
String[] mediaTypes = getResources().getStringArray(R.array.images);
FilenameFilter[] filter = new FilenameFilter[mediaTypes.length];
int i = 0;
@ -206,8 +205,7 @@ public class FileBrowser extends Fragment {
.findViewById(R.id.game_list);
list.removeAllViews();
String heading = parentActivity
.getString(R.string.games_listing);
String heading = getString(R.string.games_listing);
createListHeader(heading, list, true);
if (games != null && !games.isEmpty()) {
for (final File game : games) {
@ -240,7 +238,7 @@ public class FileBrowser extends Fragment {
R.layout.bios_list_item, null, false);
((TextView) childview.findViewById(R.id.item_name))
.setText(parentActivity.getString(R.string.boot_bios));
.setText(R.string.boot_bios);
childview.setTag(null);
@ -365,14 +363,11 @@ public class FileBrowser extends Fragment {
R.layout.app_list_item, null, false);
if (file == null) {
((TextView) childview.findViewById(R.id.item_name))
.setText(getString(R.string.folder_select));
((TextView) childview.findViewById(R.id.item_name)).setText(R.string.folder_select);
} else if (file == parent)
((TextView) childview.findViewById(R.id.item_name))
.setText("..");
((TextView) childview.findViewById(R.id.item_name)).setText("..");
else
((TextView) childview.findViewById(R.id.item_name))
.setText(file.getName());
((TextView) childview.findViewById(R.id.item_name)).setText(file.getName());
((ImageView) childview.findViewById(R.id.item_icon))
.setImageResource(file == null ? R.drawable.config

View File

@ -175,7 +175,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.replace(R.id.fragment_container, browseFrag,
"MAIN_BROWSER").addToBackStack(null)
.commit();
setTitle(getString(R.string.browser));
setTitle(R.string.browser);
sm.toggle(true);
}
@ -195,7 +195,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.replace(R.id.fragment_container, configFrag,
"CONFIG_FRAG").addToBackStack(null)
.commit();
setTitle(getString(R.string.settings));
setTitle(R.string.settings);
sm.toggle(true);
}
@ -217,7 +217,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.replace(R.id.fragment_container,
optionsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit();
setTitle(getString(R.string.paths));
setTitle(R.string.paths);
sm.toggle(true);
}
@ -237,7 +237,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.beginTransaction()
.replace(R.id.fragment_container, inputFrag,
"INPUT_FRAG").addToBackStack(null).commit();
setTitle(getString(R.string.input));
setTitle(R.string.input);
sm.toggle(true);
}
@ -257,7 +257,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.beginTransaction()
.replace(R.id.fragment_container, aboutFrag,
"ABOUT_FRAG").addToBackStack(null).commit();
setTitle(getString(R.string.about));
setTitle(R.string.about);
sm.toggle(true);
}
@ -274,7 +274,7 @@ public class MainActivity extends SlidingFragmentActivity implements
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("market://details?id="
+ getPackageName())));
//setTitle(getString(R.string.rateme));
//setTitle(R.string.rateme);
sm.toggle(true);
return true;
} else
@ -314,9 +314,9 @@ public class MainActivity extends SlidingFragmentActivity implements
*/
private void displayLogOutput(final String error) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(getString(R.string.report_issue));
builder.setTitle(R.string.report_issue);
builder.setMessage(error);
builder.setNegativeButton(getString(R.string.dismiss),
builder.setNegativeButton(R.string.dismiss,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
@ -353,34 +353,31 @@ public class MainActivity extends SlidingFragmentActivity implements
// set title
if (!isBiosExisting())
alertDialogBuilder.setTitle(getString(R.string.missing_bios_title));
alertDialogBuilder.setTitle(R.string.missing_bios_title);
else if (!isFlashExisting())
alertDialogBuilder.setTitle(getString(R.string.missing_flash_title));
alertDialogBuilder.setTitle(R.string.missing_flash_title);
// set dialog message
alertDialogBuilder
.setMessage(msg)
.setCancelable(false)
.setPositiveButton(getString(R.string.dismiss),
.setPositiveButton(R.string.dismiss,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
// current activity
// MainActivity.this.finish();
}
})
.setNegativeButton(getString(R.string.options),
.setNegativeButton(R.string.options,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
public void onClick(DialogInterface dialog, int id) {
FileBrowser firstFragment = new FileBrowser();
Bundle args = new Bundle();
// args.putBoolean("ImgBrowse", false);
// specify ImgBrowse option. true = images,
// false = folders only
args.putString("browse_entry",
sdcard.toString());
args.putString("browse_entry", sdcard.toString());
// specify a path for selecting folder
// options
args.putBoolean("games_entry", false);
@ -523,7 +520,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.beginTransaction()
.replace(R.id.fragment_container, fragment,
"MAIN_BROWSER").commit();
setTitle(getString(R.string.browser));
setTitle(R.string.browser);
}
@Override

View File

@ -286,7 +286,7 @@ public class InputFragment extends Fragment {
buttonRemoveControllerPlayer1.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer1
.setText(getString(R.string.controller_none_selected));
.setText(R.string.controller_none_selected);
buttonRemoveControllerPlayer1.setEnabled(false);
}
}
@ -306,7 +306,7 @@ public class InputFragment extends Fragment {
buttonRemoveControllerPlayer2.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer2
.setText(getString(R.string.controller_none_selected));
.setText(R.string.controller_none_selected);
buttonRemoveControllerPlayer2.setEnabled(false);
}
}
@ -326,7 +326,7 @@ public class InputFragment extends Fragment {
buttonRemoveControllerPlayer3.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer3
.setText(getString(R.string.controller_none_selected));
.setText(R.string.controller_none_selected);
buttonRemoveControllerPlayer3.setEnabled(false);
}
}
@ -346,7 +346,7 @@ public class InputFragment extends Fragment {
buttonRemoveControllerPlayer4.setEnabled(true);
} else {
textViewDeviceDescriptorPlayer4
.setText(getString(R.string.controller_none_selected));
.setText(R.string.controller_none_selected);
buttonRemoveControllerPlayer4.setEnabled(false);
}
}
@ -356,17 +356,17 @@ public class InputFragment extends Fragment {
listenForButton = playerNum;
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(getString(R.string.select_controller_title));
builder.setTitle(R.string.select_controller_title);
builder.setMessage(getString(R.string.select_controller_message,
String.valueOf(listenForButton)));
builder.setPositiveButton(getString(R.string.cancel),
builder.setPositiveButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
listenForButton = 0;
dialog.dismiss();
}
});
builder.setNegativeButton(getString(R.string.manual),
builder.setNegativeButton(R.string.manual,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
InputModFragment inputModFrag = new InputModFragment();

View File

@ -471,7 +471,7 @@ public class InputModFragment extends Fragment {
this.output = output;
isMapping = true;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(getString(R.string.map_keycode_title));
builder.setTitle(R.string.map_keycode_title);
builder.setMessage(getString(R.string.map_keycode_message, button.replace("_", " ")));
builder.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {

View File

@ -185,11 +185,11 @@ public class MOGAInput
if (mControllerVersion == Controller.ACTION_VERSION_MOGAPRO) {
pad.isMogaPro[playerNum] = true;
pad.isActiveMoga[playerNum] = true;
Log.d("com.reicast.emulator", act.getApplicationContext().getString(R.string.moga_pro_connect));
Log.d("com.reicast.emulator", act.getString(R.string.moga_pro_connect));
} else if (mControllerVersion == Controller.ACTION_VERSION_MOGA) {
pad.isMogaPro[playerNum] = false;
pad.isActiveMoga[playerNum] = true;
Log.d("com.reicast.emulator", act.getApplicationContext().getString(R.string.moga_connect));
Log.d("com.reicast.emulator", act.getString(R.string.moga_connect));
}
if (pad.isActiveMoga[playerNum]) {
notifyMogaConnected(notify, playerNum);