Skip to content
Browse files

Spielauswertungsmethode ausgeweitet

  • Loading branch information...
1 parent f183526 commit 819a99be987ef0c47aeccd6b5c16df9b18013180 @DerDaniel DerDaniel committed
View
BIN res/drawable-nodpi/pokal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-nodpi/verloren.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 res/values/strings.xml
@@ -34,6 +34,7 @@
<br><br>
</string>
-
+ <string name="validate_not_success">&lt;b>Das ist leider nicht korrekt!&lt;/b>&lt;br>Versuch es weiter.</string>
+ <string name="validate_success">&lt;b>Herzlichen Glückwunsch!&lt;/b>&lt;br>Du hast alles richtig gemacht.</string>
</resources>
View
12 src/de/fhdw/atpinfo/linafm/Spiel.java
@@ -50,6 +50,11 @@
private Button mBtnPopup;
/**
+ * Der Button zur Validierung
+ */
+ private Button mBtnCheck;
+
+ /**
* Der Popup-Dialog
*/
private Dialog mDlgPopup;
@@ -109,6 +114,10 @@ protected void onCreate(Bundle savedInstanceState) {
mBtnPopup = (Button) findViewById(R.id.btnPopup);
mBtnPopup.setOnClickListener(this);
+
+ // Validierung
+ mBtnCheck = (Button) findViewById(R.id.btnCheck);
+ mBtnCheck.setOnClickListener(this);
}
@@ -149,6 +158,9 @@ public void onClick(View v) {
showPopup();
}
break;
+ case R.id.btnCheck:
+ spielfeld.vaildate(context);
+ break;
case R.id.btnAbbruch:
mDlgPopup.cancel();
break;
View
26 src/de/fhdw/atpinfo/linafm/Spielfeld.java
@@ -10,6 +10,7 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
+import android.text.Html;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -108,11 +109,28 @@ public boolean getPopupOpen()
* Prüft, ob alle Plätchen im Popup auf der richtigen Position liegen
* @return true, wenn Level korrekt gelöst wurde
*/
- private boolean vaildate() {
- if ( !rasterPopup.isComplete() )
- return false;
+ public void vaildate(Context context) {
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService("layout_inflater");
+ View toast_layout = inflater.inflate(R.layout.toastlayout, null);
+ ImageView image = (ImageView) toast_layout.findViewById(R.id.toastimage);
+ TextView text = (TextView) toast_layout.findViewById(R.id.toasttext);
- return Arrays.equals(solution, rasterPopup.getTileIDs());
@Brueggus Owner
Brueggus added a note

Der Teil wäre wichtig gewesen... der prüft nämlich, ob die Plättchen auch an der richtigen Stelle liegen ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if ( rasterPopup.isComplete() ) {
+ image.setImageResource(R.drawable.pokal);
+ text.setText(Html.fromHtml(context.getString(R.string.validate_success)));
+
+ } else {
+ image.setImageResource(R.drawable.verloren);
+ text.setText(Html.fromHtml(context.getString(R.string.validate_not_success)));
+ }
+ Toast t = new Toast(context);
+ // mittig positionieren
+ t.setGravity(Gravity.CENTER, 0, 0);
+ t.setDuration(Toast.LENGTH_LONG);
+ t.setView(toast_layout);
+ t.show();
+
+ //return Arrays.equals(solution, rasterPopup.getTileIDs());
}

0 comments on commit 819a99b

Please sign in to comment.
Something went wrong with that request. Please try again.