Skip to content

Commit d09302b

Browse files
committed
Analysis: Resolve type mismatch type warning for app module
Warning Message: "Type mismatch: inferred type is Bitmap? but Bitmap was expected"
1 parent 1315ae8 commit d09302b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,13 @@ open class MainActivity : AppCompatActivity(),
253253

254254
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
255255
if (resultCode == Activity.RESULT_OK) {
256-
var bitmap: Bitmap
257-
258256
when (requestCode) {
259257
REQUEST_MEDIA_CAMERA_PHOTO -> {
260258
// By default, BitmapFactory.decodeFile sets the bitmap's density to the device default so, we need
261259
// to correctly set the input density to 160 ourselves.
262260
val options = BitmapFactory.Options()
263261
options.inDensity = DisplayMetrics.DENSITY_DEFAULT
264-
bitmap = BitmapFactory.decodeFile(mediaPath, options)
262+
val bitmap = BitmapFactory.decodeFile(mediaPath, options)
265263
insertImageAndSimulateUpload(bitmap, mediaPath)
266264
}
267265
REQUEST_MEDIA_PHOTO -> {
@@ -271,7 +269,7 @@ open class MainActivity : AppCompatActivity(),
271269
// to correctly set the input density to 160 ourselves.
272270
val options = BitmapFactory.Options()
273271
options.inDensity = DisplayMetrics.DENSITY_DEFAULT
274-
bitmap = BitmapFactory.decodeStream(stream, null, options)
272+
val bitmap = BitmapFactory.decodeStream(stream, null, options)
275273

276274
insertImageAndSimulateUpload(bitmap, mediaPath)
277275
}
@@ -287,7 +285,7 @@ open class MainActivity : AppCompatActivity(),
287285

288286
override fun onThumbnailLoaded(drawable: Drawable?) {
289287
val conf = Bitmap.Config.ARGB_8888 // see other conf types
290-
bitmap = Bitmap.createBitmap(drawable!!.intrinsicWidth, drawable.intrinsicHeight, conf)
288+
val bitmap = Bitmap.createBitmap(drawable!!.intrinsicWidth, drawable.intrinsicHeight, conf)
291289
val canvas = Canvas(bitmap)
292290
drawable.setBounds(0, 0, canvas.width, canvas.height)
293291
drawable.draw(canvas)

0 commit comments

Comments
 (0)