Merge remote-tracking branch 'origin/hotfix-4.5.4-254-crash' into release

# Conflicts:
#	libraries/LGLibrary
This commit is contained in:
chenjuntao
2020-12-29 14:20:50 +08:00
9 changed files with 88 additions and 62 deletions

View File

@ -67,7 +67,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
activateTv.setOnClickListener {
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "点击立即开启")
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "${styleEntity.scenes}_${styleEntity.styleNo}_点击立即开启")
dismiss()
dismissAllowingStateLoss()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//这种方案适用于 API 26, 即8.0含8.0)以上可以用
val intent = Intent()
@ -80,7 +80,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
}
closeIv.setOnClickListener {
dismiss()
dismissAllowingStateLoss()
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "点击关闭")
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "${styleEntity.scenes}_${styleEntity.styleNo}_点击关闭")
}

View File

@ -260,6 +260,8 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
return
}
if (activity.isFinishing) return
var dialogFragment = activity.supportFragmentManager.findFragmentByTag(PackageCheckDialogFragment::class.java.simpleName) as? PackageCheckDialogFragment
if (dialogFragment == null) {
dialogFragment = PackageCheckDialogFragment()
@ -283,7 +285,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
val isPackagesInstall: (ArrayList<String>) -> Boolean = { packages ->
var isPackagesInstalled = false
packages.forEach {packageName->
packages.forEach { packageName ->
val isInstalled = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0).find { it.packageName == packageName } != null
if (isInstalled) {
isPackagesInstalled = true

View File

@ -15,6 +15,7 @@ import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.InflateException;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
@ -34,6 +35,7 @@ import android.widget.FrameLayout;
import androidx.annotation.Keep;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import org.json.JSONArray;
import org.json.JSONException;
@ -716,6 +718,8 @@ public class DWebView extends WebView {
return true;
}
}
Activity activity = (AppCompatActivity) getContext();
if (activity.isFinishing()) return true;
Dialog alertDialog = new AlertDialog.Builder(getContext()).
setMessage(message).
setCancelable(false).
@ -742,6 +746,8 @@ public class DWebView extends WebView {
if (webChromeClient != null && webChromeClient.onJsConfirm(view, url, message, result)) {
return true;
} else {
Activity activity = (AppCompatActivity) getContext();
if (activity.isFinishing()) return true;
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -784,6 +790,8 @@ public class DWebView extends WebView {
if (webChromeClient != null && webChromeClient.onJsPrompt(view, url, message, defaultValue, result)) {
return true;
} else {
Activity activity = (AppCompatActivity) getContext();
if (activity.isFinishing()) return true;
final EditText editText = new EditText(getContext());
editText.setText(defaultValue);
if (defaultValue != null) {
@ -1028,10 +1036,7 @@ public class DWebView extends WebView {
try {
super.setOverScrollMode(mode);
} catch (Throwable e) {
String trace = Log.getStackTraceString(e);
if (trace.contains("android.content.pm.PackageManager$NameNotFoundException")
|| trace.contains("java.lang.RuntimeException: Cannot load WebView")
|| trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) {
if (e instanceof InflateException) {
e.printStackTrace();
} else {
throw e;

View File

@ -163,7 +163,13 @@ public class PagerLayoutManager extends LinearLayoutManager {
return 0;
}
this.mDrift = dy;
return super.scrollVerticallyBy(dy, recycler, state);
//fix for `java.lang.IndexOutOfBoundsException: Inconsistency detected.`
try {
return super.scrollVerticallyBy(dy, recycler, state);
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**

View File

@ -41,6 +41,7 @@ import com.lightgame.download.DownloadEntity;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import androidx.annotation.Nullable;
import androidx.collection.ArrayMap;
@ -59,7 +60,7 @@ public class InstalledGameFragmentAdapter extends BaseRecyclerAdapter<ViewHolder
private InstalledGameFragment mFragment;
private ArrayList<GameEntity> gameList;
private ArrayList<GameInstall> sortedList;
private CopyOnWriteArrayList<GameInstall> sortedList;
//下载用到的map
private ArrayMap<String, ArrayList<Integer>> locationMap;
@ -73,7 +74,7 @@ public class InstalledGameFragmentAdapter extends BaseRecyclerAdapter<ViewHolder
mFragment = fragment;
gameList = new ArrayList<>();
sortedList = new ArrayList<>();
sortedList = new CopyOnWriteArrayList<>();
locationMap = new ArrayMap<>();
@ -256,7 +257,10 @@ public class InstalledGameFragmentAdapter extends BaseRecyclerAdapter<ViewHolder
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
if (holder instanceof GameItemViewHolder) {
initGameNormal((GameItemViewHolder) holder, gameList.get(position));
GameEntity gameEntity = ExtensionsKt.safelyGetInRelease(gameList, position);
if (gameEntity != null) {
initGameNormal((GameItemViewHolder) holder, gameEntity);
}
}
}

View File

@ -805,9 +805,12 @@ class GameDetailFragment : NormalFragment() {
}
mTopVideoView.fullscreenButton.setOnClickListener {
val horizontalVideoView = mTopVideoView.startWindowFullscreen(requireContext(), true, true) as? TopVideoView
if (horizontalVideoView == null) {
toastInInternalRelease("全屏失败,请向技术人员提供具体的操作步骤")
return@setOnClickListener
}
mOrientationUtils?.resolveByClick()
val horizontalVideoView = mTopVideoView.startWindowFullscreen(requireContext(), true, true) as TopVideoView
horizontalVideoView.viewModel = mViewModel
horizontalVideoView.video = topVideo
horizontalVideoView.updateThumb(topVideo.poster)

View File

@ -59,57 +59,61 @@ class VideoAdapter(val mContext: Context, val mRecyclerView: RecyclerView, val r
val videoView = (holder.itemView as DetailPlayerView)
videoView.resetProgressAndTime()//重置进度条,避免进度复用
videoView.findViewById<View>(R.id.placeholderView)?.goneIf(!mViewModel.isHomeVideo)
val mOrientationUtils = OrientationUtils(mContext as Activity, videoView)
mOrientationUtils.isEnable = false
videoView.setViewModel(mViewModel)
GSYVideoOptionBuilder()
.setIsTouchWiget(false)
.setUrl(videoList[position].url)
.setRotateViewAuto(false)
.setCacheWithPlay(true)
.setRotateWithSystem(false)
.setReleaseWhenLossAudio(true)
val video = videoList.safelyGetInRelease(position)
video?.let {
val mOrientationUtils = OrientationUtils(mContext as Activity, videoView)
mOrientationUtils.isEnable = false
videoView.setViewModel(mViewModel)
GSYVideoOptionBuilder()
.setIsTouchWiget(false)
.setUrl(it.url)
.setRotateViewAuto(false)
.setCacheWithPlay(true)
.setRotateWithSystem(false)
.setReleaseWhenLossAudio(true)
// .setLockLand(true)
.setLooping(false)
.setShowFullAnimation(false)
.setVideoAllCallBack(object : GSYSampleCallBack() {
override fun onQuitFullscreen(url: String?, vararg objects: Any) {
mOrientationUtils.backToProtVideo()
videoView.hideAllButton(false)
videoView.recordMta("全屏播放-退出全屏")
MtaHelper.onEvent("视频详情", "全屏播放-退出全屏", "${videoList[position].title}${videoList[position].id}")
videoView.uploadVideoStreamingPlaying("全屏播放-退出全屏")
}
})
.build(videoView)
.setLooping(false)
.setShowFullAnimation(false)
.setVideoAllCallBack(object : GSYSampleCallBack() {
override fun onQuitFullscreen(url: String?, vararg objects: Any) {
mOrientationUtils.backToProtVideo()
videoView.hideAllButton(false)
videoView.recordMta("全屏播放-退出全屏")
MtaHelper.onEvent("视频详情", "全屏播放-退出全屏", "${videoList[position].title}${videoList[position].id}")
videoView.uploadVideoStreamingPlaying("全屏播放-退出全屏")
}
})
.build(videoView)
videoView.updateViewDetail(videoList[position])
videoView.updateThumb(videoList[position].getThumb())
videoView.updateMuteStatus()
videoView.fullscreenButton.setOnClickListener {
if (refreshLayout.isRefreshing) return@setOnClickListener
if (mOrientationUtils.isLand == 0) {
videoView.recordMta("进入全屏")
MtaHelper.onEvent("视频详情", "进入全屏", "${videoList[position].title}${videoList[position].id}")
videoView.uploadVideoStreamingPlaying("全屏")
}
videoView.hideAllButton(true)
mOrientationUtils.resolveByClick()
val fullVideoPlayer = videoView.startWindowFullscreen(mContext, true, true) as? DetailPlayerView
fullVideoPlayer?.observeVolume(mContext as AppCompatActivity)
fullVideoPlayer?.setViewModel(mViewModel)
fullVideoPlayer?.hideAllButton(true)
fullVideoPlayer?.updateViewDetail(videoList[position])
fullVideoPlayer?.updateMuteStatus()
//金进入全屏后直接播放
if (fullVideoPlayer?.currentState == GSYVideoView.CURRENT_STATE_PAUSE) {
fullVideoPlayer.setCurrentPosition(videoView.getCurrentPosition())
fullVideoPlayer.onVideoResume()
videoView.updateViewDetail(it)
videoView.updateThumb(it.getThumb())
videoView.updateMuteStatus()
videoView.fullscreenButton.setOnClickListener {
if (refreshLayout.isRefreshing) return@setOnClickListener
if (mOrientationUtils.isLand == 0) {
videoView.recordMta("进入全屏")
MtaHelper.onEvent("视频详情", "进入全屏", "${videoList[position].title}${videoList[position].id}")
videoView.uploadVideoStreamingPlaying("全屏")
}
videoView.hideAllButton(true)
mOrientationUtils.resolveByClick()
val fullVideoPlayer = videoView.startWindowFullscreen(mContext, true, true) as? DetailPlayerView
fullVideoPlayer?.observeVolume(mContext as AppCompatActivity)
fullVideoPlayer?.setViewModel(mViewModel)
fullVideoPlayer?.hideAllButton(true)
fullVideoPlayer?.updateViewDetail(videoList[position])
fullVideoPlayer?.updateMuteStatus()
//金进入全屏后直接播放
if (fullVideoPlayer?.currentState == GSYVideoView.CURRENT_STATE_PAUSE) {
fullVideoPlayer.setCurrentPosition(videoView.getCurrentPosition())
fullVideoPlayer.onVideoResume()
}
}
videoView.isNeedShowWifiTip = HaloApp.get(Constants.SHOULD_SHOW_VIDEO_MOBILE_WARNING, false) as Boolean?
?: false
}
videoView.isNeedShowWifiTip = HaloApp.get(Constants.SHOULD_SHOW_VIDEO_MOBILE_WARNING, false) as Boolean?
?: false
if (position == mViewModel.startPosition && isVisible) {
if (position + 2 <= videoList.size - 1) {//预加载视频
ExoCacheManager.preload(videoList[position + 1].url)

View File

@ -554,8 +554,10 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
}
fun showMoreMenuDialog(targetView: View) {
mViewModel.currentDisplayingVideo?.let {
showMoreMenuDialog(it, targetView)
if (::mViewModel.isInitialized) {
mViewModel.currentDisplayingVideo?.let {
showMoreMenuDialog(it, targetView)
}
}
}