Replace Assertions with BuildConfig
This commit is contained in:
parent
26387e5f44
commit
6fc3aed810
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue