From 3965218bf911a94d3b14b7f3d5a734b6d5dc09e2 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 19 Jul 2019 12:12:17 +0200 Subject: [PATCH] Cleaning / Review --- .../home/room/detail/RoomDetailFragment.kt | 9 +++------ .../features/media/ImageMediaViewerActivity.kt | 15 +++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index b260979f..cc973381 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -22,7 +22,6 @@ import android.content.Context import android.content.Intent import android.graphics.drawable.ColorDrawable import android.net.Uri -import android.os.Build import android.os.Bundle import android.os.Parcelable import android.text.Editable @@ -623,11 +622,9 @@ class RoomDetailFragment : // TODO Use navigator val intent = ImageMediaViewerActivity.newIntent(vectorBaseActivity, mediaData, ViewCompat.getTransitionName(view)) - var bundle: Bundle? = null - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, ViewCompat.getTransitionName(view) - ?: "").toBundle() - } + val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( + requireActivity(), view, ViewCompat.getTransitionName(view) + ?: "").toBundle() startActivity(intent, bundle) } diff --git a/vector/src/main/java/im/vector/riotx/features/media/ImageMediaViewerActivity.kt b/vector/src/main/java/im/vector/riotx/features/media/ImageMediaViewerActivity.kt index 618b5c12..a44672a5 100644 --- a/vector/src/main/java/im/vector/riotx/features/media/ImageMediaViewerActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/media/ImageMediaViewerActivity.kt @@ -125,7 +125,7 @@ class ImageMediaViewerActivity : VectorBaseActivity() { object : ViewTreeObserver.OnPreDrawListener { override fun onPreDraw(): Boolean { sharedElement.viewTreeObserver.removeOnPreDrawListener(this) - supportStartPostponedEnterTransition() + supportStartPostponedEnterTransition() return true } }) @@ -153,7 +153,10 @@ class ImageMediaViewerActivity : VectorBaseActivity() { .load(mediaData) .dontAnimate() .listener(object : RequestListener { - override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { + override fun onLoadFailed(e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean): Boolean { //TODO ? Timber.e("TRANSITION onLoadFailed") imageMediaViewerImageView.isVisible = false @@ -161,7 +164,11 @@ class ImageMediaViewerActivity : VectorBaseActivity() { return false } - override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { + override fun onResourceReady(resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean): Boolean { Timber.e("TRANSITION onResourceReady") imageTransitionView.isInvisible = true imageMediaViewerImageView.isVisible = false @@ -201,7 +208,7 @@ class ImageMediaViewerActivity : VectorBaseActivity() { fun newIntent(context: Context, mediaData: ImageContentRenderer.Data, shareTransitionName: String?): Intent { return Intent(context, ImageMediaViewerActivity::class.java).apply { putExtra(EXTRA_MEDIA_DATA, mediaData) - shareTransitionName?.let { putExtra(EXTRA_SHARED_TRANSITION_NAME, it) } + putExtra(EXTRA_SHARED_TRANSITION_NAME, shareTransitionName) } } }