From 32904188c731dfd82f3e0aae5c4ac0aeffc2fce7 Mon Sep 17 00:00:00 2001 From: tgyuuAn Date: Sun, 28 Jul 2024 17:12:27 +0900 Subject: [PATCH] =?UTF-8?q?update=20:=20AndroidBridege=EC=97=90=EC=84=9C?= =?UTF-8?q?=20'android'=20=EB=A1=9C=20=ED=98=B8=EC=B6=9C=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD,?= =?UTF-8?q?=20=EB=8F=84=EB=A1=9C=EB=AA=85=20=EC=A3=BC=EC=86=8C=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 77 ++++++++++++++++++++++++- index.html | 163 ++++++++++++++++++++++++++++++++--------------------- 2 files changed, 174 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 943106f..95d28ae 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,79 @@


-**WebView**를 사용할 때 url을`tgyuuan.github.io/DaumAddressApi`로 설정하고 사용하면 된다. +**WebView**를 사용할 때 url을`https://tgyuuan.github.io/DaumAddressApi`로 설정하고 사용하면 된다. + +```kotlin +@AndroidEntryPoint +class PostCodeFragment : DialogFragment() { + + private var _binding: FragmentPostCodeBinding? = null + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentPostCodeBinding.inflate(inflater, container, false) + binding.lifecycleOwner = this.viewLifecycleOwner + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setupWebView() + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + + @SuppressLint("SetJavaScriptEnabled") + private fun setupWebView() { + binding.postcodeWV.apply { + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + settings.useWideViewPort = true + settings.loadWithOverviewMode = true + settings.cacheMode = WebSettings.LOAD_NO_CACHE + + webViewClient = WebViewClient() + webChromeClient = WebChromeClient() + + addJavascriptInterface(AndroidBridge(), "android") + loadUrl("https://tgyuuan.github.io/DaumAddressApi") + } + } + + private inner class AndroidBridge { + @JavascriptInterface + fun onPostCodeReceived(roadNameAddress: String, lotNumberAddress: String) { + + // 여기서 받아온 데이터를 핸들링 할 코드를 작성 + + dismiss() + } + } +} +``` + +```xml + + + + + + + + +``` \ No newline at end of file diff --git a/index.html b/index.html index e84764f..3091a0c 100644 --- a/index.html +++ b/index.html @@ -1,104 +1,132 @@ + - -
+ +
+
+ + +
+ 접기 버튼
- - + - + \ No newline at end of file