Load task edit info in parallel

pull/1074/head
Alex Baker 4 years ago
parent 3ca6ccae1b
commit 4cd6e081f5

@ -26,7 +26,7 @@ import com.todoroo.astrid.data.Task
import com.todoroo.astrid.service.TaskCreator import com.todoroo.astrid.service.TaskCreator
import com.todoroo.astrid.timers.TimerControlSet.TimerControlSetCallback import com.todoroo.astrid.timers.TimerControlSet.TimerControlSetCallback
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch import kotlinx.coroutines.*
import org.tasks.BuildConfig import org.tasks.BuildConfig
import org.tasks.LocalBroadcastManager import org.tasks.LocalBroadcastManager
import org.tasks.R import org.tasks.R
@ -355,17 +355,27 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
it.save() it.save()
} }
clearUi() clearUi()
val fragment = newTaskEditFragment( coroutineScope {
task, val freshTask = async { if (task.isNew) task else taskDao.fetch(task.id) ?: task }
defaultFilterProvider.getList(task), val list = async { defaultFilterProvider.getList(task) }
locationDao.getLocation(task, preferences), val location = async { locationDao.getLocation(task, preferences) }
tagDataDao.getTags(task), val tags = async { tagDataDao.getTags(task) }
alarmDao.getAlarms(task), val alarms = async { alarmDao.getAlarms(task) }
filterColor) val fragment = withContext(Dispatchers.Default) {
supportFragmentManager.beginTransaction() newTaskEditFragment(
.replace(R.id.detail, fragment, TaskEditFragment.TAG_TASKEDIT_FRAGMENT) freshTask.await(),
.runOnCommit(this::showDetailFragment) list.await(),
.commitNow() location.await(),
tags.await(),
alarms.await(),
filterColor)
}
supportFragmentManager.beginTransaction()
.replace(R.id.detail, fragment, TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
.runOnCommit { showDetailFragment() }
.commitNow()
}
} }
override fun onNavigationIconClicked() { override fun onNavigationIconClicked() {

Loading…
Cancel
Save