implemented dialog
This commit is contained in:
parent
39c36b1827
commit
ddffc25db6
@ -1,11 +1,11 @@
|
|||||||
package com.wyattjmiller.tictactoeapp
|
package com.wyattjmiller.tictactoeapp
|
||||||
|
|
||||||
class Stats {
|
class Stats {
|
||||||
private var mGamesPlayed: Int = 0
|
var mGamesPlayed: Int = 0
|
||||||
private var mGamesWonX: Int = 0
|
var mGamesWonX: Int = 0
|
||||||
private var mGamesWonO: Int = 0
|
var mGamesWonO: Int = 0
|
||||||
private var mGamesCats: Int = 0
|
var mGamesCats: Int = 0
|
||||||
private var mGamePiecesPlaced: Int = 0
|
var mGamePiecesPlaced: Int = 0
|
||||||
|
|
||||||
fun updateGamesPlayed() {
|
fun updateGamesPlayed() {
|
||||||
mGamesPlayed++
|
mGamesPlayed++
|
||||||
|
@ -1,4 +1,55 @@
|
|||||||
package com.wyattjmiller.tictactoeapp
|
package com.wyattjmiller.tictactoeapp
|
||||||
|
|
||||||
class StatsDialogFragment {
|
import android.app.Dialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import org.w3c.dom.Text
|
||||||
|
|
||||||
|
class StatsDialogFragment(): DialogFragment() {
|
||||||
|
private lateinit var mGameTitle: TextView
|
||||||
|
private lateinit var mGamesPlayedTextView: TextView
|
||||||
|
private lateinit var mGamesWonXTextView: TextView
|
||||||
|
private lateinit var mGamesWonOTextView: TextView
|
||||||
|
private lateinit var mGamesCatsTextView: TextView
|
||||||
|
private lateinit var mGamePiecesPlacedTextView: TextView
|
||||||
|
private lateinit var mDismissButton: Button
|
||||||
|
private lateinit var mStats: Stats
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val builder = AlertDialog.Builder(this.activity!!)
|
||||||
|
val dialogView = activity!!.layoutInflater.inflate(R.layout.dialog_stats, null)
|
||||||
|
|
||||||
|
mGameTitle = dialogView.findViewById(R.id.gameStatsTitle)
|
||||||
|
mGamesPlayedTextView = dialogView.findViewById(R.id.gamesPlayedTextView)
|
||||||
|
mGamesWonXTextView = dialogView.findViewById(R.id.gamesWonXTextView)
|
||||||
|
mGamesWonOTextView = dialogView.findViewById(R.id.gamesWonOTextView)
|
||||||
|
mGamesCatsTextView = dialogView.findViewById(R.id.gamesCatsTextView)
|
||||||
|
mGamePiecesPlacedTextView = dialogView.findViewById(R.id.gamePiecesPlacedTextView)
|
||||||
|
mDismissButton = dialogView.findViewById(R.id.dismissButton)
|
||||||
|
|
||||||
|
mGamesPlayedTextView.text = "Games Played: ${mStats.mGamesPlayed.toString()}"
|
||||||
|
mGamesWonXTextView.text = "Games Won - X: ${mStats.mGamesWonX.toString()}"
|
||||||
|
mGamesWonOTextView.text = "Games Won - O: ${mStats.mGamesWonO.toString()}"
|
||||||
|
mGamesCatsTextView.text = "Games Cats: ${mStats.mGamesCats.toString()}"
|
||||||
|
mGamePiecesPlacedTextView.text = "Games Pieces Placed: ${mStats.mGamePiecesPlaced.toString()}"
|
||||||
|
|
||||||
|
builder.setView(dialogView)
|
||||||
|
|
||||||
|
mDismissButton.setOnClickListener {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.create()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendStats(statPresent: Stats) {
|
||||||
|
mStats = statPresent
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user