[Android] Simplify the setting of the AlertDialog in function detectDevice. setMessage allows setting the message through just the message string ID.

This commit is contained in:
Lioncash 2013-11-17 03:28:19 -05:00
parent 4368467977
commit 26e9bef7ac

View File

@ -222,14 +222,14 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
final Context ctx = getActivity(); final Context ctx = getActivity();
final boolean mentionPlayStore = !Build.MODEL.equals("OUYA Console"); final boolean mentionPlayStore = !Build.MODEL.equals("OUYA Console");
final String message = (mentionPlayStore ? getString(R.string.detect_device_msg_general) : getString(R.string.detect_device_msg_ouya)); final int messageId = (mentionPlayStore ? R.string.detect_device_msg_general : R.string.detect_device_msg_ouya);
Log.i("Device MODEL", Build.MODEL); Log.i("Device MODEL", Build.MODEL);
if (Build.MODEL.equals("SHIELD")) if (Build.MODEL.equals("SHIELD"))
{ {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx); AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.nvidia_shield_detected); alert.setTitle(R.string.nvidia_shield_detected);
alert.setMessage(message); alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{ {
@Override @Override
@ -253,7 +253,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{ {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx); AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.game_mid_detected); alert.setTitle(R.string.game_mid_detected);
alert.setMessage(message); alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{ {
@Override @Override
@ -276,7 +276,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{ {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx); AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.ouya_detected); alert.setTitle(R.string.ouya_detected);
alert.setMessage(message); alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{ {
@Override @Override
@ -299,7 +299,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{ {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx); AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.xperia_play_detected); alert.setTitle(R.string.xperia_play_detected);
alert.setMessage(message); alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{ {
@Override @Override
@ -324,7 +324,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{ {
AlertDialog.Builder alert = new AlertDialog.Builder(ctx); AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle(R.string.nexus_7_2013_detected); alert.setTitle(R.string.nexus_7_2013_detected);
alert.setMessage(message); alert.setMessage(messageId);
alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{ {
@Override @Override