|
|
1b8111 |
package com.icystar.findnumber;
|
|
|
1b8111 |
|
|
|
1b8111 |
import android.app.Activity;
|
|
|
1b8111 |
import android.app.AlertDialog;
|
|
|
1b8111 |
import android.content.DialogInterface;
|
|
|
1b8111 |
import android.content.DialogInterface.OnClickListener;
|
|
|
1b8111 |
import android.content.Intent;
|
|
|
1b8111 |
import android.os.Bundle;
|
|
|
1b8111 |
import android.view.View;
|
|
|
1b8111 |
import android.widget.Button;
|
|
|
1b8111 |
|
|
|
1b8111 |
public class MainActivity extends Activity {
|
|
|
1b8111 |
|
|
|
1b8111 |
@Override
|
|
|
1b8111 |
public void onCreate(Bundle savedInstanceState) {
|
|
|
1b8111 |
super.onCreate(savedInstanceState);
|
|
|
1b8111 |
SoundPlayer.initSounds(getApplication());
|
|
|
1b8111 |
setContentView(R.layout.activity_main);
|
|
|
1b8111 |
}
|
|
|
1b8111 |
|
|
|
1b8111 |
@Override
|
|
|
1b8111 |
protected void onResume() {
|
|
|
1b8111 |
super.onResume();
|
|
|
1b8111 |
Game.loadState(getApplication());
|
|
|
1b8111 |
findViewById(R.id.buttonContinue).setVisibility(Game.getAnyPlaying() ? View.VISIBLE : View.GONE);
|
|
|
1b8111 |
((Button)findViewById(R.id.buttonSound)).setCompoundDrawablesWithIntrinsicBounds(
|
|
|
1b8111 |
SoundPlayer.getEnabled() ? R.drawable.ic_button_sound_on : R.drawable.ic_button_sound_off,
|
|
|
1b8111 |
0, 0, 0 );
|
|
|
1b8111 |
((Button)findViewById(R.id.buttonSound)).setText(
|
|
|
1b8111 |
SoundPlayer.getEnabled() ? R.string.soundEnabled : R.string.soundDisabled );
|
|
|
1b8111 |
}
|
|
|
1b8111 |
|
|
|
1b8111 |
@Override
|
|
|
1b8111 |
protected void onPause() {
|
|
|
1b8111 |
Game.saveState(getApplication());
|
|
|
1b8111 |
super.onPause();
|
|
|
1b8111 |
}
|
|
|
1b8111 |
|
|
|
1b8111 |
public void onButton(View view) {
|
|
|
1b8111 |
switch (view.getId()) {
|
|
|
1b8111 |
case R.id.buttonContinue:
|
|
|
1b8111 |
switch (Game.getMode()) {
|
|
|
1b8111 |
case 1:
|
|
|
1b8111 |
startActivity(new Intent(this, SingleActivity.class));
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case 2:
|
|
|
1b8111 |
startActivity(new Intent(this, DoubleActivity.class));
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
}
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case R.id.buttonNewGame:
|
|
|
1b8111 |
if (Game.getAnyPlaying()) {
|
|
|
1b8111 |
final MainActivity context = this;
|
|
|
1b8111 |
new AlertDialog.Builder(this)
|
|
|
1b8111 |
.setTitle(R.string.dialogGameAlreadyStartedTitle)
|
|
|
1b8111 |
.setIcon(R.drawable.ic_dialog_alert)
|
|
|
1b8111 |
.setMessage(R.string.dialogGameAlreadyStartedMessage)
|
|
|
1b8111 |
.setPositiveButton(R.string.dialogYes, new OnClickListener() {
|
|
|
1b8111 |
@Override
|
|
|
1b8111 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
1b8111 |
startActivity(new Intent(context, NewGameActivity.class));
|
|
|
1b8111 |
}
|
|
|
1b8111 |
})
|
|
|
1b8111 |
.setNegativeButton(R.string.dialogNo, null)
|
|
|
1b8111 |
.show();
|
|
|
1b8111 |
} else {
|
|
|
1b8111 |
startActivity(new Intent(this, NewGameActivity.class));
|
|
|
1b8111 |
}
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case R.id.buttonSound:
|
|
|
1b8111 |
SoundPlayer.setEnabled( !SoundPlayer.getEnabled() );
|
|
|
1b8111 |
((Button)findViewById(R.id.buttonSound)).setCompoundDrawablesWithIntrinsicBounds(
|
|
|
1b8111 |
SoundPlayer.getEnabled() ? R.drawable.ic_button_sound_on : R.drawable.ic_button_sound_off,
|
|
|
1b8111 |
0, 0, 0 );
|
|
|
1b8111 |
((Button)findViewById(R.id.buttonSound)).setText(
|
|
|
1b8111 |
SoundPlayer.getEnabled() ? R.string.soundEnabled : R.string.soundDisabled );
|
|
|
1b8111 |
SoundPlayer.playSound(R.raw.sound_test);
|
|
|
1b8111 |
Game.saveState(getApplication());
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case R.id.buttonScoreboard:
|
|
|
1b8111 |
startActivity(new Intent(this, ScoreboardActivity.class));
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case R.id.buttonHelp:
|
|
|
1b8111 |
new AlertDialog.Builder(this)
|
|
|
1b8111 |
.setTitle(R.string.dialogHelpTitle)
|
|
|
1b8111 |
.setIcon(R.drawable.ic_dialog_info)
|
|
|
1b8111 |
.setMessage(R.string.dialogHelpMessage)
|
|
|
1b8111 |
.setPositiveButton(R.string.dialogOk, null)
|
|
|
1b8111 |
.show();
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
case R.id.buttonExit:
|
|
|
1b8111 |
finish();
|
|
|
1b8111 |
break;
|
|
|
1b8111 |
}
|
|
|
1b8111 |
}
|
|
|
1b8111 |
}
|