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
d1f25a69
authored
Sep 26, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced CardStyle. WIP
parent
9eae27a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
app/src/main/java/com/example/quickmax/CardStyle.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/java/com/example/quickmax/CardStyle.kt
0 → 100644
View file @
d1f25a69
package
com.example.quickmax
import
android.graphics.Color
class
CardStyle
(
var
isCheckable
:
Boolean
,
var
isEnabled
:
Boolean
,
var
isChecked
:
Boolean
,
var
backgroundColor
:
Int
,
var
textColorId
:
Int
)
{
companion
object
{
fun
initial
():
CardStyle
{
return
CardStyle
(
isCheckable
=
true
,
isEnabled
=
true
,
isChecked
=
false
,
backgroundColor
=
Color
.
WHITE
,
textColorId
=
R
.
color
.
transparent_black
)
}
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
d1f25a69
...
@@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity
...
@@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.Answer
import
com.example.quickmax.answers.Answer
import
com.example.quickmax.answers.AnswerSet
import
com.example.quickmax.answers.AnswerSet
import
com.google.android.material.card.MaterialCardView
import
kotlinx.android.synthetic.main.activity_task.*
import
kotlinx.android.synthetic.main.activity_task.*
class
TaskActivity
:
AppCompatActivity
()
{
class
TaskActivity
:
AppCompatActivity
()
{
...
@@ -34,6 +35,10 @@ class TaskActivity : AppCompatActivity() {
...
@@ -34,6 +35,10 @@ class TaskActivity : AppCompatActivity() {
private
fun
startNewRound
()
{
private
fun
startNewRound
()
{
answerSet
=
AnswerSet
(
numDigits
,
listOf
(
card_left_top
,
card_right_top
,
card_left_bottom
,
card_right_bottom
))
answerSet
=
AnswerSet
(
numDigits
,
listOf
(
card_left_top
,
card_right_top
,
card_left_bottom
,
card_right_bottom
))
answerSet
.
forEach
{
answer
->
answer
.
card
.
setOnClickListener
{
answer
.
card
.
isChecked
=
true
}
answer
.
card
.
setOnCheckedChangeListener
{
_
,
isChecked
->
if
(
isChecked
)
processAnswer
(
answer
)
}
}
setUpCards
()
setUpCards
()
timer
.
start
()
timer
.
start
()
startProgressBarAnimation
()
startProgressBarAnimation
()
...
@@ -47,13 +52,7 @@ class TaskActivity : AppCompatActivity() {
...
@@ -47,13 +52,7 @@ class TaskActivity : AppCompatActivity() {
private
fun
setUpCards
()
{
private
fun
setUpCards
()
{
for
(
answer
in
answerSet
)
{
for
(
answer
in
answerSet
)
{
getTextView
(
answer
.
card
).
text
=
answer
.
value
.
toString
()
getTextView
(
answer
.
card
).
text
=
answer
.
value
.
toString
()
getTextView
(
answer
.
card
).
setTextColor
(
color
(
this
,
R
.
color
.
transparent_black
))
styleCard
(
answer
.
card
,
CardStyle
.
initial
())
answer
.
card
.
isCheckable
=
true
answer
.
card
.
isEnabled
=
true
answer
.
card
.
isChecked
=
false
answer
.
card
.
setOnClickListener
{
answer
.
card
.
isChecked
=
true
}
answer
.
card
.
setOnCheckedChangeListener
{
_
,
isChecked
->
if
(
isChecked
)
processAnswer
(
answer
)
}
answer
.
card
.
setCardBackgroundColor
(
Color
.
WHITE
)
}
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_next
.
apply
{
btn_next
.
apply
{
...
@@ -62,6 +61,14 @@ class TaskActivity : AppCompatActivity() {
...
@@ -62,6 +61,14 @@ class TaskActivity : AppCompatActivity() {
}
}
}
}
private
fun
styleCard
(
card
:
MaterialCardView
,
style
:
CardStyle
)
{
card
.
isCheckable
=
style
.
isCheckable
card
.
isEnabled
=
style
.
isEnabled
card
.
isChecked
=
style
.
isChecked
card
.
setCardBackgroundColor
(
style
.
backgroundColor
)
getTextView
(
card
).
setTextColor
(
color
(
this
,
style
.
textColorId
))
}
private
fun
processAnswer
(
answer
:
Answer
)
{
private
fun
processAnswer
(
answer
:
Answer
)
{
timer
.
cancel
()
timer
.
cancel
()
colorAnimation
.
cancel
()
colorAnimation
.
cancel
()
...
...
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