From a9a659209c8d192a9f08cbf2409690bc97d8f687 Mon Sep 17 00:00:00 2001 From: Michael Vogt <231274+michaelvogt@users.noreply.github.com> Date: Sat, 19 Jan 2019 00:00:01 +0100 Subject: [PATCH] fixing exception reported to play (#14) --- .../michaelvogt/ar/author/fragments/WebViewFragment.kt | 2 +- .../eu/michaelvogt/ar/author/utils/ViewConverters.kt | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/michaelvogt/ar/author/fragments/WebViewFragment.kt b/app/src/main/java/eu/michaelvogt/ar/author/fragments/WebViewFragment.kt index 644eb5e..7e50cc8 100644 --- a/app/src/main/java/eu/michaelvogt/ar/author/fragments/WebViewFragment.kt +++ b/app/src/main/java/eu/michaelvogt/ar/author/fragments/WebViewFragment.kt @@ -56,7 +56,7 @@ class WebViewFragment : AppFragment(), View.OnClickListener { NavigationUI.setupWithNavController(top_toolbar, navController) - val content = WebViewFragmentArgs.fromBundle(arguments).contentUrl + val content = WebViewFragmentArgs.fromBundle(arguments!!).contentUrl when (content) { R.string.about_key -> content_info.loadUrl(getString(R.string.file_prefix) + getString(R.string.about_url)) R.string.location_intro_key -> initLocationIntro() diff --git a/app/src/main/java/eu/michaelvogt/ar/author/utils/ViewConverters.kt b/app/src/main/java/eu/michaelvogt/ar/author/utils/ViewConverters.kt index 53f58f3..a1d3247 100644 --- a/app/src/main/java/eu/michaelvogt/ar/author/utils/ViewConverters.kt +++ b/app/src/main/java/eu/michaelvogt/ar/author/utils/ViewConverters.kt @@ -35,6 +35,7 @@ import eu.michaelvogt.ar.author.R import eu.michaelvogt.ar.author.data.* import eu.michaelvogt.ar.author.data.utils.Converters import eu.michaelvogt.ar.author.fragments.AreaEditCard +import java.io.FileNotFoundException @InverseMethod("floatFromString") fun floatToString(value: Float): String { @@ -78,8 +79,13 @@ fun setImage(view: ImageView, url: String, placeholder: Drawable) { if (url.isEmpty()) { view.setImageDrawable(placeholder) } else if (url.startsWith(ImageUtils.assetPathPrefix)) { - val asset = view.resources.assets.open(url.removePrefix(ImageUtils.assetPathPrefix)) - view.setImageDrawable(Drawable.createFromStream(asset, null)) + try { + val asset = view.resources.assets.open(url.removePrefix(ImageUtils.assetPathPrefix)) + view.setImageDrawable(Drawable.createFromStream(asset, null)) + } catch (e: FileNotFoundException) { + Log.i("ViewConverters", "Image not found", e) + view.setImageResource(R.drawable.touristar_logo) + } } else { val bitmap: Bitmap try {