Skip to content

Commit

Permalink
Cleanup unnecessary usages of toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
farmerbb committed Jan 17, 2023
1 parent e40c818 commit 0ae75c5
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down Expand Up @@ -166,14 +166,11 @@ public void onStop() {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// Override default Android "up" behavior to instead mimic the back button
if (item.getItemId() == android.R.id.home) {// Override default Android "up" behavior to instead mimic the back button
this.onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}

public void onBackPressed() {
Expand Down Expand Up @@ -253,7 +250,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener opcl = (preference, value) -> {
private static final Preference.OnPreferenceChangeListener opcl = (preference, value) -> {
String stringValue = value.toString();

// Damage control if user inputs an empty value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down Expand Up @@ -178,9 +178,9 @@ public void onCreate(Bundle savedInstanceState) {

if(prefMain.getBoolean("expert_mode", false)) {
if("reset".equals(prefSaved.getString("size", "reset"))) {
editor.putString("size", Integer.toString(prefMain.getInt("width", 0))
editor.putString("size", prefMain.getInt("width", 0)
+ "x"
+ Integer.toString(prefMain.getInt("height", 0)));
+ prefMain.getInt("height", 0));

editor.putBoolean("size-reset", true);
} else
Expand All @@ -195,9 +195,9 @@ public void onCreate(Bundle savedInstanceState) {
if(prefSaved.getBoolean("size-reset", false)) {
editor.remove("size-reset");

String nativeRes = Integer.toString(prefMain.getInt("width", 0))
String nativeRes = prefMain.getInt("width", 0)
+ "x"
+ Integer.toString(prefMain.getInt("height", 0));
+ prefMain.getInt("height", 0);

if(nativeRes.equals(prefSaved.getString("size", "reset")))
editor.putString("size", "reset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down Expand Up @@ -264,17 +264,11 @@ private void listProfiles() {
if("quick_actions".equals(prefCurrent.getString("filename", "0"))) {
SharedPreferences prefSaved = listener.getPrefQuickActions();
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefSaved.getString("original_filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefSaved.getString("original_filename", "0")));
}
} else {
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefCurrent.getString("filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefCurrent.getString("filename", "0")));
}
}

Expand All @@ -292,17 +286,11 @@ private void listProfiles() {
if("quick_actions".equals(prefCurrent.getString("filename", "0"))) {
SharedPreferences prefSaved = listener.getPrefQuickActions();
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefSaved.getString("original_filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefSaved.getString("original_filename", "0")));
}
} else {
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefCurrent.getString("filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefCurrent.getString("filename", "0")));
}
}

Expand All @@ -319,17 +307,11 @@ private void listProfiles() {
if("quick_actions".equals(prefCurrent.getString("filename", "0"))) {
SharedPreferences prefSaved = listener.getPrefQuickActions();
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefSaved.getString("original_filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefSaved.getString("original_filename", "0")));
}
} else {
for(int i = 0; i < numOfFiles; i++) {
if(profileList[0][i].equals(prefCurrent.getString("filename", "0")))
listView.setItemChecked(i, true);
else
listView.setItemChecked(i, false);
listView.setItemChecked(i, profileList[0][i].equals(prefCurrent.getString("filename", "0")));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down Expand Up @@ -171,10 +171,8 @@ private void showUI() {
generateProfileSettings(prefSaved.getBoolean("navbar", false), R.string.profile_view_navbar);
generateProfileSettings(prefSaved.getBoolean("freeform", false), R.string.profile_view_freeform);

switch(prefSaved.getString("hdmi_rotation", "landscape")) {
case "portrait":
generateProfileSettings(true, R.string.profile_view_hdmi_output);
break;
if ("portrait".equals(prefSaved.getString("hdmi_rotation", "landscape"))) {
generateProfileSettings(true, R.string.profile_view_hdmi_output);
}

if(U.canEnableOverscan())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onAttach(Activity activity) {
listener = (Listener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
throw new ClassCastException(activity
+ " must implement Listener");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void onHandleIntent(Intent intent) {
Arrays.fill(su, "");

if("auto-rotate".equals(prefCurrent.getString("rotation_lock_new", "do-nothing"))) {
su[rotationCommand] = U.rotationCommand + Integer.toString(Intent.EXTRA_DOCK_STATE_DESK);
su[rotationCommand] = U.rotationCommand + Intent.EXTRA_DOCK_STATE_DESK;
if(Settings.Secure.getInt(getContentResolver(), "screensaver_enabled", 0) == 1
&& Settings.Secure.getInt(getContentResolver(), "screensaver_activate_on_dock", 0) == 1) {
su[rotationPreCommand] = U.rotationPrePostCommands + "0";
Expand Down
Loading

0 comments on commit 0ae75c5

Please sign in to comment.