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
5d376899
authored
Sep 25, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CardView to MaterialCardView + refactoring
parent
c1ccc474
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
51 deletions
app/src/main/java/com/example/quickmax/MainActivity.kt
app/src/main/java/com/example/quickmax/TaskActivity.kt
app/src/main/java/com/example/quickmax/answers/Answer.kt
app/src/main/java/com/example/quickmax/answers/AnswerSet.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_task.xml
app/src/main/res/values/styles.xml
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
5d376899
...
...
@@ -6,7 +6,7 @@ import android.os.Bundle
import
android.view.View
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.cardview.widget.
CardView
import
com.google.android.material.card.Material
CardView
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
...
...
@@ -30,7 +30,7 @@ class MainActivity: AppCompatActivity() {
}
private
val
cardOnClickListener
=
View
.
OnClickListener
{
card
->
val
numDigits
=
((
card
as
CardView
).
getChildAt
(
0
)
as
TextView
).
text
.
toString
().
toInt
()
val
numDigits
=
((
card
as
Material
CardView
).
getChildAt
(
0
)
as
TextView
).
text
.
toString
().
toInt
()
saveSelectedValues
()
...
...
app/src/main/java/com/example/quickmax/TaskActivity.kt
View file @
5d376899
...
...
@@ -40,12 +40,6 @@ class TaskActivity : AppCompatActivity() {
startProgressBarAnimation
()
}
fun
reload
()
{
val
intent
=
intent
finish
()
startActivity
(
intent
)
}
private
fun
retrieveExtras
()
{
numDigits
=
intent
.
getIntExtra
(
"num_digits"
,
3
)
millisToSolve
=
1000
*
intent
.
getIntExtra
(
"sec_to_solve"
,
4
).
toLong
()
...
...
@@ -56,7 +50,7 @@ class TaskActivity : AppCompatActivity() {
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
text
=
answer
.
value
.
toString
()
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
color
(
R
.
color
.
transparent_black
))
answer
.
card
.
setOnClickListener
{
processAnswer
(
answer
)
}
answer
.
card
.
background
.
clearColorFilter
(
)
answer
.
card
.
setCardBackgroundColor
(
Color
.
WHITE
)
}
btn_back
.
setOnClickListener
{
startActivity
(
Intent
(
this
@TaskActivity
,
MainActivity
::
class
.
java
))
}
btn_next
.
apply
{
...
...
@@ -78,13 +72,13 @@ class TaskActivity : AppCompatActivity() {
if
(
answer
.
correct
)
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_correct
)
answer
.
card
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorAccent
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorAccent
),
PorterDuff
.
Mode
.
MULTIPLY
)
answer
.
card
.
setCardBackgroundColor
(
color
(
R
.
color
.
colorAccent
)
)
btn_next
.
background
TintList
=
ContextCompat
.
getColorStateList
(
this
,
R
.
color
.
colorAccent
)
btn_next
.
setTextColor
(
color
(
R
.
color
.
transparent_dark_black
))
}
else
{
tv_timer
.
text
=
resources
.
getString
(
R
.
string
.
response_wrong
)
answer
.
card
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
btn_next
.
background
.
setColorFilter
(
color
(
R
.
color
.
colorPrimary
),
PorterDuff
.
Mode
.
MULTIPLY
)
answer
.
card
.
setCardBackgroundColor
(
color
(
R
.
color
.
colorPrimary
)
)
btn_next
.
background
TintList
=
ContextCompat
.
getColorStateList
(
this
,
(
R
.
color
.
colorPrimary
)
)
btn_next
.
setTextColor
(
Color
.
WHITE
)
(
answer
.
card
.
getChildAt
(
0
)
as
TextView
).
setTextColor
(
Color
.
WHITE
)
}
...
...
app/src/main/java/com/example/quickmax/answers/Answer.kt
View file @
5d376899
package
com.example.quickmax.answers
import
androidx.cardview.widget.
CardView
import
com.google.android.material.card.Material
CardView
class
Answer
(
val
card
:
CardView
,
val
value
:
Int
)
{
class
Answer
(
val
card
:
Material
CardView
,
val
value
:
Int
)
{
var
correct
:
Boolean
=
false
}
\ No newline at end of file
app/src/main/java/com/example/quickmax/answers/AnswerSet.kt
View file @
5d376899
package
com.example.quickmax.answers
import
androidx.cardview.widget.
CardView
import
com.google.android.material.card.Material
CardView
class
AnswerSet
(
numDigits
:
Int
,
private
val
cards
:
List
<
CardView
>):
Iterable
<
Answer
>
{
class
AnswerSet
(
numDigits
:
Int
,
cards
:
List
<
Material
CardView
>):
Iterable
<
Answer
>
{
private
val
numAnswers
=
4
private
lateinit
var
correctAnswer
:
Answer
...
...
app/src/main/res/layout/activity_main.xml
View file @
5d376899
<?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"
style=
"@style/Base.CardView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/gradient"
>
...
...
@@ -33,7 +32,7 @@
app:layout_constraintTop_toBottomOf=
"@+id/tv_how_many_digits"
app:layout_constraintBottom_toTopOf=
"@+id/seek_bar"
>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_2_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -45,9 +44,9 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_2"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_3_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -59,9 +58,9 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_3"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_4_digits"
style=
"@style/MyCard"
android:foreground=
"?android:attr/selectableItemBackground"
...
...
@@ -73,7 +72,7 @@
<TextView
style=
"@style/AnswerCardText"
android:text=
"@string/number_digits_4"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.crystal.crystalrangeseekbar.widgets.CrystalSeekbar
...
...
app/src/main/res/layout/activity_task.xml
View file @
5d376899
...
...
@@ -44,15 +44,12 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/cv_task"
style=
"@style/
CardView.Light
"
style=
"@style/
MyCard
"
android:layout_width=
"0dp"
android:layout_height=
"150dp"
android:layout_margin=
"16dp"
app:cardBackgroundColor=
"@android:color/white"
app:cardCornerRadius=
"4dp"
app:cardElevation=
"2dp"
app:layout_constraintBottom_toTopOf=
"@+id/layout_answers"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -76,7 +73,7 @@
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"#323753"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/layout_answers"
...
...
@@ -93,9 +90,10 @@
app:layout_constraintVertical_bias=
"0.5"
app:layout_constraintVertical_chainStyle=
"packed"
>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_left_top"
style=
"@style/MyCard"
app:cardCornerRadius=
"10dp"
app:layout_constraintBottom_toTopOf=
"@+id/card_left_bottom"
app:layout_constraintEnd_toStartOf=
"@+id/card_right_top"
app:layout_constraintHorizontal_bias=
"0.5"
...
...
@@ -104,9 +102,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_right_top"
style=
"@style/MyCard"
app:layout_constraintBottom_toTopOf=
"@id/card_right_bottom"
...
...
@@ -117,9 +115,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_left_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -130,9 +128,9 @@
<TextView
style=
"@style/AnswerCardText"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
<
androidx.cardview.widget.
CardView
<
com.google.android.material.card.Material
CardView
android:id=
"@+id/card_right_bottom"
style=
"@style/MyCard"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -143,7 +141,7 @@
<TextView
style=
"@style/AnswerCardText"
/>
</
androidx.cardview.widget.
CardView>
</
com.google.android.material.card.Material
CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
...
...
app/src/main/res/values/styles.xml
View file @
5d376899
...
...
@@ -4,18 +4,18 @@
<style
name=
"AppTheme"
parent=
"Theme.AppCompat.Light.DarkActionBar"
>
<!-- Customize your theme here. -->
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item
>
<!-- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>--
>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
<style
name=
"MyCard"
parent=
"CardView"
>
<style
name=
"MyCard"
parent=
"
Widget.MaterialComponents.
CardView"
>
<item
name=
"android:layout_width"
>
0dp
</item>
<item
name=
"android:layout_height"
>
0dp
</item>
<item
name=
"android:layout_margin"
>
8dp
</item>
<item
name=
"android:clickable"
>
true
</item>
<item
name=
"android:focusable"
>
true
</item>
<item
name=
"android:foreground"
>
?attr/selectableItemBackground
</item>
<item
name=
"cardCornerRadius"
>
4
dp
</item>
<item
name=
"cardCornerRadius"
>
6
dp
</item>
<item
name=
"cardBackgroundColor"
>
@android:color/white
</item>
</style>
...
...
@@ -26,14 +26,4 @@
<item
name=
"android:focusable"
>
false
</item>
<item
name=
"android:textAppearance"
>
@style/TextAppearance.MaterialComponents.Headline4
</item>
</style>
<style
name=
"ButtonNext"
>
<item
name=
"android:layout_width"
>
wrap_content
</item>
<item
name=
"android:layout_height"
>
wrap_content
</item>
<item
name=
"android:layout_marginTop"
>
8dp
</item>
<item
name=
"android:layout_marginEnd"
>
24dp
</item>
<item
name=
"android:layout_marginBottom"
>
8dp
</item>
<item
name=
"android:background"
>
@android:color/transparent
</item>
<item
name=
"tint"
>
@android:color/white
</item>
</style>
</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