Ошибка приведения в NativeAdView
Не понимаю, в чем ошибка приведения данных Smart cast to 'MediaView!' is impossible, because 'adView.mediaView' is a mutable property that could have been changed by this time. т.д. Раньше вроде бы работало
ImageAdapter.kt: (192, 13): Smart cast to 'MediaView!' is impossible, because 'adView.mediaView' is a mutable property that could have been changed by this time ImageAdapter.kt: (192, 46): Type mismatch: inferred type is MediaContent? but MediaContent was expected ImageAdapter.kt: (194, 17): Smart cast to 'View!' is impossible, because 'adView.bodyView' is a mutable property that could have been changed by this time ImageAdapter.kt: (196, 17): Smart cast to 'View!' is impossible, because 'adView.bodyView' is a mutable property that could have been changed by this time ImageAdapter.kt: (201, 17): Smart cast to 'View!' is impossible, because 'adView.callToActionView' is a mutable property that could have been changed by this time ImageAdapter.kt: (203, 17): Smart cast to 'View!' is impossible, because 'adView.callToActionView' is a mutable property that could have been changed by this time ImageAdapter.kt: (208, 17): Smart cast to 'View!' is impossible, because 'adView.iconView' is a mutable property that could have been changed by this time ImageAdapter.kt: (211, 21): Smart cast to 'NativeAd.Image' is impossible, because 'nativeAd.icon' is a property that has open or custom getter ImageAdapter.kt: (213, 17): Smart cast to 'ImageView' is impossible, because 'adView.iconView' is a mutable property that could have been changed by this time ImageAdapter.kt: (217, 17): Smart cast to 'View!' is impossible, because 'adView.priceView' is a mutable property that could have been changed by this time ImageAdapter.kt: (219, 17): Smart cast to 'View!' is impossible, because 'adView.priceView' is a mutable property that could have been changed by this time ImageAdapter.kt: (224, 17): Smart cast to 'View!' is impossible, because 'adView.storeView' is a mutable property that could have been changed by this time ImageAdapter.kt: (226, 17): Smart cast to 'View!' is impossible, because 'adView.storeView' is a mutable property that could have been changed by this time ImageAdapter.kt: (231, 17): Smart cast to 'View!' is impossible, because 'adView.starRatingView' is a mutable property that could have been changed by this time ImageAdapter.kt: (233, 63): Smart cast to 'Double' is impossible, because 'nativeAd.starRating' is a property that has open or custom getter ImageAdapter.kt: (234, 17): Smart cast to 'RatingBar' is impossible, because 'adView.starRatingView' is a mutable property that could have been changed by this time ImageAdapter.kt: (238, 17): Smart cast to 'View!' is impossible, because 'adView.advertiserView' is a mutable property that could have been changed by this time ImageAdapter.kt: (241, 17): Smart cast to 'TextView' is impossible, because 'adView.advertiserView' is a mutable property that could have been changed by this time
private fun populateNativeAdView(nativeAd: NativeAd, adView: NativeAdView) {
adView.mediaView = adView.findViewById(R.id.ad_media)
adView.headlineView = adView.findViewById(R.id.ad_headline)
adView.bodyView = adView.findViewById(R.id.ad_body)
adView.callToActionView = adView.findViewById(R.id.call)
adView.iconView = adView.findViewById(R.id.ad_app_icon)
adView.priceView = adView.findViewById(R.id.ad_price)
adView.starRatingView = adView.findViewById(R.id.ad_stars)
adView.storeView = adView.findViewById(R.id.ad_store)
adView.advertiserView = adView.findViewById(R.id.ad_advertiser)
(adView.headlineView as TextView).text = nativeAd.headline
adView.mediaView.setMediaContent(nativeAd.mediaContent)
if (nativeAd.body == null) {
adView.bodyView.visibility = View.INVISIBLE
} else {
adView.bodyView.visibility = View.VISIBLE
(adView.bodyView as TextView).text = nativeAd.body
}
if (nativeAd.callToAction == null) {
adView.callToActionView.visibility = View.INVISIBLE
} else {
adView.callToActionView.visibility = View.VISIBLE
(adView.callToActionView as Button).setText(nativeAd.callToAction)
}
if (nativeAd.icon == null) {
adView.iconView.visibility = View.GONE
} else {
(adView.iconView as ImageView).setImageDrawable(
nativeAd.icon.drawable
)
adView.iconView.setVisibility(View.VISIBLE)
}
if (nativeAd.price == null) {
adView.priceView.visibility = View.INVISIBLE
} else {
adView.priceView.visibility = View.VISIBLE
(adView.priceView as TextView).text = nativeAd.price
}
if (nativeAd.store == null) {
adView.storeView.visibility = View.INVISIBLE
} else {
adView.storeView.visibility = View.VISIBLE
(adView.storeView as TextView).text = nativeAd.store
}
if (nativeAd.starRating == null) {
adView.starRatingView.visibility = View.INVISIBLE
} else {
(adView.starRatingView as RatingBar).rating = nativeAd.starRating.toFloat()
adView.starRatingView.visibility = View.VISIBLE
}
if (nativeAd.advertiser == null) {
adView.advertiserView.visibility = View.INVISIBLE
} else {
(adView.advertiserView as TextView).text = nativeAd.advertiser
adView.advertiserView.visibility = View.VISIBLE
}
adView.setNativeAd(nativeAd)
}

