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
1752e93b
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed ResponseFragment
parent
4b6d125e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
78 deletions
app/src/main/java/com/example/quickmax/ResponseFragment.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/res/layout/activity_task.xml
app/src/main/res/layout/fragment_response.xml
app/src/main/java/com/example/quickmax/ResponseFragment.kt
deleted
100644 → 0
View file @
4b6d125e
package
com.example.quickmax
import
android.graphics.Color
import
android.graphics.PorterDuff
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
com.google.android.material.button.MaterialButton
class
ResponseFragment
:
Fragment
()
{
companion
object
{
fun
newInstance
():
ResponseFragment
{
return
ResponseFragment
()
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
val
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_response
,
container
,
false
)
val
correct
=
arguments
!!
.
getBoolean
(
"correct"
)
return
if
(
correct
)
view
(
view
,
color
(
R
.
color
.
colorAccent
),
color
(
R
.
color
.
transparent_dark_black
))
else
view
(
view
,
color
(
R
.
color
.
colorPrimary
),
Color
.
WHITE
)
}
private
fun
view
(
view
:
View
,
color
:
Int
,
textColor
:
Int
):
View
{
view
.
findViewById
<
MaterialButton
>(
R
.
id
.
btn_next
).
apply
{
background
.
setColorFilter
(
color
,
PorterDuff
.
Mode
.
MULTIPLY
)
setTextColor
(
textColor
)
setOnClickListener
{
(
activity
as
TaskActivity
).
reload
()
}
}
return
view
}
private
fun
color
(
colorId
:
Int
):
Int
{
return
ContextCompat
.
getColor
(
activity
!!
,
colorId
)
}
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
1752e93b
...
...
@@ -4,14 +4,17 @@ import android.animation.ArgbEvaluator
import
android.animation.ValueAnimator
import
android.content.Intent
import
android.graphics.Color
import
android.graphics.PorterDuff
import
android.os.Bundle
import
android.os.CountDownTimer
import
android.util.TypedValue
import
android.view.View
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
com.example.quickmax.answers.Answer
import
com.example.quickmax.answers.AnswerSet
import
com.google.android.material.button.MaterialButton
import
kotlinx.android.synthetic.main.activity_task.*
class
TaskActivity
:
AppCompatActivity
()
{
...
...
@@ -53,32 +56,26 @@ class TaskActivity : AppCompatActivity() {
colorAnimation
.
cancel
()
setResponseText
(
answer
)
makeButtonsUncheckable
()
startResponseFragment
(
answer
)
}
private
fun
setResponseText
(
answer
:
Answer
)
{
tv_timer
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
resources
.
getDimension
(
R
.
dimen
.
response_text_size
))
btn_next
.
visibility
=
View
.
VISIBLE
btn_next
.
setOnClickListener
{
reload
()
}
if
(
answer
.
correct
)
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorAccent
))
btn_next
.
background
.
setColorFilter
(
resources
.
getColor
(
R
.
color
.
colorAccent
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
transparent_dark_black
))
}
else
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
setCardBackgroundColor
(
resources
.
getColor
(
R
.
color
.
colorPrimary
))
btn_next
.
background
.
setColorFilter
(
resources
.
getColor
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
}
}
private
fun
startResponseFragment
(
answer
:
Answer
)
{
val
responseFragment
=
ResponseFragment
.
newInstance
().
also
{
f
->
f
.
arguments
=
Bundle
().
also
{
b
->
b
.
putBoolean
(
"correct"
,
answer
.
correct
)
}
}
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
main_layout
,
responseFragment
,
"response"
)
.
commitAllowingStateLoss
()
}
private
fun
makeButtonsUncheckable
()
{
for
(
answer
in
answerSet
)
{
answer
.
card
.
isClickable
=
false
...
...
app/src/main/res/layout/activity_task.xml
View file @
1752e93b
...
...
@@ -146,4 +146,15 @@
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
android:text=
"@string/btn_next"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
android:visibility=
"invisible"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_response.xml
deleted
100644 → 0
View file @
4b6d125e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/response_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btn_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginBottom=
"8dp"
android:text=
"@string/btn_next"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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