Compare commits
170 Commits
fix/system
...
hotfix/va-
| Author | SHA1 | Date | |
|---|---|---|---|
| c6f70d1b4c | |||
| 0cd281a53c | |||
| e92d89d498 | |||
| a22858389b | |||
| e9d091043d | |||
| db4ac95094 | |||
| 13be47d440 | |||
| beee098cfe | |||
| d67aaf956b | |||
| 1ed9151b1f | |||
| 13f20f6883 | |||
| 78e320a192 | |||
| e51db47fad | |||
| ac02ea88b9 | |||
| f60004fc81 | |||
| 0cf39a82e2 | |||
| 315f244153 | |||
| f4bdc02d70 | |||
| aef39eb481 | |||
| dc2e7147d9 | |||
| fdcb6342bf | |||
| b0da4f8986 | |||
| f7cc906cc5 | |||
| 795fbabd90 | |||
| e770f8a359 | |||
| dd12b103be | |||
| 21f4a398d5 | |||
| 8dfb1644a8 | |||
| 9744b95126 | |||
| 009608165c | |||
| 98356a7dd7 | |||
| 8389041379 | |||
| 2e63257523 | |||
| fa663cd2f6 | |||
| 19af061311 | |||
| d643795fa3 | |||
| b1f2d0a303 | |||
| bb906f0bb8 | |||
| 6f242dcc95 | |||
| b47a64c63d | |||
| 948df2582c | |||
| 35edcf1d68 | |||
| 286d7650f2 | |||
| e566ab838f | |||
| cae720d4ec | |||
| 925516724f | |||
| a5f807c038 | |||
| f442a70bd3 | |||
| 9b3dab9897 | |||
| d939aae901 | |||
| 028974ec0d | |||
| ecd4610186 | |||
| 21e5f2c98d | |||
| 71c0cfe350 | |||
| 3b8b60bc6b | |||
| ac59158dbb | |||
| 5becdf2095 | |||
| a88b49344f | |||
| f34646cde8 | |||
| 9e8ffce772 | |||
| 008985489a | |||
| 2f3fbd3e7c | |||
| abef224830 | |||
| 8feb9b788e | |||
| 0a059deb44 | |||
| 448160d255 | |||
| 533f93a340 | |||
| d80b8a97a3 | |||
| f2e6d98788 | |||
| 238a83c5fe | |||
| ca71f23363 | |||
| c96b41c621 | |||
| e8ee63d52c | |||
| 90359cfffd | |||
| a3da883033 | |||
| a9f1437a52 | |||
| 8c95286fe5 | |||
| 8a835a94e3 | |||
| 14ec4aed3a | |||
| 07f956a1f0 | |||
| 6ef8d04e57 | |||
| 30248ef205 | |||
| 87b9bb0bf3 | |||
| b346882bfa | |||
| eeddb5ea51 | |||
| 78f9aa3ee4 | |||
| f34ad0675d | |||
| 36abcc9f19 | |||
| ae878eddf1 | |||
| ece519115b | |||
| b9e0a8e37a | |||
| 34ca8896ae | |||
| d6e19bfaff | |||
| 943fb4d4e0 | |||
| 2c5471d524 | |||
| cf527db60e | |||
| f261991a55 | |||
| ab66621751 | |||
| af262c624a | |||
| d2813ecbda | |||
| 0ea932e36d | |||
| 68151ed6f9 | |||
| e6d2361008 | |||
| 570b777c8e | |||
| 0e557b2246 | |||
| f155440814 | |||
| 62ba9fc7bf | |||
| 4637aa8808 | |||
| 81998e3aad | |||
| 82a8aa03ba | |||
| c876711578 | |||
| 41fcee7f4d | |||
| 0ccbc4d581 | |||
| f05fc73e3a | |||
| ca3c545f26 | |||
| 226539328e | |||
| bb7db78b0c | |||
| ede62c5363 | |||
| 12bb6824ea | |||
| 15c0950754 | |||
| f86b7fe12a | |||
| d12cdbd34b | |||
| 8436d4eda3 | |||
| be832037a7 | |||
| b620257825 | |||
| 6c88cace99 | |||
| f875fa1b14 | |||
| 8076c3a70a | |||
| bebab317a3 | |||
| c450ca570d | |||
| d239b0755f | |||
| 8f8ac99dae | |||
| 0be7db94ad | |||
| ae80359b48 | |||
| 81281855a1 | |||
| a5174c6931 | |||
| a3cc74afb3 | |||
| 84e78de6fc | |||
| 9bf4c73250 | |||
| 57a222b87a | |||
| 3e125b90a2 | |||
| 1809265d4f | |||
| 3b3774596d | |||
| bded49c366 | |||
| 841711b5f1 | |||
| 7a080115a7 | |||
| 337c4724a7 | |||
| 2119691bf6 | |||
| caf50055c9 | |||
| 3ee3c2453f | |||
| 5e431e8a61 | |||
| ff72c7cac8 | |||
| 047325e9bc | |||
| afbb758740 | |||
| 5de629cfdd | |||
| f026623600 | |||
| 2f5ee0eb91 | |||
| e7651e8092 | |||
| 82d51d6375 | |||
| 6080edfd8a | |||
| d9713571c9 | |||
| b466525e8b | |||
| 2a25675dce | |||
| 5486ad8818 | |||
| 5552fcf7bc | |||
| 782a0af13c | |||
| c6c2d9cd12 | |||
| f929a08e46 | |||
| e48f96d7d7 | |||
| 3cc95dbc08 |
@ -101,6 +101,8 @@ android {
|
||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
|
||||
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "WGAME_CPM_BUSIAPPID", "\"${WGAME_CPM_BUSIAPPID}\""
|
||||
buildConfigField "String", "WGAME_CPM_API_HOST", "\"${WGAME_CPM_API_HOST}\""
|
||||
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
|
||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
||||
|
||||
@ -663,7 +663,8 @@
|
||||
android:name=".authorization.AuthorizationActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait">
|
||||
android:screenOrientation="portrait"
|
||||
android:taskAffinity=".auth">
|
||||
<intent-filter>
|
||||
<data android:scheme="ghzhushou_authorization" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
@ -864,10 +865,6 @@
|
||||
<!-- tools:node="remove" />-->
|
||||
<!-- </provider>-->
|
||||
|
||||
<service android:name="com.gh.gamecenter.install.InstallService" />
|
||||
|
||||
<service android:name="com.gh.download.suspendwindow.DownloadSuspendWindowService" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
android:exported="false">
|
||||
|
||||
@ -588,7 +588,7 @@ document.addEventListener("selectionchange", function(e) {
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
RE.enabledEditingItems(e)
|
||||
setTimeout(() => RE.enabledEditingItems(e), 10)
|
||||
});
|
||||
|
||||
RE.recursion = function(dom) {
|
||||
|
||||
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
@ -13,11 +14,13 @@ import android.widget.TextView
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.facebook.drawee.controller.BaseControllerListener
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils.logOpenScreenAdSkip
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.MainActivity
|
||||
@ -59,6 +62,8 @@ object AdDelegateHelper {
|
||||
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||
private var mVGameLaunchAd: AdConfig? = null
|
||||
|
||||
private var ownerSplashAdLoadTime = 0L
|
||||
|
||||
val vGameLaunchAd: AdConfig?
|
||||
get() = mVGameLaunchAd
|
||||
|
||||
@ -76,6 +81,7 @@ object AdDelegateHelper {
|
||||
}
|
||||
|
||||
var isShowingSplashAd = false // 是否正在显示开屏广告
|
||||
var isOwnerSplashAdShown = false // 自有开屏广告是否展示
|
||||
var gameSearchKeyword = ""
|
||||
|
||||
fun initAdSdk(context: Context) {
|
||||
@ -303,6 +309,7 @@ object AdDelegateHelper {
|
||||
) {
|
||||
val hideCallback = {
|
||||
isShowingSplashAd = false
|
||||
isOwnerSplashAdShown = false
|
||||
hideAction.invoke()
|
||||
}
|
||||
if (mSplashAd != null) {
|
||||
@ -575,6 +582,8 @@ object AdDelegateHelper {
|
||||
handler: BaseActivity.BaseHandler,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
isOwnerSplashAdShown = false
|
||||
|
||||
val jumpBtn = startAdContainer.findViewById<TextView>(R.id.jumpBtn)
|
||||
val jumpDetailBtn: TextView = startAdContainer.findViewById(R.id.jumpDetailBtn)
|
||||
val adImage: SimpleDraweeView = startAdContainer.findViewById(R.id.adImage)
|
||||
@ -593,38 +602,62 @@ object AdDelegateHelper {
|
||||
)
|
||||
|
||||
adImage.visibleIf(true)
|
||||
ImageUtils.display(adImage, ad.img)
|
||||
ImageUtils.displayWithCallback(adImage, ad.img, true, object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onSubmit(id: String?, callerContext: Any?) {
|
||||
super.onSubmit(id, callerContext)
|
||||
adImage.post {
|
||||
ownerSplashAdLoadTime = System.currentTimeMillis()
|
||||
NewFlatLogUtils.logSplashAdLoad(ad.id)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
||||
isOwnerSplashAdShown = true
|
||||
adImage.post {
|
||||
NewFlatLogUtils.logSplashAdShow(ad.id, System.currentTimeMillis() - ownerSplashAdLoadTime)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(id: String?, throwable: Throwable?) {
|
||||
super.onFailure(id, throwable)
|
||||
NewFlatLogUtils.logSplashAdFail(ad.id, "启动广告图加载失败")
|
||||
}
|
||||
})
|
||||
|
||||
if (ad.isImageType) {
|
||||
adVideo.visibleIf(false)
|
||||
} else {
|
||||
adVideo.visibleIf(true)
|
||||
adVideo.startPlay(ad.video.url)
|
||||
}
|
||||
startAdContainer.setOnClickListener {
|
||||
// 拦截点击事件传递
|
||||
}
|
||||
jumpBtn.setOnClickListener {
|
||||
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
||||
hideCallback.invoke()
|
||||
val linkEntity = ad.jump
|
||||
logOpenScreenAdSkip(
|
||||
ad.id,
|
||||
(if (linkEntity.text != null) linkEntity.text else "")!!,
|
||||
(if (linkEntity.type != null) linkEntity.type else "")!!,
|
||||
(if (linkEntity.link != null) linkEntity.link else "")!!
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"SplashAdOwnSkip",
|
||||
"splash_ad_id",
|
||||
ad.id,
|
||||
"link_type",
|
||||
linkEntity.type ?: "",
|
||||
"link_id",
|
||||
linkEntity.link ?: "",
|
||||
"link_text",
|
||||
linkEntity.text ?: ""
|
||||
)
|
||||
it.debounceActionWithInterval(1000L) {
|
||||
if (!isOwnerSplashAdShown) {
|
||||
NewFlatLogUtils.logSplashAdFail(ad.id, "加载过程中点击跳过广告")
|
||||
}
|
||||
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
||||
hideCallback.invoke()
|
||||
val linkEntity = ad.jump
|
||||
NewFlatLogUtils.logOpenScreenAdSkip(
|
||||
ad.id,
|
||||
(if (linkEntity.text != null) linkEntity.text else "")!!,
|
||||
(if (linkEntity.type != null) linkEntity.type else "")!!,
|
||||
(if (linkEntity.link != null) linkEntity.link else "")!!
|
||||
)
|
||||
SensorsBridge.trackEvent(
|
||||
"SplashAdOwnSkip",
|
||||
"splash_ad_id",
|
||||
ad.id,
|
||||
"link_type",
|
||||
linkEntity.type ?: "",
|
||||
"link_id",
|
||||
linkEntity.link ?: "",
|
||||
"link_text",
|
||||
linkEntity.text ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
val sources: MutableList<ExposureSource> = ArrayList()
|
||||
sources.add(ExposureSource("开屏广告", ad.id))
|
||||
|
||||
@ -44,6 +44,16 @@ class SplashAdVideoView @JvmOverloads constructor(
|
||||
return R.layout.layout_splash_ad_video
|
||||
}
|
||||
|
||||
override fun touchSurfaceMoveFullLogic(absDeltaX: Float, absDeltaY: Float) {
|
||||
// no nothing
|
||||
}
|
||||
|
||||
override fun onPrepared() {
|
||||
super.onPrepared()
|
||||
|
||||
visibility = VISIBLE
|
||||
}
|
||||
|
||||
override fun onAutoCompletion() {
|
||||
setStateAndUi(CURRENT_STATE_AUTO_COMPLETE);
|
||||
|
||||
|
||||
@ -374,7 +374,7 @@ object DefaultUrlHandler {
|
||||
val iconSubscript = uri.getQueryParameter("game_icon_subscript") ?: ""
|
||||
val gameEntity =
|
||||
if (forumType == BbsType.OFFICIAL_BBS.value && gameId.isNotEmpty() && gameName.isNotEmpty() && icon.isNotEmpty()) {
|
||||
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||
GameEntity(_id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||
} else null
|
||||
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
|
||||
ActivityLabelEntity(
|
||||
|
||||
@ -63,6 +63,9 @@ public class Config {
|
||||
public static final String NEW_API_HOST = EnvHelper.getNewHost();
|
||||
public static final String VAPI_HOST = EnvHelper.getVHost();
|
||||
|
||||
public static final String WGAME_CPM_BUSIAPPID = BuildConfig.WGAME_CPM_BUSIAPPID;
|
||||
public static final String WGAME_CPM_API_HOST = EnvHelper.getWGameCPMHost();
|
||||
|
||||
// Third-Party confs
|
||||
public static final String WECHAT_APPID = BuildConfig.WECHAT_APPID;
|
||||
public static final String WECHAT_SECRET = BuildConfig.WECHAT_SECRET;
|
||||
@ -111,8 +114,6 @@ public class Config {
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
|
||||
}
|
||||
|
||||
mSettingsEntity.setGameSmooth("off");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -287,19 +287,11 @@ public class BindingAdapters {
|
||||
});
|
||||
break;
|
||||
case RESERVED:
|
||||
if ("download".equals(gameEntity.getReserveStatus())) {
|
||||
ReservationHelper.showDeleteReservationDialog(progressBar.getContext(), () -> {
|
||||
ReservationHelper.deleteReservation(gameEntity, () -> {
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
ReservationHelper.showCancelReservationDialog(progressBar.getContext(),gameEntity, () -> {
|
||||
ReservationHelper.cancelReservation(gameEntity, () -> {
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(progressBar.getContext(),gameEntity, () -> {
|
||||
ReservationHelper.cancelReservation(gameEntity, () -> {
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case H5_GAME:
|
||||
LinkEntity linkEntity = gameEntity.getH5Link();
|
||||
|
||||
@ -17,7 +17,7 @@ import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.DialogWechatBindingFailedBinding
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
class WechatBindingFailedDialogFragment : BaseDialogFragment() {
|
||||
@ -48,10 +48,10 @@ class WechatBindingFailedDialogFragment : BaseDialogFragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
UserRepository.getInstance().loginUserInfo.observe(viewLifecycleOwner) {
|
||||
currentUserId = it.data.getShortUserId()
|
||||
binding.tvCurrentName.text = it.data.name
|
||||
binding.ivCurrentAvatar.displayAvatar(it.data.icon)
|
||||
UserManager.getInstance().userInfoEntity?.let {
|
||||
currentUserId = it.getShortUserId()
|
||||
binding.tvCurrentName.text = it.name ?: ""
|
||||
binding.ivCurrentAvatar.displayAvatar(it.icon)
|
||||
binding.tvUserId.text = getString(R.string.user_id, currentUserId)
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import io.reactivex.functions.Consumer
|
||||
|
||||
@ -16,8 +17,9 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
|
||||
val throttleBus: ExposureThrottleBus by lazy {
|
||||
ExposureThrottleBus(
|
||||
Consumer { commitExposure(it) },
|
||||
Consumer(Throwable::printStackTrace)
|
||||
{ commitExposure(it) },
|
||||
Consumer(Throwable::printStackTrace),
|
||||
{ commitWXCPMExposure(it) }
|
||||
)
|
||||
}
|
||||
var layoutManager: LayoutManager? = null
|
||||
@ -29,6 +31,7 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
if (fragment == f) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
visibleState?.let { commitWXCPMExposure(it) }
|
||||
throttleBus.clear()
|
||||
}
|
||||
}
|
||||
@ -93,4 +96,32 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
ExposureManager.log(eventList)
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小游戏CPM曝光事件接口上报,由于普通曝光事件的上报通道存在节流特性,不符合CPM接口对于数据上报的实时性和准确性的要求,所以使用额外的通道进行上报
|
||||
*/
|
||||
private fun commitWXCPMExposure(visibleState: ExposureThrottleBus.VisibleState) {
|
||||
|
||||
val eventList = arrayListOf<ExposureEvent>()
|
||||
|
||||
for (pos in visibleState.firstVisiblePosition..visibleState.lastVisiblePosition) {
|
||||
try {
|
||||
exposable.getEventByPosition(pos)?.let {
|
||||
if (it.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
|
||||
eventList.add(it)
|
||||
}
|
||||
}
|
||||
exposable.getEventListByPosition(pos)?.let { list ->
|
||||
list.forEach {
|
||||
if (it.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
|
||||
eventList.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ignore: Exception) {
|
||||
// Just ignore the error.
|
||||
}
|
||||
}
|
||||
ExposureManager.logCPM(eventList)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.loghub.TLogHubHelper
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.minigame.wechat.WGameSubjectCPMListReportHelper
|
||||
import com.lightgame.utils.Utils
|
||||
import com.volcengine.model.tls.LogItem
|
||||
|
||||
@ -32,6 +34,9 @@ object ExposureManager {
|
||||
*/
|
||||
fun log(event: ExposureEvent) {
|
||||
AppExecutor.logExecutor.execute {
|
||||
if (event.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
|
||||
WGameSubjectCPMListReportHelper.reportExposure(event)
|
||||
}
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
exposureSet.add(event)
|
||||
exposureCache.add(event.id)
|
||||
@ -58,6 +63,17 @@ object ExposureManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a wechat mini game cpm collection of exposure event.
|
||||
*/
|
||||
fun logCPM(eventList: List<ExposureEvent>) {
|
||||
AppExecutor.logExecutor.execute {
|
||||
if (eventList.isNotEmpty()) {
|
||||
WGameSubjectCPMListReportHelper.reportExposure(eventList.toSet())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forcedUpload Ignore all restrictions.
|
||||
*/
|
||||
|
||||
@ -3,16 +3,20 @@ package com.gh.common.exposure
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.functions.Consumer
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Consumer<Throwable>) {
|
||||
class ExposureThrottleBus(
|
||||
var onSuccess: Consumer<VisibleState>,
|
||||
var onError: Consumer<Throwable>,
|
||||
onPreSuccess: Consumer<VisibleState>
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val THRESHOLD_TIME = 300L
|
||||
}
|
||||
|
||||
private val mPublishSubject: PublishSubject<VisibleState> = PublishSubject.create()
|
||||
private val mPublishSubject: BehaviorSubject<VisibleState> = BehaviorSubject.create()
|
||||
private val mCompositeDisposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
init {
|
||||
@ -24,6 +28,7 @@ class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Co
|
||||
*/
|
||||
val disposable = mPublishSubject
|
||||
.distinctUntilChanged()
|
||||
.doOnNext(onPreSuccess)
|
||||
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(onSuccess, onError)
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gh.common.fragment
|
||||
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import java.lang.reflect.Field
|
||||
|
||||
fun FragmentManager.popBackStackAllowStateLoss() {
|
||||
popBackStackAllowStateLoss(-1, 0)
|
||||
}
|
||||
|
||||
fun FragmentManager.popBackStackAllowStateLoss(id: Int, flags: Int) {
|
||||
if (!isStateSaved) {
|
||||
popBackStack(id, flags)
|
||||
}
|
||||
}
|
||||
|
||||
fun FragmentManager.popBackStackAllowStateLoss(name: String?, flags: Int) {
|
||||
if (!isStateSaved) {
|
||||
popBackStack(name, flags)
|
||||
}
|
||||
}
|
||||
|
||||
fun FragmentManager.popBackStackImmediateAllowStateLoss() = popBackStackAllowStateLoss(-1, 0)
|
||||
|
||||
fun FragmentManager.popBackStackImmediateAllowStateLoss(id: Int, flags: Int) =
|
||||
if (!isStateSaved) {
|
||||
popBackStackImmediate(id, flags)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
@Throws(NoSuchFieldException::class)
|
||||
private fun getField(clazz: Class<*>, name: String): Field {
|
||||
var cls: Class<*>? = clazz
|
||||
while (cls != null) {
|
||||
try {
|
||||
val declaredField = cls.getDeclaredField(name)
|
||||
declaredField.isAccessible = true
|
||||
return declaredField
|
||||
} catch (e: NoSuchFieldException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
cls = cls.superclass
|
||||
}
|
||||
throw NoSuchFieldException()
|
||||
}
|
||||
@ -1,12 +1,9 @@
|
||||
package com.gh.common.iinterface
|
||||
|
||||
interface ISmartRefreshContent {
|
||||
/**
|
||||
* 启用/关闭 页面滑动
|
||||
* @param isScrollEnabled 是否启用
|
||||
*/
|
||||
fun setScrollEnabled(isScrollEnabled: Boolean)
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout
|
||||
import com.scwang.smartrefresh.layout.constant.RefreshState
|
||||
|
||||
interface ISmartRefreshContent {
|
||||
fun onRefresh()
|
||||
|
||||
/**
|
||||
@ -14,4 +11,6 @@ interface ISmartRefreshContent {
|
||||
* @param isSwipeRefreshEnabled 是否启用
|
||||
*/
|
||||
fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean)
|
||||
|
||||
fun onStateChanged(refreshLayout: RefreshLayout, oldState: RefreshState, newState: RefreshState)
|
||||
}
|
||||
@ -33,5 +33,9 @@ class BuildConfigImpl : IBuildConfigProvider {
|
||||
|
||||
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
||||
|
||||
override fun getWGameCPMApiHost(): String = BuildConfig.WGAME_CPM_API_HOST
|
||||
|
||||
override fun getWGameCPMBusiAppId(): String = BuildConfig.WGAME_CPM_BUSIAPPID
|
||||
|
||||
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
||||
}
|
||||
@ -62,7 +62,13 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToCommunityArticle(context, articleId, communityId, entrance, path, sourceEntrance)
|
||||
}
|
||||
|
||||
override fun directToVideoDetail(context: Context, videoId: String, entrance: String?, path: String?, sourceEntrance: String) {
|
||||
override fun directToVideoDetail(
|
||||
context: Context,
|
||||
videoId: String,
|
||||
entrance: String?,
|
||||
path: String?,
|
||||
sourceEntrance: String
|
||||
) {
|
||||
DirectUtils.directToVideoDetail(context, videoId, entrance, path, sourceEntrance)
|
||||
}
|
||||
|
||||
@ -78,8 +84,13 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToQQGameById(activity, qqAppId)
|
||||
}
|
||||
|
||||
override fun directToWechatGameById(activity: Activity, qqAppId: String) {
|
||||
DirectUtils.directToWechatGameById(activity, qqAppId)
|
||||
override fun directToWechatGameById(
|
||||
activity: Activity,
|
||||
wechatAppId: String,
|
||||
wechatAppPath: String,
|
||||
wechatAppExtData: String
|
||||
) {
|
||||
DirectUtils.directToWechatGameById(activity, wechatAppId, wechatAppPath, wechatAppExtData)
|
||||
}
|
||||
|
||||
override fun directToExternalBrowser(context: Context, url: String) {
|
||||
|
||||
@ -115,6 +115,12 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
"本地下载"
|
||||
}
|
||||
|
||||
// 小游戏的启动不需要上报下载点击事件
|
||||
// @see https://jira.shanqu.cc/browse/GHZSCY-7013
|
||||
if (boundedObject is GameEntity && boundedObject.isMiniGame()) {
|
||||
return
|
||||
}
|
||||
|
||||
// 上报神策点击事件
|
||||
val customPageKV = customPageTrackData?.toKV() ?: arrayOf()
|
||||
SensorsBridge.trackEventWithExposureSource(
|
||||
@ -124,7 +130,7 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
"game_name", gameName,
|
||||
"game_type", gameTypeInChinese,
|
||||
"download_status", downloadStatusInChinese,
|
||||
"button_name", downloadButton.text,
|
||||
"button_name", text,
|
||||
"game_schema_type", gameSchemaType,
|
||||
"download_type", downloadType,
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
|
||||
@ -4,6 +4,8 @@ import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.sqlite.SQLiteDiskIOException
|
||||
import android.database.sqlite.SQLiteException
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
@ -284,7 +286,11 @@ object SimulatorGameManager {
|
||||
entity.isRecentlyPlayed = it.id == gameId
|
||||
simulatorGameRecordList.add(entity)
|
||||
}
|
||||
simulatorGameDao.addSimulatorGameList(simulatorGameRecordList)
|
||||
try {
|
||||
simulatorGameDao.addSimulatorGameList(simulatorGameRecordList)
|
||||
} catch (e: SQLiteException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.provider.ISentryProvider;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
@ -39,6 +40,11 @@ import io.reactivex.schedulers.Schedulers;
|
||||
*/
|
||||
public class DataUtils {
|
||||
|
||||
// 神策 OAID 是否已绑定
|
||||
private static boolean isSensorOAIDBounded = false;
|
||||
// 原始的 OAID 是否已成功获取
|
||||
private static boolean originalOAIDIsReceived = false;
|
||||
|
||||
private DataUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
@ -65,7 +71,6 @@ public class DataUtils {
|
||||
// 默认用 APP 级已存储的 GID 来使用,不使用外部 GID
|
||||
String savedGid = SPUtils.getString(Constants.GID);
|
||||
if (!TextUtils.isEmpty(savedGid)) {
|
||||
HaloApp.getInstance().setGid(savedGid);
|
||||
onGidReceived(savedGid);
|
||||
} else {
|
||||
GidHelper.getInstance().registerDevice(HaloApp.getInstance().getApplication(), new GidCallback() {
|
||||
@ -89,6 +94,8 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
private static void onGidReceived(String gid) {
|
||||
bindValidOaidToSensor(false);
|
||||
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
// 更新广告配置
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
@ -111,6 +118,35 @@ public class DataUtils {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 为神策绑定有效的 OAID
|
||||
*/
|
||||
public static void bindValidOaidToSensor(boolean fromOaidResult) {
|
||||
if (isSensorOAIDBounded) return;
|
||||
|
||||
String oaid = HaloApp.getInstance().getOAID();
|
||||
|
||||
// 来自于 oaid 获取回调,或者说原始 oaid 已经获取成功
|
||||
if (fromOaidResult || originalOAIDIsReceived) {
|
||||
originalOAIDIsReceived = true;
|
||||
// 遇到异常的 OAID
|
||||
if (Constants.INVALID_OAID_1.equals(oaid)
|
||||
|| Constants.INVALID_OAID_2.equals(oaid)
|
||||
|| Constants.INVALID_OAID_3.equals(oaid)
|
||||
|| TextUtils.isEmpty(oaid)) {
|
||||
// 若 gid 不为空,那么整合 gid 作为 oaid https://jira.shanqu.cc/browse/GHZSCY-7004
|
||||
if (HaloApp.getInstance().getGid() != null) {
|
||||
oaid = "GID" + HaloApp.getInstance().getGid();
|
||||
SensorsBridge.INSTANCE.setOAID(oaid);
|
||||
isSensorOAIDBounded = true;
|
||||
}
|
||||
} else {
|
||||
SensorsBridge.INSTANCE.setOAID(oaid);
|
||||
isSensorOAIDBounded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用 gid 绑定的实名信息
|
||||
*/
|
||||
|
||||
@ -139,6 +139,7 @@ public class DetailDownloadUtils {
|
||||
// 游戏包含多 APK 的情况
|
||||
viewHolder.getMultiVersionDownloadTv().setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
|
||||
viewHolder.getMultiVersionDownloadTv().setVisibility(View.VISIBLE);
|
||||
viewHolder.getDownloadPb().setTag(com.gh.gamecenter.feature.R.string.download, viewHolder.getMultiVersionDownloadTv().getText());
|
||||
viewHolder.getDownloadPb().setText("");
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
|
||||
@ -485,11 +485,13 @@ object DirectUtils {
|
||||
ColumnCollectionDetailFragment.TYPE_QQ_MINI_GAME_COLUMN -> directToQGameHome(context)
|
||||
|
||||
// QQ游戏专题详情页
|
||||
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN, ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN -> {
|
||||
val subjectType = if (linkEntity.type == ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN) {
|
||||
SubjectData.SubjectType.QQ_GAME
|
||||
} else {
|
||||
SubjectData.SubjectType.WECHAT_GAME
|
||||
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN,
|
||||
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN,
|
||||
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN -> {
|
||||
val subjectType = when (linkEntity.type) {
|
||||
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN -> SubjectData.SubjectType.QQ_GAME
|
||||
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN -> SubjectData.SubjectType.WECHAT_GAME_CPM
|
||||
else -> SubjectData.SubjectType.WECHAT_GAME
|
||||
}
|
||||
directToSubject(
|
||||
context = context,
|
||||
@ -2009,6 +2011,8 @@ object DirectUtils {
|
||||
fun directToWechatGameById(
|
||||
activity: Activity,
|
||||
wechatAppId: String,
|
||||
wechatAppPath: String = "",
|
||||
wechatAppExtData: String = ""
|
||||
) {
|
||||
|
||||
val wxApiProxy = WXAPIFactory.createWXAPI(
|
||||
@ -2023,8 +2027,9 @@ object DirectUtils {
|
||||
wxApiProxy.sendReq(
|
||||
WXLaunchMiniProgram.Req().apply {
|
||||
userName = wechatAppId
|
||||
path = Constants.WECHAT_MINI_GAME_PCS
|
||||
miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;
|
||||
path = wechatAppPath.ifEmpty { Constants.WECHAT_MINI_GAME_PCS }
|
||||
extData = wechatAppExtData
|
||||
miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -839,34 +839,25 @@ object DownloadItemUtils {
|
||||
} else {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
ReservationHelper.showDeleteReservationDialog(context) {
|
||||
ReservationHelper.deleteReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
ReservationHelper.showCancelReservationDialog(context, gameEntity, {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(context, gameEntity,{
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
"关闭弹窗",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"关闭弹窗",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -880,7 +871,7 @@ object DownloadItemUtils {
|
||||
}
|
||||
if (gameEntity.isMiniGame()) {
|
||||
downloadBtn.setOnClickListener {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
clickCallback?.onCallback()
|
||||
allStateClickCallback?.onCallback()
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ object DownloadObserver {
|
||||
private const val CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED = "CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED"
|
||||
|
||||
private val mRetryableHashMap = hashMapOf<String, Boolean>()
|
||||
private val mRetryableProgressMap = hashMapOf<String, Long>()
|
||||
|
||||
/**
|
||||
* 当下载任务是 预约上线提醒 触发的,则所有弹窗均不显示
|
||||
@ -146,7 +147,8 @@ object DownloadObserver {
|
||||
|| DownloadStatus.timeout == status
|
||||
) {
|
||||
if (mRetryableHashMap[downloadEntity.url] == true
|
||||
&& NetworkUtils.isWifiConnected(HaloApp.getInstance().application)
|
||||
&& (NetworkUtils.isWifiConnected(HaloApp.getInstance().application)
|
||||
|| NDownloadBridge.isDownloadViaTrafficAllowed(downloadEntity))
|
||||
) {
|
||||
downloadManager.resumeDownload(downloadEntity.url)
|
||||
mRetryableHashMap[downloadEntity.url] = false
|
||||
@ -257,6 +259,7 @@ object DownloadObserver {
|
||||
}
|
||||
|
||||
mRetryableHashMap.remove(downloadEntity.url)
|
||||
mRetryableProgressMap.remove(downloadEntity.url)
|
||||
|
||||
EventBus.getDefault().post(EBDownloadStatus("done", "", "", "", downloadEntity.packageName, ""))
|
||||
}
|
||||
@ -264,7 +267,9 @@ object DownloadObserver {
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
// 如果已下载大小发生变化,表示成功恢复下载,则重置重试标记
|
||||
if (status == DownloadStatus.downloading) {
|
||||
if (status == DownloadStatus.downloading
|
||||
&& downloadEntity.progress != mRetryableProgressMap[downloadEntity.url]) {
|
||||
mRetryableProgressMap[downloadEntity.url] = downloadEntity.progress
|
||||
mRetryableHashMap[downloadEntity.url] = true
|
||||
}
|
||||
}
|
||||
@ -494,7 +499,7 @@ object DownloadObserver {
|
||||
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
val exposureEvent = ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
GameEntity(
|
||||
id = downloadEntity.gameId,
|
||||
_id = downloadEntity.gameId,
|
||||
mName = downloadEntity.name.removeSuffix(Constants.GAME_NAME_DECORATOR),
|
||||
gameVersion = downloadEntity.versionName ?: "",
|
||||
isPlatformRecommend = isPlatformRecommend,
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -19,10 +16,8 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 下载完成跳安装,
|
||||
*/
|
||||
@ -49,15 +44,15 @@ public class InstallUtils {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == INSTALL_WHAT && packageManager != null) {
|
||||
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
|
||||
ArrayList<String> list = new ArrayList<>(packageNameList);
|
||||
if (installMap != null && installMap.size() != 0) {
|
||||
ArrayList<String> keys = new ArrayList<>();
|
||||
for (String packageName : installMap.keySet()) {
|
||||
if (TextUtils.isEmpty(packageName)) continue;
|
||||
|
||||
long time = installMap.get(packageName);
|
||||
if (System.currentTimeMillis() - time >= MAX_TIME) {
|
||||
keys.add(packageName);
|
||||
} else if (list.contains(packageName)) {
|
||||
} else if (PackageUtils.isInstalled(context, packageName)) {
|
||||
keys.add(packageName);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntityByPackageName(packageName);
|
||||
@ -80,7 +75,7 @@ public class InstallUtils {
|
||||
long time = uninstallMap.get(packageName);
|
||||
if (System.currentTimeMillis() - time >= MAX_TIME) {
|
||||
keys.add(packageName);
|
||||
} else if (!list.contains(packageName)) {
|
||||
} else if (!PackageUtils.isInstalled(context, packageName)) {
|
||||
keys.add(packageName);
|
||||
EventBus.getDefault().post(new EBPackage("卸载", packageName, "", false));
|
||||
}
|
||||
@ -105,6 +100,8 @@ public class InstallUtils {
|
||||
}
|
||||
|
||||
public void addInstall(String packageName) {
|
||||
if (TextUtils.isEmpty(packageName)) return;
|
||||
|
||||
if (installMap == null) {
|
||||
installMap = Collections.synchronizedMap(new HashMap<String, Long>());
|
||||
}
|
||||
|
||||
@ -2778,4 +2778,34 @@ object NewFlatLogUtils {
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
// 自有开屏广告加载
|
||||
fun logSplashAdLoad(id: String) {
|
||||
json {
|
||||
KEY_EVENT to "splash_ad_load"
|
||||
"ad_id" to id
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
// 自有开屏广告展示
|
||||
fun logSplashAdShow(id: String, duration: Long) {
|
||||
json {
|
||||
KEY_EVENT to "splash_ad_show"
|
||||
"ad_id" to id
|
||||
"duration" to duration
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
// 自有开屏广告加载/展示失败
|
||||
@JvmStatic
|
||||
fun logSplashAdFail(id: String, error: String) {
|
||||
json {
|
||||
KEY_EVENT to "splash_ad_fail"
|
||||
"ad_id" to id
|
||||
"error" to error
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
}
|
||||
@ -814,7 +814,7 @@ object PackageHelper {
|
||||
uploadUIDGapLog = false
|
||||
|
||||
val uidGap = (android.os.Process.LAST_APPLICATION_UID - lastValidUid) / 100 * 100
|
||||
SentryHelper.onEvent("UID_GAP", "gap", uidGap.toString())
|
||||
// SentryHelper.onEvent("UID_GAP", "gap", uidGap.toString())
|
||||
}
|
||||
|
||||
return packageList
|
||||
|
||||
@ -18,7 +18,6 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.install.InstallService
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -194,12 +193,6 @@ object PackageInstaller {
|
||||
private fun install(context: Context, pkgPath: String, pkgName: String?) {
|
||||
HaloApp.put(Constants.LAST_INSTALL_GAME, pkgPath)
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU && Build.MANUFACTURER.lowercase().contains("xiaomi")) {
|
||||
val foregroundServiceIntent = Intent(context, InstallService::class.java)
|
||||
foregroundServiceIntent.putExtra(InstallService.KEY_SERVICE_ACTION, InstallService.START_FOREGROUND)
|
||||
context.startForegroundService(foregroundServiceIntent)
|
||||
}
|
||||
|
||||
val installIntent = getInstallIntent(context, pkgPath)
|
||||
context.startActivity(installIntent)
|
||||
|
||||
@ -284,7 +277,12 @@ object PackageInstaller {
|
||||
installIntent.setDataAndType(uri, "application/vnd.android.package-archive")
|
||||
}
|
||||
|
||||
updateSystemInstallerIfAvailable(context, installIntent)
|
||||
// 优选系统的安装器(遇到 Exception 就回落到正常的安装器)
|
||||
try {
|
||||
updateSystemInstallerIfAvailable(context, installIntent)
|
||||
} catch (ignored: Exception) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
InstallUtils.getInstance()
|
||||
.addInstall(PackageUtils.getPackageNameByPath(context, path))
|
||||
|
||||
@ -7,7 +7,7 @@ import com.gh.gamecenter.common.utils.isVGameDownloadInDualDownloadMode
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
object PackageLauncher {
|
||||
@ -81,28 +81,11 @@ object PackageLauncher {
|
||||
gameEntity: GameEntity? = null,
|
||||
packageName: String?
|
||||
) {
|
||||
|
||||
if (packageName.isNullOrEmpty()) {
|
||||
ToastUtils.toast("启动失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 获取 GameInstall 实体,用于记录启动日志用
|
||||
val gameInstall = if (gameEntity != null) {
|
||||
GameInstall.transformGameInstall(gameEntity, packageName)
|
||||
} else {
|
||||
PackageRepository.gameInstalled.find { it.packageName == packageName }
|
||||
}
|
||||
|
||||
if (gameInstall != null) {
|
||||
NewFlatLogUtils.logGameLaunch(
|
||||
gameId = gameInstall.id ?: "unknown",
|
||||
gameName = gameInstall.name ?: "unknown",
|
||||
gameCategory = gameInstall.category ?: "unknown",
|
||||
downloadStatus = if (gameInstall.downloadStatus == "demo") "试玩" else "下载"
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
val intent = context.applicationContext.packageManager.getLaunchIntentForPackage(packageName)
|
||||
if (intent != null) {
|
||||
@ -113,6 +96,26 @@ object PackageLauncher {
|
||||
} catch (e: Exception) {
|
||||
ToastUtils.toast( "启动失败")
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取 GameInstall 实体,用于记录启动日志用
|
||||
val gameInstall = if (gameEntity != null) {
|
||||
GameInstall.transformGameInstall(gameEntity, packageName)
|
||||
} else {
|
||||
PackagesManager.getInstalledList().find { it.packageName == packageName }
|
||||
}
|
||||
|
||||
if (gameInstall != null) {
|
||||
NewFlatLogUtils.logGameLaunch(
|
||||
gameId = gameInstall.id ?: "unknown",
|
||||
gameName = gameInstall.name ?: "unknown",
|
||||
gameCategory = gameInstall.category ?: "unknown",
|
||||
downloadStatus = if (gameInstall.downloadStatus == "demo") "试玩" else "下载"
|
||||
)
|
||||
}
|
||||
} catch (e: RuntimeException) {
|
||||
// 都 DeadSystemException 了,还想啥日志上报
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,7 +14,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AndroidException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -29,9 +28,9 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.utils.MD5Utils;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
@ -225,17 +224,6 @@ public class PackageUtils {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
if (e instanceof AndroidException) {
|
||||
// 有些设备会出现 DeadSystemException
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"GET_META_DATA_ERROR",
|
||||
"packageName",
|
||||
packageName,
|
||||
"exception_digest",
|
||||
e.getLocalizedMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -313,7 +301,7 @@ public class PackageUtils {
|
||||
Signature[] signatures = packageInfo.signatures;
|
||||
|
||||
// 使用幸运破解器破解安卓签名认证可能会出现不用签名也能装的情况,这里有可能是空的
|
||||
if (signatures[0] != null) {
|
||||
if (signatures.length > 0 && signatures[0] != null) {
|
||||
return parseSignature(signatures[0].toByteArray());
|
||||
} else {
|
||||
return new String[]{null, null};
|
||||
@ -497,7 +485,6 @@ public class PackageUtils {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SentryHelper.INSTANCE.onEvent("GET_PACKAGE_INFO_ERROR", "path", path);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -554,10 +541,8 @@ public class PackageUtils {
|
||||
try {
|
||||
Intent intent = context.getApplicationContext().getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
return intent != null;
|
||||
} catch (IllegalArgumentException exception) {
|
||||
// 一些设备调用获取 intent 的时候会触发 Parcel.readException !
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
} catch (Exception exception) {
|
||||
return PackageHelper.INSTANCE.getLocalPackageNameSet().contains(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,17 +625,6 @@ public class PackageUtils {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
if (e instanceof AndroidException) {
|
||||
// 有些设备会出现 DeadSystemException
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"GET_VERSION_NAME_ERROR",
|
||||
"packageName",
|
||||
packageName,
|
||||
"exception_digest",
|
||||
e.getLocalizedMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -664,20 +638,23 @@ public class PackageUtils {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof AndroidException) {
|
||||
// 有些设备会出现 DeadSystemException
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"GET_VERSION_CODE_ERROR",
|
||||
"packageName",
|
||||
packageName,
|
||||
"exception_digest",
|
||||
e.getLocalizedMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取应用的名称
|
||||
*/
|
||||
public static CharSequence getNameByPackageName(Context context, String packageName) {
|
||||
try {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
return packageManager.getApplicationLabel(packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取应用的 icon
|
||||
@ -688,16 +665,6 @@ public class PackageUtils {
|
||||
return packageManager.getApplicationIcon(packageName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof AndroidException) {
|
||||
// 有些设备会出现 DeadSystemException
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"GET_ICON_ERROR",
|
||||
"packageName",
|
||||
packageName,
|
||||
"exception_digest",
|
||||
e.getLocalizedMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -731,17 +698,6 @@ public class PackageUtils {
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof AndroidException) {
|
||||
// 有些设备会出现 DeadSystemException
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"GET_APP_BASIC_INFO_BY_PACKAGE_NAME",
|
||||
"packageName",
|
||||
packageName,
|
||||
"exception_digest",
|
||||
e.getLocalizedMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,53 +29,31 @@ import okhttp3.ResponseBody
|
||||
|
||||
object ReservationHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteReservation(game: GameEntity, refreshCallback: EmptyCallback) {
|
||||
deleteOrCancelReservation(game, true, refreshCallback)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun cancelReservation(game: GameEntity, refreshCallback: EmptyCallback) {
|
||||
deleteOrCancelReservation(game, false, refreshCallback)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun deleteOrCancelReservation(
|
||||
@JvmStatic
|
||||
fun cancelReservation(
|
||||
game: GameEntity,
|
||||
deleteReservation: Boolean,
|
||||
refreshCallback: EmptyCallback
|
||||
) {
|
||||
|
||||
val retrofit = RetrofitManager.getInstance()
|
||||
val single = if (deleteReservation) {
|
||||
retrofit.newApi
|
||||
.deleteGameReservation(
|
||||
game.id,
|
||||
getReserveRequestBody(game, context = HaloApp.getInstance().application)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
} else {
|
||||
retrofit.newApi
|
||||
.cancelGameReservation(
|
||||
game.id,
|
||||
getReserveRequestBody(game, context = HaloApp.getInstance().application)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
retrofit.newApi
|
||||
.cancelGameReservation(
|
||||
game.id,
|
||||
getReserveRequestBody(game, context = HaloApp.getInstance().application)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
ReservationRepository.removeReservationFromMemoryAndRefresh(game.id)
|
||||
refreshCallback.onCallback()
|
||||
}
|
||||
|
||||
single.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
ReservationRepository.removeReservationFromMemoryAndRefresh(game.id)
|
||||
refreshCallback.onCallback()
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
Utils.toast(HaloApp.getInstance().application, exception.message)
|
||||
exception.printStackTrace()
|
||||
}
|
||||
})
|
||||
override fun onFailure(exception: Exception) {
|
||||
Utils.toast(HaloApp.getInstance().application, exception.message)
|
||||
exception.printStackTrace()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -146,21 +124,6 @@ object ReservationHelper {
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showDeleteReservationDialog(context: Context, emptyCallback: EmptyCallback) {
|
||||
DialogUtils.showCancelOrDeleteReservationDialog(
|
||||
context,
|
||||
"删除预约",
|
||||
"游戏已上线,你可以删除此预约记录,确定删除吗?",
|
||||
"确定删除",
|
||||
"暂不删除", object : ConfirmListener {
|
||||
override fun onConfirm() {
|
||||
emptyCallback.onCallback()
|
||||
}
|
||||
}, null
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showCancelReservationDialog(context: Context, game: GameEntity?, emptyCallback: EmptyCallback) {
|
||||
showCancelReservationDialog(context, game, emptyCallback, null)
|
||||
|
||||
@ -27,7 +27,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
@ -176,7 +178,7 @@ object UsageStatsHelper {
|
||||
return
|
||||
}
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), postBody.toString())
|
||||
val body = postBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
mApi.postUsageStatus(body, UserManager.getInstance().userId)
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
|
||||
@ -65,6 +65,7 @@ object ViewPagerFragmentHelper {
|
||||
const val TYPE_COLUMN = "column" // 游戏专题详情页
|
||||
const val TYPE_QQ_MINI_GAME_COLUMN = "qq_mini_game_column_detail" // QQ小游戏专题详情页
|
||||
const val TYPE_WECHAT_GAME_COLUMN = "wechat_game_column_detail" // 微信小游戏专题详情页
|
||||
const val TYPE_WECHAT_GAME_CPM_COLUMN = "wechat_game_cpm_column_detail" // 微信小游戏CPM专题详情页
|
||||
const val TYPE_COLUMN_COLLECTION = "column_collection" // 专题合集详情页
|
||||
const val TYPE_SERVER = "server" // 开服表
|
||||
const val TYPE_COLUMN_TEST = "column_test_v2" // 新游开测
|
||||
@ -163,10 +164,11 @@ object ViewPagerFragmentHelper {
|
||||
className = GameCollectionSquareFragment::class.java.name
|
||||
}
|
||||
// 游戏专题详情页/QQ游戏专题详情页
|
||||
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN, TYPE_WECHAT_GAME_COLUMN -> {
|
||||
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN, TYPE_WECHAT_GAME_COLUMN, TYPE_WECHAT_GAME_CPM_COLUMN -> {
|
||||
val subjectType = when(entity.type) {
|
||||
TYPE_QQ_MINI_GAME_COLUMN -> SubjectData.SubjectType.QQ_GAME
|
||||
TYPE_WECHAT_GAME_COLUMN -> SubjectData.SubjectType.WECHAT_GAME
|
||||
TYPE_WECHAT_GAME_CPM_COLUMN -> SubjectData.SubjectType.WECHAT_GAME_CPM
|
||||
else -> SubjectData.SubjectType.NORMAL
|
||||
}
|
||||
className = SubjectFragment::class.java.name
|
||||
|
||||
@ -34,7 +34,9 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
@ -216,7 +218,7 @@ object PackageObserver {
|
||||
try {
|
||||
jsonObject.put("game_id", gameId)
|
||||
jsonObject.put("package", packageName)
|
||||
val rBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
|
||||
val rBody = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
RetrofitManager.getInstance().api
|
||||
.postPlayedGame(UserManager.getInstance().userId, rBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@ -94,8 +94,8 @@ object ExoCacheManager {
|
||||
response =
|
||||
OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(5, TimeUnit.SECONDS).build()
|
||||
.newCall(request).execute()
|
||||
if (response!!.isSuccessful && response.body() != null) {
|
||||
val length = response.body()!!.contentLength()
|
||||
if (response!!.isSuccessful && response.body != null) {
|
||||
val length = response.body!!.contentLength()
|
||||
contentLength = if (length == 0L) -1L else length
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.download.simple
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.database.sqlite.SQLiteException
|
||||
import android.database.sqlite.SQLiteFullException
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.lg.download.*
|
||||
import com.lg.download.listener.InnerDownloadListener
|
||||
@ -174,6 +175,9 @@ object DownloadMessageHandler : InnerDownloadListener {
|
||||
DownloadError.CONTENT_LENGTH_IS_ZERO -> {
|
||||
ToastUtils.toast("下载链接异常,请检查")
|
||||
}
|
||||
DownloadError.DISK_IS_FULL -> {
|
||||
ToastUtils.toast("磁盘已满,请清理空间后获得更好的体验")
|
||||
}
|
||||
else -> {
|
||||
// 想怎么处理就怎么处理
|
||||
}
|
||||
@ -264,18 +268,30 @@ object DownloadMessageHandler : InnerDownloadListener {
|
||||
}
|
||||
|
||||
fun insertDownloadToDatabase(downloadEntity: SimpleDownloadEntity) {
|
||||
mDownloadDao.insertDownloadEntity(downloadEntity)
|
||||
updateDownloadList()
|
||||
try {
|
||||
mDownloadDao.insertDownloadEntity(downloadEntity)
|
||||
updateDownloadList()
|
||||
} catch (e: SQLiteException) {
|
||||
if (e is SQLiteFullException) {
|
||||
ToastUtils.showToast("磁盘已满,请清理空间获得更好的体验")
|
||||
}
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun updateDownloadToDatabase(
|
||||
downloadEntity: SimpleDownloadEntity,
|
||||
updateDownloadList: Boolean = false
|
||||
) {
|
||||
mDownloadDao.updateDownloadEntity(downloadEntity)
|
||||
try {
|
||||
mDownloadDao.updateDownloadEntity(downloadEntity)
|
||||
|
||||
if (updateDownloadList) {
|
||||
updateDownloadList()
|
||||
if (updateDownloadList) {
|
||||
updateDownloadList()
|
||||
}
|
||||
} catch (e: SQLiteFullException) {
|
||||
// 底层的下载服务遇到 SQLiteFullException 时会自动暂停下载任务,上层这里就不用纠结处理方式了
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,12 +27,24 @@ object SimpleDownloadManager {
|
||||
val downloadStatus = mDownloadQueue.getStatus(config.uniqueId)
|
||||
|
||||
if (downloadStatus != DownloadStatus.PAUSED) {
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
DownloadMessageHandler.insertDownloadToDatabase(getDownloadEntity(config))
|
||||
mDownloadQueue.submitNewTask(config)
|
||||
}
|
||||
createNewTaskAndDownload(config)
|
||||
} else {
|
||||
resume(config.uniqueId)
|
||||
try {
|
||||
resume(config.uniqueId)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
createNewTaskAndDownload(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新任务并下载
|
||||
*/
|
||||
private fun createNewTaskAndDownload(config: DownloadConfig) {
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
mDownloadQueue.cancel(config.uniqueId)
|
||||
DownloadMessageHandler.insertDownloadToDatabase(getDownloadEntity(config))
|
||||
mDownloadQueue.submitNewTask(config)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -166,8 +166,13 @@ public class MainActivity extends BaseActivity {
|
||||
private final Handler handler = new Handler();
|
||||
private boolean mShouldShowAd = false; // 是否显示广告
|
||||
|
||||
private Bundle mTempSavedInstanceState;
|
||||
private boolean mFragmentIsCreated = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mTempSavedInstanceState = savedInstanceState;
|
||||
|
||||
mShouldShowAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null
|
||||
&& !HaloApp.getInstance().isAlreadyUpAndRunning;
|
||||
HaloApp.getInstance().isAlreadyUpAndRunning = true;
|
||||
@ -175,21 +180,12 @@ public class MainActivity extends BaseActivity {
|
||||
mMainWrapperViewModel = new ViewModelProvider(this, new MainWrapperViewModel.Factory(HaloApp.getInstance()))
|
||||
.get(MainWrapperViewModel.class);
|
||||
|
||||
DisplayUtils.transparentStatusBar(this);
|
||||
DisplayUtils.updateGlobalScreen(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
Fragment fragmentFromFM = getSupportFragmentManager().findFragmentById(com.gh.gamecenter.selector.R.id.layout_activity_content);
|
||||
|
||||
mMainWrapperFragment = fragmentFromFM != null ? (MainWrapperFragment) fragmentFromFM : new MainWrapperFragment();
|
||||
if (savedInstanceState != null) {
|
||||
mMainWrapperFragment.setArguments(savedInstanceState);
|
||||
} else if (getIntent() != null) {
|
||||
mMainWrapperFragment.setArguments(getIntent().getExtras());
|
||||
}
|
||||
replaceFragment(mMainWrapperFragment);
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (HaloApp.getInstance().isNewForThisVersion) {
|
||||
LunchType lunchType = HaloApp.getInstance().getLaunchType();
|
||||
@ -215,7 +211,6 @@ public class MainActivity extends BaseActivity {
|
||||
DataUtils.getGid();
|
||||
}
|
||||
|
||||
|
||||
mPackageViewModel = ViewModelProviders.of(this, new PackageViewModel.Factory()).get(PackageViewModel.class);
|
||||
|
||||
final boolean containsErrorMsg = com.gh.gamecenter.common.constant.Config.isContainsErrorMsg();
|
||||
@ -273,6 +268,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (mShouldShowAd) {
|
||||
showAd();
|
||||
} else {
|
||||
doInitMainFragment(mTempSavedInstanceState);
|
||||
hideTextAd();
|
||||
hideSplashAd();
|
||||
}
|
||||
@ -328,6 +324,23 @@ public class MainActivity extends BaseActivity {
|
||||
CertificationSwitchHelper.getCertificationSwitch();
|
||||
}
|
||||
|
||||
private void doInitMainFragment(Bundle savedInstanceState) {
|
||||
if (mFragmentIsCreated) return;
|
||||
|
||||
mTempSavedInstanceState = null;
|
||||
Fragment fragmentFromFM = getSupportFragmentManager().findFragmentById(com.gh.gamecenter.selector.R.id.layout_activity_content);
|
||||
|
||||
mMainWrapperFragment = fragmentFromFM != null ? (MainWrapperFragment) fragmentFromFM : new MainWrapperFragment();
|
||||
if (savedInstanceState != null) {
|
||||
mMainWrapperFragment.setArguments(savedInstanceState);
|
||||
} else if (getIntent() != null) {
|
||||
mMainWrapperFragment.setArguments(getIntent().getExtras());
|
||||
}
|
||||
replaceFragment(mMainWrapperFragment);
|
||||
|
||||
mFragmentIsCreated = true;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void getTeenagerMode() {
|
||||
RetrofitManager.getInstance()
|
||||
@ -541,19 +554,31 @@ public class MainActivity extends BaseActivity {
|
||||
protected void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == COUNTDOWN_AD || msg.what == COUNTDOWN_SDK_AD) {
|
||||
mCountdownCount++;
|
||||
int maxCount;
|
||||
|
||||
if (msg.what == COUNTDOWN_AD) {
|
||||
maxCount = mCountdownMaxCount;
|
||||
} else {
|
||||
maxCount = COUNTDOWN_SDK_MAX_COUNT;
|
||||
}
|
||||
|
||||
// 读秒到一半的时候初始化 MainWrapperFragment
|
||||
if (mCountdownCount == maxCount / 2) {
|
||||
doInitMainFragment(mTempSavedInstanceState);
|
||||
}
|
||||
|
||||
mCountdownCount++;
|
||||
|
||||
if (maxCount < mCountdownCount) {
|
||||
AdDelegateHelper.INSTANCE.setShowingSplashAd(false);
|
||||
hideSplashAd();
|
||||
|
||||
if (msg.what == COUNTDOWN_AD && msg.obj instanceof StartupAdEntity) {
|
||||
StartupAdEntity ad = (StartupAdEntity) msg.obj;
|
||||
if (!AdDelegateHelper.INSTANCE.isOwnerSplashAdShown()) {
|
||||
com.gh.common.util.NewFlatLogUtils.logSplashAdFail(ad.getId(), "广告加载超时");
|
||||
}
|
||||
AdDelegateHelper.INSTANCE.setOwnerSplashAdShown(false);
|
||||
LinkEntity linkEntity = ad.getJump();
|
||||
SensorsBridge.trackEvent(
|
||||
"SplashAdOwnSkip",
|
||||
@ -633,10 +658,11 @@ public class MainActivity extends BaseActivity {
|
||||
ExtensionsKt.removeFromParent(startSdkAdIcpContainer, true);
|
||||
}
|
||||
|
||||
onSplashHidden();
|
||||
onAdHidden();
|
||||
}
|
||||
|
||||
private void onSplashHidden() {
|
||||
private void onAdHidden() {
|
||||
doInitMainFragment(mTempSavedInstanceState);
|
||||
// 通知全局弹窗可以进行显示
|
||||
AppExecutor.getUiExecutor().execute(GlobalPriorityChainHelper.INSTANCE::start);
|
||||
}
|
||||
@ -854,7 +880,9 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && !mMainWrapperFragment.onHandleBackPressed()) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
|
||||
&& mMainWrapperFragment != null
|
||||
&& !mMainWrapperFragment.onHandleBackPressed()) {
|
||||
DownloadEntity downloadEntity = null;
|
||||
for (DownloadEntity entity : DownloadManager.getInstance().getAllDownloadEntityExcludeSilentTask()) {
|
||||
if (entity.getStatus().equals(DownloadStatus.done)) {
|
||||
@ -1045,6 +1073,7 @@ public class MainActivity extends BaseActivity {
|
||||
blackList.add(R.id.historyTv);
|
||||
blackList.add(R.id.myCollectionTv);
|
||||
blackList.add(R.id.searchTv);
|
||||
blackList.add(R.id.subject_tab);
|
||||
updateStaticView(view, blackList);
|
||||
|
||||
View communityHomeWrapper = view.findViewById(R.id.communityHomeContainer);
|
||||
|
||||
@ -15,6 +15,7 @@ import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.common.fragment.popBackStackAllowStateLoss
|
||||
import com.gh.common.util.DataCollectionUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.gamecenter.DisplayType.*
|
||||
@ -311,6 +312,19 @@ open class SearchActivity : BaseActivity() {
|
||||
// MtaHelper.onEvent("游戏搜索", "主动搜索", newSearchKey)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val newSearchKey = searchEt.text.toString().trim { it <= ' ' }
|
||||
if (newSearchKey.isBlank()) {
|
||||
try {
|
||||
popBackToFragment(SearchDefaultFragment::class.java.name)
|
||||
} catch (e: Exception) {
|
||||
// no implement
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun provideDao(): ISearchHistoryDao = SearchHistoryDao(this)
|
||||
|
||||
open fun updateDisplayType(type: DisplayType) {
|
||||
@ -381,7 +395,7 @@ open class SearchActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
protected fun popBackToFragment(tag: String) {
|
||||
supportFragmentManager.popBackStack(tag, 0)
|
||||
supportFragmentManager.popBackStackAllowStateLoss(tag, 0)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
|
||||
@ -408,7 +408,7 @@ public class SkipActivity extends BaseActivity {
|
||||
try {
|
||||
JSONObject extJsonObject = new JSONObject(extJson);
|
||||
String qqGameId = extJsonObject.optString("aid");
|
||||
MiniGameItemHelper.INSTANCE.launchMiniGame(qqGameId, Constants.QQ_MINI_GAME);
|
||||
MiniGameItemHelper.INSTANCE.launchMiniGame(qqGameId, Constants.QQ_MINI_GAME, "", "");
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
break;
|
||||
|
||||
@ -282,11 +282,11 @@ class SplashScreenActivity : BaseActivity() {
|
||||
SensorsBridge.init(HaloApp.getInstance(), HaloApp.getInstance().channel)
|
||||
SensorsBridge.setOAID(HaloApp.getInstance().oaid)
|
||||
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
val registrationId = pushProvider?.getRegistrationId(this)
|
||||
if (!registrationId.isNullOrEmpty()) {
|
||||
SensorsBridge.profileAppend(KEY_REGISTRATION_ID, registrationId)
|
||||
}
|
||||
// val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
// val registrationId = pushProvider?.getRegistrationId(this)
|
||||
// if (!registrationId.isNullOrEmpty()) {
|
||||
// SensorsBridge.profileSet(KEY_REGISTRATION_ID, registrationId)
|
||||
// }
|
||||
}
|
||||
|
||||
private fun prefetchData() {
|
||||
|
||||
@ -455,17 +455,9 @@ class DetailViewHolder(
|
||||
}
|
||||
|
||||
ButtonStyle.RESERVED -> {
|
||||
if ("download" == mGameEntity.reserveStatus) {
|
||||
ReservationHelper.showDeleteReservationDialog(mViewHolder.context) {
|
||||
ReservationHelper.deleteReservation(mGameEntity) {
|
||||
DetailDownloadUtils.updateViewHolder(mViewHolder)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(mViewHolder.context, mGameEntity) {
|
||||
ReservationHelper.cancelReservation(mGameEntity) {
|
||||
DetailDownloadUtils.updateViewHolder(mViewHolder)
|
||||
}
|
||||
ReservationHelper.showCancelReservationDialog(mViewHolder.context, mGameEntity) {
|
||||
ReservationHelper.cancelReservation(mGameEntity) {
|
||||
DetailDownloadUtils.updateViewHolder(mViewHolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package com.gh.gamecenter.authorization
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
@ -16,6 +18,7 @@ import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.ActivityAuthorizationBinding
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.utils.Utils
|
||||
@ -68,6 +71,8 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
//授权token
|
||||
private var mToken = ""
|
||||
|
||||
private var loadingDialog: Dialog? = null
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_authorization
|
||||
}
|
||||
@ -80,11 +85,16 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
mBinding = ActivityAuthorizationBinding.bind(mContentView)
|
||||
checkParam()
|
||||
initView()
|
||||
mBinding.authorizeBtn.postDelayed({
|
||||
mBaseHandler.post {
|
||||
if (loadingDialog == null) {
|
||||
loadingDialog = DialogUtils.showWaitDialog(this, "请稍后...")
|
||||
}
|
||||
}
|
||||
UserRepository.getInstance().loginUserInfo.observe(this) {
|
||||
checkLogin {
|
||||
initUserInfo()
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
NewFlatLogUtils.logLoginFromGHZSShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName
|
||||
@ -97,14 +107,21 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
if (mToken.isNotEmpty() || isFinishing) return
|
||||
val loadingDialog = DialogUtils.showWaitDialog(this, "请稍后...")
|
||||
if (mToken.isNotEmpty() || isFinishing) {
|
||||
loadingDialog?.dismiss()
|
||||
return
|
||||
}
|
||||
if (loadingDialog == null) {
|
||||
loadingDialog = DialogUtils.showWaitDialog(this, "请稍后...")
|
||||
} else if (loadingDialog?.isShowing == false) {
|
||||
loadingDialog?.show()
|
||||
}
|
||||
mViewModel.getAccessToken(listOf(mContent), {
|
||||
mToken = it
|
||||
loadingDialog.dismiss()
|
||||
loadingDialog?.dismiss()
|
||||
}, {
|
||||
toast("获取token失败")
|
||||
loadingDialog.dismiss()
|
||||
loadingDialog?.dismiss()
|
||||
})
|
||||
}
|
||||
|
||||
@ -152,8 +169,8 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
private fun initView() {
|
||||
//通过包名获取app图标和名称
|
||||
val pkgName = mRemotePkgName ?: return
|
||||
val icon = packageManager.getApplicationIcon(pkgName)
|
||||
val name = packageManager.getApplicationLabel(packageManager.getApplicationInfo(pkgName, 0))
|
||||
val icon = PackageUtils.getIconByPackageName(this, pkgName)
|
||||
val name = PackageUtils.getNameByPackageName(this, pkgName)
|
||||
mBinding.authorizeAppIcon.setImageDrawable(icon)
|
||||
mBinding.authorizeAppName.text = name
|
||||
mBinding.authorizeBtn.setOnClickListener {
|
||||
@ -242,10 +259,10 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
VHelper.launch(this, gamePkg, ignoreGApps = true, showLoading = showLoading)
|
||||
return
|
||||
}
|
||||
val remotePkgName = this.mRemotePkgName
|
||||
if (remotePkgName != null) {// 跳转回其他授权app
|
||||
startActivity(packageManager.getLaunchIntentForPackage(remotePkgName))
|
||||
}
|
||||
// val remotePkgName = this.mRemotePkgName
|
||||
// if (remotePkgName != null) {// 跳转回其他授权app
|
||||
// startActivity(packageManager.getLaunchIntentForPackage(remotePkgName))
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
@ -27,7 +27,7 @@ open class BaseCloudArchiveViewModel(application: Application, private val mConf
|
||||
)
|
||||
.enqueue(object : Callback {
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
mArchiveConfigStr = response.body()?.string() ?: ""
|
||||
mArchiveConfigStr = response.body?.string() ?: ""
|
||||
callback?.invoke(mArchiveConfigStr)
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ class AdGameBannerAdapter(
|
||||
it.name ?: ""
|
||||
)
|
||||
if (it.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(it.miniGameAppId, it.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(it)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext,
|
||||
|
||||
@ -9,14 +9,22 @@ import kotlinx.parcelize.Parcelize
|
||||
@Parcelize
|
||||
data class SearchSubjectEntity(
|
||||
val name: String = "",
|
||||
val games: List<GameEntity> = listOf(),
|
||||
var games: List<GameEntity> = listOf(),
|
||||
val location: Int = 0,
|
||||
@SerializedName("column_id")
|
||||
val columnId: String = "",
|
||||
val adId: String = "", // 广告ID(本地字段),不为空时为广告专题
|
||||
val codeId: String = "", // 广告CODE_ID(本地字段),不为空时为广告专题
|
||||
@SerializedName("ad_icon_active")
|
||||
val adIconActive: Boolean = false
|
||||
val adIconActive: Boolean = false,
|
||||
// 本地字段,标记是否为微信小游戏CPM专题
|
||||
var isWGameSubjectCPM: Boolean = false,
|
||||
val type: String = ""
|
||||
) : Parcelable {
|
||||
|
||||
companion object {
|
||||
const val TYPE_WECHAT_GAME_CPM_COLUMN = "wechat_game_cpm_column"
|
||||
}
|
||||
|
||||
fun getFilterGame() = RegionSettingHelper.filterGame(games)
|
||||
}
|
||||
@ -63,6 +63,11 @@ class SubjectData(
|
||||
/**
|
||||
* 微信小游戏专题
|
||||
*/
|
||||
WECHAT_GAME
|
||||
WECHAT_GAME,
|
||||
|
||||
/**
|
||||
* 微信小游戏CPM专题
|
||||
*/
|
||||
WECHAT_GAME_CPM,
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +104,8 @@ data class SubjectEntity(
|
||||
@SerializedName("is_wechat_column")
|
||||
var isWechatColumn: Boolean = false,
|
||||
|
||||
var isWechatColumnCPM: Boolean = false,
|
||||
|
||||
var explain: String = "", // 游戏单合集说明
|
||||
|
||||
@SerializedName("show_star")
|
||||
@ -130,6 +132,7 @@ data class SubjectEntity(
|
||||
|
||||
val subjectType: SubjectData.SubjectType get() = when {
|
||||
isQQColumn -> SubjectData.SubjectType.QQ_GAME
|
||||
isWechatColumnCPM -> SubjectData.SubjectType.WECHAT_GAME_CPM
|
||||
isWechatColumn -> SubjectData.SubjectType.WECHAT_GAME
|
||||
else -> SubjectData.SubjectType.NORMAL
|
||||
}
|
||||
|
||||
@ -611,7 +611,7 @@ class GameFragmentAdapter(
|
||||
val subjectData = gameEntity.subjectData
|
||||
DataCollectionUtils.uploadClick(mContext, subjectData?.name + "-列表", "游戏-专题", gameEntity.name)
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext, gameEntity,
|
||||
@ -1322,7 +1322,7 @@ class GameFragmentAdapter(
|
||||
DataCollectionUtils.uploadClick(mContext, subjectData.name + "-列表", "游戏-专题", gameEntity.name)
|
||||
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else if (gameEntity.isPluggable) {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext,
|
||||
|
||||
@ -135,7 +135,7 @@ class GameGallerySlideViewHolder(val binding: GameGallerySlideItemBinding) : Bas
|
||||
binding.iconIv.displayGameIcon(gameEntity)
|
||||
binding.iconIv.setOnClickListener {
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
binding.root.context,
|
||||
|
||||
@ -55,7 +55,7 @@ class GameGalleryViewHolder(val cell: GameGalleryItemCell) :
|
||||
|
||||
if (subjectEntity.isMiniGame) {
|
||||
gameIcon.setOnClickListener {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
}
|
||||
} else {
|
||||
gameIcon.setOnClickListener(null)
|
||||
|
||||
@ -140,7 +140,7 @@ class GameHorizontalAdapter(
|
||||
}
|
||||
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext,
|
||||
|
||||
@ -68,7 +68,7 @@ class GameHorizontalSlideAdapter(
|
||||
holder.bindGameHorizontalItem(gameEntity, mSubjectEntity)
|
||||
holder.itemView.setOnClickListener {
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else {
|
||||
val exposureEvent = exposureEventList?.safelyGetInRelease(position)
|
||||
if (exposureEvent != null) {
|
||||
|
||||
@ -45,7 +45,9 @@ import com.zhihu.matisse.Matisse
|
||||
import com.zhihu.matisse.internal.utils.PathUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.io.File
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
@ -420,10 +422,8 @@ class GameUploadFragment : ToolbarFragment() {
|
||||
requestMap["type"] = mGameType
|
||||
}
|
||||
|
||||
val body = RequestBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
GsonUtils.toJson(requestMap)
|
||||
)
|
||||
val body = GsonUtils.toJson(requestMap)
|
||||
.toRequestBody("application/json".toMediaTypeOrNull())
|
||||
mViewModel.uploadGames(body)
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,9 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.gh.common.util.DirectUtils
|
||||
@ -21,6 +24,17 @@ class GameCollectionAmwayViewHolder(var binding: GameCollectionSquareAmwayItemBi
|
||||
private val mAdapter = GameCollectionAmwayAdapter(binding.root.context)
|
||||
private val mLooperHandle = LooperHandle(this)
|
||||
private val mSlideLooperKey = 333
|
||||
private val mLifecycleObserver = object : DefaultLifecycleObserver {
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
super.onResume(owner)
|
||||
startAutoPlay()
|
||||
}
|
||||
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
super.onPause(owner)
|
||||
stopAutoPlay()
|
||||
}
|
||||
}
|
||||
|
||||
fun bindAmway(amwayList: List<AmwayCommentEntity>, viewModel: GameCollectionSquareViewModel) {
|
||||
mAdapter.setAmwayList(amwayList)
|
||||
@ -54,6 +68,14 @@ class GameCollectionAmwayViewHolder(var binding: GameCollectionSquareAmwayItemBi
|
||||
mLooperHandle.removeMessages(mSlideLooperKey)
|
||||
}
|
||||
|
||||
fun onViewAttach(lifecycle: Lifecycle) {
|
||||
lifecycle.addObserver(mLifecycleObserver)
|
||||
}
|
||||
|
||||
fun onViewDetach(lifecycle: Lifecycle) {
|
||||
lifecycle.removeObserver(mLifecycleObserver)
|
||||
}
|
||||
|
||||
fun ViewPager2.setCurrentItem(
|
||||
item: Int,
|
||||
duration: Long,
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.gamecollection.square
|
||||
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.DirectUtils
|
||||
@ -23,6 +24,7 @@ import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
class GameCollectionBannerAdapter(
|
||||
context: Context,
|
||||
private val mLifecycleOwner: LifecycleOwner,
|
||||
private val mViewModel: GameCollectionSquareViewModel,
|
||||
var mBannerList: List<CarouselEntity> = emptyList(),
|
||||
private var mAmwayListItem: List<AmwayCommentEntity>? = null,
|
||||
@ -78,6 +80,20 @@ class GameCollectionBannerAdapter(
|
||||
return index
|
||||
}
|
||||
|
||||
override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
if (holder is GameCollectionAmwayViewHolder) {
|
||||
holder.onViewAttach(mLifecycleOwner.lifecycle)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
if (holder is GameCollectionAmwayViewHolder) {
|
||||
holder.onViewDetach(mLifecycleOwner.lifecycle)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ITEM_AMWAY = 100
|
||||
const val ITEM_BANNER = 101
|
||||
|
||||
@ -12,6 +12,9 @@ import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.PagerSnapHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -47,6 +50,7 @@ import java.lang.ref.WeakReference
|
||||
|
||||
class GameCollectionSquareAdapter(
|
||||
context: Context,
|
||||
private val mLifecycleOwner: LifecycleOwner,
|
||||
private val mIsHome: Boolean = false,
|
||||
private val mFragment: GameCollectionSquareFragment,
|
||||
private val mViewModel: GameCollectionSquareViewModel,
|
||||
@ -157,7 +161,7 @@ class GameCollectionSquareAdapter(
|
||||
when (holder) {
|
||||
is GameCollectionHeaderItemViewHolder -> {
|
||||
val itemData = mEntityList[position]
|
||||
holder.bindHeader(itemData, mBasicExposureSource, mViewModel)
|
||||
holder.bindHeader(mLifecycleOwner, itemData, mBasicExposureSource, mViewModel)
|
||||
}
|
||||
|
||||
is GameCollectionFilterItemViewHolder -> holder.bindFilter(mFragment, mViewModel, mRefreshCallback)
|
||||
@ -211,6 +215,20 @@ class GameCollectionSquareAdapter(
|
||||
override fun getItemCount() =
|
||||
if (mEntityList.isNullOrEmpty()) 0 else if (mIsHome && mEntityList.size == 2) mEntityList.size else mEntityList.size + 1
|
||||
|
||||
override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
if (holder is GameCollectionHeaderItemViewHolder) {
|
||||
holder.onViewAttach(mLifecycleOwner.lifecycle)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
if (holder is GameCollectionHeaderItemViewHolder) {
|
||||
holder.onViewDetach(mLifecycleOwner.lifecycle)
|
||||
}
|
||||
}
|
||||
|
||||
class GameCollectionHeaderItemViewHolder(val binding: ItemGameCollectionHeaderBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
private lateinit var mBannerAdapter: GameCollectionBannerAdapter
|
||||
@ -218,8 +236,20 @@ class GameCollectionSquareAdapter(
|
||||
private lateinit var mBannerLayoutManager: LinearLayoutManager
|
||||
private val mLooperHandle = LooperHandle(this)
|
||||
private val mSlideLooperKey = 111
|
||||
private val mLifecycleObserver = object : DefaultLifecycleObserver {
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
super.onResume(owner)
|
||||
startAutoPlay()
|
||||
}
|
||||
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
super.onPause(owner)
|
||||
stopAutoPlay()
|
||||
}
|
||||
}
|
||||
|
||||
fun bindHeader(
|
||||
lifecycleOwner: LifecycleOwner,
|
||||
itemData: GameCollectionListItemData,
|
||||
mBasicExposureSource: List<ExposureSource>,
|
||||
viewModel: GameCollectionSquareViewModel
|
||||
@ -249,6 +279,7 @@ class GameCollectionSquareAdapter(
|
||||
mBannerLayoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||
mBannerAdapter = GameCollectionBannerAdapter(
|
||||
context,
|
||||
lifecycleOwner,
|
||||
viewModel,
|
||||
bannerList,
|
||||
amwayListItem,
|
||||
@ -345,6 +376,14 @@ class GameCollectionSquareAdapter(
|
||||
mLooperHandle.removeMessages(mSlideLooperKey)
|
||||
}
|
||||
|
||||
fun onViewAttach(lifecycle: Lifecycle) {
|
||||
lifecycle.addObserver(mLifecycleObserver)
|
||||
}
|
||||
|
||||
fun onViewDetach(lifecycle: Lifecycle) {
|
||||
lifecycle.removeObserver(mLifecycleObserver)
|
||||
}
|
||||
|
||||
class LooperHandle(viewHolder: GameCollectionHeaderItemViewHolder) : Handler(Looper.getMainLooper()) {
|
||||
private val mWeakReference: WeakReference<GameCollectionHeaderItemViewHolder> = WeakReference(viewHolder)
|
||||
|
||||
|
||||
@ -138,6 +138,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
mGuideContainer?.visibility = View.GONE
|
||||
} else {
|
||||
if (mExposureEventList.isNotEmpty()) ExposureManager.log(mExposureEventList)
|
||||
stopAutoPlay()
|
||||
}
|
||||
val stayTime = (System.currentTimeMillis() - startPageTime) / 1000
|
||||
NewFlatLogUtils.logGameCollectSquareStayTime(stayTime, if (mUseAlternativeLayout) "首页tab栏" else "游戏单广场")
|
||||
@ -175,6 +176,8 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
startAutoPlay()
|
||||
}
|
||||
mElapsedHelper.resetCounting()
|
||||
mElapsedHelper.resumeCounting()
|
||||
@ -206,7 +209,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (data == null || resultCode != Activity.RESULT_OK) return
|
||||
if (data == null || resultCode != Activity.RESULT_OK || !::mViewModel.isInitialized) return
|
||||
if (requestCode == REQUEST_SELECT_TAG) {
|
||||
val tagInfoEntity = data.getParcelableExtra<TagInfoEntity>(GameCollectionTagSelectFragment.SELECTED_TAG)
|
||||
val tagCategory = data.getStringExtra(GameCollectionTagSelectFragment.SELECTED_TAG_CATEGORY)
|
||||
@ -270,6 +273,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
mAdapter =
|
||||
GameCollectionSquareAdapter(
|
||||
requireContext(),
|
||||
viewLifecycleOwner,
|
||||
mUseAlternativeLayout,
|
||||
this,
|
||||
mViewModel,
|
||||
@ -382,6 +386,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
|
||||
val bannerAdapter = GameCollectionBannerAdapter(
|
||||
requireContext(),
|
||||
viewLifecycleOwner,
|
||||
mViewModel,
|
||||
mEntrance = "游戏单广场",
|
||||
mBasicExposureSource = mBasicExposureSourceList
|
||||
@ -515,7 +520,8 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
|
||||
}
|
||||
|
||||
private fun startAutoPlay() {
|
||||
if ((mDefaultBinding.headerContainer.bannerRv.adapter as GameCollectionBannerAdapter).getActualSize() <= 1) return
|
||||
val bannerAdapter = mDefaultBinding.headerContainer.bannerRv.adapter as? GameCollectionBannerAdapter
|
||||
if (bannerAdapter == null || bannerAdapter.getActualSize() <= 1) return
|
||||
stopAutoPlay()
|
||||
mLooperHandle.sendEmptyMessageDelayed(mSlideLooperKey, BANNER_LOOP_TIME)
|
||||
}
|
||||
|
||||
@ -866,10 +866,11 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
|
||||
|
||||
showConcernIconAtBottomBarIfAvailable()
|
||||
|
||||
val downloadEntitySnapshot = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity)
|
||||
val downloadEntitySnapshot = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity)
|
||||
|
||||
if (isSpecialDownloadDialogAvailable(downloadEntitySnapshot)
|
||||
&& downloadEntitySnapshot != null) {
|
||||
&& downloadEntitySnapshot != null
|
||||
) {
|
||||
updateSpecialDownloadDialogIcon(true)
|
||||
}
|
||||
|
||||
@ -1855,19 +1856,10 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
|
||||
|
||||
)
|
||||
} else {
|
||||
if ("download" == mGameEntity?.reserveStatus) {
|
||||
ReservationHelper.showDeleteReservationDialog(requireContext()) {
|
||||
ReservationHelper.deleteReservation(mGameEntity!!) {
|
||||
DetailDownloadUtils.updateViewHolder(detailViewHolder)
|
||||
showReserveBtn(isShowReserveBtn())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(requireContext(), mGameEntity) {
|
||||
ReservationHelper.cancelReservation(mGameEntity!!) {
|
||||
DetailDownloadUtils.updateViewHolder(detailViewHolder)
|
||||
showReserveBtn(isShowReserveBtn())
|
||||
}
|
||||
ReservationHelper.showCancelReservationDialog(requireContext(), mGameEntity) {
|
||||
ReservationHelper.cancelReservation(mGameEntity!!) {
|
||||
DetailDownloadUtils.updateViewHolder(detailViewHolder)
|
||||
showReserveBtn(isShowReserveBtn())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -983,14 +983,17 @@ class DescAdapter(
|
||||
setExpandMaxLines(maxDesLines)
|
||||
setIsExpanded(Int.MAX_VALUE == maxDesLines)
|
||||
if (customColumn.isHtmlDes == true) {
|
||||
val decoratedDesBrief = (customColumn.desBrief ?: "").dropFontColorInDarkMode(contentTv.context)
|
||||
val decoratedDes = (customColumn.des ?: "").dropFontColorInDarkMode(contentTv.context)
|
||||
|
||||
shrankSpanned = HtmlCompat.fromHtml(
|
||||
customColumn.desBrief ?: "",
|
||||
decoratedDesBrief,
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT,
|
||||
PicassoImageGetter(contentTv),
|
||||
ExtraTagHandler()
|
||||
)
|
||||
expandedSpanned = HtmlCompat.fromHtml(
|
||||
customColumn.des ?: "",
|
||||
decoratedDes,
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT,
|
||||
PicassoImageGetter(contentTv),
|
||||
ExtraTagHandler()
|
||||
|
||||
@ -25,10 +25,10 @@ import com.gh.gamecenter.common.utils.toPx
|
||||
import com.gh.gamecenter.core.iinterface.IScrollable
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.RatingComment
|
||||
import com.gh.gamecenter.eventbus.EBStar
|
||||
import com.gh.gamecenter.eventbus.EBTypeChange
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||||
import com.halo.assistant.HaloApp
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@ -60,7 +60,7 @@ class RatingFragment : LazyListFragment<RatingComment, RatingViewModel>(), IScro
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == RATING_EDIT_REQUEST && resultCode == Activity.RESULT_OK) {
|
||||
mListViewModel.initData()
|
||||
mListViewModel?.initData()
|
||||
} else if (
|
||||
(requestCode == RATING_REPLAY_REQUEST || requestCode == RATING_PATCH_REQUEST)
|
||||
&& resultCode == Activity.RESULT_OK
|
||||
|
||||
@ -45,7 +45,9 @@ import com.gh.gamecenter.login.user.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
|
||||
@ -541,7 +543,7 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
|
||||
jsonObject.put("rom", MetaUtil.getRom().name + " " + MetaUtil.getRom().versionName)
|
||||
jsonObject.put("again", again)
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
|
||||
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
|
||||
CheckLoginUtils.checkLogin(this, mEntrance) {
|
||||
mViewModel.postGameComment(mComment?.id ?: "", body)
|
||||
|
||||
@ -97,7 +97,7 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie
|
||||
}
|
||||
holder.itemView.setOnClickListener {
|
||||
if (game.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(game.miniGameAppId, game.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(game)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
binding.root.context,
|
||||
|
||||
@ -3,7 +3,11 @@ package com.gh.gamecenter.home.custom
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -54,6 +58,7 @@ import com.gh.gamecenter.feature.entity.PageLocation
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
|
||||
import com.gh.gamecenter.feature.utils.SentryHelper
|
||||
import com.gh.gamecenter.game.commoncollection.detail.CustomCommonCollectionDetailActivity
|
||||
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
import com.gh.gamecenter.home.PageConfigure
|
||||
@ -69,6 +74,9 @@ import com.gh.gamecenter.wrapper.SearchToolbarTabWrapperViewModel
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout
|
||||
import com.scwang.smartrefresh.layout.constant.RefreshState
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ -140,7 +148,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
searchToolbarTabWrapperViewModel =
|
||||
viewModelProviderFromParent(
|
||||
SearchToolbarTabWrapperViewModel.Factory(multiTabNavId, noTabLinkId),
|
||||
multiTabNavId
|
||||
multiTabNavId + noTabLinkId
|
||||
)
|
||||
}
|
||||
if (bottomTabId.isNotEmpty()) {
|
||||
@ -179,6 +187,22 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
viewModel.init(pageConfigure, searchToolbarTabWrapperViewModel, pageLocation)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
binding = try {
|
||||
FragmentCustomBinding.inflate(layoutInflater)
|
||||
} catch (e: Exception) {
|
||||
SentryHelper.onEvent(
|
||||
"VIEW_BINDING_BIND_ERROR",
|
||||
"digest", e.localizedMessage,
|
||||
"gid", HaloApp.getInstance().gid
|
||||
)
|
||||
// 玄学,重试一次,该闪退闪退
|
||||
FragmentCustomBinding.inflate(layoutInflater)
|
||||
}
|
||||
mCachedView = binding.root
|
||||
return mCachedView
|
||||
}
|
||||
|
||||
override fun getRealLayoutId() = R.layout.fragment_custom
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
@ -215,7 +239,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
viewModel.loadFirst(false)
|
||||
}
|
||||
}
|
||||
binding.reuseNoConnectionStub.inflate()
|
||||
binding.reuseNoConnectionStub.inflateOrShow()
|
||||
} else {
|
||||
noConnectionBinding?.root?.visibility = View.VISIBLE
|
||||
}
|
||||
@ -225,7 +249,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
noDataBinding = ReuseNoneDataBinding.bind(inflated)
|
||||
noDataBinding?.root?.visibility = View.VISIBLE
|
||||
}
|
||||
binding.reuseNoDataStub.inflate()
|
||||
binding.reuseNoDataStub.inflateOrShow()
|
||||
} else {
|
||||
noDataBinding?.root?.visibility = View.VISIBLE
|
||||
}
|
||||
@ -275,9 +299,12 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
if (searchBarBinding == null) {
|
||||
binding.reuseSearchBarStub.setOnInflateListener { _, inflated ->
|
||||
searchBarBinding = LayoutSearchBarBinding.bind(inflated)
|
||||
binding.gameRefresh.updateLayoutParams<RelativeLayout.LayoutParams> {
|
||||
addRule(RelativeLayout.BELOW, R.id.reuseSearchBar)
|
||||
}
|
||||
initSearchBar(it)
|
||||
}
|
||||
binding.reuseSearchBarStub.inflate()
|
||||
binding.reuseSearchBarStub.inflateOrShow()
|
||||
} else {
|
||||
initSearchBar(it)
|
||||
}
|
||||
@ -292,7 +319,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
|
||||
gameDetailDestination.observe(viewLifecycleOwner, EventObserver { (entrance, game) ->
|
||||
if (game.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(game.miniGameAppId, game.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(game)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
requireContext(),
|
||||
@ -490,8 +517,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
override fun initRealView() {
|
||||
super.initRealView()
|
||||
|
||||
binding = FragmentCustomBinding.bind(mCachedView)
|
||||
|
||||
scrollCalculatorHelper = ScrollCalculatorHelper(binding.gameList, R.id.autoVideoView, 0, false)
|
||||
|
||||
buildPriorityChain()
|
||||
@ -745,7 +770,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
}
|
||||
}
|
||||
|
||||
override fun setScrollEnabled(isScrollEnabled: Boolean) {
|
||||
private fun setScrollEnabled(isScrollEnabled: Boolean) {
|
||||
if (::layoutManager.isInitialized) {
|
||||
layoutManager.isScrollVerticallyEnabled = isScrollEnabled
|
||||
}
|
||||
@ -761,6 +786,32 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStateChanged(refreshLayout: RefreshLayout, oldState: RefreshState, newState: RefreshState) {
|
||||
if (oldState == RefreshState.None && newState == RefreshState.PullDownToRefresh) {
|
||||
pauseVideo()
|
||||
} else if ((oldState == RefreshState.TwoLevelFinish || oldState == RefreshState.RefreshFinish) && newState == RefreshState.None) {
|
||||
val currentPlayer = scrollCalculatorHelper.currentPlayer
|
||||
if (currentPlayer == null) {
|
||||
scrollCalculatorHelper.playIfValid()
|
||||
} else if (currentPlayer.currentState == GSYVideoView.CURRENT_STATE_PAUSE) {
|
||||
resumeVideo()
|
||||
}
|
||||
}
|
||||
|
||||
when (newState) {
|
||||
RefreshState.TwoLevel -> {
|
||||
setScrollEnabled(false)
|
||||
}
|
||||
RefreshState.None -> {
|
||||
setScrollEnabled(true)
|
||||
}
|
||||
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun scrollToTop() {
|
||||
if (::binding.isInitialized) {
|
||||
binding.gameList.stopScroll()
|
||||
|
||||
@ -78,6 +78,7 @@ class CustomPageViewModel(
|
||||
addSource(repository.customDiscoverItemLiveData, ::notifyItemChanged)
|
||||
addSource(repository.recentGamesItemLiveData, ::notifyItemChanged)
|
||||
addSource(repository.customPluginItemLiveData, ::notifyItemChanged)
|
||||
addSource(repository.wechatMiniGameCPMItemLiveData, ::notifyWechatMiniGameCPMSubjectItemChanged)
|
||||
}
|
||||
|
||||
val dataList: LiveData<List<CustomPageItem>> = _dataList
|
||||
@ -357,11 +358,11 @@ class CustomPageViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChangeABatch(subjectEntity: SubjectEntity, position: Int) {
|
||||
override fun onChangeABatch(subjectEntity: SubjectEntity) {
|
||||
val subjectId = subjectEntity.id ?: return
|
||||
val gameList = subjectChangedMap[subjectId]
|
||||
if (gameList != null) {
|
||||
changeSubjectCustomPageItem(position, getRandomGameList(subjectEntity.data, ArrayList(gameList)))
|
||||
changeSubjectCustomPageItem(subjectId, getRandomGameList(subjectEntity.data, ArrayList(gameList)))
|
||||
} else {
|
||||
repository.loadChangeSubjectGame(subjectEntity)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -370,7 +371,7 @@ class CustomPageViewModel(
|
||||
override fun onResponse(response: List<GameEntity>?) {
|
||||
if (response != null) {
|
||||
subjectChangedMap[subjectId] = response
|
||||
onChangeABatch(subjectEntity, position)
|
||||
onChangeABatch(subjectEntity)
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,21 +397,32 @@ class CustomPageViewModel(
|
||||
return resultGameList
|
||||
}
|
||||
|
||||
private fun changeSubjectCustomPageItem(position: Int, newGameList: MutableList<GameEntity>) {
|
||||
private fun changeSubjectCustomPageItem(id: String, newGameList: MutableList<GameEntity>) {
|
||||
val oldData = _dataList.value as? MutableList<CustomPageItem>
|
||||
if (!oldData.isNullOrEmpty() && newGameList.isNotEmpty()) {
|
||||
val newData = oldData?.toMutableList()
|
||||
if (!newData.isNullOrEmpty() && newGameList.isNotEmpty()) {
|
||||
// 替换当前专题游戏数据
|
||||
val customPageItem = oldData.getOrNull(position)
|
||||
val position = newData.indexOfFirst {
|
||||
when(it) {
|
||||
is CustomSubjectItem -> it.data.id == id
|
||||
is CustomSplitSubjectItem -> it.data.id == id
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
if (position == -1) return
|
||||
|
||||
val customPageItem = newData[position]
|
||||
if (customPageItem is CustomSubjectItem) {
|
||||
val newCustomPageItem = customPageItem.copy(data = customPageItem.data.copy(mData = newGameList))
|
||||
oldData[position] = newCustomPageItem
|
||||
val newCustomPageItem =
|
||||
customPageItem.copy(data = customPageItem.data.copy(mData = newGameList), _position = position)
|
||||
newData[position] = newCustomPageItem
|
||||
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newCustomPageItem, newGameList))
|
||||
}
|
||||
|
||||
if (customPageItem is CustomSplitSubjectItem) {
|
||||
|
||||
// 移除所有旧数据
|
||||
oldData.removeAll {
|
||||
newData.removeAll {
|
||||
it.componentPosition == customPageItem.componentPosition
|
||||
}
|
||||
|
||||
@ -433,21 +445,15 @@ class CustomPageViewModel(
|
||||
)
|
||||
|
||||
// 将新的 items 添加到列表集合
|
||||
if (position >= oldData.size) {
|
||||
oldData.addAll(newItems)
|
||||
} else {
|
||||
oldData.addAll(position, newItems)
|
||||
}
|
||||
|
||||
newData.addAll(position, newItems)
|
||||
|
||||
// 修正集合中 item 的position 取值
|
||||
oldData.forEachIndexed { index, item ->
|
||||
newData.forEachIndexed { index, item ->
|
||||
item.position = index
|
||||
}
|
||||
|
||||
}
|
||||
// 通知更新
|
||||
_dataList.value = oldData
|
||||
_dataList.value = newData
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,6 +473,40 @@ class CustomPageViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过CPM接口异步请求获取的微信小游戏数据插入
|
||||
*/
|
||||
private fun notifyWechatMiniGameCPMSubjectItemChanged(result: Pair<String, List<GameEntity>>) {
|
||||
val oldData = _dataList.value ?: return
|
||||
val index = oldData.indexOfFirst {
|
||||
it is CustomWeChatMiniGamesCPMSubjectItem && it.data.id == result.first
|
||||
}
|
||||
if (index == -1) return
|
||||
val subjectItem = (oldData[index] as CustomWeChatMiniGamesCPMSubjectItem).apply {
|
||||
data.data = result.second.toMutableList()
|
||||
data.isWechatColumnCPM = true
|
||||
}
|
||||
val position = subjectItem.position
|
||||
val componentPosition = subjectItem.componentPosition
|
||||
val newData = oldData.toMutableList()
|
||||
val customPageItemList = repository.convertColumnDetailSubjectItems(
|
||||
position,
|
||||
componentPosition,
|
||||
subjectItem.link,
|
||||
subjectItem.data
|
||||
)
|
||||
if (customPageItemList.isEmpty()) return
|
||||
newData[index] = customPageItemList[0]
|
||||
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
|
||||
newData.forEachIndexed { pos, customPageItem ->
|
||||
customPageItem.position = pos
|
||||
}
|
||||
repository.notifyPositionChanged(newData.size)
|
||||
gamePositionAndPackageHelper.clear()
|
||||
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newData))
|
||||
_dataList.value = newData
|
||||
}
|
||||
|
||||
private fun notifyItemRemoved(removeItem: CustomPageItem) {
|
||||
val oldData = _dataList.value ?: return
|
||||
val newData = oldData.toMutableList()
|
||||
@ -476,7 +516,7 @@ class CustomPageViewModel(
|
||||
for (i in removeItem.position until newData.size) {
|
||||
newData[i].position--
|
||||
}
|
||||
repository.notifyPositionChanged(-1)
|
||||
repository.notifyPositionAdded(-1)
|
||||
gamePositionAndPackageHelper.clear()
|
||||
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newData))
|
||||
_dataList.value = newData
|
||||
|
||||
@ -6,6 +6,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.toDrawable
|
||||
import com.gh.gamecenter.databinding.RecyclerContentLabelLaneItemBinding
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageData
|
||||
|
||||
@ -28,6 +30,10 @@ class ContentLabelLaneAdapter(
|
||||
override fun onBindViewHolder(holder: ContentLabelChildViewHolder, position: Int) {
|
||||
val item = getItem(position)
|
||||
with(holder.binding) {
|
||||
vBackground.background = R.drawable.bg_shape_content_label_lane_item.toDrawable(context)
|
||||
tvTitle.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
|
||||
tvSubTitle.setTextColor(com.gh.gamecenter.common.R.color.primary_theme.toColor(context))
|
||||
|
||||
ivIcon.goneIf(item.image.isBlank()){
|
||||
ivIcon.displayGameIcon(item.image, null, null)
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class CustomGameHorizontalAdapter(
|
||||
}
|
||||
|
||||
if (gameEntity.isMiniGame()) {
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(gameEntity)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
context,
|
||||
|
||||
@ -29,7 +29,7 @@ interface OnCustomPageEventListener {
|
||||
/**
|
||||
* 换一批
|
||||
*/
|
||||
fun onChangeABatch(subjectEntity: SubjectEntity, position: Int)
|
||||
fun onChangeABatch(subjectEntity: SubjectEntity)
|
||||
|
||||
fun onChangeAppBarColor(color: Int)
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ class SubjectEventHelper(viewModel: CustomPageViewModel) : CustomPageItemChildEv
|
||||
|
||||
fun onChangeABatch(subject: SubjectEntity) {
|
||||
tracker.trackColumnClick(_item, null, "右上角", "换一批")
|
||||
viewModel.onChangeABatch(subject, _item.position)
|
||||
viewModel.onChangeABatch(subject)
|
||||
}
|
||||
|
||||
fun onMoreClick(link: LinkEntity) {
|
||||
|
||||
@ -73,6 +73,8 @@ class CustomPageData(
|
||||
val qqMiniGameColumn: SubjectEntity? = null,
|
||||
@SerializedName("link_wechat_game_column_detail")
|
||||
val wechatMiniGameColumn: SubjectEntity? = null,
|
||||
@SerializedName("link_wechat_game_cpm_column_detail")
|
||||
val wechatMiniGameCPMColumn: SubjectEntity? = null,
|
||||
@SerializedName("link_common_collection")
|
||||
val linkCommonCollection: CommonContentCollection? = null,
|
||||
@SerializedName("link_qq_game_recently_played")
|
||||
@ -83,6 +85,7 @@ class CustomPageData(
|
||||
get() = when (link.type) {
|
||||
CustomPageItem.CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL -> qqMiniGameColumn
|
||||
CustomPageItem.CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> wechatMiniGameColumn
|
||||
CustomPageItem.CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL -> wechatMiniGameCPMColumn
|
||||
else -> linkColumn
|
||||
}
|
||||
|
||||
@ -672,7 +675,7 @@ class CustomPageData(
|
||||
@SerializedName("home")
|
||||
private val _home: String? = null,
|
||||
@SerializedName("more_link")
|
||||
val moreLink: LinkEntity? = null
|
||||
val moreLink: LinkEntity? = null
|
||||
) {
|
||||
|
||||
val home: String
|
||||
|
||||
@ -4,10 +4,7 @@ import com.gh.common.util.ViewPagerFragmentHelper
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.entity.AmwayCommentEntity
|
||||
import com.gh.gamecenter.entity.DiscoveryCardEntity
|
||||
import com.gh.gamecenter.entity.HomeItemTestV2Entity
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.vspace.VGameItemData
|
||||
@ -84,6 +81,7 @@ abstract class CustomPageItem(
|
||||
const val CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED = "wechat_game_recently_played"
|
||||
const val CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN
|
||||
const val CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN
|
||||
const val CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN
|
||||
const val CUSTOM_LINK_TYPE_HALO_RECOMMEND = "halo_recommend"
|
||||
const val CUSTOM_LINK_TYPE_COLUMN_COLLECTION = "column_collection" // 专题合集
|
||||
const val CUSTOM_LINK_TYPE_GAME_LIST_COLLECTION = "game_list_collection"
|
||||
@ -300,6 +298,7 @@ abstract class CustomPageItem(
|
||||
CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED to "最近在玩",
|
||||
CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL to "QQ小游戏专题",
|
||||
CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL to "微信小游戏专题",
|
||||
CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL to "微信小游戏专题",
|
||||
CUSTOM_LINK_TYPE_HALO_RECOMMEND to "光环推荐",
|
||||
CUSTOM_LINK_TYPE_COLUMN_COLLECTION to "专题合集",
|
||||
CUSTOM_LINK_TYPE_GAME_LIST_COLLECTION to "游戏单合集",
|
||||
@ -623,6 +622,25 @@ data class CustomRecentWeChatMiniGamesItem(
|
||||
}
|
||||
}
|
||||
|
||||
// 微信小游戏CPM专题组件
|
||||
data class CustomWeChatMiniGamesCPMSubjectItem(
|
||||
private val _link: LinkEntity,
|
||||
val data: SubjectEntity,
|
||||
private val _position: Int,
|
||||
private val _componentPosition: Int
|
||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
||||
|
||||
override val itemType: Int
|
||||
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
||||
|
||||
override fun doAreContentsTheSames(other: CustomPageItem): Boolean {
|
||||
return other is CustomWeChatMiniGamesCPMSubjectItem
|
||||
&& data == other.data
|
||||
&& position == other.position
|
||||
&& componentPosition == other.componentPosition
|
||||
}
|
||||
}
|
||||
|
||||
// qq小游戏-最近在玩
|
||||
data class CustomRecentQqMiniGamesItem(
|
||||
private val _link: LinkEntity,
|
||||
|
||||
@ -3,12 +3,12 @@ package com.gh.gamecenter.home.custom.model
|
||||
import android.graphics.Paint
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.GameSubstituteRepositoryHelper
|
||||
import com.gh.common.util.HomePluggableHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.TextHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.sp2px
|
||||
@ -18,11 +18,11 @@ import com.gh.gamecenter.entity.DiscoveryCardEntity
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.entity.PullDownPush
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
||||
import com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_BANNER
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_DOUBLE_ROW_BANNER
|
||||
@ -47,7 +47,6 @@ import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_S
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL_SLIDE
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_TIMELINE_HORIZONTAL_SLIDE
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_VERTICAL_SLIDE
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_SINGLE_GAME_CARD
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_COLUMN
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_GAME
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_HALO_RECOMMEND
|
||||
@ -55,7 +54,11 @@ import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL
|
||||
import com.gh.gamecenter.minigame.MiniGameRecentlyPlayUseCase
|
||||
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMListRepository
|
||||
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMListUseCase
|
||||
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMRemoteDataSource
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.wrapper.MainWrapperRepository
|
||||
@ -63,12 +66,14 @@ import com.gh.vspace.VHelper
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
class CustomPageRepository private constructor(
|
||||
private val remoteDataSource: CustomPageRemoteDataSource,
|
||||
private val localDataSource: CustomPageLocalDataSource
|
||||
private val localDataSource: CustomPageLocalDataSource,
|
||||
private val wGameSubjectCPMRemoteDataSource: WGameSubjectCPMRemoteDataSource
|
||||
) {
|
||||
|
||||
private val pageInfo = PageInfo()
|
||||
@ -77,6 +82,10 @@ class CustomPageRepository private constructor(
|
||||
|
||||
private val shareRepository = CustomPageShareRepository.instance
|
||||
|
||||
private val wGameSubjectCPMListUseCase = WGameSubjectCPMListUseCase(
|
||||
WGameSubjectCPMListRepository(wGameSubjectCPMRemoteDataSource)
|
||||
)
|
||||
|
||||
private var recentItem: CustomRecentGamesItem? = null
|
||||
|
||||
private var recentQQItem: CustomRecentQqMiniGamesItem? = null
|
||||
@ -91,14 +100,13 @@ class CustomPageRepository private constructor(
|
||||
|
||||
private var displayingGameIdSet = hashSetOf<String>() // 当前正在显示的游戏 id 列表
|
||||
|
||||
private val _customPluginItemLiveData = MediatorLiveData<CustomPluginItem>().apply {
|
||||
val customPluginItemLiveData: LiveData<CustomPluginItem> = MediatorLiveData<CustomPluginItem>().apply {
|
||||
addSource(PackageRepository.gameUpdateLiveData) {
|
||||
refreshPluginIfNeed(it)?.let(this::setValue)
|
||||
}
|
||||
}
|
||||
val customPluginItemLiveData: LiveData<CustomPluginItem> = _customPluginItemLiveData
|
||||
|
||||
private val _recentGamesItemLiveData = MediatorLiveData<CustomRecentGamesItem>().apply {
|
||||
val recentGamesItemLiveData: LiveData<CustomRecentGamesItem> = MediatorLiveData<CustomRecentGamesItem>().apply {
|
||||
addSource(DownloadManager.getInstance().downloadEntityLiveData) {
|
||||
refreshRecentVGameIfNeed()?.let(this::setValue)
|
||||
}
|
||||
@ -106,29 +114,30 @@ class CustomPageRepository private constructor(
|
||||
refreshRecentVGameIfNeed()?.let(this::setValue)
|
||||
}
|
||||
}
|
||||
val recentGamesItemLiveData: LiveData<CustomRecentGamesItem> = _recentGamesItemLiveData
|
||||
|
||||
private val _recentMiniGamesItemLiveData = MediatorLiveData<CustomRecentWeChatMiniGamesItem>().apply {
|
||||
addSource(MiniGameRecentlyPlayUseCase.wechatRecentGamesItemLiveData) {
|
||||
refreshRecentWechatMiniGameIfNeed(it)?.let(this::setValue)
|
||||
val recentMiniGamesItemLiveData: LiveData<CustomRecentWeChatMiniGamesItem> =
|
||||
MediatorLiveData<CustomRecentWeChatMiniGamesItem>().apply {
|
||||
addSource(MiniGameRecentlyPlayUseCase.wechatRecentGamesItemLiveData) {
|
||||
refreshRecentWechatMiniGameIfNeed(it)?.let(this::setValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val recentMiniGamesItemLiveData: LiveData<CustomRecentWeChatMiniGamesItem> = _recentMiniGamesItemLiveData
|
||||
|
||||
private val _recentQqMiniGamesItemLiveData = MediatorLiveData<CustomRecentQqMiniGamesItem>().apply {
|
||||
addSource(MiniGameRecentlyPlayUseCase.qqRecentGamesItemLiveData) {
|
||||
refreshRecentQQMiniGameIfNeed(it)?.let(this::setValue)
|
||||
val recentQqMiniGamesItemLiveData: LiveData<CustomRecentQqMiniGamesItem> =
|
||||
MediatorLiveData<CustomRecentQqMiniGamesItem>().apply {
|
||||
addSource(MiniGameRecentlyPlayUseCase.qqRecentGamesItemLiveData) {
|
||||
refreshRecentQQMiniGameIfNeed(it)?.let(this::setValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
val recentQqMiniGamesItemLiveData: LiveData<CustomRecentQqMiniGamesItem> = _recentQqMiniGamesItemLiveData
|
||||
|
||||
private val _customDiscoverItemLiveData = MediatorLiveData<CustomDiscoverCardItem>().apply {
|
||||
addSource(shareRepository.discoverData) {
|
||||
refreshDiscoverDataIfNeed(it)?.let(this::setValue)
|
||||
val customDiscoverItemLiveData: LiveData<CustomDiscoverCardItem> =
|
||||
MediatorLiveData<CustomDiscoverCardItem>().apply {
|
||||
addSource(shareRepository.discoverData) {
|
||||
refreshDiscoverDataIfNeed(it)?.let(this::setValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
val customDiscoverItemLiveData: LiveData<CustomDiscoverCardItem> = _customDiscoverItemLiveData
|
||||
|
||||
val wechatMiniGameCPMItemLiveData: LiveData<Pair<String, List<GameEntity>>> =
|
||||
wGameSubjectCPMListUseCase.wechatMiniGameCPMListLiveData
|
||||
|
||||
val hiddenNotifications: LiveData<HashMap<String, MutableSet<String>>>
|
||||
get() = shareRepository.hiddenNotifications
|
||||
@ -224,6 +233,7 @@ class CustomPageRepository private constructor(
|
||||
|
||||
private fun transformRawDataIntoItemData(data: CustomPageData, reloadDiscoverData: Boolean): List<CustomPageItem> {
|
||||
val list = arrayListOf<CustomPageItem>()
|
||||
|
||||
data.customsComponents
|
||||
.forEachIndexed { _, item ->
|
||||
// 如果当前item不是展开大图,并且上一个item为展开大图,则说明展开大图组件已结束
|
||||
@ -265,112 +275,24 @@ class CustomPageRepository private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
item.link.type == CUSTOM_LINK_TYPE_COLUMN || item.link.type == CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL || item.link.type == CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> {
|
||||
// 游戏专题
|
||||
val gameSubject = item.gameSubjectEntity?.also {
|
||||
if (item.link.type == CUSTOM_LINK_TYPE_COLUMN) {
|
||||
it.data?.forEach { game ->
|
||||
game.gameLocation = GameEntity.GameLocation.INDEX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isAdded = false
|
||||
if (gameSubject != null && !gameSubject.data.isNullOrEmpty()) {
|
||||
// 记录已显示的游戏 id
|
||||
for (game in gameSubject.data!!) {
|
||||
displayingGameIdSet.add(game.id)
|
||||
}
|
||||
|
||||
// 替换游戏
|
||||
substituteGameIfNeeded(gameSubject)
|
||||
|
||||
if (gameSubject.tag == "update") {
|
||||
// 优先显示更新标签
|
||||
gameSubject.data?.forEach {
|
||||
it.tagStyle.clear()
|
||||
it.tagStyle.add(
|
||||
TagStyleEntity(
|
||||
id = "local_generated",
|
||||
name = TimeUtils.getFormatTime(it.updateTime, "MM-dd") + " 更新",
|
||||
color = "1383EB",
|
||||
background = "E8F3FF",
|
||||
column = "1383EB"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
when (gameSubject.type) {
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_DOUBLE_CARD, COMPONENTS_SUBJECT_TYPE_DOUBLE_GAME_WELFARE_CARD -> {
|
||||
// 双列卡片 双列福利卡片
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
|
||||
val subjectItems = convertSplitSubjectItems(item, 2, false)
|
||||
list.addAll(subjectItems)
|
||||
isAdded = true
|
||||
}
|
||||
}
|
||||
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VERTICAL -> {
|
||||
// 长列表式
|
||||
val subjectItems = convertSplitSubjectItems(item, 1, false)
|
||||
list.addAll(subjectItems)
|
||||
isAdded = true
|
||||
}
|
||||
|
||||
COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL -> {
|
||||
// 图标矩阵
|
||||
val subjectItems = convertSplitSubjectItems(item, 4, true)
|
||||
list.addAll(subjectItems)
|
||||
isAdded = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (gameSubject.type == COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE ||
|
||||
gameSubject.type == COMPONENTS_SUBJECT_TYPE_GAME_FOLD_SLIDE
|
||||
) {
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
|
||||
list.add(
|
||||
CustomSubjectItem(
|
||||
item.link,
|
||||
gameSubject,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition
|
||||
)
|
||||
)
|
||||
pageInfo.positionIncrement()
|
||||
isAdded = true
|
||||
}
|
||||
|
||||
} else {
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount > 0) {
|
||||
list.add(
|
||||
CustomSubjectItem(
|
||||
item.link,
|
||||
gameSubject,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition
|
||||
)
|
||||
)
|
||||
pageInfo.positionIncrement()
|
||||
isAdded = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (isAdded) {
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
item.link.type == CUSTOM_LINK_TYPE_COLUMN
|
||||
|| item.link.type == CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL
|
||||
|| item.link.type == CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> {
|
||||
val subItems = convertColumnDetailSubjectItems(
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition,
|
||||
item.link,
|
||||
item.gameSubjectEntity
|
||||
)
|
||||
if (subItems.isNotEmpty()) {
|
||||
list.addAll(subItems)
|
||||
pageInfo.positionGetAndAdd(subItems.size)
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
}
|
||||
|
||||
//QQ小游戏-最近在玩(需要用户登录才显示)
|
||||
item.link.type == CUSTOM_LINK_TYPE_QQ_GAME_RECENTLY_PLAYED -> {
|
||||
//QQ小游戏-最近在玩(需要用户登录才显示)
|
||||
val linkQqGameRecentlyPlayed = item.linkQqGameRecentlyPlayed
|
||||
if (linkQqGameRecentlyPlayed != null) {
|
||||
recentQQItem = CustomRecentQqMiniGamesItem(
|
||||
@ -386,8 +308,8 @@ class CustomPageRepository private constructor(
|
||||
|
||||
}
|
||||
|
||||
// 微信小游戏-最近在玩
|
||||
item.link.type == CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED -> {
|
||||
// 微信小游戏-最近在玩
|
||||
recentWechatItem = CustomRecentWeChatMiniGamesItem(
|
||||
item.link,
|
||||
MiniGameRecentlyPlayUseCase.getRecentlyPlayedMiniGameList(Constants.WECHAT_MINI_GAME),
|
||||
@ -398,6 +320,23 @@ class CustomPageRepository private constructor(
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
|
||||
// 微信小游戏CPM专题
|
||||
item.link.type == CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL -> {
|
||||
item.gameSubjectEntity?.let { subject ->
|
||||
list.add(
|
||||
CustomWeChatMiniGamesCPMSubjectItem(
|
||||
item.link,
|
||||
subject,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition
|
||||
)
|
||||
)
|
||||
wGameSubjectCPMListUseCase.getWechatMiniGameCPMList(subject.id)
|
||||
pageInfo.positionIncrement()
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
}
|
||||
|
||||
item.linkColumnCollection != null -> {
|
||||
// 专题合集
|
||||
val linkColumnCollection = item.linkColumnCollection
|
||||
@ -475,7 +414,9 @@ class CustomPageRepository private constructor(
|
||||
|| layout == COMMON_CONTENT_COLLECTION_LAYOUT_DOUBLE_ROW_VERTICAL_CARD
|
||||
|| layout == COMMON_CONTENT_COLLECTION_LAYOUT_VERTICAL_IMAGE_TEXT
|
||||
) {
|
||||
list.addAll(convertSplitCommonContentCollection(item))
|
||||
val subItems = convertSplitCommonContentCollection(item)
|
||||
list.addAll(subItems)
|
||||
pageInfo.positionGetAndAdd(subItems.size)
|
||||
pageInfo.componentPositionIncrement()
|
||||
} else {
|
||||
var show = true
|
||||
@ -528,12 +469,16 @@ class CustomPageRepository private constructor(
|
||||
// 最近在玩
|
||||
val entities = VHelper.getSortedRecentlyPlayedList()
|
||||
recentItem =
|
||||
CustomRecentGamesItem(item.link, entities, pageInfo.position, pageInfo.componentPosition)
|
||||
.also {
|
||||
list.add(it)
|
||||
pageInfo.positionIncrement()
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
CustomRecentGamesItem(
|
||||
item.link,
|
||||
entities,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition
|
||||
).also {
|
||||
list.add(it)
|
||||
pageInfo.positionIncrement()
|
||||
pageInfo.componentPositionIncrement()
|
||||
}
|
||||
}
|
||||
|
||||
item.link.type == "plugin_area" -> {
|
||||
@ -666,45 +611,155 @@ class CustomPageRepository private constructor(
|
||||
}
|
||||
|
||||
pageInfo.nextPage()
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
fun convertColumnDetailSubjectItems(
|
||||
position: Int,
|
||||
componentPosition: Int,
|
||||
link: LinkEntity,
|
||||
subjectEntity: SubjectEntity?,
|
||||
): List<CustomPageItem> {
|
||||
|
||||
var currentPosition = position
|
||||
val list = mutableListOf<CustomPageItem>()
|
||||
|
||||
// 游戏专题
|
||||
val gameSubject = subjectEntity?.also {
|
||||
if (link.type == CUSTOM_LINK_TYPE_COLUMN) {
|
||||
it.data?.forEach { game ->
|
||||
game.gameLocation = GameEntity.GameLocation.INDEX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gameSubject != null && !gameSubject.data.isNullOrEmpty()) {
|
||||
// 记录已显示的游戏 id
|
||||
for (game in gameSubject.data!!) {
|
||||
displayingGameIdSet.add(game.id)
|
||||
}
|
||||
|
||||
// 替换游戏
|
||||
substituteGameIfNeeded(gameSubject)
|
||||
|
||||
if (gameSubject.tag == "update") {
|
||||
// 优先显示更新标签
|
||||
gameSubject.data?.forEach {
|
||||
it.tagStyle.clear()
|
||||
it.tagStyle.add(
|
||||
TagStyleEntity(
|
||||
id = "local_generated",
|
||||
name = TimeUtils.getFormatTime(it.updateTime, "MM-dd") + " 更新",
|
||||
color = "1383EB",
|
||||
background = "E8F3FF",
|
||||
column = "1383EB"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
when (gameSubject.type) {
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_DOUBLE_CARD, COMPONENTS_SUBJECT_TYPE_DOUBLE_GAME_WELFARE_CARD -> {
|
||||
// 双列卡片 双列福利卡片
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
|
||||
val subjectItems =
|
||||
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 2, false)
|
||||
list.addAll(subjectItems)
|
||||
currentPosition += subjectItems.size
|
||||
}
|
||||
}
|
||||
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VERTICAL -> {
|
||||
// 长列表式
|
||||
val subjectItems =
|
||||
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 1, false)
|
||||
list.addAll(subjectItems)
|
||||
currentPosition += subjectItems.size
|
||||
}
|
||||
|
||||
COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL -> {
|
||||
// 图标矩阵
|
||||
val subjectItems =
|
||||
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 4, true)
|
||||
list.addAll(subjectItems)
|
||||
currentPosition += subjectItems.size
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (gameSubject.type == COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE ||
|
||||
gameSubject.type == COMPONENTS_SUBJECT_TYPE_GAME_FOLD_SLIDE
|
||||
) {
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
|
||||
list.add(
|
||||
CustomSubjectItem(
|
||||
link,
|
||||
gameSubject,
|
||||
currentPosition,
|
||||
componentPosition
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
val gameCount = gameSubject.data?.size ?: 0
|
||||
if (gameCount > 0) {
|
||||
list.add(
|
||||
CustomSubjectItem(
|
||||
link,
|
||||
gameSubject,
|
||||
currentPosition,
|
||||
componentPosition
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
private fun convertSplitSubjectItems(
|
||||
item: CustomPageData.CustomsComponent,
|
||||
link: LinkEntity,
|
||||
subjectEntity: SubjectEntity?,
|
||||
position: Int,
|
||||
componentPosition: Int,
|
||||
stepNum: Int,
|
||||
isMustFullyCover: Boolean
|
||||
): List<CustomPageItem> {
|
||||
val gameSubject = item.gameSubjectEntity ?: return emptyList()
|
||||
val gameSubject = subjectEntity ?: return emptyList()
|
||||
val items = arrayListOf<CustomPageItem>()
|
||||
val games = gameSubject.data ?: emptyList()
|
||||
var currentPosition = position
|
||||
(games.indices step stepNum).forEach { start ->
|
||||
if (isMustFullyCover) {
|
||||
if (start + stepNum - 1 < games.size) {
|
||||
items.add(
|
||||
CustomSplitSubjectItem(
|
||||
item.link,
|
||||
link,
|
||||
gameSubject,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition,
|
||||
currentPosition++,
|
||||
componentPosition,
|
||||
stepNum,
|
||||
start
|
||||
)
|
||||
)
|
||||
pageInfo.positionIncrement()
|
||||
}
|
||||
} else {
|
||||
items.add(
|
||||
CustomSplitSubjectItem(
|
||||
item.link,
|
||||
link,
|
||||
gameSubject,
|
||||
pageInfo.position,
|
||||
pageInfo.componentPosition,
|
||||
currentPosition++,
|
||||
componentPosition,
|
||||
stepNum,
|
||||
start
|
||||
)
|
||||
)
|
||||
pageInfo.positionIncrement()
|
||||
}
|
||||
}
|
||||
items.forEach {
|
||||
@ -729,7 +784,6 @@ class CustomPageRepository private constructor(
|
||||
left
|
||||
)
|
||||
)
|
||||
pageInfo.positionIncrement()
|
||||
}
|
||||
return items
|
||||
}
|
||||
@ -742,12 +796,20 @@ class CustomPageRepository private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun notifyPositionChanged(offset: Int) {
|
||||
pageInfo.position += offset
|
||||
fun notifyPositionAdded(offset: Int) {
|
||||
pageInfo.positionGetAndAdd(offset)
|
||||
}
|
||||
|
||||
fun notifyPositionChanged(value: Int) {
|
||||
pageInfo.position = value
|
||||
}
|
||||
|
||||
fun loadChangeSubjectGame(subjectEntity: SubjectEntity): Observable<List<GameEntity>> =
|
||||
remoteDataSource.loadChangeSubjectGame(subjectEntity)
|
||||
if (subjectEntity.isWechatColumnCPM) {// 微信小游戏CPM专题的“换一批”接口
|
||||
wGameSubjectCPMRemoteDataSource.getEditorRecommendCPMList(2, 10).toObservable()
|
||||
} else {
|
||||
remoteDataSource.loadChangeSubjectGame(subjectEntity)
|
||||
}
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
|
||||
@ -798,16 +860,16 @@ class CustomPageRepository private constructor(
|
||||
val page: Int
|
||||
get() = _page
|
||||
|
||||
private var _position: Int = 0
|
||||
private var _position: AtomicInteger = AtomicInteger(0)
|
||||
var position: Int
|
||||
get() = _position
|
||||
get() = _position.get()
|
||||
set(value) {
|
||||
_position = value
|
||||
_position.set(value)
|
||||
}
|
||||
|
||||
private var _componentPosition = 0
|
||||
private var _componentPosition: AtomicInteger = AtomicInteger(0)
|
||||
val componentPosition: Int
|
||||
get() = _componentPosition
|
||||
get() = _componentPosition.get()
|
||||
|
||||
|
||||
fun nextPage() {
|
||||
@ -815,17 +877,25 @@ class CustomPageRepository private constructor(
|
||||
}
|
||||
|
||||
fun positionIncrement() {
|
||||
_position++
|
||||
positionGetAndAdd(1)
|
||||
}
|
||||
|
||||
fun componentPositionIncrement() {
|
||||
_componentPosition++
|
||||
componentPositionGetAndAdd(1)
|
||||
}
|
||||
|
||||
fun positionGetAndAdd(value: Int) {
|
||||
_position.getAndAdd(value)
|
||||
}
|
||||
|
||||
fun componentPositionGetAndAdd(value: Int) {
|
||||
_componentPosition.getAndAdd(value)
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
_page = 1
|
||||
_position = 0
|
||||
_componentPosition = 0
|
||||
_position.set(0)
|
||||
_componentPosition.set(0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -844,7 +914,8 @@ class CustomPageRepository private constructor(
|
||||
RetrofitManager.getInstance().newApi,
|
||||
MainWrapperRepository.getInstance()
|
||||
),
|
||||
CustomPageLocalDataSource()
|
||||
CustomPageLocalDataSource(),
|
||||
WGameSubjectCPMRemoteDataSource()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class SubjectTracker(private val pageLocation: PageLocation) {
|
||||
pageLocation.pageName,
|
||||
subject?.id ?: "",
|
||||
subject?.name ?: "",
|
||||
"最近在玩",
|
||||
"自定义页面",
|
||||
item.componentStyle,
|
||||
"",
|
||||
)
|
||||
|
||||
@ -363,7 +363,7 @@ class CommonContentHomeSlideWithCardsUi(
|
||||
homeSlideCardItemBinding.cardIv.visibility = View.VISIBLE
|
||||
// 防止重复加载图片导致闪烁
|
||||
if (homeSubSlide.image != cardIv.getTag(R.string.tag_img_url_id)) {
|
||||
ImageUtils.display(cardIv, homeSubSlide.image, false, AlphaGradientProcess())
|
||||
ImageUtils.display(cardIv, homeSubSlide.image, true, AlphaGradientProcess())
|
||||
cardIv.setTag(R.string.tag_img_url_id, homeSubSlide.image)
|
||||
}
|
||||
ConstraintSet().apply {
|
||||
@ -398,7 +398,7 @@ class CommonContentHomeSlideWithCardsUi(
|
||||
descTv.text = homeSubSlide.cardDesc
|
||||
// 防止重复加载图片导致闪烁
|
||||
if (homeSubSlide.image != cardIv.getTag(R.string.tag_img_url_id)) {
|
||||
ImageUtils.display(cardIv, homeSubSlide.image, false, AlphaGradientProcess())
|
||||
ImageUtils.display(cardIv, homeSubSlide.image, true, AlphaGradientProcess())
|
||||
cardIv.setTag(R.string.tag_img_url_id, homeSubSlide.image)
|
||||
}
|
||||
ConstraintSet().apply {
|
||||
|
||||
@ -40,7 +40,7 @@ class CustomGameGallerySlideViewHolder(
|
||||
override fun bindView(item: CustomPageItem) {
|
||||
super.bindView(item)
|
||||
if (item is CustomSubjectItem) {
|
||||
|
||||
binding.cardView.setCardBackgroundColor(com.gh.gamecenter.common.R.color.ui_container_1.toColor(binding.root.context))
|
||||
if (item.data == cachedSubject) return
|
||||
|
||||
cachedSubject = item.data
|
||||
@ -77,7 +77,6 @@ class CustomGameGallerySlideViewHolder(
|
||||
val gameList = item.data.data ?: emptyList()
|
||||
(recyclerView.adapter as? GameGallerySlideAdapter)?.submitList(gameList)
|
||||
}
|
||||
binding.cardView.setCardBackgroundColor(com.gh.gamecenter.common.R.color.text_FAFAFA.toColor(binding.root.context))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -193,9 +193,6 @@ class CustomGameItemViewHolder(
|
||||
adLabelTv: TextView? = null,
|
||||
canShowSubTitle: Boolean
|
||||
) {
|
||||
if (entity.id == gameSubtitleTv.getTag(com.gh.gamecenter.common.R.string.tag_game_name_id)) return
|
||||
gameSubtitleTv.setTag(com.gh.gamecenter.common.R.string.tag_game_name_id, entity.id)
|
||||
|
||||
var showSubtitle = false
|
||||
var showAdvancedDownload = false
|
||||
if (canShowSubTitle && entity.serverLabel == null && entity.subtitle.isNotEmpty() && !entity.advanceDownload) {
|
||||
@ -215,6 +212,9 @@ class CustomGameItemViewHolder(
|
||||
setColor("#${entity.subtitleStyle?.background}".hexStringToIntColor())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setTextColor(com.gh.gamecenter.common.R.color.text_secondary.toColor(context))
|
||||
background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,6 +227,10 @@ class CustomGameItemViewHolder(
|
||||
background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context)
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.id == gameSubtitleTv.getTag(com.gh.gamecenter.common.R.string.tag_game_name_id)) return
|
||||
gameSubtitleTv.setTag(com.gh.gamecenter.common.R.string.tag_game_name_id, entity.id)
|
||||
|
||||
if (showSubtitle || showAdvancedDownload) {
|
||||
val minWidth =
|
||||
if (showSubtitle) SUBTITLE_MIN_WIDTH.dip2px() else if (showAdvancedDownload) ADVANCED_DOWNLOAD_WIDTH.dip2px() else 0
|
||||
|
||||
@ -109,7 +109,9 @@ class CustomHomeGameItemViewHolder(
|
||||
item.linkColumn?.id ?: ""
|
||||
)
|
||||
}
|
||||
binding.gameBrief.text = game.recommendText
|
||||
binding.gameBrief.goneIf(game.recommendText.isEmpty()) {
|
||||
binding.gameBrief.text = game.recommendText
|
||||
}
|
||||
binding.gameImage.visibleIf(game.showImage) {
|
||||
if (game.isWechatMiniGame()) {
|
||||
ImageUtils.display(binding.gameImage, game.banner)
|
||||
|
||||
@ -53,6 +53,7 @@ class CustomHomeSlideListItemViewHolder(val binding: HomeSlideListItemCustomBind
|
||||
ImageUtils.displayWithCallback(
|
||||
binding.slideBackground,
|
||||
homeSlide.image,
|
||||
false,
|
||||
object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
||||
binding.bottomGradient.visibility = View.VISIBLE
|
||||
|
||||
@ -67,6 +67,7 @@ class CustomHomeSubSlideListItemViewHolder(val binding: HomeSubSlideListItemCust
|
||||
ImageUtils.displayWithCallback(
|
||||
binding.slideBackground,
|
||||
homeSlide.image,
|
||||
false,
|
||||
object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
||||
if (homeSlide.placeholderColor.isNotEmpty() && homeSlide.linkGame != null) {
|
||||
|
||||
@ -41,6 +41,8 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
var thumbImage: SimpleDraweeView = findViewById(R.id.thumbImage)
|
||||
var containerView: RadiusCardView = findViewById(R.id.container)
|
||||
var detailBtn: TextView? = null
|
||||
var isMute = true
|
||||
private var mIsFirstPlay = true
|
||||
private var mMuteDisposable: Disposable? = null
|
||||
private var mMaskDisposable: Disposable? = null
|
||||
private val mUUID = UUID.randomUUID().toString()
|
||||
@ -89,10 +91,11 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
mVideoAllCallBack.onClickStartThumb(mOriginUrl, mTitle, this)
|
||||
}
|
||||
prepareVideo()
|
||||
val topVideoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
|
||||
if (topVideoVoiceStatus) {
|
||||
violenceUpdateMuteStatus()
|
||||
if (mIsFirstPlay) {
|
||||
isMute = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
|
||||
mIsFirstPlay = false
|
||||
}
|
||||
violenceUpdateMuteStatus()
|
||||
resetDetailMask()
|
||||
}
|
||||
|
||||
@ -106,15 +109,21 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
mMuteDisposable?.dispose()
|
||||
mMuteDisposable = null
|
||||
}
|
||||
mute()
|
||||
if (isMute) {
|
||||
mute()
|
||||
} else {
|
||||
unMute()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun mute() {
|
||||
isMute = true
|
||||
CustomManager.getCustomManager(getKey()).isNeedMute = true
|
||||
}
|
||||
|
||||
fun unMute() {
|
||||
isMute = false
|
||||
CustomManager.getCustomManager(getKey()).isNeedMute = false
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,10 @@ class ScrollCalculatorHelper(
|
||||
|
||||
fun enableAndPlayIfValid() {
|
||||
isEnabled = true
|
||||
playIfValid()
|
||||
}
|
||||
|
||||
fun playIfValid() {
|
||||
if (mListRv.isAttachedToWindow
|
||||
&& mListRv.scrollState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
playVideo(mListRv)
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
package com.gh.gamecenter.install
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.lightgame.download.ForegroundNotificationManager
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
|
||||
class InstallService : Service() {
|
||||
|
||||
private var mForegroundTimer: Timer? = null
|
||||
private var mForegroundNotificationManager: ForegroundNotificationManager? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
mForegroundNotificationManager = ForegroundNotificationManager(this, this.application)
|
||||
Utils.log(InstallService::class.java.simpleName, "onCreate")
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
Utils.log(InstallService::class.java.simpleName, "onStartCommand")
|
||||
val notificationId = 9999
|
||||
if (intent != null && intent.extras != null) {
|
||||
val serviceAction = intent.getStringExtra(KEY_SERVICE_ACTION)
|
||||
if (START_FOREGROUND == serviceAction) {
|
||||
startForegroundIfNeeded(notificationId)
|
||||
} else if (STOP_FOREGROUND == serviceAction) {
|
||||
startForegroundIfNeeded(notificationId)
|
||||
stopForegroundIfNeeded(notificationId)
|
||||
}
|
||||
} else {
|
||||
startForegroundIfNeeded(notificationId)
|
||||
stopForegroundIfNeeded(notificationId)
|
||||
}
|
||||
|
||||
// 不需要 intent 为空的重建
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun startForegroundIfNeeded(notificationId: Int) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel =
|
||||
NotificationChannel(SERVICE_CHANNEL_ID, SERVICE_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW)
|
||||
val manager = applicationContext.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
manager.createNotificationChannel(channel)
|
||||
val notification: Notification = NotificationCompat.Builder(this, SERVICE_CHANNEL_ID)
|
||||
.setSmallIcon(com.lightgame.R.drawable.ic_download_notification)
|
||||
.setContentTitle("光环助手安装服务")
|
||||
.build()
|
||||
mForegroundNotificationManager?.notify(notificationId, notification)
|
||||
|
||||
mForegroundTimer?.cancel()
|
||||
mForegroundTimer = Timer()
|
||||
|
||||
val task: TimerTask = object : TimerTask() {
|
||||
override fun run() {
|
||||
stopForegroundIfNeeded(notificationId)
|
||||
}
|
||||
}
|
||||
|
||||
mForegroundTimer?.schedule(task, FOREGROUND_COUNT_DOWN_TIME)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopForegroundIfNeeded(notificationId: Int) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
mForegroundNotificationManager?.cancel(notificationId)
|
||||
|
||||
mForegroundTimer?.cancel()
|
||||
mForegroundTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val SERVICE_CHANNEL_ID = "安装服务"
|
||||
private const val FOREGROUND_COUNT_DOWN_TIME = 20 * 1000L
|
||||
|
||||
const val START_FOREGROUND = "start_foreground"
|
||||
const val STOP_FOREGROUND = "stop_foreground"
|
||||
const val KEY_SERVICE_ACTION = "service_action"
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ class MiniGameRecentlyPlayListAdapter(
|
||||
if (onItemClick != null) {
|
||||
onItemClick.invoke(entity, position)
|
||||
} else {
|
||||
MiniGameItemHelper.launchMiniGame(entity.miniGameAppId, entity.miniGameType)
|
||||
MiniGameItemHelper.launchMiniGame(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,10 +56,10 @@ class MiniGameSearchDefaultRankAdapter(
|
||||
|
||||
// 转成Game实体比较好处理数据
|
||||
val trackGame = GameEntity(
|
||||
id = rank.id,
|
||||
_id = rank.id,
|
||||
mName = rank.name,
|
||||
miniGameAppId = rank.link.link ?: "",
|
||||
miniGameType = Constants.WECHAT_MINI_GAME,
|
||||
miniGameCategory = Constants.WECHAT_MINI_GAME,
|
||||
usage = rank.usage ?: 0
|
||||
)
|
||||
holder.binding.playCount.visibility = View.VISIBLE
|
||||
|
||||
@ -2,14 +2,16 @@ package com.gh.gamecenter.minigame
|
||||
|
||||
import com.gh.gamecenter.entity.SearchSubjectEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMRemoteDataSource
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.search.ISearchGameResultRepository
|
||||
import io.reactivex.Observable
|
||||
import java.net.URLEncoder
|
||||
import io.reactivex.Single
|
||||
|
||||
class MiniGameSearchResultRepository(
|
||||
private val api: ApiService = RetrofitManager.getInstance().newApi
|
||||
private val api: ApiService = RetrofitManager.getInstance().newApi,
|
||||
private val mWGameSubjectCPMDataSource: WGameSubjectCPMRemoteDataSource = WGameSubjectCPMRemoteDataSource()
|
||||
) : ISearchGameResultRepository {
|
||||
|
||||
override fun getSearchGame(
|
||||
@ -19,7 +21,15 @@ class MiniGameSearchResultRepository(
|
||||
return api.getSearchMiniGameList(key, page, 20)
|
||||
}
|
||||
|
||||
override fun getSearchMiniGameCPM(key: String?): Observable<List<GameEntity>> {
|
||||
return Observable.just(emptyList())
|
||||
}
|
||||
|
||||
override fun getSearchSubject(key: String?, page: Int): Observable<List<SearchSubjectEntity>> {
|
||||
return Observable.just(emptyList())
|
||||
}
|
||||
|
||||
override fun getWGameCPMGameList(): Single<MutableList<GameEntity>> {
|
||||
return mWGameSubjectCPMDataSource.getUserRecommendCPMList()
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,9 @@ import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.subject.ISubjectRepository
|
||||
import io.reactivex.Observable
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.ResponseBody
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
|
||||
class QGameSubjectRepository(
|
||||
private val api: ApiService = RetrofitManager.getInstance().newApi
|
||||
@ -17,7 +19,7 @@ class QGameSubjectRepository(
|
||||
}
|
||||
|
||||
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
|
||||
return Observable.just(ResponseBody.create(MediaType.parse("application/json"), "{\"name\": \"专题\"}"))
|
||||
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.gh.gamecenter.minigame.wechat
|
||||
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.subject.ISubjectListRepository
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
|
||||
class WGameSubjectCPMListRepository(
|
||||
private val dataSource: WGameSubjectCPMRemoteDataSource = WGameSubjectCPMRemoteDataSource()
|
||||
) : ISubjectListRepository {
|
||||
|
||||
override fun getColumn(column_id: String?, page: Int, sort: String?, order: String?): Single<MutableList<GameEntity>> {
|
||||
return dataSource.getEditorRecommendCPMList(page)
|
||||
}
|
||||
|
||||
override fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity> {
|
||||
return Observable.just(SubjectSettingEntity())
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.gh.gamecenter.minigame.wechat
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.LiveData
|
||||
import com.gh.gamecenter.common.livedata.NonStickyMutableLiveData
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 微信小游戏CPM-网域层
|
||||
*/
|
||||
class WGameSubjectCPMListUseCase(
|
||||
private val repository: WGameSubjectCPMListRepository = WGameSubjectCPMListRepository()
|
||||
) {
|
||||
|
||||
/**
|
||||
* 微信专题CPM请求记录,用于避免重复请求,以专题ID作为Key
|
||||
*/
|
||||
private val requestKeyList = mutableListOf<String>()
|
||||
|
||||
/**
|
||||
* 微信小游戏CPM列表,这里的LiveData充当类似于EventBus的角色,因此使用NonStickyMutableLiveData
|
||||
*/
|
||||
private val _wechatMiniGameCPMListLiveData = NonStickyMutableLiveData<Pair<String, List<GameEntity>>>()
|
||||
val wechatMiniGameCPMListLiveData: LiveData<Pair<String, List<GameEntity>>> = _wechatMiniGameCPMListLiveData
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun getWechatMiniGameCPMList(subjectId: String?) {
|
||||
if (subjectId.isNullOrEmpty() || requestKeyList.contains(subjectId)) {
|
||||
return
|
||||
}
|
||||
|
||||
requestKeyList.add(subjectId)
|
||||
repository.getColumn(null, 1, null, null)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||
override fun onSuccess(data: List<GameEntity>) {
|
||||
requestKeyList.remove(subjectId)
|
||||
_wechatMiniGameCPMListLiveData.value = subjectId to data
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.gh.gamecenter.minigame.wechat
|
||||
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.utils.toRequestBody
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.feature.retrofit.WGameCPMApiService
|
||||
import io.reactivex.Single
|
||||
|
||||
class WGameSubjectCPMRemoteDataSource(
|
||||
private val api: WGameCPMApiService = RetrofitManager.getInstance().wGameCPMApi
|
||||
) {
|
||||
|
||||
fun getEditorRecommendCPMList(page: Int, pageSize: Int = 10): Single<MutableList<GameEntity>> {
|
||||
val meta = MetaUtil.getMeta()
|
||||
val request = mapOf(
|
||||
"head" to mapOf(
|
||||
"busiAppid" to Config.WGAME_CPM_BUSIAPPID,
|
||||
"oaid" to (meta.oaid ?: ""),
|
||||
"manufacturer" to (meta.manufacturer ?: ""),
|
||||
"mode" to (meta.model ?: ""),
|
||||
"androidId" to (MetaUtil.getAndroidId()),
|
||||
"imei" to (MetaUtil.getIMEI())
|
||||
),
|
||||
"body" to mapOf(
|
||||
"page" to page - 1,
|
||||
"pageSize" to pageSize,
|
||||
)
|
||||
)
|
||||
return api.getEditorRecommendList(request.toRequestBody())
|
||||
.map {
|
||||
if (it.ret == 0) {
|
||||
it.appInfoList.map { info ->
|
||||
GameEntity(
|
||||
mName = info.appName,
|
||||
mIcon = info.logo,
|
||||
mBrief = info.briefIntro,
|
||||
miniGameUid = info.appID,
|
||||
miniGameAppId = info.userName,
|
||||
miniGameCategory = Constants.WECHAT_MINI_GAME,
|
||||
profit = Constants.WECHAT_MINI_GAME_PROFIT_CPM,
|
||||
miniGameAppStatus = 2,
|
||||
miniGameAppPath = info.wechatAppPath,
|
||||
miniGameExtData = info.extData,
|
||||
miniGameRecommendId = info.recommendID,
|
||||
mTagStyle = arrayListOf(
|
||||
TagStyleEntity(name = info.categoryName),
|
||||
TagStyleEntity(name = info.subcategoryName)
|
||||
)
|
||||
)
|
||||
}.toMutableList()
|
||||
} else {
|
||||
mutableListOf()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getUserRecommendCPMList(page: Int = 1, pageSize: Int = 10): Single<MutableList<GameEntity>> {
|
||||
val meta = MetaUtil.getMeta()
|
||||
val request = mapOf(
|
||||
"head" to mapOf(
|
||||
"busiAppid" to Config.WGAME_CPM_BUSIAPPID,
|
||||
"oaid" to (meta.oaid ?: ""),
|
||||
"manufacturer" to (meta.manufacturer ?: ""),
|
||||
"mode" to (meta.model ?: ""),
|
||||
"androidId" to (MetaUtil.getAndroidId()),
|
||||
"imei" to (MetaUtil.getIMEI())
|
||||
),
|
||||
"body" to mapOf(
|
||||
"page" to page - 1,
|
||||
"pageSize" to pageSize,
|
||||
)
|
||||
)
|
||||
return api.getUserRecommendList(request.toRequestBody())
|
||||
.map {
|
||||
if (it.ret == 0) {
|
||||
it.appInfoList.map { info ->
|
||||
GameEntity(
|
||||
mName = info.appName,
|
||||
mIcon = info.logo,
|
||||
mBrief = info.briefIntro,
|
||||
miniGameUid = info.appID,
|
||||
miniGameAppId = info.userName,
|
||||
miniGameCategory = Constants.WECHAT_MINI_GAME,
|
||||
profit = Constants.WECHAT_MINI_GAME_PROFIT_CPM,
|
||||
miniGameAppStatus = 2,
|
||||
miniGameAppPath = info.wechatAppPath,
|
||||
miniGameExtData = info.extData,
|
||||
miniGameRecommendId = info.recommendID,
|
||||
mTagStyle = arrayListOf(
|
||||
TagStyleEntity(name = info.categoryName),
|
||||
TagStyleEntity(name = info.subcategoryName)
|
||||
)
|
||||
)
|
||||
}.toMutableList()
|
||||
} else {
|
||||
mutableListOf()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.gh.gamecenter.minigame.wechat
|
||||
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.gh.gamecenter.subject.ISubjectRepository
|
||||
import io.reactivex.Observable
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.ResponseBody
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
|
||||
class WGameSubjectCPMRepository : ISubjectRepository {
|
||||
override fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity> {
|
||||
return Observable.just(SubjectSettingEntity())
|
||||
}
|
||||
|
||||
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
|
||||
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,9 @@ import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.subject.ISubjectRepository
|
||||
import io.reactivex.Observable
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.ResponseBody
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
|
||||
class WGameSubjectRepository(
|
||||
private val api: ApiService = RetrofitManager.getInstance().newApi
|
||||
@ -16,6 +18,6 @@ class WGameSubjectRepository(
|
||||
}
|
||||
|
||||
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
|
||||
return Observable.just(ResponseBody.create(MediaType.parse("application/json"), "{\"name\": \"专题\"}"))
|
||||
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
|
||||
}
|
||||
}
|
||||
@ -35,17 +35,21 @@ class PackageFilterManager {
|
||||
|
||||
if (appendOnly) {
|
||||
// 添加因为异常而没能正常更新的包名列表
|
||||
finalPackageList.addAll(PackageRepository.mPendingPackageNameSet)
|
||||
synchronized(PackageRepository.mPendingPackageNameSet) {
|
||||
finalPackageList.addAll(PackageRepository.mPendingPackageNameSet)
|
||||
}
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.newApi
|
||||
.postInstalledAppList(packageList.toRequestBody())
|
||||
.postInstalledAppList(finalPackageList.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<PackageFilter>() {
|
||||
override fun onSuccess(data: PackageFilter) {
|
||||
mPackageKey = data.key
|
||||
PackageRepository.mPendingPackageNameSet.clear()
|
||||
synchronized(PackageRepository.mPendingPackageNameSet) {
|
||||
PackageRepository.mPendingPackageNameSet.removeAll(finalPackageList)
|
||||
}
|
||||
|
||||
val partialPackageList = arrayListOf<String>()
|
||||
|
||||
@ -78,7 +82,9 @@ class PackageFilterManager {
|
||||
super.onFailure(exception)
|
||||
|
||||
if (appendOnly) {
|
||||
PackageRepository.mPendingPackageNameSet.addAll(packageList)
|
||||
synchronized(PackageRepository.mPendingPackageNameSet) {
|
||||
PackageRepository.mPendingPackageNameSet.addAll(finalPackageList)
|
||||
}
|
||||
} else {
|
||||
if (exception is retrofit2.HttpException && exception.code() == 403) {
|
||||
// 403 代表 key 过期,需要重新获取
|
||||
|
||||
@ -85,7 +85,7 @@ object PackageRepository {
|
||||
_recentVaPlayedChanged.postValue(Unit)
|
||||
}
|
||||
val packageFilterManager = PackageFilterManager()
|
||||
var mPendingPackageNameSet = hashSetOf<String>() // 因遇到异常而等待下次操作更新的包名列表
|
||||
var mPendingPackageNameSet = Collections.synchronizedSet<String>(hashSetOf<String>()) // 因遇到异常而等待下次操作更新的包名列表
|
||||
var mValidPackageNameSet = hashSetOf<String>() // 已被收录的游戏包名列表
|
||||
|
||||
|
||||
|
||||
@ -374,12 +374,14 @@ class HaloPersonalFragment : BaseLazyFragment() {
|
||||
}
|
||||
|
||||
mSuperiorChain?.registerInferiorChain(mPriorityChain)
|
||||
startBannerAutoPlay()
|
||||
}
|
||||
|
||||
override fun onFragmentPause() {
|
||||
super.onFragmentPause()
|
||||
|
||||
mSuperiorChain?.unregisterInferiorChain(mPriorityChain)
|
||||
stopBannerAutoPlay()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
@ -699,7 +701,7 @@ class HaloPersonalFragment : BaseLazyFragment() {
|
||||
}
|
||||
|
||||
private fun inflateRealView() {
|
||||
mBinding.stub.inflate()
|
||||
mBinding.stub.inflateOrShow()
|
||||
|
||||
mStubBinding.statusBar.goneIf(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
mStubBinding.darkModeIv.goneIf(!(Config.getNightModeSetting()?.icon ?: false))
|
||||
@ -1011,7 +1013,7 @@ class HaloPersonalFragment : BaseLazyFragment() {
|
||||
}
|
||||
|
||||
private fun startBannerAutoPlay() {
|
||||
if (mPersonalBannerAdapter.getActualSize() < 2) return
|
||||
if (!::mPersonalBannerAdapter.isInitialized || mPersonalBannerAdapter.getActualSize() < 2) return
|
||||
stopBannerAutoPlay()
|
||||
mLooperHandle.sendEmptyMessageDelayed(mSlideLooperKey, BANNER_LOOP_TIME)
|
||||
}
|
||||
|
||||
@ -20,7 +20,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
@ -75,7 +77,7 @@ class InstalledGameDialog(
|
||||
jsonObject.put("package", game.packageName)
|
||||
objects.put(jsonObject)
|
||||
}
|
||||
val requestBody = RequestBody.create(MediaType.parse("application/json"), objects.toString())
|
||||
val requestBody = objects.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
RetrofitManager.getInstance().api
|
||||
.postPlayedGames(UserManager.getInstance().userId, requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.provider
|
||||
import android.content.*
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteException
|
||||
import android.database.sqlite.SQLiteFullException
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import android.net.Uri
|
||||
@ -12,6 +13,7 @@ import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.login.entity.UserInfoEntity
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -77,7 +79,12 @@ class GhContentProvider : ContentProvider() {
|
||||
}
|
||||
|
||||
override fun onCreate(): Boolean {
|
||||
initProviderSqliteHelper(context);
|
||||
try {
|
||||
val context = context ?: return false
|
||||
initProviderSqliteHelper(context)
|
||||
} catch (e: SQLiteException) {
|
||||
ToastUtils.toast("数据库内存已满,无法同步")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@ -25,7 +25,9 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONObject
|
||||
@ -259,10 +261,8 @@ class AnswerDetailViewModel(application: Application) : AndroidViewModel(applica
|
||||
fun toggleComment(answerId: String, isCommentable: Boolean) {
|
||||
val params = HashMap<String, Boolean>()
|
||||
params["commentable"] = isCommentable
|
||||
val body = RequestBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
JSONObject(params as Map<*, *>).toString()
|
||||
)
|
||||
val body = JSONObject(params as Map<*, *>).toString()
|
||||
.toRequestBody("application/json".toMediaTypeOrNull())
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
|
||||
@ -26,7 +26,9 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONArray
|
||||
@ -144,7 +146,7 @@ class ArticleEditViewModel(application: Application) : BaseRichEditorViewModel(a
|
||||
if (draftEntity?.id != null) {
|
||||
articleBody.put("draft_id", draftEntity?.id)
|
||||
}
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), articleBody.toString())
|
||||
val body = articleBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
val observable = if (detailEntity == null) {
|
||||
mApi.postCommunityArticle(mSelectCommunityData?.id, body)
|
||||
} else {
|
||||
@ -226,7 +228,7 @@ class ArticleEditViewModel(application: Application) : BaseRichEditorViewModel(a
|
||||
if (mSelectCommunityData != null && mSelectCommunityData!!.id.isNotEmpty()) {
|
||||
articleBody.put("community_id", mSelectCommunityData!!.id)
|
||||
}
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), articleBody.toString())
|
||||
val body = articleBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
val observable = if (draftEntity?.id != null) {
|
||||
mApi.patchCommunityArticleDrafts(UserManager.getInstance().userId, draftEntity?.id, body)
|
||||
} else {
|
||||
|
||||
@ -40,7 +40,7 @@ class GameDefaultAdapter(
|
||||
val intent = Intent()
|
||||
intent.putExtra(
|
||||
GameEntity::class.java.simpleName,
|
||||
GameEntity(id = entity.gameId, mIcon = entity.gameIcon, mName = entity.gameName, mCategory = entity.category)
|
||||
GameEntity(_id = entity.gameId, mIcon = entity.gameIcon, mName = entity.gameName, mCategory = entity.category)
|
||||
)
|
||||
(mContext as Activity).setResult(Activity.RESULT_OK, intent)
|
||||
(mContext as Activity).finish()
|
||||
|
||||
@ -28,7 +28,9 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONArray
|
||||
@ -266,7 +268,7 @@ class QuestionEditViewModel(application: Application) : BaseRichEditorViewModel(
|
||||
}
|
||||
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("提交中...", true))
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), bodyJson)
|
||||
val body = bodyJson.toRequestBody("application/json".toMediaTypeOrNull())
|
||||
mApi.moderatorsPatchQuestion(body, UserManager.getInstance().userId, questionEntity?.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@ -15,7 +15,9 @@ import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
@ -59,7 +61,7 @@ class QuestionsInviteViewModel(application: Application, var questionId: String?
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
|
||||
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
RetrofitManager.getInstance().api
|
||||
.postInvite(body, questionId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user