mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-08-01 11:40:34 +00:00
Fix potential crash
This commit is contained in:
parent
b22a4b14ad
commit
fb5d53c03a
2 changed files with 5 additions and 5 deletions
|
|
@ -54,12 +54,12 @@ class SkillTasksActivity : BaseActivity() {
|
|||
viewPager.adapter = object : FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val taskType = when (position) {
|
||||
val fragment = SkillTasksRecyclerViewFragment()
|
||||
fragment.taskType = when (position) {
|
||||
0 -> Task.TYPE_HABIT
|
||||
1 -> Task.TYPE_DAILY
|
||||
else -> Task.TYPE_TODO
|
||||
}
|
||||
val fragment = SkillTasksRecyclerViewFragment(taskType)
|
||||
|
||||
compositeSubscription.add(fragment.getTaskSelectionEvents().subscribe(Consumer { task -> taskSelected(task) }, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ import io.reactivex.subjects.PublishSubject
|
|||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class SkillTasksRecyclerViewFragment(val taskType: String) : BaseFragment() {
|
||||
class SkillTasksRecyclerViewFragment() : BaseFragment() {
|
||||
@Inject
|
||||
lateinit var taskRepository: TaskRepository
|
||||
@field:[Inject Named(AppModule.NAMED_USER_ID)]
|
||||
lateinit var userId: String
|
||||
var taskType: String? = null
|
||||
|
||||
private val recyclerView: RecyclerView? by bindView(R.id.recyclerView)
|
||||
|
||||
|
|
@ -63,13 +64,12 @@ class SkillTasksRecyclerViewFragment(val taskType: String) : BaseFragment() {
|
|||
taskSelectionEvents.onNext(it)
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
recyclerView?.adapter = adapter
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
var tasks = taskRepository.getTasks(taskType, userId)
|
||||
var tasks = taskRepository.getTasks(taskType ?: "", userId)
|
||||
if (taskType == Task.TYPE_TODO) {
|
||||
tasks = tasks.map { it.where().equalTo("completed", false).findAll() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue