Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. package com.hily.app.presentation.ui.fragments.puzzle
  2.  
  3. import android.os.Bundle
  4. import android.view.LayoutInflater
  5. import android.view.View
  6. import android.view.ViewGroup
  7. import com.hily.app.data.model.pojo.dialog.DialogResponse
  8. import com.hily.app.data.model.pojo.thread.IceBreakerListItem
  9. import com.hily.app.presentation.ui.fragments.BaseFragment
  10. import org.jetbrains.anko.AnkoContext
  11. import javax.inject.Inject
  12.  
  13. /**
  14. * Created by Kirill Stoianov on 3/7/19.
  15. */
  16. class PuzzleFunnelFragment : BaseFragment(), PuzzleFunnelViewImpl.ActionListener {
  17.  
  18. companion object {
  19. val TAG: String = PuzzleFunnelFragment::class.java.simpleName
  20.  
  21. private const val ARG_TAG_PUZZLE_QUIZ = "ARG_TAG_PUZZLE_QUIZ"
  22.  
  23. fun newInstance(puzzleQuiz: DialogResponse.PuzzleQuiz): PuzzleFunnelFragment {
  24. return PuzzleFunnelFragment().apply {
  25. val args = Bundle()
  26. args.putParcelable(ARG_TAG_PUZZLE_QUIZ, puzzleQuiz)
  27. arguments = args
  28. }
  29. }
  30. }
  31.  
  32. @Inject
  33. lateinit var puzzleFunnelPresenter: PuzzleFunnelPresenter
  34.  
  35. private val puzzleQuiz by lazy {
  36. arguments?.getParcelable<DialogResponse.PuzzleQuiz>(ARG_TAG_PUZZLE_QUIZ)
  37. }
  38.  
  39. private val puzzleFunnelViewImpl = PuzzleFunnelViewImpl()
  40.  
  41. override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  42. return context?.let { c ->
  43. puzzleFunnelViewImpl.createView(AnkoContext.create(c, this))
  44. }
  45. }
  46.  
  47. override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  48. super.onViewCreated(view, savedInstanceState)
  49. puzzleFunnelViewImpl.actionListener = this
  50. puzzleFunnelPresenter.attachView(puzzleFunnelViewImpl)
  51.  
  52. //initialize fragment with puzzle quiz
  53. puzzleQuiz?.apply { puzzleFunnelPresenter.showPuzzleQuiz(this) }
  54. }
  55.  
  56. override fun onDetach() {
  57. puzzleFunnelPresenter.detachView()
  58. super.onDetach()
  59. }
  60.  
  61. override fun onAnswer(userId: Long, puzzleAnswerId: Long, puzzleQuestionId: Long) {
  62. puzzleFunnelPresenter.sendAnswer(userId, puzzleAnswerId, puzzleQuestionId)
  63. }
  64.  
  65. override fun sendMessage(message: String) {
  66. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
  67. }
  68.  
  69. override fun sendIceBreaker(iceBreaker: IceBreakerListItem) {
  70. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
  71. }
  72.  
  73. override fun tryAgain(userId: Long) {
  74. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement