Android Open Source - spacegunner Main View Impl






From Project

Back to project page spacegunner.

License

The source code is released under:

MIT License

If you think the Android project spacegunner listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.spacegunner.main;
//from   w w w  . j  av a  2s.c o  m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;

import com.example.spacegunner.R;
import com.example.spacegunner.game.GameViewImpl;
import com.example.spacegunner.ioservice.IOService;
import com.example.spacegunner.ioservice.PlayerHighscore;

public class MainViewImpl extends Activity implements OnClickListener, MainView {

  private MainPresenter presenter;
  private IOService iOService;
  private Animation fadeIn;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    this.presenter = new MainPresenterImpl(this);
    this.iOService = new IOService(this);
    this.fadeIn = AnimationUtils.loadAnimation(this, R.anim.fadein);
    final Button button = (Button) findViewById(R.id.buttonstartgame);
    button.setOnClickListener(this);
  }

  @Override
  public void onResume() {
    super.onResume();
    View background = findViewById(R.id.main_background);
    background.startAnimation(fadeIn);
    displayHighscore();
  }

  private void displayHighscore() {
    TextView highscorelist = (TextView) findViewById(R.id.highscorelist);
    PlayerHighscore playerHighscore = iOService.readHighscore();
    highscorelist.setText(playerHighscore.getPlayerName() + ": "
        + playerHighscore.getHighscore());
  }

  @Override
  public void onClick(View v) {
    this.presenter.startGameButtonClicked();
  }

  @Override
  public void startGameActivity() {
    startActivity(new Intent(this, GameViewImpl.class));
  }

  @Override
  public void onBackPressed() {
    this.presenter.backButtonPressed();
  }

}




Java Source Code List

com.example.spacegunner.constants.Constants.java
com.example.spacegunner.game.GameModelImpl.java
com.example.spacegunner.game.GameModel.java
com.example.spacegunner.game.GamePresenterImpl.java
com.example.spacegunner.game.GamePresenter.java
com.example.spacegunner.game.GameViewImpl.java
com.example.spacegunner.game.GameView.java
com.example.spacegunner.gameresult.GameResultModelImpl.java
com.example.spacegunner.gameresult.GameResultModel.java
com.example.spacegunner.gameresult.GameResultPresenterImpl.java
com.example.spacegunner.gameresult.GameResultPresenter.java
com.example.spacegunner.gameresult.GameResultViewImpl.java
com.example.spacegunner.gameresult.GameResultView.java
com.example.spacegunner.ioservice.IOService.java
com.example.spacegunner.ioservice.PlayerHighscore.java
com.example.spacegunner.level.LevelModelImpl.java
com.example.spacegunner.level.LevelModel.java
com.example.spacegunner.level.LevelPresenterImpl.java
com.example.spacegunner.level.LevelPresenter.java
com.example.spacegunner.level.LevelViewImpl.java
com.example.spacegunner.level.LevelView.java
com.example.spacegunner.main.MainPresenterImpl.java
com.example.spacegunner.main.MainPresenter.java
com.example.spacegunner.main.MainViewImpl.java
com.example.spacegunner.main.MainView.java