[Android] Simplify resizeDrawable in OverlayConfigButton.java.

Also add a missing override to onRestart in DolphinEmulator.java.
This commit is contained in:
Lioncash 2014-01-02 11:53:28 -05:00
parent 0faf696be7
commit 5635c94a30
2 changed files with 8 additions and 5 deletions

View File

@ -82,6 +82,8 @@ public final class DolphinEmulator extends Activity
UserPreferences.LoadIniToPrefs(this); UserPreferences.LoadIniToPrefs(this);
} }
} }
@Override
protected void onRestart() protected void onRestart()
{ {
super.onRestart(); super.onRestart();

View File

@ -42,7 +42,8 @@ public final class OverlayConfigButton extends Button implements OnTouchListener
// float buttonY = sPrefs.getFloat(buttonId+"-Y", -1f); // float buttonY = sPrefs.getFloat(buttonId+"-Y", -1f);
// //
private final String buttonId; private final String buttonId;
private Drawable resizeDrawable(WindowManager wm, Context context, Drawable image, float scale) { private Drawable resizeDrawable(WindowManager wm, Drawable image, float scale)
{
// Retrieve screen dimensions. // Retrieve screen dimensions.
DisplayMetrics displayMetrics = new DisplayMetrics(); DisplayMetrics displayMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(displayMetrics); wm.getDefaultDisplay().getMetrics(displayMetrics);
@ -52,7 +53,8 @@ public final class OverlayConfigButton extends Button implements OnTouchListener
(int)(displayMetrics.heightPixels * scale), (int)(displayMetrics.heightPixels * scale),
(int)(displayMetrics.heightPixels * scale), (int)(displayMetrics.heightPixels * scale),
false); false);
return new BitmapDrawable(context.getResources(), bitmapResized);
return new BitmapDrawable(getResources(), bitmapResized);
} }
/** /**
@ -73,9 +75,8 @@ public final class OverlayConfigButton extends Button implements OnTouchListener
setOnTouchListener(this); setOnTouchListener(this);
// Set the button's icon that represents it. // Set the button's icon that represents it.
setBackground(resizeDrawable(wm, context, setBackground(resizeDrawable(wm, getResources().getDrawable(drawableId),
context.getResources().getDrawable(drawableId), drawableId == R.drawable.gcpad_joystick_range ? 0.30f : 0.20f));
drawableId == R.drawable.gcpad_joystick_range ? 0.30f : 0.20f));
// Get the SharedPreferences instance. // Get the SharedPreferences instance.
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);