1
0
mirror of https://github.com/bspeice/itcs4180 synced 2024-09-29 06:01:35 -04:00
itcs4180/HW3/src/com/uncc/hw3/ResultActivity.java

66 lines
1.9 KiB
Java
Raw Normal View History

2014-02-22 16:39:00 -05:00
package com.uncc.hw3;
2014-02-23 08:46:24 -05:00
/*
* Bradlee Speice, Brandon Rodenmayer
* ITIS 4180
* Homework 3
* ResultActivity.java
*/
2014-02-22 16:39:00 -05:00
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
2014-02-22 16:39:00 -05:00
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
2014-02-22 16:39:00 -05:00
public class ResultActivity extends Activity {
static final int winTime = 50;
2014-02-22 16:39:00 -05:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
float elapsedTime = getIntent().getExtras().getFloat("ELAPSED_TIME");
// We always show the elapsed time, so let's do that now
TextView elapsedText = (TextView)findViewById(R.id.txtResultElapsed);
elapsedText.setText("Time elapsed : " + elapsedTime);
// The layout is set for success, so we only need to change it if the
// user lost the game...
if (elapsedTime > winTime) {
TextView resultText = (TextView)findViewById(R.id.txtResultValue);
resultText.setText(R.string.txtResultValue_Failure);
ImageView imgChest = (ImageView)findViewById(R.id.imgResult);
imgChest.setImageDrawable(getResources().getDrawable(R.drawable.lose));
}
2014-02-22 16:39:00 -05:00
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.result, menu);
return true;
}
public void onClick(View v) {
// Figure out if the Try Again or Exit button was clicked
Intent intent = new Intent(this, MainActivity.class);
if (v.getId() == R.id.btnTryAgain)
{
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
else if (v.getId() == R.id.btnExit){
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
}
}
2014-02-22 16:39:00 -05:00
}