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
bd22e856
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CardView ids are replaced with cardViews in Answer class
parent
4e411cc6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
20 deletions
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/java/com/example/quickmax/answers/Answer.kt
app/src/main/java/com/example/quickmax/answers/AnswerSet.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
bd22e856
...
...
@@ -8,7 +8,6 @@ import android.os.Bundle
import
android.os.CountDownTimer
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.cardview.widget.CardView
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.Answer
import
com.example.quickmax.answers.AnswerSet
...
...
@@ -28,7 +27,7 @@ class TaskActivity : AppCompatActivity() {
val
numDigits
=
intent
.
getIntExtra
(
"num_digits"
,
3
)
millisToSolve
=
1000
*
intent
.
getIntExtra
(
"sec_to_solve"
,
4
).
toLong
()
initTimer
()
answerSet
=
AnswerSet
(
numDigits
)
answerSet
=
AnswerSet
(
numDigits
,
listOf
(
card_left_top
,
card_right_top
,
card_left_bottom
,
card_right_bottom
)
)
setUpAnswerButtons
()
timer
.
start
()
startProgressBarAnimation
()
...
...
@@ -43,8 +42,8 @@ class TaskActivity : AppCompatActivity() {
private
fun
setUpAnswerButtons
()
{
for
(
answer
in
answerSet
)
{
(
findViewById
<
CardView
>(
answer
.
cardId
)
.
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
findViewById
<
CardView
>(
answer
.
cardId
)
.
setOnClickListener
{
processAnswer
(
answer
)
}
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
answer
.
card
.
setOnClickListener
{
processAnswer
(
answer
)
}
}
}
...
...
@@ -52,10 +51,10 @@ class TaskActivity : AppCompatActivity() {
timer
.
cancel
()
colorAnimation
.
cancel
()
if
(
answer
.
correct
)
findViewById
<
CardView
>(
answer
.
cardId
)
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
))
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
))
else
{
findViewById
<
CardView
>(
answer
.
cardId
)
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorPrimary
))
(
findViewById
<
CardView
>(
answer
.
cardId
)
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorPrimary
))
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
}
makeButtonsUncheckable
()
...
...
@@ -72,7 +71,7 @@ class TaskActivity : AppCompatActivity() {
private
fun
makeButtonsUncheckable
()
{
for
(
answer
in
answerSet
)
{
findViewById
<
CardView
>(
answer
.
cardId
)
.
isClickable
=
false
answer
.
card
.
isClickable
=
false
}
}
...
...
app/src/main/java/com/example/quickmax/answers/Answer.kt
View file @
bd22e856
package
com.example.quickmax.answers
class
Answer
(
val
cardId
:
Int
,
val
value
:
Int
)
{
import
androidx.cardview.widget.CardView
class
Answer
(
val
card
:
CardView
,
val
value
:
Int
)
{
var
correct
:
Boolean
=
false
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/answers/AnswerSet.kt
View file @
bd22e856
package
com.example.quickmax.answers
import
com.example.quickmax.R
import
androidx.cardview.widget.CardView
class
AnswerSet
(
numDigits
:
Int
):
Iterable
<
Answer
>
{
private
val
buttonIds
=
listOf
(
R
.
id
.
card_left_top
,
R
.
id
.
card_right_top
,
R
.
id
.
card_left_bottom
,
R
.
id
.
card_right_bottom
)
class
AnswerSet
(
numDigits
:
Int
,
private
val
cards
:
List
<
CardView
>):
Iterable
<
Answer
>
{
private
val
numAnswers
=
4
private
lateinit
var
correctAnswer
:
Answer
...
...
@@ -21,7 +13,7 @@ class AnswerSet(numDigits: Int): Iterable<Answer> {
for
(
i
in
0
until
numAnswers
)
answers
.
add
(
Answer
(
buttonI
ds
[
i
],
car
ds
[
i
],
randomNumbers
.
elementAt
(
i
)
)
)
...
...
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