Fixed toast location for readability
This commit is contained in:
parent
ca368a891c
commit
c47f38bbee
1 changed files with 12 additions and 7 deletions
|
@ -4,6 +4,7 @@ import android.app.DialogFragment;
|
|||
import android.content.Context;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -52,18 +53,22 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
public void setResponse(Map response) {
|
||||
CharSequence text;
|
||||
Context context = getApplicationContext();
|
||||
int duration = Toast.LENGTH_SHORT;
|
||||
Toast toast = Toast.makeText(context, null, duration);
|
||||
if (response.get("code").equals("correct")) {
|
||||
String popup = String.format(getString(R.string.correct_answer), response.get("count"));
|
||||
text = getString(R.string.game_over);
|
||||
gameOver(popup);
|
||||
} else if (response.get("code").equals("too_big")) {
|
||||
text = getString(R.string.too_big);
|
||||
} else {
|
||||
text = getString(R.string.too_small);
|
||||
}
|
||||
Context context = getApplicationContext();
|
||||
int duration = Toast.LENGTH_SHORT;
|
||||
Toast toast = Toast.makeText(context, text, duration);
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
if (response.get("code").equals("too_big")) {
|
||||
text = getString(R.string.too_big);
|
||||
} else {
|
||||
text = getString(R.string.too_small);
|
||||
}
|
||||
}
|
||||
toast.setText(text);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue