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
2a6b1943
authored
Sep 28, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved buttonNext style logic to ButtonNext class
parent
a9f9c93d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
18 deletions
app/src/main/java/com/paktalin/quickmax/ButtonNext.kt
app/src/main/java/com/paktalin/quickmax/MyColorAnimation.kt
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt
app/src/main/res/layout-land/activity_task.xml
app/src/main/res/layout/activity_task.xml
app/src/main/java/com/paktalin/quickmax/ButtonNext.kt
0 → 100644
View file @
2a6b1943
package
com.paktalin.quickmax
import
android.content.Context
import
android.graphics.Color
import
android.util.AttributeSet
import
android.view.View
import
androidx.core.content.ContextCompat
import
com.google.android.material.button.MaterialButton
class
ButtonNext
:
MaterialButton
{
constructor
(
context
:
Context
)
:
super
(
context
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?,
defStyleAttr
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
)
fun
initial
()
{
visibility
=
View
.
INVISIBLE
}
fun
correct
(
context
:
Context
)
{
visibility
=
View
.
VISIBLE
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
,
R
.
color
.
colorAccent
)
setTextColor
(
color
(
context
,
R
.
color
.
transparent_dark_black
))
}
fun
incorrect
(
context
:
Context
)
{
visibility
=
View
.
VISIBLE
backgroundTintList
=
ContextCompat
.
getColorStateList
(
context
,
R
.
color
.
colorPrimary
)
setTextColor
(
Color
.
WHITE
)
}
}
app/src/main/java/com/paktalin/quickmax/MyColorAnimation.kt
0 → 100644
View file @
2a6b1943
package
com.paktalin.quickmax
app/src/main/java/com/paktalin/quickmax/TaskActivity.kt
View file @
2a6b1943
...
...
@@ -8,7 +8,6 @@ import android.graphics.PorterDuff
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.util.TypedValue
import
android.view.View
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
com.paktalin.quickmax.answers.Answer
...
...
@@ -40,7 +39,7 @@ class TaskActivity : AppCompatActivity() {
)
setUpCards
()
timer
.
start
()
start
ProgressBa
rAnimation
()
start
Colo
rAnimation
()
}
private
fun
retrieveExtras
()
{
...
...
@@ -49,14 +48,14 @@ class TaskActivity : AppCompatActivity() {
}
private
fun
setUpCards
()
{
answerSet
.
forEach
{
answer
->
answerSet
.
forEach
{
answer
->
answer
.
card
.
setOnCheckedChangeListener
{
_
,
isChecked
->
if
(
isChecked
)
processAnswer
(
answer
)
}
answer
.
card
.
initial
(
this
@TaskActivity
,
answer
.
value
)
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_next
.
apply
{
setOnClickListener
{
startNewRound
()
}
visibility
=
View
.
INVISIBLE
initial
()
}
}
...
...
@@ -69,27 +68,23 @@ class TaskActivity : AppCompatActivity() {
private
fun
setResponseText
(
answer
:
Answer
)
{
tv_response
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
btn_next
.
visibility
=
View
.
VISIBLE
if
(
answer
.
correct
)
{
answer
.
card
.
markCorrect
(
this
@TaskActivity
)
tv_response
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
colorAccent
)
btn_next
.
setTextColor
(
color
(
this
,
R
.
color
.
transparent_dark_black
))
btn_next
.
correct
(
this
@TaskActivity
)
}
else
{
answer
.
card
.
markWrong
(
this
@TaskActivity
)
tv_response
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
colorPrimary
)
btn_next
.
setTextColor
(
Color
.
WHITE
)
btn_next
.
incorrect
(
this
@TaskActivity
)
}
}
private
fun
start
ProgressBa
rAnimation
()
{
private
fun
start
Colo
rAnimation
()
{
val
colorFrom
=
Color
.
TRANSPARENT
val
colorTo
=
color
(
this
,
R
.
color
.
transparent_red
)
val
colorTo
=
color
(
this
,
R
.
color
.
transparent_red
)
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
millisToSolve
.
apply
{
duration
=
millisToSolve
}
colorAnimation
.
addUpdateListener
{
animator
->
layout_gradient
.
background
.
setColorFilter
(
animator
.
animatedValue
as
Int
,
PorterDuff
.
Mode
.
SRC_ATOP
)
...
...
@@ -106,9 +101,7 @@ class TaskActivity : AppCompatActivity() {
override
fun
onFinish
()
{
tv_response
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
tv_response
.
text
=
resources
.
getString
(
R
.
string
.
time_is_over
)
btn_next
.
backgroundTintList
=
ContextCompat
.
getColorStateList
(
this
@TaskActivity
,
R
.
color
.
colorPrimary
)
btn_next
.
setTextColor
(
Color
.
WHITE
)
btn_next
.
visibility
=
View
.
VISIBLE
btn_next
.
incorrect
(
this
@TaskActivity
)
answerSet
.
forEach
{
answer
->
answer
.
card
.
disable
()}
}
}
...
...
app/src/main/res/layout-land/activity_task.xml
View file @
2a6b1943
...
...
@@ -142,7 +142,7 @@
</com.paktalin.quickmax.AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.
google.android.material.button.MaterialButton
<com.
paktalin.quickmax.ButtonNext
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/activity_task.xml
View file @
2a6b1943
...
...
@@ -151,7 +151,7 @@
</com.paktalin.quickmax.AnswerCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.
google.android.material.button.MaterialButton
<com.
paktalin.quickmax.ButtonNext
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
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