|
|
@ -12,7 +12,6 @@ import android.view.MenuItem |
|
|
|
import android.view.ViewTreeObserver |
|
|
|
import android.view.ViewTreeObserver |
|
|
|
import android.widget.EditText |
|
|
|
import android.widget.EditText |
|
|
|
import android.widget.PopupWindow |
|
|
|
import android.widget.PopupWindow |
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
@ -46,10 +45,9 @@ class RssSourceEditActivity : |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
initView() |
|
|
|
initView() |
|
|
|
viewModel.sourceLiveData.observe(this, Observer { |
|
|
|
viewModel.initData(intent) { |
|
|
|
upRecyclerView(it) |
|
|
|
upRecyclerView() |
|
|
|
}) |
|
|
|
} |
|
|
|
viewModel.initData(intent) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
override fun onDestroy() { |
|
|
@ -85,7 +83,7 @@ class RssSourceEditActivity : |
|
|
|
clipboard?.primaryClip = ClipData.newPlainText(null, sourceStr) |
|
|
|
clipboard?.primaryClip = ClipData.newPlainText(null, sourceStr) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.menu_paste_source -> viewModel.pasteSource() |
|
|
|
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView() } |
|
|
|
} |
|
|
|
} |
|
|
|
return super.onCompatOptionsItemSelected(item) |
|
|
|
return super.onCompatOptionsItemSelected(item) |
|
|
|
} |
|
|
|
} |
|
|
@ -98,7 +96,8 @@ class RssSourceEditActivity : |
|
|
|
recycler_view.adapter = adapter |
|
|
|
recycler_view.adapter = adapter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upRecyclerView(rssSource: RssSource?) { |
|
|
|
private fun upRecyclerView() { |
|
|
|
|
|
|
|
val rssSource = viewModel.rssSource |
|
|
|
rssSource?.let { |
|
|
|
rssSource?.let { |
|
|
|
cb_is_enable.isChecked = rssSource.enabled |
|
|
|
cb_is_enable.isChecked = rssSource.enabled |
|
|
|
cb_enable_js.isChecked = rssSource.enableJs |
|
|
|
cb_enable_js.isChecked = rssSource.enableJs |
|
|
@ -136,7 +135,7 @@ class RssSourceEditActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getRssSource(): RssSource? { |
|
|
|
private fun getRssSource(): RssSource? { |
|
|
|
val source = viewModel.sourceLiveData.value ?: RssSource() |
|
|
|
val source = viewModel.rssSource?.copy() ?: RssSource() |
|
|
|
source.enabled = cb_is_enable.isChecked |
|
|
|
source.enabled = cb_is_enable.isChecked |
|
|
|
source.enableJs = cb_enable_js.isChecked |
|
|
|
source.enableJs = cb_enable_js.isChecked |
|
|
|
source.loadWithBaseUrl = cb_enable_base_url.isChecked |
|
|
|
source.loadWithBaseUrl = cb_enable_base_url.isChecked |
|
|
|