Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
quick_max
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
afc32e00
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TaskActivity reinitializes the answer set instead of reloading
parent
48834e53
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/res/values/colors.xml
app/src/main/res/values/styles.xml
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
afc32e00
...
...
@@ -14,13 +14,13 @@ import androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.Answer
import
com.example.quickmax.answers.AnswerSet
import
com.google.android.material.button.MaterialButton
import
kotlinx.android.synthetic.main.activity_task.*
class
TaskActivity
:
AppCompatActivity
()
{
private
lateinit
var
answerSet
:
AnswerSet
private
var
millisToSolve
:
Long
=
4000
private
var
numDigits
:
Int
=
3
private
lateinit
var
timer
:
CountDownTimer
private
lateinit
var
colorAnimation
:
ValueAnimator
...
...
@@ -28,14 +28,16 @@ class TaskActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_task
)
val
numDigits
=
intent
.
getIntExtra
(
"num_digits"
,
3
)
millisToSolve
=
1000
*
intent
.
getIntExtra
(
"sec_to_solve"
,
4
).
toLong
()
retrieveExtras
()
initTimer
()
startNewRound
()
}
private
fun
startNewRound
()
{
answerSet
=
AnswerSet
(
numDigits
,
listOf
(
card_left_top
,
card_right_top
,
card_left_bottom
,
card_right_bottom
))
setUp
Answer
Buttons
()
setUpButtons
()
timer
.
start
()
startProgressBarAnimation
()
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
}
fun
reload
()
{
...
...
@@ -44,10 +46,22 @@ class TaskActivity : AppCompatActivity() {
startActivity
(
intent
)
}
private
fun
setUpAnswerButtons
()
{
private
fun
retrieveExtras
()
{
numDigits
=
intent
.
getIntExtra
(
"num_digits"
,
3
)
millisToSolve
=
1000
*
intent
.
getIntExtra
(
"sec_to_solve"
,
4
).
toLong
()
}
private
fun
setUpButtons
()
{
for
(
answer
in
answerSet
)
{
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
color
(
R
.
color
.
transparent_black
))
answer
.
card
.
setOnClickListener
{
processAnswer
(
answer
)
}
answer
.
card
.
background
.
clearColorFilter
()
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_next
.
apply
{
setOnClickListener
{
startNewRound
()
}
visibility
=
View
.
INVISIBLE
}
}
...
...
@@ -61,18 +75,18 @@ class TaskActivity : AppCompatActivity() {
private
fun
setResponseText
(
answer
:
Answer
)
{
tv_timer
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
btn_next
.
visibility
=
View
.
VISIBLE
btn_next
.
setOnClickListener
{
reload
()
}
if
(
answer
.
correct
)
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
)
)
answer
.
card
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorAccent
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorAccent
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
setTextColor
(
color
(
R
.
color
.
transparent_dark_black
))
}
else
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
setCardBackgroundColor
(
color
(
R
.
color
.
colorPrimary
)
)
answer
.
card
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
}
}
...
...
app/src/main/res/values/colors.xml
View file @
afc32e00
...
...
@@ -3,7 +3,7 @@
<color
name=
"colorPrimary"
>
#4a148c
</color>
<color
name=
"colorPrimaryDark"
>
#12005e
</color>
<color
name=
"colorAccent"
>
#4dd0e1
</color>
<color
name=
"transparent_black"
>
#
97
000000
</color>
<color
name=
"transparent_black"
>
#
83
000000
</color>
<color
name=
"transparent_dark_black"
>
#BB000000
</color>
<color
name=
"transparent_red"
>
#97FF0000
</color>
</resources>
app/src/main/res/values/styles.xml
View file @
afc32e00
...
...
@@ -23,6 +23,7 @@
<item
name=
"android:layout_height"
>
wrap_content
</item>
<item
name=
"android:layout_width"
>
wrap_content
</item>
<item
name=
"android:layout_gravity"
>
center
</item>
<item
name=
"android:focusable"
>
false
</item>
<item
name=
"android:textAppearance"
>
@style/TextAppearance.MaterialComponents.Headline4
</item>
</style>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment