From 903f06d10ac9aa2e9f68b6837cb2de1e8bd18769 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 29 Sep 2021 17:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/help/{IntentDataHelp.kt => IntentData.kt} | 6 +++--- .../java/io/legado/app/ui/document/HandleFileActivity.kt | 4 ++-- .../java/io/legado/app/ui/document/HandleFileContract.kt | 4 ++-- app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt | 1 + app/src/main/java/io/legado/app/ui/web/WebViewModel.kt | 3 +++ 5 files changed, 11 insertions(+), 7 deletions(-) rename app/src/main/java/io/legado/app/help/{IntentDataHelp.kt => IntentData.kt} (75%) diff --git a/app/src/main/java/io/legado/app/help/IntentDataHelp.kt b/app/src/main/java/io/legado/app/help/IntentData.kt similarity index 75% rename from app/src/main/java/io/legado/app/help/IntentDataHelp.kt rename to app/src/main/java/io/legado/app/help/IntentData.kt index dc2f16ee9..e8c1f7c1c 100644 --- a/app/src/main/java/io/legado/app/help/IntentDataHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentData.kt @@ -1,17 +1,17 @@ package io.legado.app.help -object IntentDataHelp { +object IntentData { private val bigData: MutableMap = mutableMapOf() - fun putData(data: Any, tag: String = ""): String { + fun put(data: Any, tag: String = ""): String { val key = tag + System.currentTimeMillis() bigData[key] = data return key } @Suppress("UNCHECKED_CAST") - fun getData(key: String?): T? { + fun get(key: String?): T? { if (key == null) return null val data = bigData[key] bigData.remove(key) diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt index 7f5f45ea9..756e1cbe0 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt @@ -11,7 +11,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.Theme 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.alert import io.legado.app.lib.permission.Permissions @@ -122,7 +122,7 @@ class HandleFileActivity : private fun getFileData(): Triple? { val fileName = intent.getStringExtra("fileName") val file = intent.getStringExtra("fileKey")?.let { - IntentDataHelp.getData(it) + IntentData.get(it) } val contentType = intent.getStringExtra("contentType") if (fileName != null && file != null && contentType != null) { diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt index 29a01662b..fb18b5699 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt @@ -5,7 +5,7 @@ import android.content.Context import android.content.Intent import android.net.Uri 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.utils.putJson @@ -32,7 +32,7 @@ class HandleFileContract : intent.putJson("otherActions", it.otherActions) it.fileData?.let { fileData -> intent.putExtra("fileName", fileData.first) - intent.putExtra("fileKey", IntentDataHelp.putData(fileData.second)) + intent.putExtra("fileKey", IntentData.put(fileData.second)) intent.putExtra("contentType", fileData.third) } } diff --git a/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt b/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt index 46248d6d9..7bf0e1378 100644 --- a/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt +++ b/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt @@ -36,6 +36,7 @@ class WebViewActivity : VMBaseActivity() { override fun onActivityCreated(savedInstanceState: Bundle?) { initWebView() + } @SuppressLint("JavascriptInterface") diff --git a/app/src/main/java/io/legado/app/ui/web/WebViewModel.kt b/app/src/main/java/io/legado/app/ui/web/WebViewModel.kt index c5b0577f0..0bc580587 100644 --- a/app/src/main/java/io/legado/app/ui/web/WebViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/web/WebViewModel.kt @@ -15,6 +15,9 @@ import java.util.* class WebViewModel(application: Application) : BaseViewModel(application) { + fun initData(url: String, header: Map?) { + + } fun saveImage(webPic: String?, path: String) { webPic ?: return