Merge remote-tracking branch 'origin/dev-4.5.0' into dev-4.5.0

This commit is contained in:
lyr
2020-11-23 10:28:43 +08:00
3 changed files with 26 additions and 2 deletions

View File

@ -333,6 +333,15 @@ fun throwExceptionInDebug(message: String = "", predicate: Boolean = true) {
}
}
/**
* 在自动打包的包里弹 toast
*/
fun toastInInternalRelease(content: String) {
if (BuildConfig.BUILD_TIME != 0L) {
Utils.toast(HaloApp.getInstance(), content)
}
}
/**
* 主动抛出异常
*/
@ -454,6 +463,7 @@ fun Float.sp2px(): Int {
return (this * scale + 0.5f).toInt()
}
/**
* PopupWindow 自动适配方向
* 弹出与锚点右对齐
@ -577,6 +587,19 @@ fun TextView.setTextChangedListener(action: (s: CharSequence, start: Int, before
})
}
/**
* ArrayList related
*/
fun <T> ArrayList<T>.safelyGetInRelease(index: Int): T? {
return if (index >= size) {
throwExceptionInDebug("这里触发了数组越界,请检查")
toastInInternalRelease("这个操作可能触发闪退,请确定复现方式并联系开发处理")
null
} else {
this[index]
}
}
/**
* 拦截 TextView 中的 Url Span用应用内页面的形式打开链接
* @param shrankText 未展开时的文字

View File

@ -236,7 +236,7 @@ class GameFragmentAdapter(context: Context,
DataCollectionUtils.uploadClick(mContext, subjectData?.name + "-列表", "游戏-专题", gameEntity.name)
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
StringUtils.buildString("(游戏-专题:", subjectData?.name, "-列表[", (subjectData?.position).toString(), "])"),
listExposureEventList[snapPosition])
listExposureEventList.safelyGetInRelease(snapPosition))
}
val verticalSlide = mItemDataList[position].verticalSlide!!

View File

@ -229,6 +229,7 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
private fun bindVerticalSlide(holder: GameVerticalSlideViewHolder, item: LegacyHomeItemData) {
if (mMakeItemBackgroundTransparent) holder.itemView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.transparent))
// TODO 曝光复用有问题!!!
val binding = holder.binding
val verticalSlide = item.verticalSlide!!
val exposureEventList = arrayListOf<ExposureEvent>()
@ -239,7 +240,7 @@ class LegacyHomeFragmentAdapterAssistant(private var mContext: Context,
DataCollectionUtils.uploadClick(mContext, subjectData?.name + "-列表", "游戏-专题", gameEntity.name)
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
StringUtils.buildString("(游戏-专题:", subjectData?.name, "-列表[", (subjectData?.position).toString(), "])"),
listExposureEventList[snapPosition])
listExposureEventList.safelyGetInRelease(snapPosition))
}
holder.bindVerticalSlide(verticalSlide, clickClosure, mMakeItemBackgroundTransparent)