Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1613: Start Question Player not work when Orientation Change #1614

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import javax.inject.Inject
class TopicPracticeFragment : InjectableFragment() {
companion object {
internal const val SUBTOPIC_ID_LIST_ARGUMENT_KEY = "SUBTOPIC_ID_LIST_ARGUMENT_KEY"
internal const val SKILL_ID_LIST_ARGUMENT_KEY = "SKILL_ID_LIST_ARGUMENT_KEY"

/** Returns a new [TopicPracticeFragment]. */
fun newInstance(internalProfileId: Int, topicId: String): TopicPracticeFragment {
Expand All @@ -40,8 +41,11 @@ class TopicPracticeFragment : InjectableFragment() {
savedInstanceState: Bundle?
): View? {
var selectedIdList = ArrayList<Int>()
var selectedSkillId = HashMap<Int, MutableList<String>>()
if (savedInstanceState != null) {
selectedIdList = savedInstanceState.getIntegerArrayList(SUBTOPIC_ID_LIST_ARGUMENT_KEY)!!
selectedSkillId = savedInstanceState
.getSerializable(SKILL_ID_LIST_ARGUMENT_KEY)!! as HashMap<Int, MutableList<String>>
}
val internalProfileId = arguments?.getInt(PROFILE_ID_ARGUMENT_KEY, -1)!!
val topicId = checkNotNull(arguments?.getString(TOPIC_ID_ARGUMENT_KEY)) {
Expand All @@ -51,6 +55,7 @@ class TopicPracticeFragment : InjectableFragment() {
inflater,
container,
selectedIdList,
selectedSkillId,
internalProfileId,
topicId
)
Expand All @@ -62,5 +67,9 @@ class TopicPracticeFragment : InjectableFragment() {
SUBTOPIC_ID_LIST_ARGUMENT_KEY,
topicPracticeFragmentPresenter.selectedSubtopicIdList
)
outState.putSerializable(
SKILL_ID_LIST_ARGUMENT_KEY,
topicPracticeFragmentPresenter.skillIdHashMap
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TopicPracticeFragmentPresenter @Inject constructor(
private lateinit var binding: TopicPracticeFragmentBinding
private lateinit var linearLayoutManager: LinearLayoutManager
lateinit var selectedSubtopicIdList: ArrayList<Int>
private var skillIdHashMap = HashMap<Int, MutableList<String>>()
var skillIdHashMap = HashMap<Int, MutableList<String>>()
private lateinit var topicId: String
private lateinit var topicPracticeFooterViewBinding: TopicPracticeFooterViewBinding
private val routeToQuestionPlayerListener = activity as RouteToQuestionPlayerListener
Expand All @@ -41,6 +41,7 @@ class TopicPracticeFragmentPresenter @Inject constructor(
inflater: LayoutInflater,
container: ViewGroup?,
subtopicList: ArrayList<Int>,
selectedSkillId: HashMap<Int, MutableList<String>>,
internalProfileId: Int,
topicId: String
): View? {
Expand All @@ -50,6 +51,7 @@ class TopicPracticeFragmentPresenter @Inject constructor(
viewModel.setInternalProfileId(internalProfileId)

selectedSubtopicIdList = subtopicList
skillIdHashMap = selectedSkillId
binding = TopicPracticeFragmentBinding.inflate(
inflater,
container,
Expand Down