Initialer Upload neues Unity-Projekt
This commit is contained in:
52
app/src/main/java/com/dano/test1/MainActivity.kt
Normal file
52
app/src/main/java/com/dano/test1/MainActivity.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package com.dano.test1
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var openingScreenHandler: HandlerOpeningScreen
|
||||
|
||||
var isInQuestionnaire: Boolean = false
|
||||
var isFirstQuestionnairePage: Boolean = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// Initialize the opening screen handler and show the opening screen
|
||||
openingScreenHandler = HandlerOpeningScreen(this)
|
||||
openingScreenHandler.init()
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the given questionnaire and attaches it to this activity.
|
||||
* @param questionnaire The questionnaire instance to start.
|
||||
* @param languageID The language identifier for localization.
|
||||
*/
|
||||
fun startQuestionnaire(questionnaire: QuestionnaireBase<*>, languageID: String) {
|
||||
isInQuestionnaire = true
|
||||
isFirstQuestionnairePage = true
|
||||
questionnaire.attach(this, languageID)
|
||||
questionnaire.startQuestionnaire()
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the back button press.
|
||||
* If the openingScreenHandler can handle it, do not call super.
|
||||
* Otherwise, call the default back press behavior.
|
||||
*/
|
||||
override fun onBackPressed() {
|
||||
if (!openingScreenHandler.onBackPressed()) {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish the questionnaire and return to the opening screen.
|
||||
*/
|
||||
fun finishQuestionnaire() {
|
||||
// For example, switch back to the opening screen:
|
||||
isInQuestionnaire = false
|
||||
isFirstQuestionnairePage = false
|
||||
openingScreenHandler.init()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user