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
49eba251
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Background animation instead of progressBar
parent
cef6183d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
41 deletions
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/res/layout/activity_task.xml
app/src/main/res/values/colors.xml
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
49eba251
...
...
@@ -55,12 +55,12 @@ class TaskActivity : AppCompatActivity() {
}
private
fun
startProgressBarAnimation
()
{
val
colorFrom
=
Co
ntextCompat
.
getColor
(
this
,
R
.
color
.
colorPrimary
)
val
colorTo
=
Co
lor
.
RED
val
colorFrom
=
Co
lor
.
TRANSPARENT
val
colorTo
=
Co
ntextCompat
.
getColor
(
this
,
R
.
color
.
transparent_red
)
val
colorAnimation
=
ValueAnimator
.
ofObject
(
ArgbEvaluator
(),
colorFrom
,
colorTo
)
colorAnimation
.
duration
=
timeToSolve
colorAnimation
.
addUpdateListener
{
animator
->
progress_bar
.
progressDrawable
.
setColorFilter
(
animator
.
animatedValue
as
Int
,
layout_gradient
.
background
.
setColorFilter
(
animator
.
animatedValue
as
Int
,
android
.
graphics
.
PorterDuff
.
Mode
.
SRC_ATOP
)
}
colorAnimation
.
start
()
...
...
@@ -72,13 +72,9 @@ class TaskActivity : AppCompatActivity() {
startActivity
(
intent
)
}
private
val
timer
=
object
:
CountDownTimer
(
timeToSolve
,
100
)
{
private
val
timer
=
object
:
CountDownTimer
(
timeToSolve
,
100
0
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
val
progress
=
((
timeToSolve
-
millisUntilFinished
).
toFloat
()
/
timeToSolve
)
*
100
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
progress_bar
.
setProgress
(
progress
.
toInt
(),
true
)
else
progress_bar
.
progress
=
progress
.
toInt
()
tv_timer
.
text
=
(
millisUntilFinished
/
1000
).
toString
()
}
override
fun
onFinish
()
{
...
...
app/src/main/res/layout/activity_task.xml
View file @
49eba251
...
...
@@ -9,33 +9,16 @@
tools:context=
".TaskActivity"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/layout_gradient"
android:layout_width=
"0dp"
android:layout_height=
"200dp"
android:layout_height=
"0dp"
android:layout_marginBottom=
"32dp"
android:background=
"@drawable/gradient"
app:layout_constraintBottom_toBottomOf=
"@+id/cv_task"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/layout_progress_bar"
android:layout_width=
"match_parent"
android:layout_height=
"4dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ProgressBar
android:id=
"@+id/progress_bar"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_gravity=
"center"
android:foregroundTint=
"#320A64"
android:indeterminate=
"false"
android:max=
"100"
/>
</FrameLayout>
<ImageButton
android:id=
"@+id/imageButton"
android:layout_width=
"wrap_content"
...
...
@@ -45,24 +28,23 @@
android:background=
"@android:color/transparent"
android:tint=
"@android:color/white"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_to
BottomOf=
"@+id/layout_progress_bar
"
app:layout_constraintTop_to
TopOf=
"parent
"
app:srcCompat=
"@drawable/ic_back"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id=
"@+id/tv_score
"
android:id=
"@+id/tv_timer
"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_height=
"0dp"
android:gravity=
"center"
android:text=
"Score: 5"
android:textAppearance=
"@style/TextAppearance.AppCompat.Medium"
android:text=
"@string/number_digits_3"
android:textColor=
"@android:color/white"
app:layout_constraintBottom_toBottomOf=
"@+id/imageButton"
app:autoSizeTextType=
"uniform"
app:layout_constraintBottom_toTopOf=
"@+id/cv_task"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/layout_progress_bar"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.cardview.widget.CardView
android:id=
"@+id/cv_task"
...
...
@@ -77,7 +59,6 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<TextView
...
...
app/src/main/res/values/colors.xml
View file @
49eba251
...
...
@@ -4,4 +4,5 @@
<color
name=
"colorPrimaryDark"
>
#12005e
</color>
<color
name=
"colorAccent"
>
#4dd0e1
</color>
<color
name=
"transparent_black"
>
#97000000
</color>
<color
name=
"transparent_red"
>
#97FF0000
</color>
</resources>
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