Skip to content

Commit

Permalink
put all the stups inside the if
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash-Codes committed Jan 3, 2025
1 parent 0f27640 commit f657b1c
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.webkit.*
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -27,21 +26,8 @@ class WebViewActivity : AppCompatActivity() {
val dataFromDeepLink = intent.dataString
fromDeepLink = !TextUtils.isEmpty(dataFromDeepLink)
val title: String? = intent.getStringExtra("title")
Log.d("WebViewActivity", "onCreate: $title")
link = intent.getStringExtra("link") ?: ""
val resourceId = intent.getStringExtra("RESOURCE_ID")

val hasIndexHtml = resourceId?.let {
val directory = File(getExternalFilesDir(null), "ole/$resourceId")
File(directory, "index.html").exists()
} ?: false

requestedOrientation = if (hasIndexHtml) {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} else {
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}

clearCookie()
if (!TextUtils.isEmpty(title)) {
activityWebViewBinding.contentWebView.webTitle.text = title
Expand All @@ -57,6 +43,7 @@ class WebViewActivity : AppCompatActivity() {
val indexFile = File(directory, "index.html")

if (indexFile.exists()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
activityWebViewBinding.contentWebView.wv.loadUrl("file://${indexFile.absolutePath}")
}
} else {
Expand Down

0 comments on commit f657b1c

Please sign in to comment.