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.content.Context;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -52,18 +53,22 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
public void setResponse(Map response) {
|
public void setResponse(Map response) {
|
||||||
CharSequence text;
|
CharSequence text;
|
||||||
|
Context context = getApplicationContext();
|
||||||
|
int duration = Toast.LENGTH_SHORT;
|
||||||
|
Toast toast = Toast.makeText(context, null, duration);
|
||||||
if (response.get("code").equals("correct")) {
|
if (response.get("code").equals("correct")) {
|
||||||
String popup = String.format(getString(R.string.correct_answer), response.get("count"));
|
String popup = String.format(getString(R.string.correct_answer), response.get("count"));
|
||||||
text = getString(R.string.game_over);
|
text = getString(R.string.game_over);
|
||||||
gameOver(popup);
|
gameOver(popup);
|
||||||
} else if (response.get("code").equals("too_big")) {
|
} else {
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||||
|
if (response.get("code").equals("too_big")) {
|
||||||
text = getString(R.string.too_big);
|
text = getString(R.string.too_big);
|
||||||
} else {
|
} else {
|
||||||
text = getString(R.string.too_small);
|
text = getString(R.string.too_small);
|
||||||
}
|
}
|
||||||
Context context = getApplicationContext();
|
}
|
||||||
int duration = Toast.LENGTH_SHORT;
|
toast.setText(text);
|
||||||
Toast toast = Toast.makeText(context, text, duration);
|
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue