fix: requirecontext issues ?

This commit is contained in:
aminecmi 2023-02-26 16:05:26 +01:00
parent bf37209a15
commit c2a1c9eaac

View File

@ -151,6 +151,7 @@ class ArticleFragment : Fragment(), DIAware {
} catch (e: InflateException) {
e.sendSilentlyWithAcraWithName("webview not available")
if (context != null) {
AlertDialog.Builder(requireContext())
.setMessage(requireContext().getString(R.string.webview_dialog_issue_message))
.setTitle(requireContext().getString(R.string.webview_dialog_issue_title))
@ -163,6 +164,7 @@ class ArticleFragment : Fragment(), DIAware {
.create()
.show()
}
}
return binding.root
}
@ -305,14 +307,16 @@ class ArticleFragment : Fragment(), DIAware {
binding.webcontent.webViewClient = object : WebViewClient() {
@Deprecated("Deprecated in Java")
override fun shouldOverrideUrlLoading(view: WebView?, url: String): Boolean {
if (binding.webcontent.hitTestResult.type != WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
return if (context != null && binding.webcontent.hitTestResult.type != WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
try {
requireContext().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
} catch (e: ActivityNotFoundException) {
e.sendSilentlyWithAcraWithName("activityNotFound > $url")
}
true
} else {
false
}
return true
}
@Deprecated("Deprecated in Java")
@ -364,7 +368,7 @@ class ArticleFragment : Fragment(), DIAware {
}
private fun htmlToWebview() {
if (context != null) {
val attrs: IntArray = intArrayOf(android.R.attr.fontFamily)
val a: TypedArray = requireContext().obtainStyledAttributes(resId, attrs)
@ -505,6 +509,7 @@ class ArticleFragment : Fragment(), DIAware {
null
)
}
}
fun scrollDown() {
val height = binding.nestedScrollView.measuredHeight