Skip to content

Commit

Permalink
[feat/upgrade_web_bridge]: 그룹 만들기 페이지 웹뷰 연동
Browse files Browse the repository at this point in the history
  • Loading branch information
soopeach committed Mar 15, 2024
1 parent 86ce5b6 commit 2746646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,23 @@ import org.gdsc.presentation.utils.repeatWhenUiStarted

class WebViewActivity : AppCompatActivity() {
private lateinit var binding: ActivityWebViewBinding
private lateinit var webView:WebView
private lateinit var webView: WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityWebViewBinding.inflate(layoutInflater)
setContentView(binding.root)

// webViewInit()

webView = binding.webView

setWebViewBackPress()
intent.extras?.let {
binding.webView.apply {

repeatWhenUiStarted {
loadUrl(it.getString("url") ?: WEB_BASE_URL)
}
webViewInit()

settings.javaScriptEnabled = true
settings.domStorageEnabled = true
webViewClient = WebViewClient()

addJavascriptInterface(WebAppInterface(context), "webviewBridge")
}

}
setWebViewBackPress()

// val actionBar: ActionBar? = supportActionBar
// actionBar!!.hide()
}

private fun setWebViewBackPress() {
this.onBackPressedDispatcher.addCallback(this) {
if (binding.webView.canGoBack()) {
Expand All @@ -60,14 +47,20 @@ class WebViewActivity : AppCompatActivity() {
}
}

fun webViewInit() {
val webSettings: WebSettings = webView.getSettings()
webSettings.javaScriptEnabled = true // allow the js
private fun webViewInit() {

webView.apply {
loadUrl(WEB_BASE_URL + "group-create/name/")

settings.javaScriptEnabled = true // allow the js
settings.domStorageEnabled = true
webViewClient = WebViewClient()
addJavascriptInterface(WebAppInterface(this@WebViewActivity), "webviewBridge")
}


window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) //화면이 계속 켜짐
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_USER
webView.webViewClient = WebViewClient()

webView.addJavascriptInterface(WebAppInterface(this), "webviewBridge")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class HomeFragment : Fragment(), ViewHolderBindListener {
is ResultState.OnSuccess -> {
val groupList = state.response

if (groupList.isNullOrEmpty()) {
if (groupList.isEmpty()) {
viewModel.setCurrentGroup(null)

BottomSheetDialog(requireContext())
Expand Down

0 comments on commit 2746646

Please sign in to comment.