|
|
@ -8,7 +8,10 @@ import android.os.Bundle |
|
|
|
import android.view.Menu |
|
|
|
import android.view.Menu |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
|
|
|
|
import androidx.lifecycle.LiveData |
|
|
|
|
|
|
|
import androidx.lifecycle.Observer |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.AppConfig |
|
|
@ -24,6 +27,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
private var rootDoc: DocumentFile? = null |
|
|
|
private var rootDoc: DocumentFile? = null |
|
|
|
private val subDirs = arrayListOf<String>() |
|
|
|
private val subDirs = arrayListOf<String>() |
|
|
|
private lateinit var importBookAdapter: ImportBookAdapter |
|
|
|
private lateinit var importBookAdapter: ImportBookAdapter |
|
|
|
|
|
|
|
private var localUriLiveData: LiveData<List<String>>? = null |
|
|
|
|
|
|
|
|
|
|
|
override val viewModel: ImportBookViewModel |
|
|
|
override val viewModel: ImportBookViewModel |
|
|
|
get() = getViewModel(ImportBookViewModel::class.java) |
|
|
|
get() = getViewModel(ImportBookViewModel::class.java) |
|
|
@ -31,6 +35,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
initView() |
|
|
|
initView() |
|
|
|
initEvent() |
|
|
|
initEvent() |
|
|
|
|
|
|
|
initData() |
|
|
|
upRootDoc() |
|
|
|
upRootDoc() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -64,6 +69,14 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
|
|
|
localUriLiveData?.removeObservers(this) |
|
|
|
|
|
|
|
localUriLiveData = App.db.bookDao().observeLocalUri() |
|
|
|
|
|
|
|
localUriLiveData?.observe(this, Observer { |
|
|
|
|
|
|
|
importBookAdapter.upBookHas(it) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upRootDoc() { |
|
|
|
private fun upRootDoc() { |
|
|
|
AppConfig.importBookPath?.let { |
|
|
|
AppConfig.importBookPath?.let { |
|
|
|
val rootUri = Uri.parse(it) |
|
|
|
val rootUri = Uri.parse(it) |
|
|
|