@@ -38,6 +38,7 @@ import android.view.MenuItem
3838import android.view.View
3939import androidx.annotation.PluralsRes
4040import androidx.annotation.RequiresApi
41+ import kotlinx.coroutines.CoroutineDispatcher
4142import kotlinx.coroutines.CoroutineScope
4243import kotlinx.coroutines.Dispatchers
4344import kotlinx.coroutines.launch
@@ -75,7 +76,9 @@ import java.io.IOException
7576import java.util.concurrent.locks.ReentrantLock
7677
7778@SuppressLint(" NotifyDataSetChanged" )
78- class ProjectListFragment : RecyclerViewFragment <ProjectData ?>(), ProjectLoadListener {
79+ class ProjectListFragment (
80+ private val mainDispatcher : CoroutineDispatcher = Dispatchers .Main
81+ ) : RecyclerViewFragment<ProjectData?>(), ProjectLoadListener {
7982 private var items: MutableList <ProjectData > = ArrayList ()
8083
8184 private var filesForUnzipAndImportTask: ArrayList <File >? = null
@@ -95,7 +98,9 @@ class ProjectListFragment : RecyclerViewFragment<ProjectData?>(), ProjectLoadLis
9598 importProject(requireArguments().getParcelable(" intent" ))
9699 }
97100 if (requireActivity().intent?.hasExtra(ProjectListActivity .IMPORT_LOCAL_INTENT ) == true ) {
98- adapter.showSettings = false
101+ if (adapter != null ) {
102+ adapter.showSettings = false
103+ }
99104 actionModeType = IMPORT_LOCAL
100105 }
101106 }
@@ -559,7 +564,7 @@ class ProjectListFragment : RecyclerViewFragment<ProjectData?>(), ProjectLoadLis
559564 items = newItems
560565 lock.unlock()
561566
562- withContext(Dispatchers . Main ) {
567+ withContext(mainDispatcher ) {
563568 callback.onProjectsLoaded()
564569 }
565570 }
0 commit comments