Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
This commit is contained in:
@ -5,14 +5,17 @@ object SyncFieldConstants {
|
||||
// 是否点赞
|
||||
const val ANSWER_VOTE = "ANSWER_VOTE"
|
||||
const val ARTICLE_VOTE = "ARTICLE_VOTE"
|
||||
const val ARTICLE_COMMENT_VOTE = "ARTICLE_COMMENT_VOTE"
|
||||
|
||||
// 赞同数量
|
||||
const val ANSWER_VOTE_COUNT = "ANSWER_VOTE_COUNT"
|
||||
const val ARTICLE_VOTE_COUNT = "ARTICLE_VOTE_COUNT"
|
||||
const val ARTICLE_COMMENT_VOTE_COUNT = "ARTICLE_COMMENT_VOTE_COUNT"
|
||||
|
||||
// 评论数量
|
||||
const val ANSWER_COMMENT_COUNT = "ANSWER_COMMENT_COUNT"
|
||||
const val ARTICLE_COMMENT_COUNT = "ARTICLE_COMMENT_COUNT"
|
||||
const val ARTICLE_COMMENT_REPLY_COUNT = "ARTICLE_COMMENT_REPLY_COUNT"
|
||||
|
||||
// 回答数量
|
||||
const val ANSWER_COUNT = "ANSWER_COUNT"
|
||||
|
||||
@ -120,7 +120,6 @@ public class PostCommentUtils {
|
||||
final String commentId,
|
||||
final PostCommentListener listener) {
|
||||
|
||||
|
||||
Observable<ResponseBody> observable;
|
||||
|
||||
if (!TextUtils.isEmpty(answerId)) {
|
||||
@ -260,7 +259,6 @@ public class PostCommentUtils {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public interface PostCommentListener {
|
||||
void postSuccess(JSONObject response);
|
||||
|
||||
|
||||
@ -14,11 +14,11 @@ import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.gh.common.DefaultJsApi;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EmptyCallback;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.HtmlUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
@ -69,6 +69,8 @@ public class RichEditor extends WebView {
|
||||
private int mDefaultImageWidth;
|
||||
private int mThumbnailImageWidth;
|
||||
|
||||
private EmptyCallback mInitialLayoutCallback;
|
||||
|
||||
public enum Type {
|
||||
BOLD,
|
||||
ITALIC,
|
||||
@ -173,6 +175,10 @@ public class RichEditor extends WebView {
|
||||
mChromeClientListener = chromeClientListener;
|
||||
}
|
||||
|
||||
public void setLayoutCallback(EmptyCallback layoutCallback) {
|
||||
mInitialLayoutCallback = layoutCallback;
|
||||
}
|
||||
|
||||
private void callback(String text) {
|
||||
mContents = text.replaceFirst(CALLBACK_SCHEME, "");
|
||||
if (mTextChangeListener != null) {
|
||||
@ -720,4 +726,15 @@ public class RichEditor extends WebView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if (mInitialLayoutCallback != null &&getHeight() > 0) {
|
||||
// 仅初次 layout 完成会有回调
|
||||
mInitialLayoutCallback.onCallback();
|
||||
mInitialLayoutCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.gh.common.annotation.SyncPage
|
||||
import com.gh.common.syncpage.SyncFieldConstants
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@ -12,7 +14,9 @@ data class CommentEntity(@SerializedName("_id")
|
||||
@SerializedName("parent_user")
|
||||
var parentUser: CommentParentEntity? = null,
|
||||
var content: String? = null,
|
||||
@SyncPage(syncNames = [SyncFieldConstants.ARTICLE_COMMENT_VOTE, SyncFieldConstants.ARTICLE_COMMENT_VOTE_COUNT])
|
||||
var vote: Int = 0,
|
||||
@SyncPage(syncNames = [SyncFieldConstants.ARTICLE_COMMENT_REPLY_COUNT])
|
||||
var reply: Int = 0,
|
||||
var time: Long = 0,
|
||||
var priority: Int = 0,
|
||||
|
||||
@ -56,6 +56,7 @@ class MeEntity(@SerializedName("is_community_voted")
|
||||
@SerializedName("is_comment_own", alternate = ["is_answer_commented", "is_community_article_commented", "is_video_commented"])
|
||||
var isCommentOwner: Boolean = false, // 是否是当前评论的拥有者
|
||||
|
||||
@SyncPage(syncNames = [SyncFieldConstants.ARTICLE_COMMENT_VOTE])
|
||||
@SerializedName("is_comment_voted", alternate = ["is_answer_comment_voted", "is_video_comment_voted", "is_community_article_comment_voted"])
|
||||
var isCommentVoted: Boolean = false, // 是否已经点赞过当前评论
|
||||
|
||||
|
||||
@ -38,10 +38,16 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
richEditor.setInputEnabled(false)
|
||||
richEditor.setPadding(20, 15, 20, 15)
|
||||
richEditor.addJavascriptInterface(JsInterface(), "imagelistener")
|
||||
richEditor.addJavascriptInterface(OnLinkClickListener(root.context, mEntrance, "社区文章详情"), "OnLinkClickListener")
|
||||
richEditor.addJavascriptInterface(OnLinkClickListener(root.context, mEntrance, "帖子详情"), "OnLinkClickListener")
|
||||
richEditor.setLayoutCallback(object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
viewModel.articleRenderedLiveData.postValue(true)
|
||||
}
|
||||
})
|
||||
|
||||
likeContainer.setDebouncedClickListener {
|
||||
root.context.ifLogin("社区文章详情-赞同") {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "点赞")
|
||||
root.context.ifLogin("帖子详情-赞同") {
|
||||
if (!article.me.isCommunityArticleVote) {
|
||||
viewModel.likeArticle()
|
||||
if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) {
|
||||
@ -54,6 +60,7 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
}
|
||||
|
||||
shareContainer.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "分享")
|
||||
GdtHelper.logAction(ActionType.SHARE,
|
||||
GdtHelper.CONTENT_TYPE, "QA_ARTICLE",
|
||||
GdtHelper.CONTENT_ID, viewModel.articleId)
|
||||
@ -79,7 +86,8 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
}
|
||||
|
||||
starContainer.setDebouncedClickListener {
|
||||
root.context.ifLogin(entrance = "社区文章详情-收藏") {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "收藏")
|
||||
root.context.ifLogin(entrance = "帖子详情-收藏") {
|
||||
viewModel.collectionCommand(!article.me.isCommunityArticleFavorite, callback = {
|
||||
viewModel.detailEntity?.me?.isCommunityArticleFavorite = it
|
||||
if (it) {
|
||||
@ -93,7 +101,8 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
}
|
||||
|
||||
dislikeContainer.setDebouncedClickListener {
|
||||
root.context.ifLogin("社区文章详情-反对") {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "反对")
|
||||
root.context.ifLogin("帖子详情-反对") {
|
||||
if (!article.me.isCommunityArticleOppose) {
|
||||
viewModel.dislikeArticle()
|
||||
} else {
|
||||
@ -103,7 +112,8 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
}
|
||||
|
||||
followBtn.setOnClickListener {
|
||||
root.context.ifLogin("社区文章详情-[关注]用户") {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "关注")
|
||||
root.context.ifLogin("帖子详情-[关注]用户") {
|
||||
if (followBtn.text == "关注") {
|
||||
viewModel.follow()
|
||||
} else {
|
||||
@ -120,9 +130,13 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
}
|
||||
|
||||
userNameTv.setOnClickListener {
|
||||
DirectUtils.directToHomeActivity(root.context, article.user.id, mEntrance, "社区文章详情")
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "用户名字")
|
||||
DirectUtils.directToHomeActivity(root.context, article.user.id, mEntrance, "帖子详情")
|
||||
}
|
||||
userIconContainer.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", "用户名字")
|
||||
DirectUtils.directToHomeActivity(root.context, article.user.id, mEntrance, "帖子详情")
|
||||
}
|
||||
userIconContainer.setOnClickListener { userNameTv.performClick() }
|
||||
|
||||
binding.run {
|
||||
if (article.me.isCommunityArticleFavorite) {
|
||||
@ -173,8 +187,8 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
badgeTv.text = article.user.badge?.name
|
||||
ImageUtils.display(badgeIv, article.user.badge?.icon)
|
||||
badgeIv.setOnClickListener {
|
||||
MtaHelper.onEvent("进入徽章墙_用户记录", "社区文章详情", "${article.user.name}(${article.user.id})")
|
||||
MtaHelper.onEvent("徽章中心", "进入徽章中心", "社区文章详情")
|
||||
MtaHelper.onEvent("进入徽章墙_用户记录", "帖子详情", "${article.user.name}(${article.user.id})")
|
||||
MtaHelper.onEvent("徽章中心", "进入徽章中心", "帖子详情")
|
||||
DirectUtils.directToBadgeWall(root.context, viewModel.detailEntity?.user?.id, article.user.name, article.user.icon)
|
||||
}
|
||||
badgeTv.setOnClickListener { badgeIv.performClick() }
|
||||
@ -259,13 +273,18 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
tagTv.setRoundedColorBackground(R.color.text_F5F5F5, 5F)
|
||||
tagTv.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(root.context, R.drawable.ic_article_detail_forum_tag), null, null, null)
|
||||
tagTv.compoundDrawablePadding = 4F.dip2px()
|
||||
tagTv.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", tag)
|
||||
DirectUtils.directForumDetail(tagTv.context, viewModel.detailEntity?.communityId, "帖子详情")
|
||||
}
|
||||
} else {
|
||||
tagTv.setRoundedColorBackground(R.color.text_EEF5FB, 5F)
|
||||
tagTv.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", tag)
|
||||
MtaHelper.onEvent("问题标签", viewModel.detailEntity?.community?.name, viewModel.detailEntity!!.title + "-" + tag)
|
||||
root.context.startActivity(AskColumnDetailActivity.getIntentByTag(root.context, tag,
|
||||
CommunityEntity(viewModel.detailEntity!!.community.id,
|
||||
viewModel.detailEntity!!.community.name), mEntrance, "问题详情"))
|
||||
viewModel.detailEntity!!.community.name), mEntrance, "帖子详情"))
|
||||
}
|
||||
}
|
||||
tagTv.layoutParams = params
|
||||
@ -294,7 +313,7 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
i++
|
||||
}
|
||||
val intent = ImageViewerActivity.getIntent(binding.root.context, articleImgUrlList, current,
|
||||
mEntrance + "+(社区文章详情[" + binding.titleTv.text.toString() + "])")
|
||||
mEntrance + "+(帖子详情[" + binding.titleTv.text.toString() + "])")
|
||||
(binding.root.context as Activity).startActivityForResult(intent, ImageViewerActivity.REQUEST_FOR_VIEWED_IMAGE)
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,8 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
val commentCount = data?.getIntExtra(CommentActivity.COMMENT_COUNT, 0)
|
||||
if (commentCount != 0 && commentCount != null) {
|
||||
mViewModel.detailEntity?.count?.comment = commentCount
|
||||
bottomCommentTv.text = mViewModel.getCommentText(mViewModel.detailEntity?.count?.comment ?: 0, "评论")
|
||||
bottomCommentTv.text = mViewModel.getCommentText(mViewModel.detailEntity?.count?.comment
|
||||
?: 0, "评论")
|
||||
updateFixedTopFilterView()
|
||||
if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) {
|
||||
LogUtils.uploadCommentFromWelcomeDialog()
|
||||
@ -131,8 +132,8 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
val elapsedTime = mElapsedHelper?.elapsedTime ?: 0
|
||||
val combinedTitleAndId = StringUtils.combineTwoString(mViewModel.detailEntity?.title, mViewModel.detailEntity?.id)
|
||||
|
||||
MtaHelper.onEventWithTime("文章阅读量_社区加位置", elapsedTime, mViewModel.detailEntity?.community?.name, path)
|
||||
MtaHelper.onEventWithTime("文章阅读量_按位置", elapsedTime, path, combinedTitleAndId)
|
||||
MtaHelper.onEventWithTime("帖子阅读量_社区加位置", elapsedTime, mViewModel.detailEntity?.community?.name, path)
|
||||
MtaHelper.onEventWithTime("帖子阅读量_按位置", elapsedTime, path, combinedTitleAndId)
|
||||
|
||||
LogUtils.uploadCommunityArticle(mEntrance,
|
||||
mViewModel.articleId,
|
||||
@ -185,12 +186,14 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
mSkeletonScreen = Skeleton.bind(skeletonView).shimmer(false).load(R.layout.fragment_article_detail_skeleton).show()
|
||||
|
||||
bottomLikeContainer.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "底部", "点赞")
|
||||
mAdapter?.articleDetailVH?.binding?.likeContainer?.performClick()
|
||||
}
|
||||
|
||||
replyTv.text = "说点什么吧"
|
||||
replyTv.setRoundedColorBackground(R.color.text_F0F0F0, 19F)
|
||||
replyTv.setDebouncedClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "底部", "评论输入框")
|
||||
startCommentActivity()
|
||||
}
|
||||
|
||||
@ -201,6 +204,7 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
}
|
||||
|
||||
bottomCommentContainer.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "底部", "评论")
|
||||
mListRv.smoothScrollToPosition(1)
|
||||
}
|
||||
|
||||
@ -254,6 +258,10 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
}
|
||||
}
|
||||
|
||||
mViewModel.articleRenderedLiveData.observeNonNull(this) {
|
||||
showSkeleton(false)
|
||||
}
|
||||
|
||||
mViewModel.followLiveData.observeNonNull(this) { isFollowed ->
|
||||
if (isFollowed) {
|
||||
toast(R.string.concern_success)
|
||||
@ -312,9 +320,17 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
|
||||
private fun initToolbar() {
|
||||
toolbar.inflateMenu(R.menu.menu_answer)
|
||||
toolbar.setNavigationOnClickListener { onBackPressed() }
|
||||
toolbar.setNavigationOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "顶部区域", "返回")
|
||||
onBackPressed()
|
||||
}
|
||||
toolbar.menu.findItem(R.id.menu_more).setOnMenuItemClickListener {
|
||||
consume { mViewModel.detailEntity?.let { showMoreItemDialog() } }
|
||||
consume {
|
||||
mViewModel.detailEntity?.let {
|
||||
showMoreItemDialog()
|
||||
MtaHelper.onEvent("帖子详情", "顶部区域", "更多")
|
||||
}
|
||||
}
|
||||
}
|
||||
toolbar.menu.findItem(R.id.menu_question_and_answer).isVisible = false
|
||||
}
|
||||
@ -351,7 +367,7 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
}
|
||||
|
||||
if (mViewModel.detailEntity?.user?.id == UserManager.getInstance().userId) {
|
||||
reportTv.text = "编辑文章"
|
||||
reportTv.text = "编辑帖子"
|
||||
reportIv.setImageResource(R.drawable.menu_more_edit)
|
||||
}
|
||||
|
||||
@ -361,7 +377,7 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
startActivityForResult(ArticleEditActivity.getPatchIntent(requireContext(), mViewModel.detailEntity!!), ArticleDetailActivity.ARTICLE_PATCH_REQUEST)
|
||||
} else {
|
||||
SuggestionActivity.startSuggestionActivity(requireContext(), SuggestType.normal, "report",
|
||||
"文章投诉(" + mViewModel.articleId + "):")
|
||||
"帖子投诉(" + mViewModel.articleId + "):")
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,8 +392,8 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
private fun showControlDialog(article: ArticleDetailEntity) {
|
||||
val permissions = article.me.moderatorPermissions
|
||||
|
||||
val highlight = "加精文章"
|
||||
val hide = "隐藏文章"
|
||||
val highlight = "加精帖子"
|
||||
val hide = "隐藏帖子"
|
||||
|
||||
var highlightDialogHintContent = ""
|
||||
var hideDialogHintContent = ""
|
||||
@ -411,9 +427,9 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
when (text) {
|
||||
highlight -> {
|
||||
when {
|
||||
article.me.isContentOwner -> toast("不能加精自己的文章")
|
||||
article.me.isContentOwner -> toast("不能加精自己的帖子")
|
||||
|
||||
article.isHighlighted -> toast("文章已经加精")
|
||||
article.isHighlighted -> toast("帖子已经加精")
|
||||
|
||||
else -> DialogUtils.showAlertDialog(requireContext(), highlight, highlightDialogHintContent,
|
||||
"确定", "取消",
|
||||
@ -437,7 +453,8 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
|
||||
bottomContainer.visibility = View.VISIBLE
|
||||
bottomShadowView.visibility = View.VISIBLE
|
||||
bottomCommentTv.text = mViewModel.getCommentText(mViewModel.detailEntity?.count?.comment ?: 0, "评论")
|
||||
bottomCommentTv.text = mViewModel.getCommentText(mViewModel.detailEntity?.count?.comment
|
||||
?: 0, "评论")
|
||||
|
||||
mListRv.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
@ -469,6 +486,10 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
|
||||
}
|
||||
}
|
||||
|
||||
override fun addSyncPageObserver() = true
|
||||
|
||||
override fun provideSyncAdapter() = mAdapter
|
||||
|
||||
private fun startCommentActivity(commentEntity: CommentEntity? = null) {
|
||||
mViewModel.detailEntity?.let {
|
||||
val intent = CommentActivity.getArticleCommentIntent(
|
||||
|
||||
@ -43,6 +43,8 @@ class ArticleDetailViewModel(application: Application,
|
||||
val commentable = MutableLiveData<Boolean>()
|
||||
val followLiveData = mFollowLiveData
|
||||
|
||||
var articleRenderedLiveData = MutableLiveData<Boolean>()
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<List<CommentEntity>> {
|
||||
return RetrofitManager.getInstance(getApplication()).api.getCommunityArticleCommentList(communityId, articleId, currentSortType.value, page)
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.common.syncpage.ISyncAdapterHandler
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
@ -25,7 +26,7 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
private var mViewModel: BaseArticleDetailCommentViewModel,
|
||||
var type: AdapterType,
|
||||
var commentClosure: ((CommentEntity) -> Unit)? = null)
|
||||
: ListAdapter<CommentItemData>(context) {
|
||||
: ListAdapter<CommentItemData>(context), ISyncAdapterHandler {
|
||||
|
||||
var filterVH: ArticleDetailCommentFilterViewHolder? = null
|
||||
|
||||
@ -110,6 +111,13 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyncData(position: Int): Pair<String, Any>? {
|
||||
if (position >= mEntityList.size) return null
|
||||
val item = mEntityList[position]
|
||||
val comment = (item.commentNormal ?: item.commentTop) ?: return null
|
||||
return Pair(comment.id ?: "", comment)
|
||||
}
|
||||
|
||||
inner class ArticleDetailCommentFooterViewHolder(var binding: ItemArticleDetailCommentFooterBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bindView(isLoading: Boolean, isNetworkError: Boolean, isOver: Boolean) {
|
||||
when {
|
||||
@ -145,10 +153,22 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
filterLatestTv.setOnClickListener {
|
||||
mViewModel.changeSort(BaseArticleDetailCommentViewModel.SortType.LATEST)
|
||||
updateSortType()
|
||||
|
||||
if (article == null) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "正序")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "正序")
|
||||
}
|
||||
}
|
||||
filterOldestTv.setOnClickListener {
|
||||
mViewModel.changeSort(BaseArticleDetailCommentViewModel.SortType.OLDEST)
|
||||
updateSortType()
|
||||
|
||||
if (article == null) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "倒序")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "倒序")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,6 +207,7 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
ArticleDetailCommentActivity.getIntent(binding.root.context, comment.id!!, viewModel.communityId, viewModel.articleId, "", "").apply {
|
||||
binding.root.context.startActivity(this)
|
||||
}
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "评论正文")
|
||||
}
|
||||
binding.commentCountTv.text = viewModel.getCommentText(comment.reply, "评论")
|
||||
} else {
|
||||
@ -203,6 +224,7 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
binding.replyBadgeTv.text = it.badge?.name
|
||||
binding.replyUserNameTv.setOnClickListener {
|
||||
DirectUtils.directToHomeActivity(binding.root.context, comment.user.id, 1, "", "")
|
||||
MtaHelper.onEvent("帖子详情", "引用回复区域", "用户名字")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,8 +251,21 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
binding.iconContainer.setOnClickListener {
|
||||
// TODO 补全路径
|
||||
DirectUtils.directToHomeActivity(binding.root.context, comment.user.id, 1, "", "")
|
||||
if (viewModel is ArticleDetailViewModel) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "用户头像")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "用户头像")
|
||||
}
|
||||
}
|
||||
binding.userNameTv.setOnClickListener {
|
||||
DirectUtils.directToHomeActivity(binding.root.context, comment.user.id, 1, "", "")
|
||||
|
||||
if (viewModel is ArticleDetailViewModel) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "用户名字")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "用户名字")
|
||||
}
|
||||
}
|
||||
binding.userNameTv.setOnClickListener { binding.iconContainer.performClick() }
|
||||
|
||||
binding.likeCountTv.text = viewModel.getLikeText(comment.vote)
|
||||
|
||||
@ -244,6 +279,12 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
binding.likeCountTv.context.ifLogin("帖子评论-点赞") {
|
||||
if (comment.me?.isCommentVoted != true) {
|
||||
viewModel.like(comment)
|
||||
|
||||
if (viewModel is ArticleDetailViewModel) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "点赞")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "点赞")
|
||||
}
|
||||
} else {
|
||||
Utils.toast(HaloApp.getInstance().application, "已点过赞了")
|
||||
}
|
||||
@ -251,8 +292,8 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
}
|
||||
|
||||
binding.badgeTv.setOnClickListener {
|
||||
MtaHelper.onEvent("进入徽章墙_用户记录", "社区文章详情-评论管理", comment.user.name + "(" + comment.user.id + ")")
|
||||
MtaHelper.onEvent("徽章中心", "进入徽章中心", "社区文章详情-评论管理")
|
||||
MtaHelper.onEvent("进入徽章墙_用户记录", "帖子详情-评论管理", comment.user.name + "(" + comment.user.id + ")")
|
||||
MtaHelper.onEvent("徽章中心", "进入徽章中心", "帖子详情-评论管理")
|
||||
DirectUtils.directToBadgeWall(binding.root.context, comment.user.id, comment.user.name, comment.user.icon)
|
||||
}
|
||||
binding.badgeIv.setOnClickListener { binding.badgeTv.performClick() }
|
||||
@ -265,6 +306,12 @@ abstract class BaseArticleDetailCommentAdapter(context: Context,
|
||||
viewModel.articleId,
|
||||
viewModel.communityId,
|
||||
null)
|
||||
|
||||
if (viewModel is ArticleDetailViewModel) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "更多")
|
||||
} else {
|
||||
MtaHelper.onEvent("帖子详情", "评论详情", "更多")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,15 +71,28 @@ abstract class BaseArticleDetailCommentFragment<T, VM : BaseArticleDetailComment
|
||||
}
|
||||
|
||||
override fun onLoadRefresh() {
|
||||
// do nothing
|
||||
showSkeleton(true)
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
// do nothing
|
||||
showSkeleton(false)
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
mReuseNoConn?.visibility = View.GONE
|
||||
mReuseNoData?.visibility = View.GONE
|
||||
mListLoading?.visibility = View.GONE
|
||||
|
||||
mListRv.visibility = View.VISIBLE
|
||||
hideRefreshingLayout()
|
||||
|
||||
mListRv.postDelayed({
|
||||
if (provideListAdapter().itemCount < theNumberNeededToFillAScreen()) {
|
||||
autoLoadMore()
|
||||
}
|
||||
}, autoLoadMoreDelay.toLong())
|
||||
}
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration {
|
||||
val insetDivider = InsetDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_article_detail_comment), DisplayUtils.dip2px(20F), 0, DisplayUtils.dip2px(20F), 0)
|
||||
val itemDecoration = CustomDividerItemDecoration(requireContext(), notDecorateTheFirstTwoItems = true, notDecorateTheLastItem = true)
|
||||
|
||||
@ -2,6 +2,9 @@ package com.gh.gamecenter.qa.article.detail
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.syncpage.SyncDataEntity
|
||||
import com.gh.common.syncpage.SyncFieldConstants
|
||||
import com.gh.common.syncpage.SyncPageRepository
|
||||
import com.gh.common.util.CommentDraftContainer
|
||||
import com.gh.common.util.PostCommentUtils
|
||||
import com.gh.common.util.ToastUtils
|
||||
@ -107,6 +110,15 @@ abstract class BaseArticleDetailCommentViewModel(application: Application, var a
|
||||
object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
updateLike(comment.id ?: "", true)
|
||||
comment.id?.let {
|
||||
SyncPageRepository.postSyncData(SyncDataEntity(it,
|
||||
SyncFieldConstants.ARTICLE_COMMENT_VOTE_COUNT,
|
||||
comment.vote + 1))
|
||||
SyncPageRepository.postSyncData(SyncDataEntity(it,
|
||||
SyncFieldConstants.ARTICLE_COMMENT_VOTE,
|
||||
true,
|
||||
checkFieldEntity = true))
|
||||
}
|
||||
}
|
||||
|
||||
override fun postFailed(e: Throwable) {
|
||||
|
||||
@ -96,20 +96,33 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment<CommentIte
|
||||
toolbar.inflateMenu(R.menu.menu_answer)
|
||||
toolbar.setNavigationOnClickListener { onBackPressed() }
|
||||
toolbar.menu.findItem(R.id.menu_more).setOnMenuItemClickListener {
|
||||
consume { }
|
||||
consume { mViewModel.commentDetail?.let { showMoreItemDialog(it, mViewModel.articleId, mViewModel.communityId) } }
|
||||
}
|
||||
toolbar.menu.findItem(R.id.menu_question_and_answer).isVisible = false
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
// if (SyncDataBetweenPageHelper.setResultAndFinish(requireContext(), mViewModel.detailEntity)) {
|
||||
// return true
|
||||
// }
|
||||
private fun showMoreItemDialog(commentDetail: CommentEntity, articleId: String, communityId: String) {
|
||||
if (isAdded) {
|
||||
CommentHelper.showCommunityArticleCommentOptions(
|
||||
toolbar.menu.getItem(2).actionView,
|
||||
commentDetail,
|
||||
false,
|
||||
articleId,
|
||||
communityId,
|
||||
null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
requireActivity().finish()
|
||||
return super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
showSkeleton(false)
|
||||
super.onLoadDone()
|
||||
}
|
||||
|
||||
private fun initObserver() {
|
||||
mViewModel.loadResultLiveData.observeNonNull(this) {
|
||||
when (it) {
|
||||
@ -147,6 +160,7 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment<CommentIte
|
||||
}
|
||||
|
||||
private fun startCommentActivity(comment: CommentEntity) {
|
||||
MtaHelper.onEvent("帖子详情", "全部评论", "输入框")
|
||||
val intent = CommentActivity.getArticleCommentReplyIntent(
|
||||
requireContext(),
|
||||
mViewModel.articleId,
|
||||
|
||||
@ -364,6 +364,11 @@ open class NewCommentFragment : ListFragment<CommentEntity, NewCommentViewModel>
|
||||
return
|
||||
}
|
||||
|
||||
if (mShowInputOnly) {
|
||||
// Fuck pm
|
||||
MtaHelper.onEvent("帖子详情", "评论详情-全部回复", "发送")
|
||||
}
|
||||
|
||||
mViewModel.postComment(content, mCommentEntity)
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,9 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.gh.common.syncpage.SyncDataEntity
|
||||
import com.gh.common.syncpage.SyncFieldConstants
|
||||
import com.gh.common.syncpage.SyncPageRepository
|
||||
import com.gh.common.util.CommentDraftContainer
|
||||
import com.gh.common.util.createRequestBody
|
||||
import com.gh.gamecenter.baselist.ListViewModel
|
||||
@ -110,6 +113,13 @@ open class NewCommentViewModel(application: Application,
|
||||
val apiResponse = ApiResponse<JSONObject>()
|
||||
apiResponse.data = JSONObject()
|
||||
mPostCommentLiveData.postValue(apiResponse)
|
||||
|
||||
commentEntity?.id?.let {
|
||||
SyncPageRepository.postSyncData(SyncDataEntity(
|
||||
it,
|
||||
SyncFieldConstants.ARTICLE_COMMENT_REPLY_COUNT,
|
||||
commentEntity.reply + 1))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
|
||||
Reference in New Issue
Block a user