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
b367ef90
authored
Sep 23, 2019
by
likorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RadioButtons are uncheckable after answering
parent
138ec96f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
12 deletions
app/build.gradle
app/src/androidTest/java/com/example/quickmax/MainActivityTest.kt
app/src/main/java/com/example/quickmax/MainActivity.kt
app/src/main/res/layout/fragment_time_is_over.xml
app/src/main/res/values/strings.xml
app/build.gradle
View file @
b367ef90
...
...
@@ -9,7 +9,7 @@ android {
buildToolsVersion
"29.0.2"
defaultConfig
{
applicationId
"com.example.quickmax"
minSdkVersion
17
minSdkVersion
21
targetSdkVersion
29
versionCode
1
versionName
"1.0"
...
...
@@ -30,8 +30,10 @@ dependencies {
implementation
'androidx.appcompat:appcompat:1.1.0'
implementation
'androidx.core:core-ktx:1.1.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'com.google.android.material:material:1.0.0'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation
'
com.android.support.test:rules:1.0.2
'
androidTestImplementation
'
androidx.test:rules:1.2.0
'
}
app/src/androidTest/java/com/example/quickmax/MainActivityTest.kt
View file @
b367ef90
...
...
@@ -67,7 +67,7 @@ class MainActivityTest {
@Test
fun
fragment_when_time_is_over
()
{
Thread
.
sleep
(
3
000
)
Thread
.
sleep
(
4
000
)
assertNotNull
(
testRule
.
activity
.
supportFragmentManager
.
fragments
.
find
{
f
->
f
is
TimeIsOverFragment
})
}
...
...
app/src/main/java/com/example/quickmax/MainActivity.kt
View file @
b367ef90
...
...
@@ -5,30 +5,29 @@ import android.os.CountDownTimer
import
android.view.View
import
android.widget.RadioButton
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.view.get
import
androidx.fragment.app.Fragment
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
var
numberSet
=
NumberSet
(
4
,
3
)
private
var
toAcceptAnswer
=
true
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
addRadioButtons
()
setTimer
()
}
private
fun
setTimer
()
{
object
:
CountDownTimer
(
3000
,
1000
)
{
object
:
CountDownTimer
(
4000
,
1000
)
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
tv_time_left
.
text
=
(
millisUntilFinished
/
1000
).
toString
()
}
override
fun
onFinish
()
{
makeRadioButtonsUncheckable
()
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
main_layout
,
TimeIsOverFragment
.
newInstance
(),
"time_is_over"
)
...
...
@@ -48,9 +47,6 @@ class MainActivity : AppCompatActivity() {
}
private
fun
processAnswer
(
answer
:
Int
)
{
if
(!
toAcceptAnswer
)
return
toAcceptAnswer
=
false
val
responseFragment
:
Fragment
=
if
(
numberSet
.
isCorrect
(
answer
))
{
ResponseCorrectFragment
.
newInstance
()
}
else
...
...
@@ -60,5 +56,12 @@ class MainActivity : AppCompatActivity() {
.
beginTransaction
()
.
add
(
R
.
id
.
main_layout
,
responseFragment
,
"response"
)
.
commitAllowingStateLoss
()
makeRadioButtonsUncheckable
()
}
private
fun
makeRadioButtonsUncheckable
()
{
for
(
i
in
0
until
radio_group
.
childCount
)
{
radio_group
[
i
].
isClickable
=
false
}
}
}
app/src/main/res/layout/fragment_time_is_over.xml
View file @
b367ef90
...
...
@@ -2,16 +2,32 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:background=
"#A80C0000"
>
<ImageView
android:id=
"@+id/imageView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:tint=
"#F44336"
app:layout_constraintBottom_to
BottomOf=
"parent
"
app:layout_constraintBottom_to
TopOf=
"@id/textView
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_chainStyle=
"packed"
app:srcCompat=
"@drawable/ic_timer_big"
/>
<TextView
android:id=
"@+id/textView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:text=
"@string/time_is_over"
android:textAppearance=
"@android:style/TextAppearance.Material.Large"
android:textColor=
"#F44336"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/imageView"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
b367ef90
...
...
@@ -3,4 +3,5 @@
<string
name=
"second_max"
>
Выберите второе наибольшее число
</string>
<string
name=
"response_correct"
>
CORRECT
</string>
<string
name=
"response_wrong"
>
WRONG
</string>
<string
name=
"time_is_over"
>
TIME IS OVER
</string>
</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