diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt index a4c016260..e1520072f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt @@ -96,6 +96,7 @@ import org.mariotaku.microblog.library.mastodon.Mastodon import org.mariotaku.microblog.library.twitter.model.FriendshipUpdate import org.mariotaku.microblog.library.twitter.model.Paging import org.mariotaku.microblog.library.twitter.model.UserList +import org.mariotaku.twidere.BuildConfig import org.mariotaku.twidere.Constants.* import org.mariotaku.twidere.R import org.mariotaku.twidere.activity.AccountSelectorActivity @@ -1130,7 +1131,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener, return } val spec = pagerAdapter.get(viewPager.currentItem) - assert(spec.type != null) + if (BuildConfig.DEBUG && spec.type == null) { error("Assertion failed") } when (spec.type) { TAB_TYPE_STATUSES, TAB_TYPE_STATUSES_WITH_REPLIES -> { actionBar.subtitle = resources.getQuantityString(R.plurals.N_statuses, diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt index 8e82518b8..d828c5251 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt @@ -31,6 +31,7 @@ import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder import org.mariotaku.ktextension.nextPowerOf2 import org.mariotaku.mediaviewer.library.CacheDownloadLoader import org.mariotaku.mediaviewer.library.subsampleimageview.SubsampleImageViewerFragment +import org.mariotaku.twidere.BuildConfig import org.mariotaku.twidere.TwidereConstants.* import org.mariotaku.twidere.activity.MediaViewerActivity import org.mariotaku.twidere.model.ParcelableMedia @@ -96,7 +97,7 @@ class ImagePageFragment : SubsampleImageViewerFragment() { } override fun getImageSource(data: CacheDownloadLoader.Result): ImageSource { - assert(data.cacheUri != null) + if (BuildConfig.DEBUG && data.cacheUri == null) { error("Assertion failed") } if (data !is SizedResult) { return super.getImageSource(data) } @@ -108,7 +109,7 @@ class ImagePageFragment : SubsampleImageViewerFragment() { override fun getPreviewImageSource(data: CacheDownloadLoader.Result): ImageSource? { if (data !is SizedResult) return null - assert(data.cacheUri != null) + if (BuildConfig.DEBUG && data.cacheUri == null) { error("Assertion failed") } return ImageSource.uri(UriUtils.appendQueryParameters(data.cacheUri, QUERY_PARAM_PREVIEW, true)) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/FavoriteItemProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/FavoriteItemProvider.kt index 4c4bd3d77..c151b7b26 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/FavoriteItemProvider.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/FavoriteItemProvider.kt @@ -29,6 +29,7 @@ import androidx.appcompat.widget.ActionMenuView import android.view.MenuItem import android.view.View import org.mariotaku.ktextension.weak +import org.mariotaku.twidere.BuildConfig import org.mariotaku.twidere.extension.view.findItemView import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable.Style @@ -52,7 +53,7 @@ class FavoriteItemProvider(context: Context) : ActionProvider(context) { } fun init(menuBar: ActionMenuView, item: MenuItem) { - assert(MenuItemCompat.getActionProvider(item) === this) + if (BuildConfig.DEBUG && MenuItemCompat.getActionProvider(item) !== this) { error("Assertion failed") } val icon = ContextCompat.getDrawable(context, this.icon) val drawable = LikeAnimationDrawable(icon, defaultColor, activatedColor, if (useStar) Style.FAVORITE else Style.LIKE) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/RetweetItemProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/RetweetItemProvider.kt index 483694cfd..913a931ce 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/RetweetItemProvider.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/RetweetItemProvider.kt @@ -24,6 +24,7 @@ import androidx.core.view.ActionProvider import androidx.core.view.MenuItemCompat import androidx.appcompat.widget.ActionMenuView import android.view.MenuItem +import org.mariotaku.twidere.BuildConfig import org.mariotaku.twidere.extension.view.findItemView /** @@ -35,7 +36,7 @@ class RetweetItemProvider(context: Context) : ActionProvider(context) { override fun onCreateActionView() = null fun init(menuBar: ActionMenuView, item: MenuItem) { - assert(MenuItemCompat.getActionProvider(item) === this) + if (BuildConfig.DEBUG && MenuItemCompat.getActionProvider(item) !== this) { error("Assertion failed") } val menuView = menuBar.findItemView(item) menuView?.setOnLongClickListener { longClickListener?.invoke() == true } }