This commit is contained in:
张玉久
2019-11-27 18:16:09 +08:00
parent e1918b56e2
commit 357b2c2a60
8 changed files with 63 additions and 39 deletions

View File

@ -30,7 +30,7 @@ public class Constants {
public static final String SP_LAST_OPENING_TIME = "last_opening_dialog_time";
public static final String SP_SHOWED_NOTIFICATION_HINT = "show_notification_hint";
//标记安装的游戏为已玩过弹窗,最多取消1
//标记安装的游戏为已玩过弹窗,最多取消2
public static final String SP_MARK_INSTALLED_GAME = "mark_installed_game";
//手机号码匹配规则

View File

@ -69,13 +69,13 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR
}
if (commentData.user.badge != null) {
binding.sdvUserBadge.visibility = View.VISIBLE
binding.tvBadgeName.visibility = View.VISIBLE
ImageUtils.display(binding.sdvUserBadge, commentData.user.badge.icon)
binding.tvBadgeName.text = commentData.user.badge.name
sdvUserBadge.visibility = View.VISIBLE
tvBadgeName.visibility = View.VISIBLE
ImageUtils.display(sdvUserBadge, commentData.user.badge.icon)
tvBadgeName.text = commentData.user.badge.name
} else {
binding.sdvUserBadge.visibility = View.GONE
binding.tvBadgeName.visibility = View.GONE
sdvUserBadge.visibility = View.GONE
tvBadgeName.visibility = View.GONE
}
if (commentData.replyData != null) {
@ -111,7 +111,7 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR
override fun onNewResultImpl(bitmap: Bitmap?) {
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, commentData.replyData?.user?.name!!.length + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
contentSpan.setSpan(CenterImageSpan(bitmapDrawable), commentData.replyData?.user?.name!!.length + 1, commentData.replyData?.user?.name!!.length + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
contentSpan.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
@ -119,15 +119,18 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR
}
override fun onClick(widget: View) {
when (path) {
"游戏详情:介绍" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏详情-玩家评论", "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
"游戏详情:评分" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏详情-评论列表", "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
"评论详情" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
val key = when (path) {
"游戏详情:介绍" -> "游戏详情-玩家评论"
"游戏详情:评分" -> "游戏详情-评论列表"
"评论详情" -> "游戏评论详情"
else -> ""
}
MtaHelper.onEvent("进入徽章墙_用户记录", key, "${commentData.replyData?.user?.name}${commentData.replyData?.user?.id}")
DirectUtils.directToBadgeWall(context, commentData.replyData!!.user.id, commentData.replyData!!.user.name, commentData.replyData!!.user.icon)
}
}, commentData.replyData?.user?.name!!.length, commentData.replyData?.user?.name!!.length + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}, commentData.replyData?.user?.name!!.length + 1, commentData.replyData?.user?.name!!.length + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
userName.movementMethod = LinkMovementMethod.getInstance()
replyContent.text = contentSpan
}
}, CallerThreadExecutor.getInstance())
@ -165,15 +168,17 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR
DirectUtils.directToHomeActivity(context, commentData.user.id, entrance, path)
}
binding.sdvUserBadge.setOnClickListener {
when (path) {
"游戏详情:介绍" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏详情-玩家评论", "${commentData.user.name}${commentData.user.id}")
"游戏详情:评分" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏详情-评论列表", "${commentData.user.name}${commentData.user.id}")
"评论详情" -> MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${commentData.user.name}${commentData.user.id}")
sdvUserBadge.setOnClickListener {
val key = when (path) {
"游戏详情:介绍" -> "游戏详情-玩家评论"
"游戏详情:评分" -> "游戏详情-评论列表"
"评论详情" -> "游戏评论详情"
else -> ""
}
MtaHelper.onEvent("进入徽章墙_用户记录", key, "${commentData.user.name}${commentData.user.id}")
DirectUtils.directToBadgeWall(context, commentData.user.id, commentData.user.name, commentData.user.icon)
}
binding.tvBadgeName.performClick()
tvBadgeName.setOnClickListener { sdvUserBadge.performClick() }
more.setOnClickListener {
showMorePopWindow(it, commentData.user.id == UserManager.getInstance().userId) { text ->

View File

@ -8,12 +8,12 @@ import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import anet.channel.util.Utils.context
import com.facebook.common.executors.CallerThreadExecutor
import com.facebook.common.references.CloseableReference
import com.facebook.datasource.DataSource
@ -247,15 +247,15 @@ class RatingReplyAdapter(context: Context,
val parent = replyEntity.parent
if (parent != null) {
var replyName = "${replyEntity.user.name} 回复 ${parent.user.name}"
var replyNameSpannable = SpanBuilder(replyName).color(mContext, replyEntity.user.name!!.length + 4, replyEntity.user.name!!.length + 6, R.color.text_9a9a9a).build()
if (replyEntity.user.badge != null) {
var replyNameSpannable = SpanBuilder(replyName).color(mContext, parent.user.name!!.length + 5, parent.user.name!!.length + 7, R.color.text_9a9a9a).build()
if (parent.user.badge != null) {
val imagePipeline = Fresco.getImagePipeline()
val imageRequest = ImageRequestBuilder
.newBuilderWithSource(Uri.parse(replyEntity.user.badge.icon))
.newBuilderWithSource(Uri.parse(parent.user.badge.icon))
.setProgressiveRenderingEnabled(true)
.build()
val dataSource = imagePipeline.fetchDecodedImage(imageRequest, context)
val dataSource = imagePipeline.fetchDecodedImage(imageRequest, mContext)
dataSource.subscribe(object : BaseBitmapDataSubscriber() {
override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>?) {
@ -264,7 +264,7 @@ class RatingReplyAdapter(context: Context,
override fun onNewResultImpl(bitmap: Bitmap?) {
val bitmapDrawable = BitmapDrawable(mContext.resources, bitmap)
bitmapDrawable.setBounds(0, 0, DensityUtil.dip2px(16F), DensityUtil.dip2px(16F))
replyNameSpannable.setSpan(CenterImageSpan(bitmapDrawable), replyEntity.user.name!!.length + 1, replyEntity.user.name!!.length + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
replyNameSpannable.setSpan(CenterImageSpan(bitmapDrawable), parent.user.name!!.length + 4, parent.user.name!!.length + 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
replyNameSpannable.setSpan(object : ClickableSpan() {
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
@ -273,16 +273,17 @@ class RatingReplyAdapter(context: Context,
override fun onClick(widget: View) {
MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${replyEntity.user.name}${replyEntity.user.id}")
DirectUtils.directToBadgeWall(context, replyEntity.user.id, replyEntity.user.name, replyEntity.user.icon)
DirectUtils.directToBadgeWall(mContext, replyEntity.user.id, replyEntity.user.name, replyEntity.user.icon)
}
}, replyEntity.user.name!!.length + 1, replyEntity.user.name!!.length + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}, parent.user.name!!.length + 4, parent.user.name!!.length + 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
userName.movementMethod=LinkMovementMethod.getInstance()
userName.text = replyNameSpannable
}
}, CallerThreadExecutor.getInstance())
} else {
replyName = "${replyEntity.user.name} 回复 ${parent.user.name}"
replyNameSpannable = SpanBuilder(replyName).color(mContext, replyEntity.user.name!!.length + 1, replyEntity.user.name!!.length + 3, R.color.text_9a9a9a).build()
replyNameSpannable = SpanBuilder(replyName).color(mContext, parent.user.name!!.length + 1, parent.user.name!!.length + 3, R.color.text_9a9a9a).build()
userName.text = replyName
}
} else {
@ -297,6 +298,12 @@ class RatingReplyAdapter(context: Context,
tvBadgeName.visibility = View.GONE
}
}
sdvUserBadge.setOnClickListener {
MtaHelper.onEvent("进入徽章墙_用户记录", "游戏评论详情", "${replyEntity.user.name}${replyEntity.user.id}")
DirectUtils.directToBadgeWall(mContext, replyEntity.user.id, replyEntity.user.name, replyEntity.user.icon)
}
tvBadgeName.setOnClickListener { sdvUserBadge.performClick() }
vote.setOnClickListener {
mContext.ifLogin("游戏详情-评分-评论详情-点赞评论") {
if (!vote.isChecked) {

View File

@ -29,6 +29,7 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.baselist.ListAdapter;
import com.gh.gamecenter.entity.MessageKeFuEntity;
import com.gh.gamecenter.entity.MessageLinkEntity;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity;
import com.gh.gamecenter.subject.SubjectActivity;
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
@ -121,7 +122,8 @@ public class KeFuFragmentAdapter extends ListAdapter<MessageKeFuEntity> {
if (TextUtils.isEmpty(link.getQq()) &&
TextUtils.isEmpty(link.getId()) &&
TextUtils.isEmpty(link.getUrl()) &&
!"7moor".equals(link.getType())) continue;
!"7moor".equals(link.getType()) &&
!"个人主页".equals(link.getType())) continue;
TextView textView = new TextView(mContext);
textView.setTextColor(mContext.getResources().getColor(R.color.theme));
textView.setTextSize(12F);
@ -286,9 +288,7 @@ public class KeFuFragmentAdapter extends ListAdapter<MessageKeFuEntity> {
}
break;
case "个人主页":
if (!TextUtils.isEmpty(data.getId())) {
DirectUtils.directToHomeActivity(mContext, data.getId(), mEntrance, "(消息-客服)");
}
DirectUtils.directToHomeActivity(mContext, UserManager.getInstance().getUserId(), mEntrance, "(消息-客服)");
break;
default:
DialogUtils.showLowVersionDialog(mContext);

View File

@ -10,6 +10,8 @@ import com.gh.common.dialog.TrackableDialog
import com.gh.common.util.GsonUtils
import com.gh.common.util.MtaHelper
import com.gh.common.util.SPUtils
import com.gh.common.util.dip2px
import com.gh.common.view.SpacingItemDecoration
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.GameInstall
import com.gh.gamecenter.manager.UserManager
@ -24,12 +26,15 @@ import okhttp3.ResponseBody
class InstalledGameDialog(val mContext: Context, val games: ArrayList<GameInstall>, private val mEvent: String, private val mKey: String) :
TrackableDialog(mContext, R.style.DialogWindowTransparent, mEvent, mKey) {
var onConfirmClickListener: (() -> Unit)? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val view = View.inflate(mContext, R.layout.dialog_installed_game, null)
setContentView(view)
view.dialog_installed_game_rv.apply {
layoutManager = GridLayoutManager(context, 4)
addItemDecoration(SpacingItemDecoration(bottom = 24F.dip2px()))
adapter = InstalledGameAdapter(mContext, games)
}
view.dialog_cancel.setOnClickListener {
@ -55,6 +60,7 @@ class InstalledGameDialog(val mContext: Context, val games: ArrayList<GameInstal
.observeOn(Schedulers.io())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
onConfirmClickListener?.invoke()
dismiss()
}
})

View File

@ -1,12 +1,12 @@
package com.gh.gamecenter.personalhome
import android.app.Dialog
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.facebook.drawee.view.SimpleDraweeView
import com.gh.base.adapter.FragmentAdapter
@ -48,7 +48,7 @@ class UserHomeFragment : NormalFragment() {
private lateinit var mUserHomeViewModel: UserHomeViewModel
private lateinit var mUserViewModel: UserViewModel
private lateinit var mMessageUnreadViewModel: MessageUnreadViewModel
private lateinit var mDialog: Dialog
private lateinit var mDialog: InstalledGameDialog
override fun getInflatedLayout(): View {
mHomeBinding = DataBindingUtil.inflate(requireActivity().layoutInflater, R.layout.fragment_home, null, false)
@ -127,16 +127,20 @@ class UserHomeFragment : NormalFragment() {
toast("网络异常")
}
mUserHomeViewModel.playedGames.observeNonNull(this) {
showPlayedGames(it)
mUserHomeViewModel.playedGames.observe(this, Observer {
if (!it.isNullOrEmpty()) {
showPlayedGames(it)
}
val installedList = PackagesManager.getInstalledList()
val count = SPUtils.getInt(Constants.SP_MARK_INSTALLED_GAME, 0)
if (count < 2 && it.isEmpty() && installedList.isNotEmpty()) {
mDialog = InstalledGameDialog(requireContext(), installedList, "个人主页详情", "个人主页详情")
mDialog.show()
mDialog.onConfirmClickListener = {
mUserHomeViewModel.getUserPlayedGame()
}
}
}
})
mMessageUnreadViewModel.liveData.observeNonNull(this) {
updateUnreadInfo(it)

View File

@ -71,6 +71,8 @@ class UserHomeViewModel(application: Application, val userId: String) : AndroidV
if (data.isNotEmpty()) {
playedGames.postValue(data.take(10))
}else{
playedGames.postValue(null)
}
}
})

View File

@ -652,5 +652,5 @@
<item>还不错</item>
<item>完美,太棒了</item>
</string-array>
<string name = "title_installed_game" >以下游戏标记为玩过的游戏</string >
<string name = "title_installed_game" >已安装游戏标记为玩过的游戏</string >
</resources >