Skip to content

Commit

Permalink
📝 Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbatovK committed Apr 4, 2022
1 parent 314daf3 commit 40ca49a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ class EnterFragment : Fragment(), MainActivity.IOnBackPressed {
dialog.show()
}

override fun onBackPressed(): Boolean {
override fun onBackPressed(): Boolean =
activity?.let {
it.finish()
it.finishAffinity()
}
return true
}
true
} ?: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.albatros.kquiz.R
import com.albatros.kquiz.databinding.GameFragmentBinding
import com.albatros.kquiz.ui.activity.MainActivity
import com.albatros.kquiz.ui.adapter.answer.AnswerAdapter
import com.albatros.kquiz.ui.adapter.answer.AnswerAdapterListener
import kotlinx.coroutines.Dispatchers
Expand All @@ -25,14 +26,16 @@ import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf

class GameFragment : Fragment() {
class GameFragment : Fragment(), MainActivity.IOnBackPressed {

private lateinit var binding: GameFragmentBinding
private val args by navArgs<GameFragmentArgs>()
private val viewModel: GameViewModel by viewModel { parametersOf(args.question) }
private var answered = false
private var currentAnswer = ""

override fun onBackPressed(): Boolean = true

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.albatros.kquiz.R
import com.albatros.kquiz.databinding.ResultFragmentBinding
import com.albatros.kquiz.model.data.info.ClientInfo
import com.albatros.kquiz.ui.activity.MainActivity
import com.albatros.kquiz.ui.adapter.client.ResultAdapter
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf

class ResultFragment : Fragment() {
class ResultFragment : Fragment(), MainActivity.IOnBackPressed {

private lateinit var binding: ResultFragmentBinding
private val args by navArgs<ResultFragmentArgs>()
private val viewModel: ResultViewModel by viewModel { parametersOf(args.question) }

override fun onBackPressed(): Boolean = true

private val onPassiveStateEndedObserver = Observer<Boolean> { value ->
if (value) {
viewModel.getNextQuestion()?.let {
Expand Down

0 comments on commit 40ca49a

Please sign in to comment.