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
50897d67
authored
Sep 24, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Progress bar works as a timer
parent
6024ee21
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
app/src/main/java/com/example/quickmax/MainActivity.kt
app/src/main/res/layout/activity_main.xml
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
50897d67
package
com.example.quickmax
import
android.os.Build
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.widget.TextView
...
...
@@ -10,6 +11,7 @@ import kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
private
lateinit
var
answerSet
:
AnswerSet
private
val
timeToSolve
=
4000
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
...
...
@@ -52,9 +54,13 @@ class MainActivity : AppCompatActivity() {
startActivity
(
intent
)
}
private
val
timer
=
object
:
CountDownTimer
(
4000
,
10
00
)
{
private
val
timer
=
object
:
CountDownTimer
(
timeToSolve
.
toLong
(),
1
00
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
// tv_time_left.text = (millisUntilFinished / 1000).toString()
val
progress
=
((
timeToSolve
-
millisUntilFinished
).
toFloat
()
/
timeToSolve
)
*
100
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
bar_time_left
.
setProgress
(
progress
.
toInt
(),
true
)
else
bar_time_left
.
progress
=
progress
.
toInt
()
}
override
fun
onFinish
()
{
...
...
app/src/main/res/layout/activity_main.xml
View file @
50897d67
...
...
@@ -25,14 +25,13 @@
app:layout_constraintTop_toTopOf=
"parent"
>
<ProgressBar
android:id=
"@+id/bar_time_left"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_height=
"32dp"
android:layout_gravity=
"center"
android:indeterminate=
"true"
android:indeterminateTint=
"#FFFFFF"
android:progressTint=
"#FF9800"
android:progressTintMode=
"src_atop"
/>
android:max=
"100"
android:indeterminate=
"false"
/>
</FrameLayout>
...
...
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