|
|
|
@ -5,9 +5,8 @@ import android.app.Activity |
|
|
|
|
import android.content.ActivityNotFoundException |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.Menu |
|
|
|
|
import android.view.MenuItem |
|
|
|
|
import android.view.SubMenu |
|
|
|
|
import android.util.DisplayMetrics |
|
|
|
|
import android.view.* |
|
|
|
|
import androidx.appcompat.widget.PopupMenu |
|
|
|
|
import androidx.appcompat.widget.SearchView |
|
|
|
|
import androidx.core.content.FileProvider |
|
|
|
@ -19,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
|
import io.legado.app.App |
|
|
|
|
import io.legado.app.BuildConfig |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
|
import io.legado.app.constant.AppPattern |
|
|
|
|
import io.legado.app.constant.EventBus |
|
|
|
@ -40,8 +40,12 @@ import io.legado.app.ui.widget.recycler.VerticalDivider |
|
|
|
|
import io.legado.app.ui.widget.text.AutoCompleteTextView |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import kotlinx.android.synthetic.main.activity_book_source.* |
|
|
|
|
import kotlinx.android.synthetic.main.activity_book_source.recycler_view |
|
|
|
|
import kotlinx.android.synthetic.main.dialog_edit_text.view.* |
|
|
|
|
import kotlinx.android.synthetic.main.dialog_progressbar_view.* |
|
|
|
|
import kotlinx.android.synthetic.main.dialog_progressbar_view.tv_footer_left |
|
|
|
|
import kotlinx.android.synthetic.main.view_search.* |
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
|
import org.jetbrains.anko.startActivityForResult |
|
|
|
|
import org.jetbrains.anko.toast |
|
|
|
@ -66,12 +70,6 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity |
|
|
|
|
private var sort = 0 |
|
|
|
|
private var sortAscending = 0 |
|
|
|
|
|
|
|
|
|
private val progressDialogBuilder by lazy { |
|
|
|
|
progressDialog("校验书源") { |
|
|
|
|
setCancelable(false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
initRecyclerView() |
|
|
|
|
initSearchView() |
|
|
|
@ -270,30 +268,6 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun observeLiveBus() { |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_INIT) { max-> |
|
|
|
|
progressDialogBuilder.max = max |
|
|
|
|
progressDialogBuilder.show() |
|
|
|
|
} |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_UP_PROGRESS) { progress-> |
|
|
|
|
progressDialogBuilder.progress = progress |
|
|
|
|
} |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_DONE) { |
|
|
|
|
if (progressDialogBuilder.isShowing) { |
|
|
|
|
progressDialogBuilder.progress = it |
|
|
|
|
progressDialogBuilder.max = it |
|
|
|
|
progressDialogBuilder.dismiss() |
|
|
|
|
} |
|
|
|
|
toast("校验完成!") |
|
|
|
|
groups.map { group-> |
|
|
|
|
if (group.contains("失效")) { |
|
|
|
|
search_view.setQuery("失效", true) |
|
|
|
|
toast("发现有失效书源,已为您自动筛选!") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean { |
|
|
|
|
when (item?.itemId) { |
|
|
|
|
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.getSelection()) |
|
|
|
@ -415,6 +389,24 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity |
|
|
|
|
}.show().applyTint() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun observeLiveBus() { |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_INIT) { max-> |
|
|
|
|
val bundle = Bundle() |
|
|
|
|
bundle.putInt("maxProgress", max) |
|
|
|
|
CheckSourceDialog().apply { |
|
|
|
|
arguments = bundle |
|
|
|
|
}.show(supportFragmentManager, "CheckDialog") |
|
|
|
|
} |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_DONE) { |
|
|
|
|
groups.map { group-> |
|
|
|
|
if (group.contains("失效")) { |
|
|
|
|
search_view.setQuery("失效", true) |
|
|
|
|
toast("发现有失效书源,已为您自动筛选!") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun upCountView() { |
|
|
|
|
select_action_bar.upCountView(adapter.getSelection().size, adapter.getActualItemCount()) |
|
|
|
|
} |
|
|
|
@ -509,4 +501,47 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity |
|
|
|
|
search_view.setQuery("", true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class CheckSourceDialog : BaseDialogFragment() { |
|
|
|
|
override fun onStart() { |
|
|
|
|
super.onStart() |
|
|
|
|
val dm = DisplayMetrics() |
|
|
|
|
activity?.windowManager?.defaultDisplay?.getMetrics(dm) |
|
|
|
|
dialog?.window?.setLayout( |
|
|
|
|
(dm.widthPixels * 0.9).toInt(), |
|
|
|
|
(dm.heightPixels * 0.14).toInt() |
|
|
|
|
) |
|
|
|
|
dialog?.setCancelable(false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateView( |
|
|
|
|
inflater: LayoutInflater, |
|
|
|
|
container: ViewGroup?, |
|
|
|
|
savedInstanceState: Bundle? |
|
|
|
|
): View? { |
|
|
|
|
return inflater.inflate(R.layout.dialog_progressbar_view, container) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
arguments?.let { bundle -> |
|
|
|
|
val maxProgress = bundle.getInt("maxProgress") |
|
|
|
|
ck_progress_text.text = getString(R.string.progress_show, "", 0, maxProgress) |
|
|
|
|
ck_progress.max = maxProgress |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_UP_PROGRESS) { progress-> |
|
|
|
|
ck_progress.progress = progress |
|
|
|
|
} |
|
|
|
|
observeEvent<String>(EventBus.CHECK_UP_PROGRESS_STRING) { |
|
|
|
|
ck_progress_text.text = it |
|
|
|
|
} |
|
|
|
|
observeEvent<Int>(EventBus.CHECK_DONE) { |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
tv_footer_left.onClick { |
|
|
|
|
CheckSource.stop(requireContext()).apply { |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |