pull/1352/head
gedoor 3 years ago
parent d03729f964
commit 903f06d10a
  1. 6
      app/src/main/java/io/legado/app/help/IntentData.kt
  2. 4
      app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt
  4. 1
      app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt
  5. 3
      app/src/main/java/io/legado/app/ui/web/WebViewModel.kt

@ -1,17 +1,17 @@
package io.legado.app.help package io.legado.app.help
object IntentDataHelp { object IntentData {
private val bigData: MutableMap<String, Any> = mutableMapOf() private val bigData: MutableMap<String, Any> = mutableMapOf()
fun putData(data: Any, tag: String = ""): String { fun put(data: Any, tag: String = ""): String {
val key = tag + System.currentTimeMillis() val key = tag + System.currentTimeMillis()
bigData[key] = data bigData[key] = data
return key return key
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T> getData(key: String?): T? { fun <T> get(key: String?): T? {
if (key == null) return null if (key == null) return null
val data = bigData[key] val data = bigData[key]
bigData.remove(key) bigData.remove(key)

@ -11,7 +11,7 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
import io.legado.app.databinding.ActivityTranslucenceBinding import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentData
import io.legado.app.lib.dialogs.SelectItem import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.permission.Permissions import io.legado.app.lib.permission.Permissions
@ -122,7 +122,7 @@ class HandleFileActivity :
private fun getFileData(): Triple<String, ByteArray, String>? { private fun getFileData(): Triple<String, ByteArray, String>? {
val fileName = intent.getStringExtra("fileName") val fileName = intent.getStringExtra("fileName")
val file = intent.getStringExtra("fileKey")?.let { val file = intent.getStringExtra("fileKey")?.let {
IntentDataHelp.getData<ByteArray>(it) IntentData.get<ByteArray>(it)
} }
val contentType = intent.getStringExtra("contentType") val contentType = intent.getStringExtra("contentType")
if (fileName != null && file != null && contentType != null) { if (fileName != null && file != null && contentType != null) {

@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import androidx.activity.result.contract.ActivityResultContract import androidx.activity.result.contract.ActivityResultContract
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentData
import io.legado.app.lib.dialogs.SelectItem import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.utils.putJson import io.legado.app.utils.putJson
@ -32,7 +32,7 @@ class HandleFileContract :
intent.putJson("otherActions", it.otherActions) intent.putJson("otherActions", it.otherActions)
it.fileData?.let { fileData -> it.fileData?.let { fileData ->
intent.putExtra("fileName", fileData.first) intent.putExtra("fileName", fileData.first)
intent.putExtra("fileKey", IntentDataHelp.putData(fileData.second)) intent.putExtra("fileKey", IntentData.put(fileData.second))
intent.putExtra("contentType", fileData.third) intent.putExtra("contentType", fileData.third)
} }
} }

@ -36,6 +36,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initWebView() initWebView()
} }
@SuppressLint("JavascriptInterface") @SuppressLint("JavascriptInterface")

@ -15,6 +15,9 @@ import java.util.*
class WebViewModel(application: Application) : BaseViewModel(application) { class WebViewModel(application: Application) : BaseViewModel(application) {
fun initData(url: String, header: Map<String, String>?) {
}
fun saveImage(webPic: String?, path: String) { fun saveImage(webPic: String?, path: String) {
webPic ?: return webPic ?: return

Loading…
Cancel
Save