-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.scala
106 lines (94 loc) · 2.64 KB
/
MainActivity.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package de.tomhoefer.jogga
import android.app.Activity
import android.os.Bundle
import android.view.animation.{Animation, AnimationUtils, LayoutAnimationController}
import android.view.View
import android.widget.{ImageView, RelativeLayout, LinearLayout, TextView}
import android.content.{Intent, Context}
import android.content.res.Resources
import extensions._
import views.SplashScreen
import extensions.implicits._
import models.userModel
/**
* Eintritts-Activity der Anwendung
*
*/
class MainActivity extends AppDefaultActivity {
/*
* Splashscreen-Instanz
*/
private var splash:SplashScreen = _
/*
* Layout mit Buttons auf den Startscreen
*/
private var mainMenuButtons:LinearLayout = _
/*
* Username-Control
*/
private var username:TextView = _
/**
* Ueberschriebener onCreate-Hook
*
* @param b Bundle mit Werten der letzten Sitzung
*/
override def onCreate(b:Bundle) = {
super.onCreate(b)
/*
* Context an Model uebergeben
*/
userModel.setContext(this)
setContentView(R.layout.main)
/*
* Views holen
*/
splash = findView(R.id.splash)
username = findView(R.id.username)
mainMenuButtons = findView(R.id.mainMenuButtons)
splash.status = "Loading sounds..."
/*
* soundPool mit Key-Value-Paaren initialisieren und Block uebergeben der nach dem Laden der Sounds
* ausgefuert werden soll. Darin Anfangs-Intro definieren.
*/
soundPool.onFinishedLoading(this, ('ding -> R.raw.ding), ('gps -> R.raw.gps), ('sung -> R.raw.sung)) {
splash startAnimation withAnim(R.anim.splash_fadeout) {anim =>
anim(end={
splash setVisibility View.GONE
mainMenuButtons setLayoutAnimation findLayoutAnim(R.anim.layout_mainmenubuttons)
mainMenuButtons.startLayoutAnimation
withView[ImageView](R.id.mainMenuLogo) { view =>
view startAnimation withAnim(R.anim.logo_scaleup) {anim =>
anim(end=soundEffect('ding))
}
}
})
}
splash.status = "Sounds ready!"
}
/*
* onTouch-Callback fuer StartButton
*/
withView(R.id.startButton) { view:ImageView =>
view touch {
val intent = new Intent(this, classOf[JoggingActivity])
startActivity(intent)
}
}
/*
* onTouch-Callback fuer SettingsButton
*/
withView[ImageView](R.id.settingsButton) { view =>
view touch {
val intent = new Intent(this, classOf[SettingsActivity])
startActivity(intent)
}
}
}
/*
* Sobald der Startscreen erscheit ggf den Benutzernamen des Users anzeigen
*/
override def onStart() = {
super.onStart()
username setText userModel.accountInfo
}
}