Compare commits

...

9 Commits

10 changed files with 93 additions and 87 deletions

View File

@ -159,7 +159,7 @@ object LoginHelper {
if (mAccessToken?.isSessionValid == true) {
// 保存 Token 到 SharedPreferences
AccessTokenKeeper.writeAccessToken(context, mAccessToken)
Toast.makeText(context, "授权成功", Toast.LENGTH_SHORT).show()
Utils.toast(context, "授权成功")
}
}

View File

@ -3,6 +3,7 @@ package com.gh.common.util
import android.widget.Toast
import com.halo.assistant.HaloApp
import com.lightgame.utils.toast.ToastHandler
object ToastUtils {
/** 之前显示的内容 */
@ -32,7 +33,7 @@ object ToastUtils {
*/
fun showToast(message: String, gravity: Int = -1, yOffset: Int = 0) {
if (mToast == null) {
mToast = Toast.makeText(HaloApp.getInstance().application, message, Toast.LENGTH_SHORT)
mToast = ToastHandler.INSTANCE.getToastInstance(HaloApp.getInstance().application, message, Toast.LENGTH_SHORT)
if (gravity != -1) mToast!!.setGravity(gravity, 0, yOffset) else
mToast!!.setGravity(DisplayUtils.getToastDefaultGravity(), 0, DisplayUtils.getToastOffset())
mToast!!.show()

View File

@ -269,6 +269,7 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi
ev.setAction(MotionEvent.ACTION_CANCEL);
returnValue = super.onTouchEvent(ev);
}
initVelocityTrackerIfNotExists();
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
int initialVelocity = (int) velocityTracker.getYVelocity(mActivePointerId);

View File

@ -1,9 +1,8 @@
package com.gh.gamecenter.gamedetail.desc
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.text.Spanned
import android.view.View
import android.view.ViewGroup
@ -20,7 +19,9 @@ import com.gh.gamecenter.entity.TagEntity
import com.lightgame.adapter.BaseRecyclerAdapter
import com.m7.imkfsdk.utils.DensityUtil
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.*
class GameDetailCustomColumnAdapter(context: Context)
@ -53,8 +54,8 @@ class GameDetailCustomColumnAdapter(context: Context)
.build()
tryWithDefaultCatch {
Picasso.with(mContext).load(icon)
.priority(Picasso.Priority.HIGH)
/*Picasso.with(mContext).load(icon)
.priority(Picasso.Priority.LOW)
.into(object : Target {
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
viewHolder.contentTv.movementMethod = CustomLinkMovementMethod.getInstance()
@ -68,6 +69,20 @@ class GameDetailCustomColumnAdapter(context: Context)
viewHolder.contentTv.movementMethod = CustomLinkMovementMethod.getInstance()
viewHolder.contentTv.text = spannable
}
})*/
Single.just(icon)
.map {
Picasso.with(mContext).load(Uri.parse(it)).priority(Picasso.Priority.HIGH).get()
}.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe ({
val bitmapDrawable = BitmapDrawable(mContext.resources, it)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
spannable.setSpan(CenterImageSpan(bitmapDrawable), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
viewHolder.contentTv.movementMethod = CustomLinkMovementMethod.getInstance()
viewHolder.contentTv.text = spannable
},{
it.printStackTrace()
})
}
}

View File

@ -1,11 +1,9 @@
package com.gh.gamecenter.gamedetail.rating
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.text.SpannableStringBuilder
import android.text.Spanned
@ -36,9 +34,10 @@ import com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity.Companion.LAB
import com.gh.gamecenter.gamedetail.rating.logs.CommentLogsActivity
import com.gh.gamecenter.manager.UserManager
import com.m7.imkfsdk.utils.DensityUtil
import com.squareup.picasso.MemoryPolicy
import com.squareup.picasso.NetworkPolicy
import com.squareup.picasso.Picasso
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.regex.Pattern
class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
@ -85,45 +84,40 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR
replyContent.highlightColor = Color.TRANSPARENT
if (commentData.replyData!!.user.badge != null) {
Picasso.with(context).load(Uri.parse(commentData.replyData!!.user.badge?.icon))
.priority(Picasso.Priority.HIGH)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE)
.into(object : com.squareup.picasso.Target {
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
Single.just(commentData.replyData!!.user.badge?.icon)
.map {
//Target对象保存为弱引用gc时对象被回收导致无法回调因此改为同步方式获取bitmap
//https://github.com/square/picasso/issues/352
Picasso.with(context).load(Uri.parse(it)).priority(Picasso.Priority.HIGH).get()
}.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe ({
val bitmapDrawable = BitmapDrawable(context.resources, it)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
contentSpan.setSpan(CenterImageSpan(bitmapDrawable), commentData.replyData?.user?.name!!.length + 2, commentData.replyData?.user?.name!!.length + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
contentSpan.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.isUnderlineText = false
}
}
override fun onBitmapFailed(errorDrawable: Drawable?) {
}
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
val bitmapDrawable = BitmapDrawable(context.resources, bitmap)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
contentSpan.setSpan(CenterImageSpan(bitmapDrawable), commentData.replyData?.user?.name!!.length + 2, commentData.replyData?.user?.name!!.length + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
contentSpan.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.isUnderlineText = false
override fun onClick(widget: View) {
val key = when (path) {
"游戏详情:介绍" -> "游戏详情-玩家评论"
"游戏详情:评分" -> "游戏详情-评论列表"
"评论详情" -> "游戏评论详情"
else -> ""
}
MtaHelper.onEvent("进入徽章墙_用户记录", key, "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
MtaHelper.onEvent("徽章中心", "进入徽章中心", key)
DirectUtils.directToBadgeWall(context, commentData.replyData!!.user.id, commentData.replyData!!.user.name, commentData.replyData!!.user.icon)
}
override fun onClick(widget: View) {
val key = when (path) {
"游戏详情:介绍" -> "游戏详情-玩家评论"
"游戏详情:评分" -> "游戏详情-评论列表"
"评论详情" -> "游戏评论详情"
else -> ""
}
MtaHelper.onEvent("进入徽章墙_用户记录", key, "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
MtaHelper.onEvent("徽章中心", "进入徽章中心", key)
DirectUtils.directToBadgeWall(context, commentData.replyData!!.user.id, commentData.replyData!!.user.name, commentData.replyData!!.user.icon)
}
}, commentData.replyData?.user?.name!!.length + 2, commentData.replyData?.user?.name!!.length + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
userName.movementMethod = CustomLinkMovementMethod.getInstance()
replyContent.text = contentSpan
}
}, commentData.replyData?.user?.name!!.length + 2, commentData.replyData?.user?.name!!.length + 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
replyContent.movementMethod = CustomLinkMovementMethod.getInstance()
replyContent.text = contentSpan
},{
it.printStackTrace()
})
} else {
name = "${commentData.replyData?.user?.name}${commentData.replyData?.content}"

View File

@ -1,11 +1,10 @@
package com.gh.gamecenter.gamedetail.rating
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.text.SpannableStringBuilder
import android.text.Spanned
@ -48,10 +47,10 @@ import com.gh.gamecenter.manager.UserManager
import com.lightgame.download.DownloadStatus
import com.lightgame.utils.Utils
import com.m7.imkfsdk.utils.DensityUtil
import com.squareup.picasso.MemoryPolicy
import com.squareup.picasso.NetworkPolicy
import com.squareup.picasso.Picasso
import com.squareup.picasso.Target
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
class RatingReplyAdapter(context: Context,
val entrance: String,
@ -452,38 +451,34 @@ class RatingReplyAdapter(context: Context,
}
}
@SuppressLint("CheckResult")
private fun RatingReplyItemBinding.setBadgeSpan(user: UserEntity, replyNameSpannable: SpannableStringBuilder, startIndex: Int, endIndex: Int) {
Picasso.with(mContext).load(Uri.parse(user.badge?.icon))
.priority(Picasso.Priority.HIGH)
.into(object : Target {
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
Single.just(user.badge?.icon)
.map {
Picasso.with(mContext).load(Uri.parse(it)).priority(Picasso.Priority.HIGH).get()
}.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe ({
val bitmapDrawable = BitmapDrawable(mContext.resources, it)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
replyNameSpannable.setSpan(CenterImageSpan(bitmapDrawable), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
replyNameSpannable.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.isUnderlineText = false
}
}
override fun onClick(widget: View) {
MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${user.name}${user.id}")
MtaHelper.onEvent("徽章中心", "进入徽章中心", "游戏评论详情")
DirectUtils.directToBadgeWall(mContext, user.id, user.name, user.icon)
}
override fun onBitmapFailed(errorDrawable: Drawable?) {
}
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
val bitmapDrawable = BitmapDrawable(mContext.resources, bitmap)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
replyNameSpannable.setSpan(CenterImageSpan(bitmapDrawable), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
replyNameSpannable.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.isUnderlineText = false
}
override fun onClick(widget: View) {
MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${user.name}${user.id}")
MtaHelper.onEvent("徽章中心", "进入徽章中心", "游戏评论详情")
DirectUtils.directToBadgeWall(mContext, user.id, user.name, user.icon)
}
}, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
userName.movementMethod = CustomLinkMovementMethod.getInstance()
userName.text = replyNameSpannable
}
}, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
userName.movementMethod = CustomLinkMovementMethod.getInstance()
userName.text = replyNameSpannable
},{
it.printStackTrace()
})
}

View File

@ -164,8 +164,6 @@ public class HaloApp extends TinkerAppLike {
FixedRateJobHelper.begin();
AntiBotHelper.getManager();
// 耗时操作
AppExecutor.getIoExecutor().execute(() -> {
//Leto.init(getApplication(), Config.LETO_APPID);
@ -193,6 +191,8 @@ public class HaloApp extends TinkerAppLike {
if (!TextUtils.isEmpty(barData.getIconUnselect())) {
Picasso.with(getApplication()).load(Uri.parse(barData.getIconUnselect())).fetch();
}
AntiBotHelper.getManager();
});
PlayerFactory.setPlayManager(Exo2PlayerManager.class);
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);

View File

@ -7,7 +7,7 @@ ext {
targetSdkVersion = 26
// application info
versionCode = 180
versionCode = 181
versionName = "4.0.2"
applicationId = "com.gh.gamecenter"

View File

@ -51,8 +51,8 @@ SENSITIVE_API_HOST=https\://and-core-api.ghzs.com/v4d0d2/
# 请不要手动改动下面的值除非你明确需要以某个apk作为基准包需要打包请以scripts/tinker*.sh为准
TINKER_ENABLE=
TINKER_ID=2aa4166
TINKER_BASE_APK_DIR=app-0709-10-15-40_2aa4166
TINKER_ID=df693ce
TINKER_BASE_APK_DIR=app-0710-17-07-17_df693ce
android.useAndroidX=true
android.enableJetifier=true