diff --git a/app/src/main/java/com/gh/common/util/CommentUtils.java b/app/src/main/java/com/gh/common/util/CommentUtils.java index 7e17331a91..5471cfe04b 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -334,15 +334,16 @@ public class CommentUtils { }); }); } + public static void voteVideoComment(final Context context, - String answerId, - String articleId, - String articleCommunityId, - String videoId, - final CommentEntity commentEntity, - final TextView commentLikeCountTv, - final ImageView commentLikeIv, - final OnVoteListener listener) { + String answerId, + String articleId, + String articleCommunityId, + String videoId, + final CommentEntity commentEntity, + final TextView commentLikeCountTv, + final ImageView commentLikeIv, + final OnVoteListener listener) { String entrance = "视频流-评论-点赞"; CheckLoginUtils.checkLogin(context, entrance, () -> { @@ -389,10 +390,10 @@ public class CommentUtils { } public static void unVoteVideoComment(final Context context, - String videoId, - final CommentEntity commentEntity, - final TextView commentLikeCountTv, - final ImageView commentLikeIv) { + String videoId, + final CommentEntity commentEntity, + final TextView commentLikeCountTv, + final ImageView commentLikeIv) { String entrance = "视频流-评论-取消点赞"; CheckLoginUtils.checkLogin(context, entrance, () -> { RetrofitManager.getInstance(context).getApi() @@ -434,10 +435,10 @@ public class CommentUtils { holder.commentLikeIv.setImageResource(R.drawable.comment_vote_unselect); if (userDataEntity == null || !userDataEntity.isCommentOwner()) { - holder.replyLine.setVisibility(View.VISIBLE); + if (holder.replyLine != null) holder.replyLine.setVisibility(View.VISIBLE); holder.commentReply.setVisibility(View.VISIBLE); } else { - holder.replyLine.setVisibility(View.GONE); + if (holder.replyLine != null) holder.replyLine.setVisibility(View.GONE); holder.commentReply.setVisibility(View.GONE); } diff --git a/app/src/main/java/com/gh/common/util/ShareUtils.java b/app/src/main/java/com/gh/common/util/ShareUtils.java index 98de9e0aad..6d32b49d53 100644 --- a/app/src/main/java/com/gh/common/util/ShareUtils.java +++ b/app/src/main/java/com/gh/common/util/ShareUtils.java @@ -319,7 +319,7 @@ public class ShareUtils { }); } - public void shareGameDetail(Activity activity, String url, String icon, String shareTitle, String shareSummary, ShareEntrance shareEntrance, String id, ShareCallBack callBack) { + public void shareParamsDetail(Activity activity, String url, String icon, String shareTitle, String shareSummary, ShareEntrance shareEntrance, String id, ShareCallBack callBack) { if (activity.isFinishing()) return; this.mActivity = new WeakReference<>(activity); this.shareIcon = icon; @@ -654,6 +654,10 @@ public class ShareUtils { } } + public String getTitle() { + return mTitle; + } + private class ShareRecyclerViewAdapter extends RecyclerView.Adapter { private OnItemClickListener listener; diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java index 68cae4c6e0..6cc6cf9faa 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java @@ -9,6 +9,7 @@ import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.BaseRecyclerViewHolder; import com.gh.gamecenter.R; +import androidx.annotation.Nullable; import butterknife.BindView; /** @@ -33,7 +34,7 @@ public class CommentViewHolder extends BaseRecyclerViewHolder { @BindView(R.id.comment_user_name) public TextView commentUserNameTv; @BindView(R.id.comment_author) - public TextView commentAuthorTv; + public View commentAuthorTv; @BindView(R.id.comment_badge) public View commentBadge; @@ -54,6 +55,7 @@ public class CommentViewHolder extends BaseRecyclerViewHolder { public View commentMore; @BindView(R.id.comment_reply) public View commentReply; + @Nullable @BindView(R.id.reply_dividing_line) public View replyLine; diff --git a/app/src/main/java/com/gh/gamecenter/entity/MenuItemEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/MenuItemEntity.kt index d741082ecd..0afe7ab9fa 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/MenuItemEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/MenuItemEntity.kt @@ -3,5 +3,6 @@ package com.gh.gamecenter.entity data class MenuItemEntity( val text: String = "", val normalIcon: Int = 0, - val disableIcon: Int = 0 + val disableIcon: Int = 0, + val isEnable:Boolean = true ) \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/forum/select/ForumAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/select/ForumAdapter.kt index cb175c8904..8dc6b38389 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/select/ForumAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/select/ForumAdapter.kt @@ -4,20 +4,21 @@ import android.content.Context import android.view.Gravity import android.view.ViewGroup import androidx.core.content.ContextCompat +import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.RecyclerView import com.gh.base.BaseRecyclerViewHolder import com.gh.common.util.* import com.gh.gamecenter.R import com.gh.gamecenter.databinding.ForumItemBinding +import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.entity.ForumEntity import com.gh.gamecenter.eventbus.EBForumFollowChange import com.gh.gamecenter.forum.detail.ForumDetailActivity -import com.gh.gamecenter.forum.home.ForumVisitDao import com.gh.gamecenter.qa.entity.CommunitySelectEntity import com.lightgame.adapter.BaseRecyclerAdapter import org.greenrobot.eventbus.EventBus -class ForumAdapter(context: Context, val mViewModel: ForumSelectViewModel?) : BaseRecyclerAdapter(context) { +class ForumAdapter(val context: Context, val mViewModel: ForumSelectViewModel?, val isSelectForum: Boolean = false, val onSelectCallback: ((entity: CommunityEntity) -> Unit)? = null) : BaseRecyclerAdapter(context) { val datas: ArrayList = arrayListOf() @@ -40,9 +41,14 @@ class ForumAdapter(context: Context, val mViewModel: ForumSelectViewModel?) : Ba val forumEntity = datas[position] holder.binding.entity = forumEntity holder.binding.forumIcon.displayGameIcon(forumEntity.game.getIcon(), forumEntity.game.iconSubscript) + holder.binding.followTv.goneIf(isSelectForum) holder.itemView.setOnClickListener { - MtaHelper.onEvent("论坛首页", "选择论坛", forumEntity.name) - mContext.startActivity(ForumDetailActivity.getIntent(mContext, forumEntity.id, "论坛-选择论坛")) + if (isSelectForum) { + onSelectCallback?.invoke(CommunityEntity(forumEntity.id, forumEntity.name, icon = forumEntity.game.getIcon(), iconSubscript = forumEntity.game.iconSubscript)) + } else { + MtaHelper.onEvent("论坛首页", "选择论坛", forumEntity.name) + mContext.startActivity(ForumDetailActivity.getIntent(mContext, forumEntity.id, "论坛-选择论坛")) + } } holder.binding.followTv.setOnClickListener { mContext.ifLogin("论坛-选择论坛") { diff --git a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt index d3180a877d..920fbdad81 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt @@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.gh.common.util.viewModelProvider import com.gh.gamecenter.R +import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.entity.ForumCategoryEntity import com.gh.gamecenter.eventbus.EBForumFollowChange import com.gh.gamecenter.mvvm.Status @@ -28,6 +29,7 @@ class ForumSelectFragment : NormalFragment() { private var mViewModel: ForumSelectViewModel? = null private var selectCategory: ForumCategoryEntity? = null + var onSelectCallback: ((entity: CommunityEntity) -> Unit)? = null override fun getLayoutId(): Int = R.layout.fragment_forum_select @@ -38,10 +40,12 @@ class ForumSelectFragment : NormalFragment() { mLoadingView.visibility = View.GONE if (it.status == Status.SUCCESS) { if (it.data != null) { - mForumCategoryAdapter?.setListData(it.data) + val data = it.data as ArrayList + if (onSelectCallback != null) data.add(0, ForumCategoryEntity("", "我的关注")) + mForumCategoryAdapter?.setListData(data) if (it.data.isNotEmpty()) { selectCategory = it.data[0] - mViewModel?.getForumByCategoryId(it.data[0].id) + mViewModel?.getForumList(selectCategory) } } mForumCategoryRv.visibility = View.VISIBLE @@ -81,13 +85,13 @@ class ForumSelectFragment : NormalFragment() { mForumCategoryAdapter = ForumCategoryAdapter(requireContext()) { selectCategory = it mLoadingView.visibility = View.VISIBLE - mViewModel?.getForumByCategoryId(it.id) + mViewModel?.getForumList(it) } adapter = mForumCategoryAdapter } mForumRv.apply { layoutManager = LinearLayoutManager(requireContext()) - mForumAdapter = ForumAdapter(requireContext(), mViewModel) + mForumAdapter = ForumAdapter(requireContext(), mViewModel, onSelectCallback != null, onSelectCallback) adapter = mForumAdapter } @@ -97,7 +101,7 @@ class ForumSelectFragment : NormalFragment() { mViewModel?.getForumCategories() } else { mLoadingView.visibility = View.VISIBLE - mViewModel?.getForumByCategoryId(selectCategory?.id ?: "") + mViewModel?.getForumList(selectCategory) } } } diff --git a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectViewModel.kt b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectViewModel.kt index 6f96f1ade5..3f0fa9650e 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectViewModel.kt @@ -8,6 +8,7 @@ import com.gh.common.util.UrlFilterUtils import com.gh.gamecenter.entity.ForumCategoryEntity import com.gh.gamecenter.entity.ForumEntity import com.gh.gamecenter.entity.LinkEntity +import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.mvvm.Resource import com.gh.gamecenter.qa.entity.CommunitySelectOpenEntity import com.gh.gamecenter.retrofit.BiResponse @@ -44,10 +45,15 @@ class ForumSelectViewModel(application: Application) : AndroidViewModel(applicat }) } - fun getForumByCategoryId(categoryId: String) { - RetrofitManager.getInstance(getApplication()).api - .getForumByCategories(categoryId) - .subscribeOn(Schedulers.io()) + fun getForumList(category: ForumCategoryEntity?) { + val observable = if (category?.name != "我的关注") { + RetrofitManager.getInstance(getApplication()).api + .getForumByCategories(category?.id ?: "") + } else { + RetrofitManager.getInstance(getApplication()).api + .getFollowsForum(UserManager.getInstance().userId) + } + observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Response>() { override fun onResponse(response: List?) { @@ -76,6 +82,7 @@ class ForumSelectViewModel(application: Application) : AndroidViewModel(applicat } }) } + @SuppressLint("CheckResult") fun unFollowForum(bbsId: String, onSuccess: () -> Unit) { RetrofitManager.getInstance(getApplication()).api diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt index 1b268f6cd4..9aea2ccb09 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt @@ -102,7 +102,7 @@ class GameDetailMoreDialog : BaseDialogFragment(), View.OnTouchListener { shareEntrance = ShareUtils.ShareEntrance.plugin } } - shareUtils.shareGameDetail(requireActivity(), url, gameEntity?.icon, gameEntity?.name, + shareUtils.shareParamsDetail(requireActivity(), url, gameEntity?.icon, gameEntity?.name, gameEntity?.brief, shareEntrance, gameEntity?.id ?: "", null) return shareUtils } diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt index bcd276cf8b..5018ba0bac 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt @@ -53,7 +53,7 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH val intent = CommentActivity.getAnswerCommentIntent(itemView.context, entity.id!!, entity.commentCount, - entity.commentCount == 0) + false) itemView.context.startActivity(intent) } diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt index 09a5d388e1..35eb1292c4 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt @@ -4,19 +4,17 @@ import android.annotation.SuppressLint import android.app.Activity import android.app.Dialog import android.content.Intent -import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.text.TextUtils import android.view.Gravity import android.view.LayoutInflater import android.view.MenuItem import android.view.View -import android.view.animation.LinearInterpolator import android.webkit.JavascriptInterface import android.widget.ImageView import android.widget.LinearLayout -import android.widget.PopupWindow import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.databinding.BindingAdapter import androidx.databinding.DataBindingUtil @@ -48,6 +46,7 @@ import com.gh.gamecenter.normal.NormalFragment import com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity import com.gh.gamecenter.qa.comment.CommentActivity +import com.gh.gamecenter.qa.dialog.MoreFunctionPanelDialog import com.gh.gamecenter.qa.editor.OnLinkClickListener import com.gh.gamecenter.qa.entity.AnswerDetailEntity import com.gh.gamecenter.qa.entity.Questions @@ -151,6 +150,8 @@ class AnswerDetailFragment : NormalFragment() { mBinding.richEditor.setInputEnabled(false) mBinding.richEditor.setPadding(20, 15, 20, 15) + mBinding.bottomController.replyTv.text = "说点什么吧" + mBinding.bottomController.replyTv.setRoundedColorBackground(R.color.text_F5F5F5, 19F) mElapsedHelper = TimeElapsedHelper(this) // 只对显示在屏幕上的 fragment 计时 @@ -231,8 +232,8 @@ class AnswerDetailFragment : NormalFragment() { val count = data.getIntExtra(CommentActivity.COMMENT_COUNT, 0) if (count != 0) { mViewModel.answerDetail?.commentCount = count - mBinding.bottomController.tvCommentCount.text = String.format("评论 %s", NumberUtils.transSimpleCount(mViewModel.answerDetail?.commentCount - ?: 0)) + mBinding.bottomController.bottomCommentTv.text = NumberUtils.transSimpleCount(mViewModel.answerDetail?.commentCount + ?: 0) if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) { LogUtils.uploadCommentFromWelcomeDialog() @@ -281,7 +282,7 @@ class AnswerDetailFragment : NormalFragment() { if (e != null && e.code() == 404 && e.response().errorBody()!!.string().isNotEmpty()) { HistoryHelper.deleteAnswerEntity(mAnswerId) - mBinding.bottomController.containerControl.visibility = View.GONE + mBinding.bottomController.root.visibility = View.GONE mNoDataTv.setText(R.string.content_delete_hint) mNoData.visibility = View.VISIBLE mNoConn.visibility = View.GONE @@ -308,7 +309,7 @@ class AnswerDetailFragment : NormalFragment() { } else { mNoConn.visibility = View.VISIBLE mBinding.scrollView.visibility = View.GONE - mBinding.bottomController.containerControl.visibility = View.GONE + mBinding.bottomController.root.visibility = View.GONE mBinding.bottomDividerView.visibility = View.GONE mBinding.bottomShadowView.visibility = View.GONE } @@ -486,25 +487,19 @@ class AnswerDetailFragment : NormalFragment() { mBinding.followTv.visibility = View.GONE } else { mBinding.followTv.isEnabled = true - if (!me.isFollower) { - mBinding.followTv.alpha = 1f - mBinding.followTv.visibility = View.VISIBLE - updateFollowBtn(false) - } else { - mBinding.followTv.visibility = View.GONE - } + updateFollowBtn(me.isFollower) } } private fun toggleComment(enable: Boolean, commentCount: Int) { if (enable) { - mBinding.bottomController.ivComment.setImageResource(R.drawable.community_content_detail_comment_open) - mBinding.bottomController.tvCommentCount.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) - mBinding.bottomController.tvCommentCount.text = String.format("评论 %d", commentCount) + mBinding.bottomController.bottomCommentIv.setImageResource(R.drawable.community_content_detail_comment_open) + mBinding.bottomController.bottomCommentTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) + mBinding.bottomController.bottomCommentTv.text = if (commentCount > 0) commentCount.toString() else "评论" } else { - mBinding.bottomController.ivComment.setImageResource(R.drawable.community_content_detail_comment_close) - mBinding.bottomController.tvCommentCount.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_b3b3b3)) - mBinding.bottomController.tvCommentCount.text = "评论已关闭" + mBinding.bottomController.bottomCommentIv.setImageResource(R.drawable.community_content_detail_comment_close) + mBinding.bottomController.bottomCommentTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_b3b3b3)) + mBinding.bottomController.bottomCommentTv.text = "评论已关闭" } } @@ -609,78 +604,76 @@ class AnswerDetailFragment : NormalFragment() { private fun showMoreItemDialog(answer: AnswerDetailEntity) { if (fragmentIsVisible()) { - val view = LayoutInflater.from(context).inflate(R.layout.menu_answer_detail_more_new, null) - val popupWindow = PopupWindow( - view, - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ) - popupWindow.apply { - setBackgroundDrawable(ColorDrawable(0)) - isTouchable = true - isFocusable = true - isOutsideTouchable = true - } - view.measure(0, 0) - val viewWidth = view.measuredWidth - popupWindow.showAsDropDown((activity as ToolBarActivity).menu.getItem(2).actionView, -viewWidth - 10, 10) - - val container = view.findViewById(R.id.container) val entities = ArrayList() - entities.add(MenuItemEntity("首页", R.drawable.menu_more_home)) if (answer.user.id != UserManager.getInstance().userId) { - entities.add(MenuItemEntity("投诉", R.drawable.ic_menu_gamedetail_feedback)) + entities.add(MenuItemEntity("投诉", R.drawable.icon_gamedetail_copyright)) } if (answer.me.isModerator) { - entities.add(MenuItemEntity("加精", R.drawable.menu_more_essence_enable, - if (answer.isHighlighted || answer.user.id == UserManager.getInstance().userId) - R.drawable.menu_more_essence_unenable else 0)) - entities.add(MenuItemEntity("折叠", R.drawable.menu_more_fold)) + val isEnable = answer.isHighlighted || answer.user.id == UserManager.getInstance().userId + entities.add(MenuItemEntity("加精", if (isEnable) + R.drawable.icon_more_panel_essence_unenable else R.drawable.icon_more_panel_essence, + isEnable = !isEnable)) + + entities.add(MenuItemEntity("折叠", R.drawable.icon_more_panel_fold)) } if (answer.user.id == UserManager.getInstance().userId) { - entities.add(MenuItemEntity(if (answer.commentable) "关闭评论" else "恢复评论", if (answer.commentable) R.drawable.ic_close_comment else R.drawable.ic_open_comment)) + entities.add(MenuItemEntity(if (answer.commentable) "关闭评论" else "恢复评论", if (answer.commentable) R.drawable.icon_more_panel_close_comment_enable + else R.drawable.icon_more_panel_close_comment_unenable)) } if (answer.me.isModerator || answer.user.id == UserManager.getInstance().userId) { - entities.add(MenuItemEntity("删除", R.drawable.menu_more_delete)) + entities.add(MenuItemEntity("删除", R.drawable.icon_more_panel_delete)) } - entities.forEachIndexed { index, item -> - val menuItem = createMenuItem(index, item) - container.addView(menuItem) - menuItem.setOnClickListener { - popupWindow.dismiss() - when (item.text) { - "首页" -> { - val community = mViewModel.answerDetail?.community - MtaHelper.onEvent("回到首页", "回答详情", community?.name + "+" + StringUtils.combineTwoString(mViewModel.answerDetail?.content, mViewModel.answerDetail?.id)) - DirectUtils.directToCommunity(requireContext(), community) - } - "投诉" -> { - SuggestionActivity.startSuggestionActivity(context, SuggestType.normal, "report", "回答投诉($mAnswerId):") - } - "加精" -> { - addEssenceForum(answer) - } - "折叠" -> { - foldForum(answer) - } - "关闭评论", "恢复评论" -> { - if (mViewModel.answerDetail?.commentable!!) { - DialogUtils.showAlertDialog(requireContext(), "提示", "关闭评论之后,该回答将无法查看和发表评论,确定关闭吗?", - "确定", "取消", { mViewModel.toggleComment(mAnswerId, false) }, null) - } else { - DialogUtils.showAlertDialog(requireContext(), "提示", "确定恢复评论吗?", - "确定", "取消", { mViewModel.toggleComment(mAnswerId, true) }, null) - } - } - "删除" -> { - DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除回答后,其中的所有回复都将被删除", "取消", "删除", {}, { - mViewModel.doHideThisAnswer(mAnswerId) - }) + val shareIcon: String = if (mAnswersImages!!.size > 0) { + mAnswersImages[0] + } else { + getString(R.string.share_ghzs_logo) + } + var shareSummary = mBinding.richEditor.text + if (TextUtils.isEmpty(shareSummary)) { + shareSummary = getString(R.string.ask_share_default_summary) + } + val shareUrl = if (isPublishEnv()) { + getString(R.string.share_answers_url, mAnswerId) + } else { + getString(R.string.share_answers_url_dev, answer.question.id, mAnswerId) + } + val shareUtils = ShareUtils.getInstance(context) + shareUtils.shareParamsDetail(activity, + shareUrl, + shareIcon, + getString(R.string.ask_share_answers_title, answer.user.name, answer.question.title, answer.vote), + shareSummary, + ShareUtils.ShareEntrance.answerNormal, mAnswerId, null) + MoreFunctionPanelDialog.showMoreDialog(requireActivity() as AppCompatActivity, entities, answer.question.title + ?: "", shareUtils) { + when (it.text) { + "投诉" -> { + SuggestionActivity.startSuggestionActivity(context, SuggestType.normal, "report", "回答投诉($mAnswerId):") + } + "加精" -> { + addEssenceForum(answer) + } + "折叠" -> { + foldForum(answer) + } + "关闭评论", "恢复评论" -> { + if (mViewModel.answerDetail?.commentable!!) { + DialogUtils.showAlertDialog(requireContext(), "提示", "关闭评论之后,该回答将无法查看和发表评论,确定关闭吗?", + "确定", "取消", { mViewModel.toggleComment(mAnswerId, false) }, null) + } else { + DialogUtils.showAlertDialog(requireContext(), "提示", "确定恢复评论吗?", + "确定", "取消", { mViewModel.toggleComment(mAnswerId, true) }, null) } } + "删除" -> { + DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除回答后,其中的所有回复都将被删除", "取消", "删除", {}, { + mViewModel.doHideThisAnswer(mAnswerId) + }) + } } } + } } @@ -731,17 +724,12 @@ class AnswerDetailFragment : NormalFragment() { } @OnClick( - R.id.iv_comment, - R.id.tv_comment_count, - R.id.iv_collect, - R.id.tv_collect, - R.id.iv_share, - R.id.tv_share, - R.id.container_dislike, + R.id.replyTv, + R.id.bottomStarContainer, R.id.reuse_no_connection, R.id.status_tv, + R.id.bottomLikeContainer, R.id.answer_count_container, - R.id.container_like, R.id.follow_tv, R.id.user_icon_iv, R.id.questionsdetail_item_pic1, @@ -758,11 +746,11 @@ class AnswerDetailFragment : NormalFragment() { mViewModel.getAnswerDetail(mAnswerId, mEntrance) } - R.id.iv_share, R.id.tv_share -> { - shareAnswer() - } +// R.id.iv_share, R.id.tv_share -> { +// shareAnswer() +// } - R.id.iv_collect, R.id.tv_collect -> { + R.id.bottomStarContainer -> { ifLogin("回答详情-收藏") { mViewModel.answerDetail?.let { if (!it.me.isAnswerFavorite) { @@ -777,42 +765,32 @@ class AnswerDetailFragment : NormalFragment() { startActivity(QuestionsDetailActivity.getIntent(context, mViewModel.answerDetail!!.question.id, mEntrance, "回答详情")) } - R.id.container_like -> debounceActionWithInterval(R.id.container_like, 1000) { - ifLogin("回答详情-赞同") { - if (mViewModel.answerDetail != null && !mViewModel.answerDetail!!.me.isAnswerVoted) { - mViewModel.like(mAnswerId) + R.id.bottomLikeContainer -> { + debounceActionWithInterval(R.id.container_like, 1000) { + ifLogin("回答详情-赞同") { + if (mViewModel.answerDetail != null && !mViewModel.answerDetail!!.me.isAnswerVoted) { + mViewModel.like(mAnswerId) - if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) { - LogUtils.uploadLikeFromWelcomeDialog() - } + if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) { + LogUtils.uploadLikeFromWelcomeDialog() + } - DataUtils.onMtaEvent(context, - "答案点赞量_社区加位置", - mViewModel.answerDetail?.community?.name, - mPath) - } else { - mViewModel.cancelLike(mAnswerId) - } - } - } - - R.id.container_dislike -> debounceActionWithInterval(R.id.container_like, 1000) { - ifLogin("回答详情-反对") { - mViewModel.answerDetail?.let { - if (it.me.isAnswerOpposed) { - mViewModel.cancelDislike(mAnswerId) + DataUtils.onMtaEvent(context, + "答案点赞量_社区加位置", + mViewModel.answerDetail?.community?.name, + mPath) } else { - mViewModel.dislike(mAnswerId) + mViewModel.cancelLike(mAnswerId) } } } } - R.id.iv_comment, R.id.tv_comment_count -> { + R.id.replyTv -> { mViewModel.answerDetail?.run { if (commentable) { DataUtils.onMtaEvent(context, "详情页面", "答案评论详情", content.subStringIfPossible(30)) - showCommentDialog(commentCount == 0) + showCommentDialog(false) } else { toast("作者已关闭评论") } @@ -853,6 +831,8 @@ class AnswerDetailFragment : NormalFragment() { ifLogin("回答详情-[关注]用户") { if (mBinding.followTv.text == "关注") { mViewModel.follow(mViewModel.answerDetail!!.user.id!!) + } else { + mViewModel.unfollow(mViewModel.answerDetail!!.user.id!!) } } } @@ -883,10 +863,6 @@ class AnswerDetailFragment : NormalFragment() { R.id.questionsdetail_item_pic3 -> showQuestionImageDetail(view, 2 - videoSize) R.id.title_tv -> { -// startActivity(QuestionsDetailActivity.getIntent( -// context, -// mViewModel.answerDetail?.question?.id, mEntrance, -// "回答详情")) val intent = QuestionsDetailActivity.getIntent( context, mViewModel.answerDetail?.question?.id, mEntrance, @@ -931,13 +907,13 @@ class AnswerDetailFragment : NormalFragment() { private fun updateCollectView(isCollected: Boolean) { if (isCollected) { - mBinding.bottomController.tvCollect.text = "已收藏" - mBinding.bottomController.ivCollect.setImageResource(R.drawable.community_content_detail_collect_select) - mBinding.bottomController.tvCollect.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font)) + mBinding.bottomController.bottomStarIv.setImageResource(R.drawable.community_content_detail_collect_select) + mBinding.bottomController.bottomStarTv.text = "已收藏" + mBinding.bottomController.bottomStarTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font)) } else { - mBinding.bottomController.tvCollect.text = "收藏" - mBinding.bottomController.ivCollect.setImageResource(R.drawable.community_content_detail_collect_unselect) - mBinding.bottomController.tvCollect.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) + mBinding.bottomController.bottomStarIv.setImageResource(R.drawable.community_content_detail_collect_unselect) + mBinding.bottomController.bottomStarTv.text = "收藏" + mBinding.bottomController.bottomStarTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) } } @@ -989,7 +965,7 @@ class AnswerDetailFragment : NormalFragment() { if (mIsShowCommentManager) { mIsShowCommentManager = false - mBinding.bottomController.ivComment.performClick() + mBinding.bottomController.bottomCommentContainer.performClick() } mBinding.richEditor.clearFocus() @@ -1013,7 +989,7 @@ class AnswerDetailFragment : NormalFragment() { private fun hideLoadingViewAndShowContent() { mNoConn.visibility = View.GONE - mBinding.bottomController.containerControl.visibility = View.VISIBLE + mBinding.bottomController.root.visibility = View.VISIBLE mBinding.scrollView.visibility = View.VISIBLE } @@ -1126,21 +1102,11 @@ class AnswerDetailFragment : NormalFragment() { } private fun updateFollowBtn(isFollowed: Boolean) { + mBinding.followTv.visibility = View.VISIBLE if (isFollowed) { - if (mBinding.followTv.visibility == View.GONE) return DrawableView.setTextDrawable(mBinding.followTv, null, "已关注") mBinding.followTv.setTextColor(R.color.text_999999.toColor()) - mBinding.followTv.postDelayed({ - if (context == null) return@postDelayed - mBinding.followTv.animate() - .alpha(0f) - .setInterpolator(LinearInterpolator()) - .doOnEnd { context?.let { mBinding.followTv.visibility = View.GONE } } - .setDuration(500L) - .start() - }, 2000L) } else { - mBinding.followTv.visibility = View.VISIBLE mBinding.followTv.background = DrawableView.getOvalDrawable(R.color.background, 2F) mBinding.followTv.setTextColor(R.color.theme_font.toColor()) DrawableView.setTextDrawable( @@ -1152,22 +1118,24 @@ class AnswerDetailFragment : NormalFragment() { @SuppressLint("SetTextI18n") private fun updateLikeView(alreadyVoted: Boolean, voteCount: Int) { - mBinding.bottomController.tvLike.text = "赞同 ${NumberUtils.transSimpleCount(voteCount)}" +// mBinding.bottomController.bottomLikeTv.text = "赞同 ${NumberUtils.transSimpleCount(voteCount)}" if (alreadyVoted) { - mBinding.bottomController.ivLike.setImageResource(R.drawable.community_content_detail_vote_select) - mBinding.bottomController.tvLike.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font)) + mBinding.bottomController.bottomLikeIv.setImageResource(R.drawable.community_content_detail_vote_select) + mBinding.bottomController.bottomLikeTv.text = NumberUtils.transSimpleCount(voteCount) + mBinding.bottomController.bottomLikeTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font)) } else { - mBinding.bottomController.ivLike.setImageResource(R.drawable.community_content_detail_vote_unselect) - mBinding.bottomController.tvLike.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) + mBinding.bottomController.bottomLikeIv.setImageResource(R.drawable.community_content_detail_vote_unselect) + mBinding.bottomController.bottomLikeTv.text = "赞同" + mBinding.bottomController.bottomLikeTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) } } private fun updateDislikeView(disliked: Boolean) { - if (disliked) { - mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_select) - } else { - mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_unselect) - } +// if (disliked) { +// mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_select) +// } else { +// mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_unselect) +// } } private fun showDragHintDialog() { diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailContentViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailContentViewHolder.kt index f50911a941..e6601214d3 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailContentViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailContentViewHolder.kt @@ -44,77 +44,6 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin } }) - likeContainer.setDebouncedClickListener { - MtaHelper.onEvent("帖子详情", "内容区域", "点赞") - root.context.ifLogin("帖子详情-赞同") { - if (!article.me.isCommunityArticleVote) { - viewModel.likeArticle() - if (EntranceUtils.ENTRANCE_WELCOME == mEntrance) { - LogUtils.uploadLikeFromWelcomeDialog() - } - } else { - viewModel.cancelLikeArticle() - } - } - } - - shareContainer.setOnClickListener { - MtaHelper.onEvent("帖子详情", "内容区域", "分享") -// GdtHelper.logAction(ActionType.SHARE, -// GdtHelper.CONTENT_TYPE, "QA_ARTICLE", -// GdtHelper.CONTENT_ID, viewModel.articleId) - - var shareSummary = richEditor.text - val shareIcon: String = if (articleImgUrlList.size > 0) { - articleImgUrlList[0] - } else { - root.context.getString(R.string.share_ghzs_logo) - } - if (TextUtils.isEmpty(shareSummary)) { - shareSummary = root.context.getString(R.string.ask_share_default_summary) - } - val shareUrl = if (isPublishEnv()) { - root.context.getString(R.string.share_community_article_url, article.community.id, article.id) - } else { - root.context.getString(R.string.share_community_article_url_dev, article.community.id, article.id) - } - ShareUtils.getInstance(root.context).showShareWindows( - root.context as Activity?, - root, - shareUrl, - shareIcon, - root.context.getString(R.string.share_community_article_title, article.user.name, article.title, article.count.vote), - shareSummary, - ShareUtils.ShareEntrance.communityArticle, - article.id) - } - - starContainer.setDebouncedClickListener { - MtaHelper.onEvent("帖子详情", "内容区域", "收藏") - root.context.ifLogin(entrance = "帖子详情-收藏") { - viewModel.collectionCommand(!article.me.isCommunityArticleFavorite, callback = { - viewModel.detailEntity?.me?.isCommunityArticleFavorite = it - if (it) { -// GdtHelper.logAction(ActionType.ADD_TO_WISHLIST, -// GdtHelper.CONTENT_TYPE, "QA_ARTICLE", -// GdtHelper.CONTENT_ID, viewModel.articleId) - } - updateCollectView(it) - }) - } - } - - dislikeContainer.setDebouncedClickListener { - MtaHelper.onEvent("帖子详情", "内容区域", "反对") - root.context.ifLogin("帖子详情-反对") { - if (!article.me.isCommunityArticleOppose) { - viewModel.dislikeArticle() - } else { - viewModel.cancelDislikeArticle() - } - } - } - followBtn.setOnClickListener { MtaHelper.onEvent("帖子详情", "内容区域", "关注") root.context.ifLogin("帖子详情-[关注]用户") { @@ -143,14 +72,6 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin } binding.run { - if (article.me.isCommunityArticleFavorite) { - starIv.setImageResource(R.drawable.ic_article_detail_stared) - starTv.text = "已收藏" - } else { - starIv.setImageResource(R.drawable.ic_article_detail_star) - starTv.text = "收藏" - } - detail = article userIconIv.display(article.user.border, article.user.icon, article.user.auth?.icon) richEditor.setContentOwner(article.me.isContentOwner) @@ -160,9 +81,9 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin } if (article.time.create == article.time.edit) { - releaseTimeTv.text = String.format("发布于 %s", NewsUtils.getFormattedTime(article.time.create)) + releaseTimeTv.text = String.format("发布于%s", NewsUtils.getFormattedTime(article.time.create)) } else { - releaseTimeTv.text = String.format("修改于 %s", NewsUtils.getFormattedTime(article.time.edit)) + releaseTimeTv.text = String.format("发布于%s 最后编辑于%s", NewsUtils.getFormattedTime(article.time.create), NewsUtils.getFormattedTime(article.time.edit)) } richEditor.visibility = View.VISIBLE @@ -199,9 +120,6 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin } } badgeTv.setOnClickListener { badgeIv.performClick() } - - updateLikeView(article.me.isCommunityArticleVote, article.count.vote) - updateDislikeView(article.me.isCommunityArticleOppose) } } } @@ -213,16 +131,6 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin followBtn.text = "已关注" followBtn.background = null followBtn.setTextColor(ContextCompat.getColor(root.context, R.color.text_999999)) - followBtn.postDelayed({ - followBtn.animate() - .alpha(0f) - .setInterpolator(LinearInterpolator()) - .doOnEnd { - tryWithDefaultCatch { followBtn.visibility = View.GONE } - } - .setDuration(500L) - .start() - }, 2000L) } else { followBtn.setRoundedColorBackground(R.color.text_EEF5FB, 14F) followBtn.setTextColor(ContextCompat.getColor(root.context, R.color.theme_font)) @@ -231,40 +139,6 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin } } - @SuppressLint("SetTextI18n") - fun updateLikeView(alreadyLiked: Boolean, likeCount: Int) { - binding.run { - likeTv.text = if (likeCount == 0) "赞同" else likeCount.toString() - if (alreadyLiked) { - likeIv.setImageResource(R.drawable.ic_article_detail_liked) - } else { - likeIv.setImageResource(R.drawable.ic_article_detail_like) - } - } - } - - fun updateDislikeView(disliked: Boolean) { - binding.run { - if (disliked) { - dislikeIv.setImageResource(R.drawable.ic_article_detail_disliked) - } else { - dislikeIv.setImageResource(R.drawable.ic_article_detail_dislike) - } - } - } - - fun updateCollectView(isCollected: Boolean) { - binding.run { - if (isCollected) { - starTv.text = "已收藏" - starIv.setImageResource(R.drawable.ic_article_detail_stared) - } else { - starTv.text = "收藏" - starIv.setImageResource(R.drawable.ic_article_detail_star) - } - } - } - private fun addTag(tag: String, isCommunityName: Boolean = false) { binding.run { if (isCommunityName) { diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailFragment.kt index ccc2e6adf0..59e49c5920 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/detail/ArticleDetailFragment.kt @@ -3,15 +3,14 @@ package com.gh.gamecenter.qa.article.detail import android.annotation.SuppressLint import android.app.Activity import android.content.Intent -import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout -import android.widget.PopupWindow import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.view.ViewCompat import androidx.lifecycle.Lifecycle @@ -37,6 +36,7 @@ import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.personal.PersonalFragment import com.gh.gamecenter.qa.article.edit.ArticleEditActivity import com.gh.gamecenter.qa.comment.CommentActivity +import com.gh.gamecenter.qa.dialog.MoreFunctionPanelDialog import com.gh.gamecenter.qa.entity.ArticleDetailEntity import com.gh.gamecenter.suggest.SuggestType import com.halo.assistant.HaloApp @@ -183,11 +183,29 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment(R.id.container) val entities = ArrayList() if (mViewModel.detailEntity?.user?.id == UserManager.getInstance().userId) { - entities.add(MenuItemEntity("修改", R.drawable.menu_more_edit)) + entities.add(MenuItemEntity("修改", R.drawable.icon_more_panel_edit)) } if (mViewModel.detailEntity?.user?.id != UserManager.getInstance().userId) { - entities.add(MenuItemEntity("投诉", R.drawable.ic_menu_gamedetail_feedback)) + entities.add(MenuItemEntity("投诉", R.drawable.icon_gamedetail_copyright)) } if (mViewModel.detailEntity?.me!!.isModerator) { - entities.add(MenuItemEntity("加精", R.drawable.menu_more_essence_enable, - if (mViewModel.detailEntity?.isHighlighted == true || mViewModel.detailEntity?.user?.id == UserManager.getInstance().userId) - R.drawable.menu_more_essence_unenable else 0)) + val isEnable = mViewModel.detailEntity?.isHighlighted == true || mViewModel.detailEntity?.user?.id == UserManager.getInstance().userId + entities.add(MenuItemEntity("加精", if (isEnable) + R.drawable.icon_more_panel_essence_unenable else R.drawable.icon_more_panel_essence, isEnable = !isEnable)) } if (mViewModel.detailEntity?.me!!.isModerator || mViewModel.detailEntity?.user?.id == UserManager.getInstance().userId) { - entities.add(MenuItemEntity("删除", R.drawable.menu_more_delete)) + entities.add(MenuItemEntity("删除", R.drawable.icon_more_panel_delete)) } - entities.forEachIndexed { index, item -> - val menuItem = createMenuItem(index, item) - container.addView(menuItem) - menuItem.setOnClickListener { - popupWindow.dismiss() - when (item.text) { - "修改" -> { - startActivityForResult(ArticleEditActivity.getPatchIntent(requireContext(), mViewModel.detailEntity!!), ArticleDetailActivity.ARTICLE_PATCH_REQUEST) - } - "投诉" -> { - SuggestionActivity.startSuggestionActivity(requireContext(), SuggestType.normal, "report", - "帖子投诉(" + mViewModel.articleId + "):") - } - "加精" -> addEssenceForum(mViewModel.detailEntity!!) - "删除" -> { - DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除帖子后,其中的所有评论及回复都将被删除", "取消", "删除", {}, { - mViewModel.doHideThisArticle(mViewModel.detailEntity!!.community.id, mViewModel.articleId) - }) - } + val shareUrl = if (isPublishEnv()) { + requireContext().getString(R.string.share_community_article_url, mViewModel.communityId, mViewModel.detailEntity?.id) + } else { + requireContext().getString(R.string.share_community_article_url_dev, mViewModel.communityId, mViewModel.detailEntity?.id) + } + + val shareIcon: String = if (mViewModel.detailEntity?.images?.isNotEmpty() == true) { + mViewModel.detailEntity?.images!![0] + } else { + requireContext().getString(R.string.share_ghzs_logo) + } + val title = requireContext().getString(R.string.share_community_article_title, mViewModel.detailEntity?.user?.name, + mViewModel.detailEntity?.title, mViewModel.detailEntity?.count?.vote ?: 0) + val shareUtils = ShareUtils.getInstance(requireContext()) + shareUtils.shareParamsDetail(requireActivity(), + shareUrl, + shareIcon, + title, + HtmlUtils.stripHtml(mViewModel.detailEntity?.content), + ShareUtils.ShareEntrance.communityArticle, + mViewModel.detailEntity?.id, null) + MoreFunctionPanelDialog.showMoreDialog(requireActivity() as AppCompatActivity, entities, mViewModel.detailEntity?.title + ?: "", shareUtils) { + when (it.text) { + "修改" -> { + startActivityForResult(ArticleEditActivity.getPatchIntent(requireContext(), mViewModel.detailEntity!!), ArticleDetailActivity.ARTICLE_PATCH_REQUEST) + } + "投诉" -> { + SuggestionActivity.startSuggestionActivity(requireContext(), SuggestType.normal, "report", + "帖子投诉(" + mViewModel.articleId + "):") + } + "加精" -> addEssenceForum(mViewModel.detailEntity!!) + "删除" -> { + DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除帖子后,其中的所有评论及回复都将被删除", "取消", "删除", {}, { + mViewModel.doHideThisArticle(mViewModel.detailEntity!!.community.id, mViewModel.articleId) + }) } } } @@ -465,11 +483,11 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment : ListFragment() { @@ -39,6 +43,7 @@ abstract class BaseArticleDetailCommentFragment?, displayFloor: Boolean = false) { + fun mergeListData(commentList: List?, displayFloor: Boolean = false, hasFilter: Boolean = true) { topItemData?.let { val mergedList = arrayListOf().apply { - if (mResultLiveData.value?.firstOrNull() != null) { - // 保持头两个 item 的内存地址不变 - add(mResultLiveData.value!![0]) - add(mResultLiveData.value!![1]) + if (hasFilter) { + if (mResultLiveData.value?.firstOrNull() != null) { + // 保持头两个 item 的内存地址不变 + add(mResultLiveData.value!![0]) + add(mResultLiveData.value!![1]) + } else { + add(topItemData!!) + add(CommentItemData(filter = true)) + } } else { add(topItemData!!) - add(CommentItemData(filter = true)) } if (commentList.isNullOrEmpty() && mLoadStatusLiveData.value == LoadStatus.INIT_EMPTY) { add(CommentItemData(errorEmpty = true)) diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentAdapter.kt index a75598c149..e59907f961 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentAdapter.kt @@ -65,9 +65,9 @@ class ArticleDetailCommentAdapter(context: Context, binding.comment = comment binding.moreIv.visibility = View.GONE + binding.divider.visibility = View.VISIBLE + binding.commentCountTv.visibility = View.GONE binding.floorHintTv.text = if (comment.floor != 0) "${comment.floor}楼" else "" - binding.commentCountTv.text = mViewModel.getCommentText(comment.reply, "回复") - binding.commentCountTv.setOnClickListener { commentClosure?.invoke(comment) } binding.contentTv.text = comment.content binding.contentTv.maxLines = Int.MAX_VALUE diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentFragment.kt index d64e4456c8..fa1a72d4b0 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentFragment.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.ViewCompat import com.ethanhua.skeleton.Skeleton +import com.gh.common.AppExecutor import com.gh.common.util.* import com.gh.gamecenter.R import com.gh.gamecenter.baselist.ListAdapter @@ -45,7 +46,6 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment - (toolbarContainer.layoutParams as ViewGroup.MarginLayoutParams).topMargin = insets.systemWindowInsetTop - insets.consumeSystemWindowInsets() - } - mSkeletonScreen = Skeleton.bind(skeletonView).shimmer(false).load(R.layout.fragment_article_detail_comment_skeleton).show() bottomLikeContainer.visibility = View.GONE + bottomStarContainer.visibility = View.GONE bottomCommentContainer.visibility = View.GONE val lp = replyTv.layoutParams as ConstraintLayout.LayoutParams @@ -99,46 +95,7 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment { - DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除评论后,评论下所有的回复都将被删除", "取消", "删除", null, { - mViewModel.hideCommunityArticleComment(entity.id ?: "") { - EventBus.getDefault().post(EBDeleteCommentDetail(entity.id)) - requireActivity().finish() - } - }) - } - else -> { - //do nothing - } - } - } - - }) - } + closeIv.setOnClickListener { requireActivity().finish() } } override fun onBackPressed(): Boolean { @@ -170,18 +127,18 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment 2) { + mListRv.smoothScrollToPosition(1) + } + }, 100) } else -> { if (it == BaseArticleDetailCommentViewModel.LoadResult.DELETED) { mReuseNoConn?.visibility = View.GONE mReuseNoData?.visibility = View.VISIBLE toast(R.string.content_delete_toast) - - toolbar.menu?.run { - for (i in 0 until size()) { - getItem(i).isVisible = false - } - } } else { mReuseNoConn?.visibility = View.VISIBLE mReuseNoData?.visibility = View.GONE diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentViewModel.kt index 901c2b185a..8a4e29d54e 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/detail/comment/ArticleDetailCommentViewModel.kt @@ -26,7 +26,7 @@ class ArticleDetailCommentViewModel(application: Application, override fun provideDataObservable(page: Int): Observable>? = null override fun mergeResultLiveData() { - mResultLiveData.addSource(mListLiveData) { mergeListData(it) } + mResultLiveData.addSource(mListLiveData) { mergeListData(it, hasFilter = false) } } override fun provideDataSingle(page: Int): Single> { @@ -46,7 +46,7 @@ class ArticleDetailCommentViewModel(application: Application, commentCount = data.reply topItemData = CommentItemData(commentTop = data) loadResultLiveData.postValue(LoadResult.SUCCESS) - mergeListData(mListLiveData.value) + mergeListData(mListLiveData.value, hasFilter = false) } override fun onFailure(exception: Exception) { diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt index 4f0bd794c3..4d5c587799 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt @@ -35,6 +35,7 @@ import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.mvvm.Status import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity import com.gh.gamecenter.qa.article.draft.ArticleDraftActivity +import com.gh.gamecenter.qa.dialog.ChooseForumDialogFragment import com.gh.gamecenter.qa.entity.ArticleDetailEntity import com.gh.gamecenter.qa.entity.ArticleDraftEntity import com.gh.gamecenter.qa.questions.edit.TagsSelectFragment @@ -171,10 +172,10 @@ class ArticleEditActivity : BaseRichEditorActivity(), KeyboardHeightObserver { closeExtendedKeyboard() AppExecutor.uiExecutor.executeWithDelay(Runnable { Util_System_Keyboard.showSoftKeyboard(this) - },100) + }, 100) AppExecutor.uiExecutor.executeWithDelay(Runnable { - mRichEditor.scrollTo(0,1000000) - },500) + mRichEditor.scrollTo(0, 1000000) + }, 500) } checkPostButtonEnable() } @@ -279,14 +280,15 @@ class ArticleEditActivity : BaseRichEditorActivity(), KeyboardHeightObserver { setNavigationTitle("发布帖子") mBaseHandler.sendEmptyMessageDelayed(1, SAVE_DRAFTS_INTERVAL_TIME.toLong()) mViewModel.mSelectCommunityData = intent.getParcelableExtra(CommunityEntity::class.java.simpleName) - if (mViewModel.mSelectCommunityData == null) { - showSelectGameDialog() - } else { + if (mViewModel.mSelectCommunityData != null) { setGameName() mGameName.isEnabled = false mGameName.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) } } + mViewModel.notSelectForum.observe(this, Observer { + if (it) showSelectGameDialog() + }) } override fun getSelectedLabel(): Int = mViewModel.selectedTags.size @@ -503,27 +505,10 @@ class ArticleEditActivity : BaseRichEditorActivity(), KeyboardHeightObserver { } private fun showSelectGameDialog() { - val selectGameDialog = Dialog(this) - val view = View.inflate(this, R.layout.dialog_article_game, null) - val recyclerView = view.findViewById(R.id.dialog_game_list) - val back = view.findViewById(R.id.dialog_back) - val loading = view.findViewById(R.id.dialog_loading) - - back.setOnClickListener { - selectGameDialog.cancel() - if (mViewModel.mSelectCommunityData == null) finish() - } - recyclerView.layoutManager = GridLayoutManager(this, 4) - recyclerView.adapter = ArticleSelectGameAdapter(this, loading) { - mViewModel.mSelectCommunityData = CommunityEntity(it.id, it.name, icon = it.game.icon, iconSubscript = it.game.iconSubscript) + ChooseForumDialogFragment.show(this) { + mViewModel.mSelectCommunityData = it setGameName() - selectGameDialog.cancel() } - - selectGameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) - selectGameDialog.setCanceledOnTouchOutside(false) - selectGameDialog.setContentView(view) - selectGameDialog.show() } private fun setGameName() { diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditViewModel.kt index 1ec0aa922d..cbdbb2aa13 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditViewModel.kt @@ -48,6 +48,7 @@ class ArticleEditViewModel(application: Application) : AndroidViewModel(applicat val postArticleDrafts = MediatorLiveData>() val articleDraftsContent = MediatorLiveData() val error = MutableLiveData() + val notSelectForum = MutableLiveData() var uploadImageSubscription: Disposable? = null @@ -88,25 +89,17 @@ class ArticleEditViewModel(application: Application) : AndroidViewModel(applicat * 根据问题标题获取相应标签(问题编辑无需获取) */ fun checkDataAndLoadTitleTag(isKeyBoardShow: Boolean = false): Boolean { - if (mSelectCommunityData == null) { - ToastUtils.showToast("请选择论坛", if (isKeyBoardShow) Gravity.CENTER else -1) - return false - } - if (TextUtils.isEmpty(title)) { ToastUtils.showToast("标题不能为空", if (isKeyBoardShow) Gravity.CENTER else -1) return false } - // 检查标题长度限制 title?.trim() -// title = title?.replace(" ", "")?.replace("\n", "") title = title?.replace("\n", "") if (title!!.length < QuestionEditViewModel.QUESTION_TITLE_MIN_LENGTH) { ToastUtils.showToast("标题至少${QuestionEditViewModel.QUESTION_TITLE_MIN_LENGTH}个字", if (isKeyBoardShow) Gravity.CENTER else -1) return false } - val articleContent = HtmlUtils.stripHtml(content).length if (articleContent < MIN_ARTICLE_TEXT_LENGTH) { ToastUtils.showToast("正文至少${QuestionEditViewModel.QUESTION_TITLE_MIN_LENGTH}个字", if (isKeyBoardShow) Gravity.CENTER else -1) @@ -116,6 +109,11 @@ class ArticleEditViewModel(application: Application) : AndroidViewModel(applicat ToastUtils.showToast("帖子最多输入${MAX_ARTICLE_TEXT_LENGTH}个字", if (isKeyBoardShow) Gravity.CENTER else -1) return false } + if (mSelectCommunityData == null) { + ToastUtils.showToast("请选择论坛", if (isKeyBoardShow) Gravity.CENTER else -1) + notSelectForum.postValue(true) + return false + } return true } diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentActivity.kt index 0a3ce8b66e..0cb44fec34 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentActivity.kt @@ -8,10 +8,14 @@ import android.view.View import butterknife.OnClick import com.gh.base.BaseActivity import com.gh.common.util.DisplayUtils +import com.gh.common.util.EntranceUtils import com.gh.common.util.doOnEnd +import com.gh.gamecenter.NormalActivity import com.gh.gamecenter.R import com.gh.gamecenter.entity.CommentEntity import com.gh.gamecenter.qa.answer.detail.AnswerDetailFragment +import com.gh.gamecenter.qa.article.detail.comment.ArticleDetailCommentActivity +import com.gh.gamecenter.qa.article.detail.comment.ArticleDetailCommentFragment import com.lightgame.utils.Util_System_Keyboard import kotlinx.android.synthetic.main.activity_comment.* @@ -39,6 +43,7 @@ class CommentActivity : BaseActivity() { val commentEntity: CommentEntity? = intent.getParcelableExtra(COMMENT_ENTITY) ?: null val useReplyApi: Boolean = intent.getBooleanExtra(USE_REPLY_API, false) + val articleCommentId = intent.getStringExtra(EntranceUtils.KEY_ARTICLE_COMMENT_ID) mShowInputOnly = intent.getBooleanExtra(SHOW_INPUT_ONLY, false) @@ -68,16 +73,18 @@ class CommentActivity : BaseActivity() { } else if (!articleId.isNullOrEmpty()) { NewCommentFragment.getCommunityArticleCommentInstance( articleId, - communityId?:"", + communityId, showKeyboard, commentCount, mShowInputOnly, useReplyApi, commentEntity, commentCallback) + } else if (!articleCommentId.isNullOrEmpty()) { + ArticleDetailCommentFragment().with(intent.extras) } else { NewCommentFragment.getVideoCommentInstance( - videoId?:"", + videoId, showKeyboard, commentCount, isVideoAuthor, @@ -86,7 +93,7 @@ class CommentActivity : BaseActivity() { } } - supportFragmentManager.beginTransaction().replace(R.id.answerCommentPlaceholderView, commentFragment, NewCommentFragment::class.java.simpleName).commitNowAllowingStateLoss() + supportFragmentManager.beginTransaction().replace(R.id.answerCommentPlaceholderView, commentFragment!!, NewCommentFragment::class.java.simpleName).commitNowAllowingStateLoss() maskView.alpha = 0f if (videoId.isNullOrEmpty()) { @@ -158,6 +165,26 @@ class CommentActivity : BaseActivity() { return intent } + @JvmStatic + fun getArticleDetailCommentIntent(context: Context, + commentId: String, + communityId: String, + articleId: String, + showKeyboard: Boolean = false, + position: Int = -1, + entrance: String, + path: String): Intent { + val intent = Intent(context, CommentActivity::class.java) + intent.putExtra(EntranceUtils.KEY_ENTRANCE, NormalActivity.mergeEntranceAndPath(entrance, path)) + intent.putExtra(EntranceUtils.KEY_COMMUNITY_ARTICLE_ID, articleId) + intent.putExtra(EntranceUtils.KEY_COMMUNITY_ID, communityId) + intent.putExtra(EntranceUtils.KEY_POSITION, position) + intent.putExtra(EntranceUtils.KEY_ARTICLE_COMMENT_ID, commentId) + intent.putExtra(EntranceUtils.KEY_SHOW_KEYBOARD_IF_NEEDED, showKeyboard) + intent.putExtra(EntranceUtils.KEY_PATH, path) + return intent + } + @JvmStatic fun getArticleCommentIntent(context: Context, articleId: String, diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt index 5a3cf695ed..f9bdc55180 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt @@ -1,6 +1,7 @@ package com.gh.gamecenter.qa.comment import android.content.Context +import android.text.SpannableStringBuilder import android.text.TextUtils import android.view.View import android.view.ViewGroup @@ -14,6 +15,7 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder import com.gh.gamecenter.baselist.ListAdapter import com.gh.gamecenter.entity.CommentEntity import com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity +import com.gh.gamecenter.qa.article.detail.BaseArticleDetailCommentAdapter class NewCommentAdapter(context: Context, var mViewModel: NewCommentViewModel, @@ -27,7 +29,7 @@ class NewCommentAdapter(context: Context, val view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false) FooterViewHolder(view) } else { - val view = mLayoutInflater.inflate(R.layout.comment_item, parent, false) + val view = mLayoutInflater.inflate(R.layout.new_comment_item, parent, false) AnswerCommentViewHolder(view) } } @@ -55,11 +57,29 @@ class NewCommentAdapter(context: Context, val commentEntity = mEntityList[position] CommentUtils.setCommentUserView(mContext, holder, commentEntity) CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.time) + if (commentEntity.parentUser != null) { + val prefix = "回复" + val colon = " :" + val parentUserName = " ${commentEntity.parentUser?.name} " - if (!TextUtils.isEmpty(mViewModel.videoId)) { - holder.commentContentTv.setTextWithHighlightedTextWrappedInsideWrapper( - text = commentEntity.content ?: "", - copyClickedText = true) + val prefixSpan = SpanBuilder(prefix).color(holder.itemView.context, 0, prefix.length, R.color.text_999999).build() + val parentUserNameSpan = SpanBuilder(parentUserName) + .click(0, parentUserName.length, R.color.text_666666) { + DirectUtils.directToHomeActivity(holder.itemView.context, commentEntity.user.id, 1, mEntrance, "") + }.build() + val colonSpan = SpanBuilder(colon).color(holder.itemView.context, 0, colon.length, R.color.text_999999).build() + val authorSpan = if (commentEntity.parentUser?.me?.isCommentOwner == true) { + SpanBuilder("作者").image(0, "作者".length, R.drawable.ic_hint_author).build() + } else { + "" + } + + holder.commentContentTv.text = SpannableStringBuilder() + .append(prefixSpan) + .append(parentUserNameSpan) + .append(authorSpan) + .append(colonSpan) + .append(commentEntity.content) } else { holder.commentContentTv.text = commentEntity.content } @@ -69,43 +89,6 @@ class NewCommentAdapter(context: Context, return@OnLongClickListener true }) - val parentUser = commentEntity.parentUser - if (parentUser != null && !TextUtils.isEmpty(parentUser.name)) { - holder.quoteContainer.visibility = View.VISIBLE - holder.quoteAuthorTv.text = String.format("@%s", parentUser.name) - - val comment: String? - if (parentUser.active) { - comment = parentUser.comment - holder.quoteContentTv.setTextColor(mContext.resources.getColor(R.color.text_5d5d5d)) - } else { - comment = mContext.getString(R.string.comment_hide_hint) - holder.quoteContentTv.setTextColor(mContext.resources.getColor(R.color.text_d5d5d5)) - } - if (!TextUtils.isEmpty(mViewModel.videoId)) { - holder.quoteContentTv.setTextWithHighlightedTextWrappedInsideWrapper( - text = comment ?: "", - copyClickedText = true) - } else { - holder.quoteContentTv.text = comment - } - } else { - holder.quoteContainer.visibility = View.GONE - } - if (parentUser?.active == true) { - holder.quoteContentTv.setOnLongClickListener(View.OnLongClickListener { - isChildLongClick = true - parentUser.comment?.replace(RatingEditActivity.LABEL_REPLACE_REGEX.toRegex(), "")?.copyTextAndToast() - return@OnLongClickListener true - }) - } - if (parentUser?.badge != null) { - holder.quoteAuthorBadgeSdv.visibility = View.VISIBLE - ImageUtils.display(holder.quoteAuthorBadgeSdv, parentUser.badge!!.icon) - } else { - holder.quoteAuthorBadgeSdv.visibility = View.GONE - } - val key = when (mEntrance) { "(答案详情-评论列表)" -> "回答详情-评论管理" "(文章详情-评论列表)" -> "社区文章详情-评论管理" diff --git a/app/src/main/java/com/gh/gamecenter/qa/dialog/ChooseForumDialogFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/dialog/ChooseForumDialogFragment.kt new file mode 100644 index 0000000000..492b4e543b --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/dialog/ChooseForumDialogFragment.kt @@ -0,0 +1,74 @@ +package com.gh.gamecenter.qa.dialog + +import android.app.Dialog +import android.os.Bundle +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.FragmentTransaction +import com.gh.base.fragment.BaseDialogFragment +import com.gh.gamecenter.R +import com.gh.gamecenter.databinding.DialogChooseForumBinding +import com.gh.gamecenter.entity.CommunityEntity +import com.gh.gamecenter.forum.select.ForumSelectFragment +import com.halo.assistant.HaloApp + +class ChooseForumDialogFragment : BaseDialogFragment() { + private lateinit var binding: DialogChooseForumBinding + var onSelectCallback: ((entity: CommunityEntity) -> Unit)? = null + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + binding = DialogChooseForumBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val beginTransaction = childFragmentManager.beginTransaction() + val forumSelectFragment = childFragmentManager.findFragmentByTag(ForumSelectFragment::class.java.simpleName) as? ForumSelectFragment + ?: ForumSelectFragment() + forumSelectFragment.onSelectCallback = { + onSelectCallback?.invoke(it) + dismissAllowingStateLoss() + } + beginTransaction.replace(binding.container.id, forumSelectFragment, ForumSelectFragment::class.java.simpleName) + beginTransaction.commitAllowingStateLoss() + binding.closeIv.setOnClickListener { dismissAllowingStateLoss() } + } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val createDialog = super.onCreateDialog(savedInstanceState) + createDialog.setCanceledOnTouchOutside(true) + + val window = createDialog.window + window?.setGravity(Gravity.BOTTOM) + window?.setWindowAnimations(R.style.community_publication_animation) + return createDialog + } + + override fun onStart() { + super.onStart() + val width = HaloApp.getInstance().application.resources.displayMetrics.widthPixels + val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT + dialog?.window?.setLayout(width, height) + } + + + companion object { + fun show(activity: AppCompatActivity, onSelectCallback: ((entity: CommunityEntity) -> Unit)) { + var fragment = activity.supportFragmentManager.findFragmentByTag(ChooseForumDialogFragment::class.java.name) as? ChooseForumDialogFragment + if (fragment == null) { + fragment = ChooseForumDialogFragment() + fragment.onSelectCallback = onSelectCallback + fragment.show(activity.supportFragmentManager, ChooseForumDialogFragment::class.java.name) + } else { + fragment.onSelectCallback = onSelectCallback + val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction() + transaction.show(fragment) + transaction.commit() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt b/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt new file mode 100644 index 0000000000..e81cf7afa2 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt @@ -0,0 +1,193 @@ +package com.gh.gamecenter.qa.dialog + +import android.app.Dialog +import android.os.Bundle +import android.view.* +import android.widget.LinearLayout +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import androidx.fragment.app.FragmentTransaction +import com.gh.base.fragment.BaseDialogFragment +import com.gh.common.util.MtaHelper +import com.gh.common.util.ShareUtils +import com.gh.common.util.dip2px +import com.gh.gamecenter.R +import com.gh.gamecenter.databinding.DialogGameDetailMoreBinding +import com.gh.gamecenter.entity.MenuItemEntity +import com.halo.assistant.HaloApp + +class MoreFunctionPanelDialog : BaseDialogFragment(), View.OnTouchListener { + + private lateinit var binding: DialogGameDetailMoreBinding + private lateinit var mGestureDetector: GestureDetector + private var mInitPositionY = 0f + var menuItems: ArrayList = arrayListOf() + var title: String = "" + var shareUrl: String = "" + var shareUtils: ShareUtils? = null + var onItemClickCallback: ((menuItem: MenuItemEntity) -> Unit)? = null + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + binding = DialogGameDetailMoreBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.gameNameTv.text = title + binding.gameNameTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_666666)) + binding.gameIconView.visibility = View.GONE + binding.feedbackTv.visibility = View.GONE + binding.copyrightTv.visibility = View.GONE + mGestureDetector = GestureDetector(requireContext(), SingleTapConfirm()) + binding.dragClose.setOnTouchListener(this) + binding.shareWechatTv.setOnClickListener { + shareUtils?.wechatShare() + MtaHelper.onEvent("内容分享", "微信好友", shareUtils?.title) + } + binding.sharePyquanTv.setOnClickListener { + shareUtils?.wechatMomentsShare() + MtaHelper.onEvent("内容分享", "微信朋友圈", shareUtils?.title) + } + binding.shareQqTv.setOnClickListener { + shareUtils?.qqShare() + MtaHelper.onEvent("内容分享", "QQ好友", shareUtils?.title) + } + binding.shareQqzoneTv.setOnClickListener { + shareUtils?.qZoneShare() + MtaHelper.onEvent("内容分享", "QQ空间", shareUtils?.title) + } + binding.shareWeiboTv.setOnClickListener { + shareUtils?.sinaWeiboShare() + MtaHelper.onEvent("内容分享", "新浪微博", shareUtils?.title) + } + binding.shareSmsTv.setOnClickListener { + shareUtils?.shortMessageShare() + MtaHelper.onEvent("内容分享", "短信", shareUtils?.title) + } + binding.copyLinkTv.setOnClickListener { + shareUtils?.copyLink(shareUrl) + MtaHelper.onEvent("内容分享", "复制链接", shareUtils?.title) + } + binding.cancelTv.setOnClickListener { + dismissAllowingStateLoss() + } + addActionItem() + } + + private fun addActionItem() { + menuItems.forEachIndexed { _, menuItemEntity -> + val itemView = createItemView(menuItemEntity) + itemView.setOnClickListener { + onItemClickCallback?.invoke(menuItemEntity) + dismissAllowingStateLoss() + } + binding.actionContainer.addView(itemView) + } + } + + private fun createItemView(itemEntity: MenuItemEntity): View { + val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) + params.leftMargin = 16f.dip2px() + return TextView(requireContext()).apply { + textSize = 11f + text = itemEntity.text + setTextColor(ContextCompat.getColor(requireContext(), if (itemEntity.isEnable) R.color.text_666666 else R.color.text_999999)) + includeFontPadding = false + gravity = Gravity.CENTER + layoutParams = params + compoundDrawablePadding = 8f.dip2px() + setCompoundDrawablesWithIntrinsicBounds(null, ContextCompat.getDrawable(requireContext(), itemEntity.normalIcon), null, null) + } + } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val createDialog = super.onCreateDialog(savedInstanceState) + createDialog.setCanceledOnTouchOutside(true) + + val window = createDialog.window + window?.setGravity(Gravity.BOTTOM) + window?.setWindowAnimations(R.style.community_publication_animation) + return createDialog + } + + override fun onTouch(v: View, event: MotionEvent): Boolean { + if (mGestureDetector.onTouchEvent(event) && binding.root.y == 0F) { + v.performClick() + return true + } + when (event.action) { + MotionEvent.ACTION_DOWN -> { + mInitPositionY = binding.root.y - event.rawY + } + MotionEvent.ACTION_MOVE -> { + val offsetY = event.rawY + mInitPositionY + val dialogY = binding.root.y + if (dialogY + offsetY > 0) { + binding.root.animate() + .y(offsetY) + .setDuration(0) + .start() + } else { + resetDialogPosition() + } + } + MotionEvent.ACTION_CANCEL, + MotionEvent.ACTION_UP, + MotionEvent.ACTION_OUTSIDE -> { + if (binding.root.y >= binding.root.height / 2) { + dismissAllowingStateLoss() + } else { + resetDialogPosition(300) + } + } + else -> return false + } + return true + } + + private fun resetDialogPosition(duration: Long = 0) { + binding.root.animate() + .y(0F) + .setDuration(duration) + .start() + } + + override fun onStart() { + super.onStart() + val width = HaloApp.getInstance().application.resources.displayMetrics.widthPixels + val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT + dialog?.window?.setLayout(width, height) + } + + private class SingleTapConfirm : GestureDetector.SimpleOnGestureListener() { + override fun onSingleTapUp(event: MotionEvent): Boolean { + return true + } + } + + companion object { + @JvmStatic + fun showMoreDialog(activity: AppCompatActivity, menuItems: ArrayList, title: String, shareUtils: ShareUtils, onItemClickCallback: (menuItem: MenuItemEntity) -> Unit) { + if (menuItems.isNullOrEmpty()) return + var fragment = activity.supportFragmentManager.findFragmentByTag(MoreFunctionPanelDialog::class.java.name) as? MoreFunctionPanelDialog + if (fragment == null) { + fragment = MoreFunctionPanelDialog() + fragment.menuItems = menuItems + fragment.title = title + fragment.shareUtils = shareUtils + fragment.onItemClickCallback = onItemClickCallback + fragment.show(activity.supportFragmentManager, MoreFunctionPanelDialog::class.java.name) + } else { + fragment.menuItems = menuItems + fragment.title = title + fragment.shareUtils = shareUtils + fragment.onItemClickCallback = onItemClickCallback + val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction() + transaction.show(fragment) + transaction.commit() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerFragment.kt index ed85877375..2394e6536a 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerFragment.kt @@ -1,14 +1,38 @@ package com.gh.gamecenter.qa.editor +import android.os.Bundle +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.RecyclerView.ItemDecoration +import com.gh.common.util.viewModelProvider +import com.gh.common.view.CustomDividerItemDecoration +import com.gh.gamecenter.R import com.gh.gamecenter.baselist.ListFragment import com.gh.gamecenter.qa.entity.AnswerEntity class AnswerFragment : ListFragment() { private var mAdapter: AnswerAdapter? = null + private var mAnswerType: InsertAnswerWrapperActivity.AnswerType = InsertAnswerWrapperActivity.AnswerType.MINE_ANSWER + + override fun onCreate(savedInstanceState: Bundle?) { + mAnswerType = arguments?.getSerializable(InsertAnswerWrapperActivity.KEY_ANSWER_TYPE) as InsertAnswerWrapperActivity.AnswerType + super.onCreate(savedInstanceState) + } + + override fun provideListViewModel(): AnswerViewModel { + return viewModelProvider(AnswerViewModel.Factory(mAnswerType)) + } override fun provideListAdapter(): AnswerAdapter { if (mAdapter == null) mAdapter = AnswerAdapter(requireContext(), mEntrance) return mAdapter!! } + + override fun getItemDecoration(): ItemDecoration? { + val insetDivider = ContextCompat.getDrawable(requireContext(), R.drawable.divider_item_line) + val itemDecoration = CustomDividerItemDecoration(requireContext(), notDecorateTheLastItem = true) + itemDecoration.setDrawable(insetDivider!!) + return itemDecoration + } + } diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerViewModel.kt index d58b92526a..640d2b2139 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/AnswerViewModel.kt @@ -2,16 +2,29 @@ package com.gh.gamecenter.qa.editor import android.app.Application import androidx.annotation.Keep +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider import com.gh.gamecenter.baselist.ListViewModel +import com.gh.gamecenter.entity.UserEntity import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.qa.entity.AnswerEntity import com.gh.gamecenter.retrofit.RetrofitManager +import com.halo.assistant.HaloApp +import com.lightgame.utils.Utils import io.reactivex.Observable @Keep -class AnswerViewModel(application: Application) : ListViewModel(application) { +class AnswerViewModel(application: Application, private val answerType: InsertAnswerWrapperActivity.AnswerType) : ListViewModel(application) { + + override fun provideDataObservable(page: Int): Observable> { - return RetrofitManager.getInstance(getApplication()).api.getCollectionAnswer(UserManager.getInstance().userId, page) + + return if (answerType == InsertAnswerWrapperActivity.AnswerType.MINE_ANSWER) { + RetrofitManager.getInstance(getApplication()).api.getMyAnswers(UserManager.getInstance().userId, page, + HaloApp.getInstance().channel, Utils.getTime(getApplication())) + } else { + RetrofitManager.getInstance(getApplication()).api.getCollectionAnswer(UserManager.getInstance().userId, page) + } } override fun mergeResultLiveData() { @@ -28,6 +41,20 @@ class AnswerViewModel(application: Application) : ListViewModel create(modelClass: Class): T { + return AnswerViewModel(HaloApp.getInstance().application, answerType) as T + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleFragment.kt index d09f452741..db2ab8784a 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleFragment.kt @@ -1,14 +1,37 @@ package com.gh.gamecenter.qa.editor +import android.os.Bundle +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.RecyclerView +import com.gh.common.util.viewModelProvider +import com.gh.common.view.CustomDividerItemDecoration +import com.gh.gamecenter.R import com.gh.gamecenter.baselist.ListFragment import com.gh.gamecenter.qa.entity.ArticleEntity class ArticleFragment : ListFragment() { private var mAdapter: ArticleAdapter? = null + private var mArticleType: InsertArticleWrapperActivity.ArticleType = InsertArticleWrapperActivity.ArticleType.MINE_ARTICLE + + override fun onCreate(savedInstanceState: Bundle?) { + mArticleType = arguments?.getSerializable(InsertArticleWrapperActivity.KEY_ARTICLE_TYPE) as InsertArticleWrapperActivity.ArticleType + super.onCreate(savedInstanceState) + } + + override fun provideListViewModel(): ArticleViewModel { + return viewModelProvider(ArticleViewModel.Factory(mArticleType)) + } override fun provideListAdapter(): ArticleAdapter { - if (mAdapter == null) mAdapter = ArticleAdapter(context!!, mEntrance) + if (mAdapter == null) mAdapter = ArticleAdapter(requireContext(), mEntrance) return mAdapter!! } + + override fun getItemDecoration(): RecyclerView.ItemDecoration? { + val insetDivider = ContextCompat.getDrawable(requireContext(), R.drawable.divider_item_line) + val itemDecoration = CustomDividerItemDecoration(requireContext(), notDecorateTheLastItem = true) + itemDecoration.setDrawable(insetDivider!!) + return itemDecoration + } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleViewModel.kt index d0346d0927..9e6b96ad31 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/ArticleViewModel.kt @@ -2,17 +2,24 @@ package com.gh.gamecenter.qa.editor import android.app.Application import androidx.annotation.Keep +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider import com.gh.gamecenter.baselist.ListViewModel import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.qa.entity.ArticleEntity import com.gh.gamecenter.retrofit.RetrofitManager +import com.halo.assistant.HaloApp import io.reactivex.Observable @Keep -class ArticleViewModel(application: Application) : ListViewModel(application) { +class ArticleViewModel(application: Application, private val articleType: InsertArticleWrapperActivity.ArticleType) : ListViewModel(application) { override fun provideDataObservable(page: Int): Observable> { - return RetrofitManager.getInstance(getApplication()).api.getCollectionCommunityArticle(UserManager.getInstance().userId, page) + return if (articleType == InsertArticleWrapperActivity.ArticleType.MINE_ARTICLE) { + RetrofitManager.getInstance(HaloApp.getInstance().application).api.getMyArticle(UserManager.getInstance().userId, page) + } else { + RetrofitManager.getInstance(getApplication()).api.getCollectionCommunityArticle(UserManager.getInstance().userId, page) + } } override fun mergeResultLiveData() { @@ -32,4 +39,10 @@ class ArticleViewModel(application: Application) : ListViewModel create(modelClass: Class): T { + return ArticleViewModel(HaloApp.getInstance().application, articleType) as T + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/InsertAnswerWrapperActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/InsertAnswerWrapperActivity.kt index 34b8de4b63..05ebef7ec4 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/InsertAnswerWrapperActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/InsertAnswerWrapperActivity.kt @@ -3,37 +3,35 @@ package com.gh.gamecenter.qa.editor import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import com.gh.base.BaseActivity_TabLayout +import com.gh.gamecenter.R class InsertAnswerWrapperActivity : BaseActivity_TabLayout() { - private lateinit var mFragment: LinkFragment - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setNavigationTitle("插入回答") - } + override fun getLayoutId(): Int = R.layout.activity_tablayout_no_title_viewpager override fun initFragmentList(fragments: MutableList?) { - mFragment = LinkFragment() - fragments?.add(mFragment) - fragments?.add(AnswerFragment()) + fragments?.add(AnswerFragment().with(bundleOf(KEY_ANSWER_TYPE to AnswerType.MINE_ANSWER))) + fragments?.add(AnswerFragment().with(bundleOf(KEY_ANSWER_TYPE to AnswerType.COLLECTION_ANSWER))) } override fun initTabTitleList(tabTitleList: MutableList?) { - tabTitleList?.add("输入链接") + tabTitleList?.add("我的回答") tabTitleList?.add("收藏回答") } - override fun onPageSelected(position: Int) { - super.onPageSelected(position) - mFragment.onPageChanged(position) - } - companion object { + const val KEY_ANSWER_TYPE = "AnswerType" + fun getIntent(context: Context): Intent { return Intent(context, InsertAnswerWrapperActivity::class.java) } } + + enum class AnswerType { + MINE_ANSWER, + COLLECTION_ANSWER + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/editor/InsertArticleWrapperActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/editor/InsertArticleWrapperActivity.kt index 6a7af842fa..44cfdce631 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/editor/InsertArticleWrapperActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/editor/InsertArticleWrapperActivity.kt @@ -3,37 +3,36 @@ package com.gh.gamecenter.qa.editor import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import com.gh.base.BaseActivity_TabLayout +import com.gh.gamecenter.R class InsertArticleWrapperActivity : BaseActivity_TabLayout() { - private lateinit var mFragment: LinkFragment + override fun getLayoutId(): Int = R.layout.activity_tablayout_no_title_viewpager - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setNavigationTitle("插入帖子") - } - - override fun initFragmentList(fragments: MutableList?) { - mFragment = LinkFragment() - fragments?.add(mFragment) - fragments?.add(ArticleFragment()) + override fun initFragmentList(fragments: MutableList?) { + fragments?.add(ArticleFragment().with(bundleOf(KEY_ARTICLE_TYPE to ArticleType.MINE_ARTICLE))) + fragments?.add(ArticleFragment().with(bundleOf(KEY_ARTICLE_TYPE to ArticleType.COLLECTION_ARTICLE))) } override fun initTabTitleList(tabTitleList: MutableList?) { - tabTitleList?.add("输入链接") + tabTitleList?.add("我的帖子") tabTitleList?.add("收藏帖子") } - override fun onPageSelected(position: Int) { - super.onPageSelected(position) - mFragment.onPageChanged(position) - } companion object { + const val KEY_ARTICLE_TYPE = "ArticleType" + fun getIntent(context: Context): Intent { return Intent(context, InsertArticleWrapperActivity::class.java) } } + + enum class ArticleType { + MINE_ARTICLE, + COLLECTION_ARTICLE + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java index 7aa2d3edf7..fcd491ca7a 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java @@ -127,10 +127,10 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { mContent.setText(entity.getBrief()); mQuestionTitle.setVisibility(View.VISIBLE); mQuestionTitle.setText(entity.getQuestions().getTitle()); - mVotecount.setText(mVotecount.getContext().getString(R.string.ask_vote_count, NumberUtils.transSimpleCount(entity.getVote()))); - // 3.6.3 产品说把右下角的社区名字换成时间, 评论隐藏掉 + String commentText = String.format("%s评论 · %s点赞 · %s", NumberUtils.transSimpleCount(entity.getCommentCount()), NumberUtils.transSimpleCount(entity.getVote()), NewsUtils.getFormattedTime(entity.getTime())); + mVotecount.setText(commentText); mCommunityName.setVisibility(View.VISIBLE); - mCommunityName.setText(NewsUtils.getFormattedTime(entity.getTime())); + mCommunityName.setText(entity.getCommunityName()); mCommentCount.setVisibility(View.GONE); // mCommentCount.setText(String.format("%s 评论", NumberUtils.transSimpleCount(entity.getCommentCount()))); // mCommunityName.setText(entity.getCommunityName()); diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/QuestionsDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/QuestionsDetailFragment.kt index ad7cbd6075..f54168b096 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/QuestionsDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/QuestionsDetailFragment.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.app.Dialog import android.content.Intent import android.graphics.Color -import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.os.Parcelable import android.text.TextUtils @@ -14,15 +13,14 @@ import android.view.View import android.view.Window import android.widget.ImageView import android.widget.LinearLayout -import android.widget.PopupWindow import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.lifecycle.Lifecycle import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import com.ethanhua.skeleton.Skeleton -import com.gh.base.ToolBarActivity import com.gh.base.fragment.BaseDialogWrapperFragment import com.gh.base.fragment.BaseFragment import com.gh.common.TimeElapsedHelper @@ -46,6 +44,7 @@ import com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity import com.gh.gamecenter.qa.answer.fold.AnswerFoldActivity +import com.gh.gamecenter.qa.dialog.MoreFunctionPanelDialog import com.gh.gamecenter.qa.entity.AnswerDraftEntity import com.gh.gamecenter.qa.entity.Questions import com.gh.gamecenter.qa.entity.QuestionsDetailEntity @@ -418,88 +417,55 @@ class QuestionsDetailFragment : private fun showMoreItemDialog() { if (lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) { mQuestionsDetailEntity?.let { questionEntity -> - val view = LayoutInflater.from(context).inflate(R.layout.menu_answer_detail_more_new, null) - val popupWindow = PopupWindow( - view, - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ) - popupWindow.apply { - setBackgroundDrawable(ColorDrawable(0)) - isTouchable = true - isFocusable = true - isOutsideTouchable = true - } - view.measure(0, 0) - val viewWidth = view.measuredWidth - popupWindow.showAsDropDown((activity as ToolBarActivity).menu.getItem(2).actionView, -viewWidth - 10, 10) - val container = view.findViewById(R.id.container) val entities = ArrayList() - entities.add(MenuItemEntity("首页", R.drawable.menu_more_home)) if (questionEntity.user.id != UserManager.getInstance().userId) { - entities.add(MenuItemEntity("投诉", R.drawable.ic_menu_gamedetail_feedback)) + entities.add(MenuItemEntity("投诉", R.drawable.icon_gamedetail_copyright)) } if (questionEntity.me.isModerator) { - entities.add(MenuItemEntity("编辑", R.drawable.menu_more_edit)) + entities.add(MenuItemEntity("编辑", R.drawable.icon_more_panel_edit)) } - entities.add(MenuItemEntity("分享", R.drawable.icon_share_gray)) if (questionEntity.me.isModerator || questionEntity.user.id == UserManager.getInstance().userId) { - entities.add(MenuItemEntity("删除", R.drawable.menu_more_delete)) + entities.add(MenuItemEntity("删除", R.drawable.icon_more_panel_delete)) } + val shareIcon = if (questionEntity.images.isNotEmpty()) { + questionEntity.images[0] + } else { + getString(R.string.share_ghzs_logo) + } + var description = questionEntity.description + if (TextUtils.isEmpty(description)) { + description = getString(R.string.ask_share_default_summary) + } + val shareUrl = if (isPublishEnv()) { + getString(R.string.share_questions_url, questionEntity.id) + } else { + getString(R.string.share_questions_url_dev, questionEntity.id) + } + val shareUtils = ShareUtils.getInstance(activity) + shareUtils.shareParamsDetail( + activity, + shareUrl, + shareIcon, + getString(R.string.ask_share_questions_title, questionEntity.title, questionEntity.answersCount), + description, + ShareUtils.ShareEntrance.askNormal, + questionEntity.id, null) + MoreFunctionPanelDialog.showMoreDialog(requireActivity() as AppCompatActivity, entities, questionEntity.title + ?: "",shareUtils) { + when (it.text) { + "投诉" -> { + SuggestionActivity.startSuggestionActivity(context, SuggestType.normal, "report", + "问题投诉(" + questionEntity.id + "):") + } + "编辑" -> { + val intent = QuestionEditActivity.getManagerIntent(requireContext(), mQuestionsDetailEntity!!) + startActivityForResult(intent, QUESTIONS_EDIT_REQUEST) + } - entities.forEachIndexed { index, item -> - val menuItem = createMenuItem(index, item) - container.addView(menuItem) - menuItem.setOnClickListener { - popupWindow.dismiss() - when (item.text) { - "首页" -> { - DirectUtils.directToCommunity(requireContext(), questionEntity.community) - MtaHelper.onEvent("回到首页", "问题详情", questionEntity.community.name + "+" + StringUtils.combineTwoString(questionEntity.title, questionEntity.id)) - } - "投诉" -> { - SuggestionActivity.startSuggestionActivity(context, SuggestType.normal, "report", - "问题投诉(" + questionEntity.id + "):") - } - "编辑" -> { - val intent = QuestionEditActivity.getManagerIntent(requireContext(), mQuestionsDetailEntity!!) - startActivityForResult(intent, QUESTIONS_EDIT_REQUEST) - } - "分享" -> { -// GdtHelper.logAction(ActionType.SHARE, -// GdtHelper.CONTENT_TYPE, "QUESTION", -// GdtHelper.CONTENT_ID, mQuestionsId) - - popupWindow.dismiss() - val shareIcon = if (questionEntity.images.isNotEmpty()) { - questionEntity.images[0] - } else { - getString(R.string.share_ghzs_logo) - } - var description = questionEntity.description - if (TextUtils.isEmpty(description)) { - description = getString(R.string.ask_share_default_summary) - } - val shareUrl = if (isPublishEnv()) { - getString(R.string.share_questions_url, questionEntity.id) - } else { - getString(R.string.share_questions_url_dev, questionEntity.id) - } - ShareUtils.getInstance(activity).showShareWindows( - activity, - view, - shareUrl, - shareIcon, - getString(R.string.ask_share_questions_title, questionEntity.title, questionEntity.answersCount), - description, - ShareUtils.ShareEntrance.askNormal, - questionEntity.id) - } - "删除" -> { - DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除问题后,其中的所有回答都将被删除", "取消", "删除", {}, { - mListViewModel.moderatorsHideQuestion() - }) - } + "删除" -> { + DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除问题后,其中的所有回答都将被删除", "取消", "删除", {}, { + mListViewModel.moderatorsHideQuestion() + }) } } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt index e8a6f3a2f8..c61d2b148c 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt @@ -42,6 +42,7 @@ import com.gh.gamecenter.entity.Permissions import com.gh.gamecenter.mvvm.Status import com.gh.gamecenter.qa.article.edit.ArticleSelectGameAdapter import com.gh.gamecenter.qa.article.edit.ArticleTagsSelectFragment +import com.gh.gamecenter.qa.dialog.ChooseForumDialogFragment import com.gh.gamecenter.qa.editor.VideoActivity import com.gh.gamecenter.qa.entity.CommunityVideoEntity import com.gh.gamecenter.qa.entity.QuestionsDetailEntity @@ -144,7 +145,6 @@ class QuestionEditActivity : ToolBarActivity(), KeyboardHeightObserver { searchKey = searchKey.substring(0, QuestionEditViewModel.QUESTION_TITLE_MAX_LENGTH) if (mViewModel.title.isNullOrEmpty()) mViewModel.title = searchKey mViewModel.isFromSearch = intent.getBooleanExtra(QuestionEditViewModel.QUESTION_FORM_SEARCH, false) - if (communityEntity == null) showSelectGameDialog() } if (communityEntity != null) { @@ -229,7 +229,10 @@ class QuestionEditActivity : ToolBarActivity(), KeyboardHeightObserver { mBinding.suggestPicRv.addItemDecoration(SpacingItemDecoration(bottom = DisplayUtils.dip2px(10f))) mBinding.suggestPicRv.adapter = picAdapter initEditorInsertContainer() - + // 增加提问时, 如果searchKey不为空 光标跳到最后 + mBaseHandler.postDelayed({ + mBinding.questionseditTitle.setSelection(mBinding.questionseditTitle.text.toString().length) + }, 50) observeData() } @@ -327,10 +330,9 @@ class QuestionEditActivity : ToolBarActivity(), KeyboardHeightObserver { picAdapter.notifyDataSetChanged() }) - // 增加提问时, 如果searchKey不为空 光标跳到最后 - mBaseHandler.postDelayed({ - mBinding.questionseditTitle.setSelection(mBinding.questionseditTitle.text.toString().length) - }, 50) + mViewModel.notSelectForum.observe(this, Observer { + if (it) showSelectGameDialog() + }) } private fun changeAddLabel(isLabelContainerShow: Boolean) { @@ -457,18 +459,8 @@ class QuestionEditActivity : ToolBarActivity(), KeyboardHeightObserver { } private fun showSelectGameDialog() { - val selectGameDialog = Dialog(this) - val view = View.inflate(this, R.layout.dialog_article_game, null) - val recyclerView = view.findViewById(R.id.dialog_game_list) - val back = view.findViewById(R.id.dialog_back) - val loading = view.findViewById(R.id.dialog_loading) - - back.setOnClickListener { - selectGameDialog.cancel() - } - recyclerView.layoutManager = GridLayoutManager(this, 4) - recyclerView.adapter = ArticleSelectGameAdapter(this, loading) { - mViewModel.communityEntity = CommunityEntity(it.id, it.name, icon = it.game.icon, iconSubscript = it.game.iconSubscript) + ChooseForumDialogFragment.show(this) { + mViewModel.communityEntity = it if (mViewModel.questionEntity != null) { mViewModel.questionEntity?.community?.id = it.id mViewModel.questionEntity?.community?.name = it.name @@ -476,13 +468,7 @@ class QuestionEditActivity : ToolBarActivity(), KeyboardHeightObserver { setForumName() if (!mViewModel.isFromSearch) mViewModel.checkQuestionDraft() mBinding.vm = mViewModel - selectGameDialog.cancel() } - - selectGameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) - selectGameDialog.setCanceledOnTouchOutside(false) - selectGameDialog.setContentView(view) - selectGameDialog.show() } // Limits of EditText diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditViewModel.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditViewModel.kt index 45160ee519..37cfee9710 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditViewModel.kt @@ -49,6 +49,7 @@ class QuestionEditViewModel(application: Application) : AndroidViewModel(applica val postLiveData = MediatorLiveData>() val moderatorPostLiveData = MediatorLiveData>() val videoLiveData = MutableLiveData() + val notSelectForum = MutableLiveData() var uploadImageSubscription: Disposable? = null @@ -105,11 +106,6 @@ class QuestionEditViewModel(application: Application) : AndroidViewModel(applica * 根据问题标题获取相应标签(问题编辑无需获取) */ fun checkTitleAndLoadTitleTag(): Boolean { - if (TextUtils.isEmpty(communityEntity?.id) || TextUtils.isEmpty(communityEntity?.name)) { - Utils.toast(getApplication(), "论坛不能为空") - return false - } - if (TextUtils.isEmpty(title)) { Utils.toast(getApplication(), "标题不能为空") return false @@ -122,6 +118,11 @@ class QuestionEditViewModel(application: Application) : AndroidViewModel(applica Utils.toast(getApplication(), "标题至少${QUESTION_TITLE_MIN_LENGTH}个字") return false } + if (TextUtils.isEmpty(communityEntity?.id) || TextUtils.isEmpty(communityEntity?.name)) { + Utils.toast(getApplication(), "论坛不能为空") + notSelectForum.postValue(true) + return false + } // 检查标题结尾是否存在问号,没则主动加上 if (title!!.length <= QUESTION_TITLE_MAX_LENGTH) { diff --git a/app/src/main/res/drawable-xxhdpi/ic_article_detail_star_bottom_bar.png b/app/src/main/res/drawable-xxhdpi/ic_article_detail_star_bottom_bar.png new file mode 100644 index 0000000000..509d7429cf Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_article_detail_star_bottom_bar.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_article_detail_stared_bottom_bar.png b/app/src/main/res/drawable-xxhdpi/ic_article_detail_stared_bottom_bar.png new file mode 100644 index 0000000000..5380afb700 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_article_detail_stared_bottom_bar.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_choose_forum_close.png b/app/src/main/res/drawable-xxhdpi/ic_choose_forum_close.png new file mode 100644 index 0000000000..fd52b88a13 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_choose_forum_close.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_enable.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_enable.png new file mode 100644 index 0000000000..6c718a6c43 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_enable.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_unenable.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_unenable.png new file mode 100644 index 0000000000..4941b41334 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_close_comment_unenable.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_delete.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_delete.png new file mode 100644 index 0000000000..60bdc0689d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_delete.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_edit.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_edit.png new file mode 100644 index 0000000000..109b3681fa Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_edit.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence.png new file mode 100644 index 0000000000..a9cb83d527 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence_unenable.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence_unenable.png new file mode 100644 index 0000000000..ad304944b5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_essence_unenable.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon_more_panel_fold.png b/app/src/main/res/drawable-xxhdpi/icon_more_panel_fold.png new file mode 100644 index 0000000000..d28d86c5bc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_more_panel_fold.png differ diff --git a/app/src/main/res/drawable/divider_item_line.xml b/app/src/main/res/drawable/divider_item_line.xml new file mode 100644 index 0000000000..321d4fc36a --- /dev/null +++ b/app/src/main/res/drawable/divider_item_line.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_tablayout_no_title_viewpager.xml b/app/src/main/res/layout/activity_tablayout_no_title_viewpager.xml new file mode 100644 index 0000000000..cbcdeaadd3 --- /dev/null +++ b/app/src/main/res/layout/activity_tablayout_no_title_viewpager.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/ask_answer_item.xml b/app/src/main/res/layout/ask_answer_item.xml index 3b1bfe88e4..d03b0d021d 100644 --- a/app/src/main/res/layout/ask_answer_item.xml +++ b/app/src/main/res/layout/ask_answer_item.xml @@ -1,25 +1,24 @@ + android:paddingLeft="16dp" + android:paddingTop="13dp" + android:paddingRight="16dp" + android:paddingBottom="16dp"> @@ -48,7 +46,9 @@ android:id="@+id/ask_answer_item_usericon" style="@style/frescoCircleStyle" android:layout_width="20dp" - android:layout_height="20dp" /> + android:layout_height="20dp" + app:roundingBorderColor="@color/black_alpha_10" + app:roundingBorderWidth="0.5dp" /> + app:layout_constraintRight_toLeftOf="@+id/sdv_user_badge" + app:layout_constraintTop_toTopOf="@id/ask_answer_item_usericon_container" /> + tools:visibility="visible" /> + tools:visibility="visible" /> + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_content" /> + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_content" /> + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_content" /> \ No newline at end of file diff --git a/app/src/main/res/layout/collection_comunity_article_item.xml b/app/src/main/res/layout/collection_comunity_article_item.xml index 767d987475..dc58fac470 100644 --- a/app/src/main/res/layout/collection_comunity_article_item.xml +++ b/app/src/main/res/layout/collection_comunity_article_item.xml @@ -16,22 +16,20 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/reuse_listview_item_style" - android:paddingTop="5dp" - android:paddingBottom="10dp"> + android:paddingLeft="16dp" + android:paddingTop="13dp" + android:paddingRight="16dp" + android:paddingBottom="16dp"> @@ -58,6 +56,8 @@ imageIcon="@{data.user.icon}" android:layout_width="20dp" android:layout_height="20dp" + app:roundingBorderColor="@color/black_alpha_10" + app:roundingBorderWidth="0.5dp" fresco:roundAsCircle="true" /> + app:layout_constraintTop_toTopOf="@id/user_icon_container" + fresco:text="我的名字很长很长有十二字" /> + fresco:visibility="visible" /> + fresco:visibility="visible" /> + - - - - + app:layout_constraintTop_toBottomOf="@id/content" /> + app:layout_constraintTop_toBottomOf="@id/content" /> diff --git a/app/src/main/res/layout/comment_item.xml b/app/src/main/res/layout/comment_item.xml index aa70d3e99d..a3e0121653 100644 --- a/app/src/main/res/layout/comment_item.xml +++ b/app/src/main/res/layout/comment_item.xml @@ -74,7 +74,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dp" - android:layout_marginRight="4dp" android:background="@drawable/button_round_2496ff" android:includeFontPadding="false" android:paddingLeft="4dp" @@ -97,6 +96,7 @@ android:layout_width="16dp" android:layout_height="16dp" android:layout_marginRight="2dp" + android:layout_marginLeft="4dp" android:visibility="gone" app:layout_constrainedWidth="true" app:layout_constraintBottom_toBottomOf="@+id/comment_user_name" diff --git a/app/src/main/res/layout/dialog_choose_forum.xml b/app/src/main/res/layout/dialog_choose_forum.xml new file mode 100644 index 0000000000..30b893105c --- /dev/null +++ b/app/src/main/res/layout/dialog_choose_forum.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_game_detail_more.xml b/app/src/main/res/layout/dialog_game_detail_more.xml index 9fbbbb6b7d..445ecaba03 100644 --- a/app/src/main/res/layout/dialog_game_detail_more.xml +++ b/app/src/main/res/layout/dialog_game_detail_more.xml @@ -13,6 +13,7 @@ android:descendantFocusability="blocksDescendants"> - - - + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/handle_view"> + + + + + + app:layout_constraintTop_toBottomOf="@+id/title_container" /> + layout="@layout/piece_article_input_container" /> - - - - - - - - + android:layout_height="match_parent"> + android:layout_height="488dp" + android:layout_gravity="bottom" + android:background="@drawable/game_detail_more_dialog_background"> - + android:layout_height="48dp"> + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_comment.xml b/app/src/main/res/layout/fragment_comment.xml index 556034f6e8..094a1bb3b3 100644 --- a/app/src/main/res/layout/fragment_comment.xml +++ b/app/src/main/res/layout/fragment_comment.xml @@ -7,7 +7,7 @@ @@ -26,18 +26,16 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" android:textColor="@color/text_333333" - android:textSize="14sp" - android:textStyle="bold" + android:textSize="16sp" tools:text="35条评论" /> + android:src="@drawable/ic_choose_forum_close" /> @@ -272,5 +270,14 @@ app:layout_constraintTop_toTopOf="@id/floorHintTv" tools:text="999" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/item_article_detail_content.xml b/app/src/main/res/layout/item_article_detail_content.xml index 720d85df36..9e2ab44ec4 100644 --- a/app/src/main/res/layout/item_article_detail_content.xml +++ b/app/src/main/res/layout/item_article_detail_content.xml @@ -42,10 +42,10 @@ android:id="@+id/userIconIv" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:avatar_width="32dp" - app:badge_width="12dp" android:layout_marginLeft="12dp" android:layout_marginTop="7dp" + app:avatar_width="32dp" + app:badge_width="12dp" app:border_color="@color/transparent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -56,8 +56,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="2dp" - android:layout_marginRight="16dp" android:layout_marginTop="8dp" + android:layout_marginRight="16dp" app:layout_constraintLeft_toRightOf="@id/userIconIv" app:layout_constraintRight_toLeftOf="@+id/followBtn" app:layout_constraintTop_toTopOf="@+id/userIconIv"> @@ -127,10 +127,10 @@ android:layout_marginLeft="2dp" android:layout_marginTop="53dp" android:layout_marginRight="20dp" + android:layout_marginBottom="8dp" android:includeFontPadding="false" android:textColor="@color/text_999999" android:textSize="11sp" - android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="@id/userIconIv" app:layout_constraintLeft_toRightOf="@id/userIconIv" tools:text="发布于1分钟前" /> @@ -184,120 +184,5 @@ android:paddingBottom="20dp" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/new_comment_item.xml b/app/src/main/res/layout/new_comment_item.xml new file mode 100644 index 0000000000..8abaf440db --- /dev/null +++ b/app/src/main/res/layout/new_comment_item.xml @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/piece_article_input_container.xml b/app/src/main/res/layout/piece_article_input_container.xml index d14b9a809e..55373f0738 100644 --- a/app/src/main/res/layout/piece_article_input_container.xml +++ b/app/src/main/res/layout/piece_article_input_container.xml @@ -5,6 +5,7 @@ android:id="@+id/bottomContainer" android:layout_width="match_parent" android:layout_height="50dp" + android:background="@color/white" android:layout_alignParentBottom="true" tools:showIn="@layout/fragment_article_detail"> @@ -20,7 +21,7 @@ android:maxLines="1" android:paddingLeft="16dp" android:paddingRight="16dp" - android:textColor="@color/AAAAAA" + android:textColor="@color/text_cccccc" android:textSize="14sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" @@ -40,8 +41,8 @@ @@ -52,25 +53,54 @@ android:gravity="center" android:text="赞同" android:textColor="@color/text_666666" - android:textSize="11sp" /> + android:textSize="10sp" /> + + + + + + + + @@ -81,7 +111,7 @@ android:gravity="center" android:text="评论" android:textColor="@color/text_666666" - android:textSize="11sp" /> + android:textSize="10sp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/piece_comment_typing_container.xml b/app/src/main/res/layout/piece_comment_typing_container.xml index 77063d4886..065dc5b25c 100644 --- a/app/src/main/res/layout/piece_comment_typing_container.xml +++ b/app/src/main/res/layout/piece_comment_typing_container.xml @@ -41,7 +41,7 @@ android:layout_height="wrap_content" android:background="@android:color/transparent" android:drawablePadding="4dp" - android:hint="写评论" + android:hint="说点什么吧" android:lineSpacingExtra="4dp" android:textColor="@color/text_333333" android:textColorHint="@color/theme_font" diff --git a/app/src/main/res/layout/piece_comment_typing_container_dark.xml b/app/src/main/res/layout/piece_comment_typing_container_dark.xml index c15ea66e8e..daeed3f1b7 100644 --- a/app/src/main/res/layout/piece_comment_typing_container_dark.xml +++ b/app/src/main/res/layout/piece_comment_typing_container_dark.xml @@ -40,7 +40,7 @@ android:layout_height="wrap_content" android:background="@android:color/transparent" android:drawablePadding="4dp" - android:hint="写评论" + android:hint="说点什么吧" android:lineSpacingExtra="4dp" android:textColor="@color/white" android:textColorHint="@color/text_666666" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb64bb146d..590fe3cc92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -119,7 +119,7 @@ 资讯 首页 我的光环 - 写评论 + 说点什么吧 发送 发表评论... 发表评论...