Commit 84a2e414 by likorn

Move to next question from TimeIsOverFragment

parent 8d4a1791
......@@ -50,6 +50,12 @@ class MainActivity : AppCompatActivity() {
}
}
fun reload() {
val intent = intent
finish()
startActivity(intent)
}
private val timer = object : CountDownTimer(4000, 1000) {
override fun onTick(millisUntilFinished: Long) {
tv_time_left.text = (millisUntilFinished / 1000).toString()
......
......@@ -35,13 +35,7 @@ class ResponseFragment: Fragment() {
private fun view(view: View, color: Int, responseId: Int): View {
view.findViewById<TextView>(R.id.tv_response).text = resources.getString(responseId)
view.findViewById<ConstraintLayout>(R.id.response_layout).setBackgroundColor(color)
view.findViewById<ImageButton>(R.id.btn_next).setOnClickListener { reloadActivity() }
view.findViewById<ImageButton>(R.id.btn_next).setOnClickListener { (activity as MainActivity).reload() }
return view
}
private fun reloadActivity() {
val intent = activity?.intent
activity?.finish()
activity?.startActivity(intent)
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import androidx.fragment.app.Fragment
class TimeIsOverFragment: Fragment() {
......@@ -16,6 +17,8 @@ class TimeIsOverFragment: Fragment() {
override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_time_is_over, container, false)
val view = inflater.inflate(R.layout.fragment_time_is_over, container, false)
view.findViewById<ImageButton>(R.id.btn_next).setOnClickListener { (activity as MainActivity).reload() }
return view
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
android:background="#A80C0000">
<ImageView
android:id="@+id/imageView"
android:id="@+id/img_view_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
......@@ -26,8 +26,35 @@
android:text="@string/time_is_over"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:textColor="#F44336"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/response_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
app:layout_constraintTop_toBottomOf="@+id/img_view_timer" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/response_layout"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="#F44336"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageButton
android:id="@+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
android:background="#009C27B0"
android:tint="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_double_arrow" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment