1. 修复启动时初始化图片加载库可能的闪退问题

2. 修复游戏详情最新开服可能的闪退问题
3. 修复在越南/法语设备上启动会闪退的问题
This commit is contained in:
juntao
2021-05-25 10:53:47 +08:00
parent fd946703a9
commit 895024aa09
7 changed files with 44 additions and 214 deletions

View File

@ -489,8 +489,8 @@ fun Float.sp2px(): Int {
return (this * scale + 0.5f).toInt()
}
fun Float.roundTo(n : Int) : Float {
return "%.${n}f".format(this).toFloat()
fun Float.roundTo(n: Int): Float {
return "%.${n}f".format(Locale.CHINA, this).toFloat()
}
/**

View File

@ -484,4 +484,22 @@ object ImageUtils {
fun getVideoSnapshot(videoUrl: String, progress: Long): String {
return "$videoUrl?x-oss-process=video/snapshot,t_$progress,f_jpg,w_0,h_0"
}
/**
* 虽然在 Application 里有使用子线程初始化但有可能出现初始化超时(卡住?)的情况,
* 这里反射获取 sDraweecontrollerbuildersupplier 根据是否有值确定是否被初始化了
*/
@JvmStatic
fun isFrescoInitialized(): Boolean {
val clazz = SimpleDraweeView::class.java
return try {
val field =
clazz.getDeclaredField("sDraweecontrollerbuildersupplier")
field.isAccessible = true
val obj = field[SimpleDraweeView::class.java]
obj != null
} catch (ignore: java.lang.Exception) {
false
}
}
}

View File

@ -121,9 +121,14 @@ object XapkInstaller : IXapkUnzipListener {
DownloadManager.getInstance(mContext).updateDownloadEntity(downloadEntity)
}
SentryHelper.onEvent("XAPK_UNZIP_ERROR",
// 仅官网渠道上报 XAPK 异常信息
if (HaloApp.getInstance().channel == "GH_206") {
SentryHelper.onEvent(
"XAPK_UNZIP_ERROR",
"gameName", downloadEntity.name,
"errorDigest", exception.localizedMessage)
"errorDigest", exception.localizedMessage
)
}
debugOnly {
Utils.log("unzip", "onFailure->$exception")

View File

@ -52,6 +52,7 @@ import com.gh.common.util.ErrorHelper;
import com.gh.common.util.ExtensionsKt;
import com.gh.common.util.GsonUtils;
import com.gh.common.util.HomePluggableHelper;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.LogUtils;
import com.gh.common.util.LunchType;
import com.gh.common.util.MtaHelper;
@ -176,7 +177,7 @@ public class MainActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setStatusBarColor(Color.TRANSPARENT);
if (!isFrescoInitialized()) {
if (!ImageUtils.isFrescoInitialized()) {
BigImageViewer.initialize(FrescoImageLoader.with(this));
}
@ -966,19 +967,4 @@ public class MainActivity extends BaseActivity {
context.startActivity(intent);
}
/**
* 虽然在 Application 里有使用子线程初始化但有可能出现初始化超时(卡住?)的情况,
* 这里反射获取 sDraweecontrollerbuildersupplier 根据是否有值确定是否被初始化了
*/
public boolean isFrescoInitialized() {
Class<SimpleDraweeView> clazz = SimpleDraweeView.class;
try {
Field field = clazz.getDeclaredField("sDraweecontrollerbuildersupplier");
field.setAccessible(true);
Object object = field.get(SimpleDraweeView.class);
return object != null;
} catch (Exception ignore) {
return false;
}
}
}

View File

@ -1,11 +1,15 @@
package com.gh.gamecenter.gamedetail.desc
import android.content.Context
import android.view.*
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View.MeasureSpec
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.util.TimeUtils
import com.gh.common.util.safelyGetInRelease
import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.ItemGameDetailLatestServiceBinding
import com.gh.gamecenter.databinding.ItemGameDetailMoreBinding
@ -79,7 +83,10 @@ class GameLatestServiceAdapter(val context: Context, val datas: ArrayList<Server
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is GameLatestServiceViewHolder) {
val entity = if (mIsExpand) mExpandEntities[position] else mShrinkEntities[position]
// TODO 这里会数组越界,需要检查原因
val entity = (if (mIsExpand) mExpandEntities.safelyGetInRelease(position) else mShrinkEntities.safelyGetInRelease(position))
?: return
holder.binding.timeTv.text = TimeUtils.getFormatDate(entity.getTime())
holder.binding.serviceNameTv.text = "${entity.getNote()} ${entity.remark}"

View File

@ -27,6 +27,7 @@ import com.gh.common.util.DeviceUtils;
import com.gh.common.util.DownloadNotificationHelper;
import com.gh.common.util.DownloadObserver;
import com.gh.common.util.HomeBottomBarHelper;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PackageHelper;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.SPUtils;
@ -141,8 +142,10 @@ public class HaloApp extends MultiDexApplication {
initDataHelper();
Tracker.init(this);
//初始化Fresco(BigImageViewer 已包含Fresco)
BigImageViewer.initialize(FrescoImageLoader.with(this));
// 初始化 Fresco(BigImageViewer 已包含Fresco)
if (!ImageUtils.isFrescoInitialized()) {
BigImageViewer.initialize(FrescoImageLoader.with(this));
}
deviceRamSize = DeviceUtils.getTotalRamSizeOfDevice(this);

View File

@ -1,191 +1,2 @@
GH_TEST
GH_TEST2
GH_REFRESH
GH_100
GH_101
GH_102
GH_103
GH_104
GH_106
GH_107
GH_108
GH_109
GH_110
GH_111
GH_113
GH_114
GH_115
GH_116
GH_117
GH_118
GH_119
GH_120
GH_121
GH_123
GH_127
GH_200
GH_201
GH_202
GH_203
GH_204
GH_205
GH_206
GH_222
GH_307
GH_333
GH_600
GH_601
GH_602
GH_603
GH_604
GH_605
GH_606
GH_607
GH_608
GH_609
GH_610
GH_611
GH_612
GH_613
GH_614
GH_615
GH_616
GH_617
GH_618
GH_619
GH_620
GH_621
GH_622
GH_623
GH_624
GH_625
GH_626
GH_627
GH_628
GH_629
GH_630
GH_631
GH_632
GH_633
GH_634
GH_635
GH_636
GH_637
GH_638
GH_639
GH_640
GH_641
GH_642
GH_643
GH_644
GH_645
GH_646
GH_647
GH_648
GH_649
GH_650
GH_651
GH_652
GH_653
GH_654
GH_655
GH_656
GH_657
GH_658
GH_659
GH_660
GH_661
GH_662
GH_663
GH_664
GH_665
GH_666
GH_667
GH_667
GH_668
GH_669
GH_670
GH_671
GH_672
GH_673
GH_674
GH_675
GH_676
GH_677
GH_678
GH_679
GH_680
GH_681
GH_682
GH_683
GH_684
GH_685
GH_686
GH_687
GH_688
GH_689
GH_690
GH_691
GH_692
GH_693
GH_694
GH_695
GH_696
GH_697
GH_698
GH_699
GH_700
GH_701
GH_702
GH_703
GH_704
GH_705
GH_706
GH_707
GH_708
GH_709
GH_710
GH_711
GH_712
GH_713
GH_714
GH_715
GH_716
GH_717
GH_718
GH_719
GH_720
GH_721
GH_722
GH_723
GH_724
GH_725
GH_726
GH_727
GH_728
GH_729
GH_730
GH_731
GH_732
GH_733
GH_734
GH_735
GH_736
GH_737
GH_738
GH_739
GH_740
GH_741
GH_742
GH_743
GH_744
GH_745
GH_746
GH_747
GH_748
GH_749
GH_750
GH_777
GH_787
GH_888
GH_999