1.【光环助手v5.10.0】消息通知相关优化(完成UI和部分跳转) https://git.shanqu.cc/pm/halo-app-issues/-/issues/1830
2.【光环助手v5.10.0】消息中心-新增评论详情页(大致完成) https://git.shanqu.cc/pm/halo-app-issues/-/issues/1829
This commit is contained in:
@ -289,6 +289,10 @@ public abstract class ToolBarActivity extends BaseActivity implements ToolbarCon
|
||||
return mActionMenuView.getMenu();
|
||||
}
|
||||
|
||||
public ActionMenuView getActionMenuView() {
|
||||
return mActionMenuView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_download) {
|
||||
|
||||
@ -126,6 +126,28 @@ object CommentHelper {
|
||||
)
|
||||
}
|
||||
|
||||
fun showCommentDetailOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
questionId: String? = null,
|
||||
videoId: String? = null,
|
||||
gameCollectionId: String? = null,
|
||||
) {
|
||||
showCommentOptions(
|
||||
view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = false,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
questionId = questionId,
|
||||
videoId = videoId,
|
||||
gameCollectionId = gameCollectionId,
|
||||
isOnlyShowCopyAndReport = true
|
||||
)
|
||||
}
|
||||
|
||||
private fun showCommentOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
@ -139,6 +161,7 @@ object CommentHelper {
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
isVideoAuthor: Boolean = false,
|
||||
isOnlyShowCopyAndReport: Boolean = false,
|
||||
listener: OnCommentOptionClickListener? = null
|
||||
) {
|
||||
val context = view.context
|
||||
@ -159,13 +182,13 @@ object CommentHelper {
|
||||
if (commentEntity.user.id != UserManager.getInstance().userId) {
|
||||
dialogOptions.add("投诉")
|
||||
}
|
||||
if (questionId != null &&
|
||||
if (!isOnlyShowCopyAndReport && questionId != null &&
|
||||
commentEntity.me?.isModerator == true &&
|
||||
(commentEntity.me?.moderatorPermissions?.highlightAnswer ?: Permissions.GUEST) > Permissions.GUEST && !commentEntity.choiceness
|
||||
) {
|
||||
dialogOptions.add("加精选")
|
||||
}
|
||||
if (questionId != null &&
|
||||
if (!isOnlyShowCopyAndReport && questionId != null &&
|
||||
commentEntity.me?.isModerator == true &&
|
||||
(commentEntity.me?.moderatorPermissions?.cancelChoicenessAnswer
|
||||
?: Permissions.GUEST) > Permissions.GUEST &&
|
||||
@ -173,11 +196,11 @@ object CommentHelper {
|
||||
) {
|
||||
dialogOptions.add("取消精选")
|
||||
}
|
||||
if (commentEntity.user.id == UserManager.getInstance().userId || commentEntity.me?.isModerator == true || commentEntity.me?.isContentAuthor == true) {
|
||||
if (!isOnlyShowCopyAndReport && commentEntity.user.id == UserManager.getInstance().userId || commentEntity.me?.isModerator == true || commentEntity.me?.isContentAuthor == true) {
|
||||
dialogOptions.add("删除评论")
|
||||
}
|
||||
|
||||
if (commentEntity.parentUser != null && showConversation) {
|
||||
if (!isOnlyShowCopyAndReport && commentEntity.parentUser != null && showConversation) {
|
||||
dialogOptions.add("查看对话")
|
||||
}
|
||||
|
||||
|
||||
@ -1708,10 +1708,11 @@ object DirectUtils {
|
||||
* 跳转至游戏单详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToGameCollectionDetail(context: Context, id: String, entrance: String? = null) {
|
||||
fun directToGameCollectionDetail(context: Context, id: String, entrance: String? = null, path: String? = null) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TO, GameCollectionDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_GAME_COLLECTION_ID, id)
|
||||
jumpActivity(context, bundle)
|
||||
|
||||
@ -394,7 +394,7 @@ public class SkipActivity extends BaseActivity {
|
||||
DirectUtils.directToHelpAndFeedback(this, TextUtils.isEmpty(position) ? 0 : Integer.parseInt(position));
|
||||
break;
|
||||
case HOST_GAME_COLLECTION_DETAIL:
|
||||
DirectUtils.directToGameCollectionDetail(this, path, ENTRANCE_BROWSER);
|
||||
DirectUtils.directToGameCollectionDetail(this, path, ENTRANCE_BROWSER, "");
|
||||
break;
|
||||
case HOST_GAME_COLLECTION_SQUARE:
|
||||
DirectUtils.directToGameCollectionSquare(this, ENTRANCE_BROWSER, "", "", "");
|
||||
|
||||
@ -37,7 +37,7 @@ class SubCategoryAdapter(
|
||||
name.setTextColor(R.color.theme_font.toColor(mContext))
|
||||
} else {
|
||||
selectedIv.visibility = View.GONE
|
||||
container.background = R.drawable.bg_category_unselect.toDrawable(mContext)
|
||||
container.background = R.drawable.bg_shape_f8_radius_8.toDrawable(mContext)
|
||||
name.setTextColor(R.color.text_title.toColor(mContext))
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class SubCategoryAdapter(
|
||||
categoryEntity.selected -> {
|
||||
categoryEntity.selected = false
|
||||
selectedIv.visibility = View.GONE
|
||||
container.background = R.drawable.bg_category_unselect.toDrawable(mContext)
|
||||
container.background = R.drawable.bg_shape_f8_radius_8.toDrawable(mContext)
|
||||
name.setTextColor(R.color.text_title.toColor(mContext))
|
||||
mViewModel.run {
|
||||
if (selectedCount > 0) {
|
||||
|
||||
@ -34,7 +34,9 @@ data class CommentEntity(
|
||||
var floor: Int = 0,
|
||||
var isExpand: Boolean = false,
|
||||
@SerializedName("attached") // 楼中楼
|
||||
var subCommentList: ArrayList<CommentEntity>? = null
|
||||
var subCommentList: ArrayList<CommentEntity>? = null,
|
||||
var isHighlight: Boolean = false, // 是否高亮处理
|
||||
var isForceExpand: Boolean = false // 是否强制展开,即显示时就是展开状态
|
||||
) : Parcelable {
|
||||
|
||||
fun clone(): CommentEntity {
|
||||
|
||||
@ -126,8 +126,12 @@ open class GameCollectionDetailViewModel(application: Application,
|
||||
} else if (list.isNullOrEmpty() && mLoadStatusLiveData.value == LoadStatus.INIT_FAILED) {
|
||||
add(CommentItemData(errorConnection = true))
|
||||
} else {
|
||||
list?.forEach {
|
||||
add(CommentItemData(commentNormal = it))
|
||||
list?.forEachIndexed { index, commentEntity ->
|
||||
if (topCommentId.isNotBlank() && index == 0) {
|
||||
commentEntity.isHighlight = true
|
||||
commentEntity.isForceExpand = true
|
||||
}
|
||||
add(CommentItemData(commentNormal = commentEntity))
|
||||
}
|
||||
add(CommentItemData(footer = true))
|
||||
}
|
||||
|
||||
@ -22,7 +22,11 @@ class GameCollectionCommentConversationViewModel(application: Application,
|
||||
override fun provideDataObservable(page: Int) = null
|
||||
|
||||
override fun provideDataSingle(page: Int): Single<MutableList<CommentEntity>> {
|
||||
return mApi.getGameCollectionCommentReply(gameCollectionId, commentId, page)
|
||||
val map = hashMapOf<String, Any>()
|
||||
if (topCommentId.isNotEmpty()) {
|
||||
map["top_comment_id"] = topCommentId
|
||||
}
|
||||
return mApi.getGameCollectionCommentReply(gameCollectionId, commentId, page, map)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
||||
@ -127,12 +127,6 @@ public class MessageAdapter extends ListAdapter<MessageEntity> {
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
footerViewHolder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver);
|
||||
footerViewHolder.initItemPadding();
|
||||
|
||||
if (mIsOver && (mEntityList == null || mEntityList.isEmpty())) {
|
||||
footerViewHolder.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0));
|
||||
} else {
|
||||
footerViewHolder.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,11 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.MessageInviteActivity;
|
||||
import com.gh.gamecenter.MessageKeFuActivity;
|
||||
@ -51,6 +54,14 @@ public class MessageFragment extends ListFragment<MessageEntity, MessageViewMode
|
||||
mListViewModel) : mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerView.ItemDecoration getItemDecoration() {
|
||||
CustomDividerItemDecoration decoration = new CustomDividerItemDecoration(requireContext(), false, true, false, false);
|
||||
decoration.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_item_line_space_16));
|
||||
mItemDecoration = decoration;
|
||||
return mItemDecoration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadEmpty() {
|
||||
super.onLoadDone();
|
||||
|
||||
@ -11,7 +11,11 @@ import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.gh.gamecenter.common.base.BaseActivity;
|
||||
import com.gh.common.databind.BindingAdapters;
|
||||
import com.gh.gamecenter.core.utils.ClickUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.gamecenter.CommentDetailActivity;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
@ -22,10 +26,6 @@ import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder;
|
||||
import com.gh.gamecenter.common.callback.OnListClickListener;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.core.utils.ClickUtils;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.databinding.MessageItemBinding;
|
||||
import com.gh.gamecenter.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.entity.LinkEntity;
|
||||
@ -38,9 +38,11 @@ import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.qa.answer.detail.SimpleAnswerDetailActivity;
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity;
|
||||
import com.gh.gamecenter.qa.comment.CommentActivity;
|
||||
import com.gh.gamecenter.qa.comment.NewCommentDetailActivity;
|
||||
import com.gh.gamecenter.qa.entity.Questions;
|
||||
import com.gh.gamecenter.qa.follow.AskFollowMoreDialog;
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity;
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -74,20 +76,20 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
|
||||
public void setMessageItem(MessageEntity messageEntity, Context context, String entrance) {
|
||||
mBinding.messageItem.setBackground(ContextCompat.getDrawable(mBinding.getRoot().getContext(), R.drawable.reuse_listview_item_style));
|
||||
mBinding.messageOriginal.setBackgroundColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.background));
|
||||
mBinding.messageUserName.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_black));
|
||||
mBinding.messageOriginal.setBackground(ContextCompat.getDrawable(mBinding.getRoot().getContext(), R.drawable.bg_shape_f8_radius_8));
|
||||
mBinding.messageUserName.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_title));
|
||||
mBinding.messageUserMore.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.theme_font));
|
||||
mBinding.messageCommand.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.title));
|
||||
mBinding.messageTime.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.hint));
|
||||
mBinding.messageContent.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_black));
|
||||
mBinding.messageOriginalTitle.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.title));
|
||||
mBinding.messageCommand.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_title));
|
||||
mBinding.messageTime.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_subtitleDesc));
|
||||
mBinding.messageContent.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_subtitle));
|
||||
mBinding.messageOriginalTitle.setTextColor(ContextCompat.getColor(mBinding.getRoot().getContext(), R.color.text_subtitleDesc));
|
||||
|
||||
setClickData(messageEntity);
|
||||
ImageUtils.display(mBinding.messageUserIcon, messageEntity.getUserEntity().getIcon());
|
||||
if (messageEntity.getUserEntity().getAuth() != null) {
|
||||
ImageUtils.display(mBinding.messageUserBadge, messageEntity.getUserEntity().getAuth().getIcon());
|
||||
mBinding.messageUserIcon.display(messageEntity.getUserEntity().getBorder(), messageEntity.getUserEntity().getIcon(), messageEntity.getUserEntity().getAuth().getIcon());
|
||||
} else {
|
||||
mBinding.messageUserIcon.display(messageEntity.getUserEntity().getBorder(), messageEntity.getUserEntity().getIcon(), null);
|
||||
}
|
||||
BindingAdapters.showHide(mBinding.messageUserBadge, messageEntity.getUserEntity().getAuth() != null);
|
||||
BindingAdapters.showHide(mBinding.messageUnread, !messageEntity.getRead());
|
||||
mBinding.messageUserName.setText(messageEntity.getUserEntity().getName());
|
||||
|
||||
@ -100,7 +102,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "answer":
|
||||
mBinding.messageCommand.setText("回答了你的问题");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(3);
|
||||
mBinding.messageContent.setText(messageEntity.getAnswer().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getQuestion().getTitle());
|
||||
images = messageEntity.getAnswer().getImages();
|
||||
@ -115,7 +116,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "reply":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getDialogue().getFrom().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getArticle().getTitle());
|
||||
targetUrl = messageEntity.getArticle().getThumb();
|
||||
@ -127,7 +127,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "follow_question":
|
||||
mBinding.messageCommand.setText("回答了你关注的问题");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(3);
|
||||
mBinding.messageContent.setText(messageEntity.getAnswer().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getQuestion().getTitle());
|
||||
images = messageEntity.getAnswer().getImages();
|
||||
@ -140,9 +139,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "reply_answer_comment":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageCommand.setText("回复了你的回答");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getDialogue().getFrom().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getQuestion().getTitle());
|
||||
images = messageEntity.getAnswer().getImages();
|
||||
@ -157,7 +155,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "answer_comment":
|
||||
mBinding.messageCommand.setText("评论了你");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getComment().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getQuestion().getTitle());
|
||||
images = messageEntity.getAnswer().getImages();
|
||||
@ -245,9 +242,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "community_article_comment":
|
||||
mBinding.messageCommand.setText("评论了你");
|
||||
mBinding.messageCommand.setText("评论了你的帖子");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getComment().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getArticle().getTitle());
|
||||
images = messageEntity.getArticle().getImages();
|
||||
@ -286,9 +282,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "reply_community_article_comment":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageCommand.setText("回复了你的评论");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getDialogue().getFrom().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getArticle().getTitle());
|
||||
images = messageEntity.getArticle().getImages();
|
||||
@ -313,7 +308,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "update-answer":
|
||||
mBinding.messageCommand.setText("更新了回答");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(3);
|
||||
mBinding.messageContent.setText(messageEntity.getAnswer().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getQuestion().getTitle());
|
||||
images = messageEntity.getAnswer().getImages();
|
||||
@ -336,9 +330,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "game_comment_reply":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageCommand.setText("回复了你的评价");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getReply().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getGame().getName());
|
||||
targetUrl = messageEntity.getGame().getDefaultIcon();
|
||||
@ -348,9 +341,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "video_comment":
|
||||
mBinding.messageCommand.setText("评论了你");
|
||||
mBinding.messageCommand.setText("评论了你的帖子");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getComment().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getVideo().getTitle());
|
||||
targetUrl = messageEntity.getVideo().getPoster();
|
||||
@ -360,9 +352,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "video_comment_reply":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageCommand.setText("回复了你的评论");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getDialogue().getFrom().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getVideo().getTitle());
|
||||
targetUrl = messageEntity.getVideo().getPoster();
|
||||
@ -404,7 +395,6 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "reply_activity_comment":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getDialogue().getFrom().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getActivity().getTitle());
|
||||
targetUrl = messageEntity.getActivity().getImageUrl();
|
||||
@ -444,9 +434,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "game_list_comment":
|
||||
mBinding.messageCommand.setText("评论了你");
|
||||
mBinding.messageCommand.setText("评价了你的游戏单");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getComment().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getGameList().getTitle());
|
||||
targetUrl = messageEntity.getGameList().getCover();
|
||||
@ -456,9 +445,8 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
voteMoreUser(messageEntity);
|
||||
break;
|
||||
case "game_list_comment_reply":
|
||||
mBinding.messageCommand.setText("回复了你");
|
||||
mBinding.messageCommand.setText("回复了你的游戏单评价");
|
||||
mBinding.messageContent.setVisibility(View.VISIBLE);
|
||||
mBinding.messageContent.setMaxLines(Integer.MAX_VALUE);
|
||||
mBinding.messageContent.setText(messageEntity.getComment().getContent());
|
||||
mBinding.messageOriginalTitle.setText(messageEntity.getGameList().getTitle());
|
||||
targetUrl = messageEntity.getGameList().getCover();
|
||||
@ -564,23 +552,24 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
MtaHelper.onEvent("消息中心", outerInfo, "点击卡片");
|
||||
}
|
||||
|
||||
Intent intent;
|
||||
switch (entity.getType()) {
|
||||
case "comment_vote":
|
||||
if (view.getId() == R.id.message_original) {
|
||||
Intent intent = NewsDetailActivity.getIntentById(context, entity.getArticle().getId(), BaseActivity.mergeEntranceAndPath(entrance, path));
|
||||
intent = NewsDetailActivity.getIntentById(context, entity.getArticle().getId(), BaseActivity.mergeEntranceAndPath(entrance, path));
|
||||
context.startActivity(intent);
|
||||
} else if (view.getId() == R.id.message_item) {
|
||||
Intent intent = MessageDetailActivity.getIntentById(context,
|
||||
intent = MessageDetailActivity.getIntentById(context,
|
||||
entity.getArticle().getId(), -1, false, BaseActivity.mergeEntranceAndPath(entrance, path));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
break;
|
||||
case "reply":
|
||||
if (view.getId() == R.id.message_original) {
|
||||
Intent intent = NewsDetailActivity.getIntentById(context, entity.getArticle().getId(), BaseActivity.mergeEntranceAndPath(entrance, path));
|
||||
intent = NewsDetailActivity.getIntentById(context, entity.getArticle().getId(), BaseActivity.mergeEntranceAndPath(entrance, path));
|
||||
context.startActivity(intent);
|
||||
} else if (view.getId() == R.id.message_item) {
|
||||
Intent intent = CommentDetailActivity.getIntent(context, entity.getDialogue().getFrom().getId(), entity.getArticle());
|
||||
intent = CommentDetailActivity.getIntent(context, entity.getDialogue().getFrom().getId(), entity.getArticle());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
break;
|
||||
@ -596,15 +585,20 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
}
|
||||
break;
|
||||
case "answer":
|
||||
intent = NewQuestionDetailActivity.getSpecifiedCommentIntent(
|
||||
context,
|
||||
entity.getQuestion().getId(),
|
||||
entity.getAnswer().getId(),
|
||||
entrance,
|
||||
path
|
||||
);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "update-answer":
|
||||
case "follow_question":
|
||||
if (view.getId() == R.id.message_original) {
|
||||
MessageEntity.Question question = entity.getQuestion();
|
||||
context.startActivity(NewQuestionDetailActivity.getCommentIntent(context, question.getId(), entity.getAnswer().getId(), entrance, path));
|
||||
|
||||
Questions questions = new Questions();
|
||||
questions.setId(question.getId());
|
||||
questions.setTitle(question.getTitle());
|
||||
} else if (view.getId() == R.id.message_item) {
|
||||
context.startActivity(SimpleAnswerDetailActivity.getIntent(context, entity.getAnswer().getId(), entrance, path));
|
||||
}
|
||||
@ -624,7 +618,7 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
linkEntity.setType("answer");
|
||||
linkEntity.setLink(entity.getAnswer().getId());
|
||||
linkEntity.setTitle(entity.getQuestion().getTitle());
|
||||
Intent intent = CommentDetailActivity.getAnswerCommentIntent(context,
|
||||
intent = CommentDetailActivity.getAnswerCommentIntent(context,
|
||||
entity.getDialogue().getFrom().getId(),
|
||||
entity.getAnswer().getId(),
|
||||
linkEntity);
|
||||
@ -653,11 +647,14 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
break;
|
||||
case "community_article_comment":
|
||||
community = new CommunityEntity(entity.getArticle().getCommunityId(), "");
|
||||
if (view.getId() == R.id.message_original) {
|
||||
context.startActivity(ArticleDetailActivity.getIntent(context, community, entity.getArticle().getId(), entrance, path, null));
|
||||
} else if (view.getId() == R.id.message_item) { // 打开评论管理
|
||||
context.startActivity(ArticleDetailActivity.getCommentIntent(context, community, entity.getArticle().getId(), entrance, path));
|
||||
}
|
||||
intent = ArticleDetailActivity.getSpecifiedCommentIntent(
|
||||
context,
|
||||
community,
|
||||
entity.getArticle().getId(),
|
||||
entity.getComment().getId(),
|
||||
entrance,
|
||||
path);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "community_article_vote":
|
||||
if (view.getId() == R.id.message_original || view.getId() == R.id.message_item) {
|
||||
@ -666,9 +663,19 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
}
|
||||
break;
|
||||
case "reply_community_article_comment":
|
||||
if (view.getId() == R.id.message_original || view.getId() == R.id.message_item) {
|
||||
context.startActivity(CommentActivity.getCommentDetailIntent(context, entity.getDialogue().getTo().getTopId(), entity.getArticle().getCommunityId(), entity.getArticle().getId(), "", "", false, 1, entrance, path));
|
||||
}
|
||||
intent = NewCommentDetailActivity.Companion.getIntent(
|
||||
context,
|
||||
entity.getDialogue().getTo().getTopId(),
|
||||
entity.getArticle().getCommunityId(),
|
||||
entity.getArticle().getId(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
entity.getDialogue().getFrom().getId(),
|
||||
entrance,
|
||||
path
|
||||
);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "game_comment_vote":
|
||||
if (view.getId() == R.id.message_original || view.getId() == R.id.message_item) {
|
||||
@ -678,7 +685,7 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
case "game_comment_reply":
|
||||
case "game_comment_reply_vote":
|
||||
if (view.getId() == R.id.message_original || view.getId() == R.id.message_item) {
|
||||
Intent intent = RatingReplyActivity.getIntent(context, entity.getGame().getId(), entity.getReply().getCommentId(), entrance, path);
|
||||
intent = RatingReplyActivity.getIntent(context, entity.getGame().getId(), entity.getReply().getCommentId(), entrance, path);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
break;
|
||||
@ -697,8 +704,30 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
}
|
||||
break;
|
||||
case "video_comment":
|
||||
case "video_comment_vote":
|
||||
intent = ForumVideoDetailActivity.Companion.getSpecifiedCommentIntent(
|
||||
context,
|
||||
entity.getVideo().getId(),
|
||||
"",
|
||||
entity.getComment().getId()
|
||||
);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "video_comment_reply":
|
||||
intent = NewCommentDetailActivity.Companion.getIntent(
|
||||
context,
|
||||
entity.getDialogue().getTo().getId(),
|
||||
"",
|
||||
"",
|
||||
entity.getVideo().getId(),
|
||||
"",
|
||||
"",
|
||||
entity.getDialogue().getFrom().getId(),
|
||||
entrance,
|
||||
path
|
||||
);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "video_comment_vote":
|
||||
case "video_comment_reply_vote":
|
||||
boolean showComment = false;
|
||||
|
||||
@ -734,6 +763,20 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder<MessageEntity>
|
||||
}
|
||||
break;
|
||||
case "game_list_comment_reply":
|
||||
intent = NewCommentDetailActivity.Companion.getIntent(
|
||||
context,
|
||||
entity.getComment().getTopId(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
entity.getGameList().getId(),
|
||||
entity.getComment().getId(),
|
||||
entrance,
|
||||
path
|
||||
);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "game_list_comment_vote":
|
||||
if (view.getId() == R.id.message_original) {
|
||||
context.startActivity(GameCollectionDetailActivity.getIntent(context, entity.getGameList().getId(), false));
|
||||
|
||||
@ -101,5 +101,27 @@ class ArticleDetailActivity : NormalActivity() {
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, path)
|
||||
return intent
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位到指定的评论并置顶
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getSpecifiedCommentIntent(
|
||||
context: Context,
|
||||
community: CommunityEntity,
|
||||
articleId: String,
|
||||
topCommentId: String,
|
||||
entrance: String,
|
||||
path: String
|
||||
): Intent {
|
||||
val intent = Intent(context, ArticleDetailActivity::class.java)
|
||||
intent.putExtra(EntranceConsts.KEY_ENTRANCE, mergeEntranceAndPath(entrance, path))
|
||||
intent.putExtra(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID, articleId)
|
||||
intent.putExtra(EntranceConsts.KEY_COMMUNITY_DATA, community)
|
||||
intent.putExtra(EntranceConsts.KEY_SCROLL_TO_COMMENT_AREA, true)
|
||||
intent.putExtra(EntranceConsts.KEY_TOP_COMMENT_ID, topCommentId)
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, path)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,8 @@ class ArticleDetailFragment : BaseCommentFragment<CommentItemData, ArticleDetail
|
||||
HaloApp.getInstance().application,
|
||||
arguments?.getString(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID) ?: "",
|
||||
arguments?.getParcelable<CommunityEntity>(EntranceConsts.KEY_COMMUNITY_DATA)?.id ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_RECOMMEND_ID) ?: ""
|
||||
arguments?.getString(EntranceConsts.KEY_RECOMMEND_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_TOP_COMMENT_ID) ?: ""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ -33,13 +33,15 @@ class ArticleDetailViewModel(
|
||||
application: Application,
|
||||
articleId: String = "",
|
||||
communityId: String = "",
|
||||
val recommendId: String = ""
|
||||
val recommendId: String = "",
|
||||
topCommentId: String
|
||||
) : BaseCommentViewModel(
|
||||
application,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
videoId = "",
|
||||
questionId = ""
|
||||
questionId = "",
|
||||
topCommentId = topCommentId
|
||||
) {
|
||||
|
||||
var detailEntity: ArticleDetailEntity? = null
|
||||
@ -60,11 +62,16 @@ class ArticleDetailViewModel(
|
||||
var articlePageFinishedLiveData = MutableLiveData<Boolean>()
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<List<CommentEntity>> {
|
||||
val map = hashMapOf<String, Any>()
|
||||
if (topCommentId.isNotEmpty()) {
|
||||
map["top_comment_id"] = topCommentId
|
||||
}
|
||||
return RetrofitManager.getInstance().api.getCommunityArticleCommentList(
|
||||
communityId,
|
||||
articleId,
|
||||
currentSortType.value,
|
||||
page
|
||||
page,
|
||||
map
|
||||
)
|
||||
}
|
||||
|
||||
@ -408,7 +415,8 @@ class ArticleDetailViewModel(
|
||||
private val application: Application,
|
||||
private val articleId: String = "",
|
||||
private val communityId: String = "",
|
||||
private val recommendId: String = ""
|
||||
private val recommendId: String = "",
|
||||
private val topCommentId: String = ""
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
@ -416,7 +424,8 @@ class ArticleDetailViewModel(
|
||||
application = application,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
recommendId = recommendId
|
||||
recommendId = recommendId,
|
||||
topCommentId = topCommentId
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class ArticleDetailCommentViewModel(application: Application,
|
||||
}
|
||||
|
||||
override fun provideDataSingle(page: Int): Single<MutableList<CommentEntity>> {
|
||||
return RetrofitManager.getInstance().api.getCommunityArticleCommentReply(communityId, articleId, commentId, currentSortType.value, page)
|
||||
return RetrofitManager.getInstance().api.getCommunityArticleCommentReply(communityId, articleId, commentId, currentSortType.value, page, mapOf())
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gh.gamecenter.qa.comment
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.NormalActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.qa.comment.conversation.CommentConversationFragment
|
||||
|
||||
class NewCommentDetailActivity: NormalActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle("评论详情")
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getIntent(
|
||||
context: Context,
|
||||
commentId: String,
|
||||
communityId: String,
|
||||
articleId: String,
|
||||
videoId: String,
|
||||
questionId: String,
|
||||
gameCollectionId: String,
|
||||
topCommentId: String,
|
||||
entrance: String,
|
||||
path: String
|
||||
): Intent {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EntranceConsts.KEY_ENTRANCE, mergeEntranceAndPath(entrance, path))
|
||||
bundle.putInt(EntranceConsts.KEY_POSITION, 1)
|
||||
bundle.putString(EntranceConsts.KEY_COMMENT_ID, commentId)
|
||||
bundle.putString(EntranceConsts.KEY_COMMUNITY_ID, communityId)
|
||||
bundle.putString(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID, articleId)
|
||||
bundle.putString(CommentActivity.VIDEO_ID, videoId)
|
||||
bundle.putString(CommentActivity.QUESTION_ID, questionId)
|
||||
bundle.putString(CommentActivity.GAME_COLLECTION_ID, gameCollectionId)
|
||||
bundle.putString(EntranceConsts.KEY_TOP_COMMENT_ID, topCommentId)
|
||||
bundle.putString(EntranceConsts.KEY_PATH, path)
|
||||
return getTargetIntent(context, NewCommentDetailActivity::class.java, CommentConversationFragment::class.java, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,7 @@ open class NewCommentFragment : ListFragment<CommentEntity, NewCommentViewModel>
|
||||
|
||||
if (mShowInputOnly) {
|
||||
if (mCommentEntity != null) {
|
||||
commentEt.hint = "回复:${mCommentEntity?.user?.name}"
|
||||
commentEt.hint = "回复 @${mCommentEntity?.user?.name}"
|
||||
}
|
||||
commentContainer?.visibility = View.GONE
|
||||
commentEt.requestFocus()
|
||||
|
||||
@ -65,7 +65,7 @@ open class NewCommentViewModel(
|
||||
CommentType.ANSWER -> api.getAnswerCommentList(answerId, page)
|
||||
CommentType.ANSWER_CONVERSATION -> api.getAnswerCommentConversationList(answerId, commentId, page)
|
||||
|
||||
CommentType.COMMUNITY_ARTICLE -> api.getCommunityArticleCommentList(communityId, articleId, "time.create:1", page)
|
||||
CommentType.COMMUNITY_ARTICLE -> api.getCommunityArticleCommentList(communityId, articleId, "time.create:1", page, mapOf())
|
||||
CommentType.COMMUNITY_ARTICLE_CONVERSATION -> api.getCommunityArticleCommentConversation(communityId, articleId, commentId, page)
|
||||
|
||||
CommentType.VIDEO -> api.getVideoCommentList(videoId, page, mapOf())
|
||||
|
||||
@ -203,6 +203,7 @@ abstract class BaseCommentAdapter(
|
||||
}
|
||||
|
||||
is CommentFooterViewHolder -> {
|
||||
holder.itemView.setBackgroundColor(R.color.background_white.toColor(mContext))
|
||||
holder.bindView(mIsLoading, mIsNetworkError, mIsOver)
|
||||
}
|
||||
|
||||
@ -251,7 +252,8 @@ abstract class BaseCommentAdapter(
|
||||
article: ArticleDetailEntity? = null,
|
||||
questions: QuestionsDetailEntity? = null,
|
||||
comment: CommentEntity? = null,
|
||||
gameCollection: Boolean? = null
|
||||
gameCollection: Boolean? = null,
|
||||
commentDetail: Boolean? = null
|
||||
) {
|
||||
binding.run {
|
||||
filterView.setBackgroundColor(R.color.background_white.toColor(mContext))
|
||||
@ -278,6 +280,9 @@ abstract class BaseCommentAdapter(
|
||||
gameCollection != null -> {
|
||||
"玩家评论"
|
||||
}
|
||||
commentDetail != null -> {
|
||||
"全部讨论"
|
||||
}
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
@ -289,7 +294,7 @@ abstract class BaseCommentAdapter(
|
||||
commentCount.toSimpleCount()
|
||||
}
|
||||
|
||||
divider.goneIf(gameCollection == true)
|
||||
divider.goneIf(gameCollection == true || commentDetail == true)
|
||||
if (orderSfv.getItemList().isEmpty()) {
|
||||
orderSfv.setItemList(listOf("正序", "倒序"), 0)
|
||||
}
|
||||
@ -327,14 +332,6 @@ abstract class BaseCommentAdapter(
|
||||
var type: AdapterType
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
init {
|
||||
if (type == AdapterType.SUB_COMMENT) {
|
||||
binding.userNameTv.textSize = 12F
|
||||
binding.contentTv.textSize = 14F
|
||||
binding.timeTv.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun bindComment(
|
||||
comment: CommentEntity,
|
||||
@ -431,9 +428,9 @@ abstract class BaseCommentAdapter(
|
||||
binding.commentCountTv.text = viewModel.getCommentText(comment.reply, "回复")
|
||||
} else {
|
||||
// 评论详情用的样式
|
||||
binding.floorHintTv.text = CommentUtils.getCommentTime(comment.time)
|
||||
binding.floorHintTv.visibility = View.GONE
|
||||
binding.commentCountTv.setOnClickListener { commentClosure?.invoke(comment) }
|
||||
binding.commentCountTv.setCompoundDrawables(null, null, null, null)
|
||||
// binding.commentCountTv.setCompoundDrawables(null, null, null, null)
|
||||
binding.commentCountTv.text = "回复"
|
||||
binding.likeCountTv.text = viewModel.getLikeText(comment.vote, "")
|
||||
binding.root.setOnClickListener { binding.commentCountTv.performClick() }
|
||||
@ -441,17 +438,16 @@ abstract class BaseCommentAdapter(
|
||||
if (comment.parentUser != null) {
|
||||
val prefix = "回复"
|
||||
val colon = " :"
|
||||
val parentUserName = " ${comment.parentUser?.name} "
|
||||
val parentUserName = " @${comment.parentUser?.name} "
|
||||
|
||||
val prefixSpan = SpanBuilder(prefix).color(
|
||||
binding.root.context,
|
||||
0,
|
||||
prefix.length,
|
||||
R.color.text_subtitleDesc
|
||||
R.color.text_4D4D4D
|
||||
).build()
|
||||
val parentUserNameSpan = SpanBuilder(parentUserName)
|
||||
.bold(0, parentUserName.length)
|
||||
.click(0, parentUserName.length, R.color.text_subtitle) {
|
||||
.click(0, parentUserName.length, R.color.text_subtitleDesc) {
|
||||
DirectUtils.directToHomeActivity(
|
||||
binding.root.context,
|
||||
comment.user.id,
|
||||
@ -465,7 +461,7 @@ abstract class BaseCommentAdapter(
|
||||
binding.root.context,
|
||||
0,
|
||||
colon.length,
|
||||
R.color.text_subtitleDesc
|
||||
R.color.text_4D4D4D
|
||||
).build()
|
||||
val authorSpan = if (comment.parentUser?.me?.isCommentOwner == true) {
|
||||
SpanBuilder("作者").image(0, "作者".length, R.drawable.ic_hint_author).build()
|
||||
@ -596,6 +592,18 @@ abstract class BaseCommentAdapter(
|
||||
}
|
||||
val mtaKey = if (viewModel is ArticleDetailViewModel) "全部评论" else "评论详情-全部回复"
|
||||
|
||||
if (comment.isHighlight) {
|
||||
comment.isHighlight = false
|
||||
binding.highlightBg.run {
|
||||
visibility = View.VISIBLE
|
||||
postDelayed({
|
||||
tryWithDefaultCatch {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
|
||||
if (!comment.images.isNullOrEmpty()) {
|
||||
if (binding.commentPictureRv.adapter == null) {
|
||||
binding.commentPictureRv.apply {
|
||||
@ -613,9 +621,18 @@ abstract class BaseCommentAdapter(
|
||||
binding.commentPictureRv.visibility = View.GONE
|
||||
}
|
||||
bindView(binding, comment)
|
||||
binding.contentTv.setExpandMaxLines(if (comment.isExpand) Int.MAX_VALUE else 4)
|
||||
binding.contentTv.setIsExpanded(comment.isExpand)
|
||||
binding.collapseTv.goneIf(!comment.isExpand)
|
||||
if (comment.isForceExpand) {
|
||||
comment.isForceExpand = false
|
||||
binding.contentTv.setExpandMaxLines(Int.MAX_VALUE)
|
||||
binding.contentTv.setIsExpanded(true)
|
||||
binding.contentTv.post {
|
||||
binding.collapseTv.goneIf(binding.contentTv.lineCount <= 4)
|
||||
}
|
||||
} else {
|
||||
binding.contentTv.setExpandMaxLines(if (comment.isExpand) Int.MAX_VALUE else 4)
|
||||
binding.contentTv.setIsExpanded(comment.isExpand)
|
||||
binding.collapseTv.goneIf(!comment.isExpand)
|
||||
}
|
||||
binding.contentTv.setExpandCallback {
|
||||
comment.isExpand = true
|
||||
binding.collapseTv.visibility = View.VISIBLE
|
||||
@ -664,7 +681,7 @@ abstract class BaseCommentAdapter(
|
||||
)
|
||||
}
|
||||
|
||||
binding.likeCountTv.text = viewModel.getLikeText(comment.vote)
|
||||
binding.likeCountTv.text = viewModel.getLikeText(comment.vote, if (viewModel is CommentConversationViewModel) "" else "赞同")
|
||||
|
||||
if (comment.me?.isCommentVoted == true) {
|
||||
binding.likeCountTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
|
||||
@ -98,10 +98,13 @@ abstract class BaseCommentFragment<T, VM : BaseCommentViewModel> : ListFragment<
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration {
|
||||
|
||||
val drawable = ContextCompat.getDrawable(requireContext(), R.drawable.divider_article_detail_comment)
|
||||
val itemDecoration = if (this !is CommentConversationFragment) {
|
||||
CustomDividerItemDecoration(requireContext(), notDecorateTheFirstTwoItems = true, notDecorateTheLastItem = true)
|
||||
} else {
|
||||
CustomDividerItemDecoration(requireContext(), notDecorateTheFirstItem = true, notDecorateTheLastItem = true)
|
||||
val itemDecoration = when {
|
||||
this !is CommentConversationFragment || mListViewModel.topCommentId.isNotBlank() -> {
|
||||
CustomDividerItemDecoration(requireContext(), notDecorateTheFirstTwoItems = true, notDecorateTheLastItem = true)
|
||||
}
|
||||
else -> {
|
||||
CustomDividerItemDecoration(requireContext(), notDecorateTheFirstItem = true, notDecorateTheLastItem = true)
|
||||
}
|
||||
}
|
||||
|
||||
itemDecoration.setDrawable(drawable!!)
|
||||
|
||||
@ -35,7 +35,8 @@ abstract class BaseCommentViewModel(
|
||||
var articleId: String,
|
||||
var videoId: String,
|
||||
var questionId: String,
|
||||
var communityId: String
|
||||
var communityId: String,
|
||||
var topCommentId: String = ""
|
||||
) : ListViewModel<CommentEntity, CommentItemData>(application) {
|
||||
protected val mApi: ApiService = RetrofitManager.getInstance().api
|
||||
var currentSortType: SortType = SortType.OLDEST
|
||||
@ -46,6 +47,8 @@ abstract class BaseCommentViewModel(
|
||||
|
||||
var commentCount = 0
|
||||
|
||||
var isHandleTopComment = false
|
||||
|
||||
override fun loadStatusControl(size: Int) {
|
||||
if (mCurLoadParams.loadOffset == LoadParams.DEFAULT_OFFSET) { // 初始化列表
|
||||
when {
|
||||
@ -89,7 +92,7 @@ abstract class BaseCommentViewModel(
|
||||
fun mergeListData(
|
||||
commentList: List<CommentEntity>?,
|
||||
displayFloor: Boolean = false,
|
||||
hasFilter: Boolean = true
|
||||
hasFilter: Boolean = true,
|
||||
) {
|
||||
topItemData?.let {
|
||||
val mergedList = arrayListOf<CommentItemData>().apply {
|
||||
@ -112,15 +115,19 @@ abstract class BaseCommentViewModel(
|
||||
} else {
|
||||
//从第二楼开始
|
||||
var floor = 2
|
||||
commentList?.forEach {
|
||||
commentList?.forEachIndexed { index, commentEntity ->
|
||||
if (displayFloor) {
|
||||
it.floor = floor
|
||||
commentEntity.floor = floor
|
||||
}
|
||||
// 没有 me 会导致不能跨页面更新点赞
|
||||
if (it.me == null) {
|
||||
it.me = MeEntity()
|
||||
if (commentEntity.me == null) {
|
||||
commentEntity.me = MeEntity()
|
||||
}
|
||||
add(CommentItemData(commentNormal = it))
|
||||
if (topCommentId.isNotBlank() && index == 0) {
|
||||
commentEntity.isHighlight = true
|
||||
commentEntity.isForceExpand = true
|
||||
}
|
||||
add(CommentItemData(commentNormal = commentEntity))
|
||||
if (displayFloor) {
|
||||
floor++
|
||||
}
|
||||
|
||||
@ -6,7 +6,10 @@ import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.CommentUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.databinding.ItemArticleDetailCommentBinding
|
||||
import com.gh.gamecenter.entity.CommentEntity
|
||||
import com.gh.gamecenter.qa.comment.base.BaseCommentAdapter
|
||||
@ -39,6 +42,10 @@ class CommentConversationAdapter(
|
||||
holder.bindView(mEntityList[position].commentTop!!)
|
||||
}
|
||||
|
||||
is CommentFilterViewHolder -> {
|
||||
holder.bindView(commentDetail = true)
|
||||
}
|
||||
|
||||
else -> super.onBindViewHolder(holder, position)
|
||||
}
|
||||
}
|
||||
@ -54,8 +61,8 @@ class CommentConversationAdapter(
|
||||
clear(binding.commentPictureRv.id, ConstraintSet.START)
|
||||
connect(binding.commentPictureRv.id, ConstraintSet.START, binding.userIconIv.id, ConstraintSet.START)
|
||||
|
||||
clear(binding.timeTv.id, ConstraintSet.START)
|
||||
connect(binding.timeTv.id, ConstraintSet.START, binding.userIconIv.id, ConstraintSet.START)
|
||||
clear(binding.bottomContainer.id, ConstraintSet.START)
|
||||
connect(binding.bottomContainer.id, ConstraintSet.START, binding.userIconIv.id, ConstraintSet.START)
|
||||
|
||||
applyTo(binding.contentTv.parent as ConstraintLayout)
|
||||
}
|
||||
@ -70,17 +77,64 @@ class CommentConversationAdapter(
|
||||
binding.commentPictureRv.layoutParams = this
|
||||
}
|
||||
|
||||
(binding.timeTv.layoutParams as ConstraintLayout.LayoutParams).apply {
|
||||
(binding.bottomContainer.layoutParams as ConstraintLayout.LayoutParams).apply {
|
||||
leftMargin = 9F.dip2px()
|
||||
binding.timeTv.layoutParams = this
|
||||
binding.bottomContainer.layoutParams = this
|
||||
}
|
||||
|
||||
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.contentTv.text = comment.content
|
||||
binding.contentTv.maxLines = Int.MAX_VALUE
|
||||
binding.run {
|
||||
moreIv.visibility = View.GONE
|
||||
divider.visibility = View.VISIBLE
|
||||
commentCountTv.visibility = View.GONE
|
||||
floorHintTv.text = if (comment.floor != 0) "${comment.floor}楼" else ""
|
||||
contentTv.text = comment.content
|
||||
contentTv.maxLines = Int.MAX_VALUE
|
||||
commentTopTimeTv.goneIf(mViewModelCommunity.topCommentId.isBlank())
|
||||
commentTopTimeTv.text = CommentUtils.getCommentTime(comment.time)
|
||||
timeTv.goneIf(mViewModelCommunity.topCommentId.isNotBlank())
|
||||
originalTv.goneIf(mViewModelCommunity.topCommentId.isBlank())
|
||||
originalTv.text = if (mViewModelCommunity.gameCollectionId.isNotEmpty()) "查看游戏单" else "查看原文"
|
||||
originalTv.setOnClickListener {
|
||||
mViewModelCommunity.run {
|
||||
val path = if (gameCollectionId.isNotEmpty()) "评论详情-查看游戏单" else "评论详情-查看原文"
|
||||
when {
|
||||
articleId.isNotEmpty() -> {
|
||||
DirectUtils.directToCommunityArticle(
|
||||
mContext,
|
||||
articleId,
|
||||
communityId,
|
||||
mEntrance,
|
||||
path
|
||||
)
|
||||
}
|
||||
videoId.isNotEmpty() -> {
|
||||
DirectUtils.directToVideoDetail(
|
||||
mContext,
|
||||
videoId,
|
||||
mEntrance,
|
||||
path
|
||||
)
|
||||
}
|
||||
questionId.isNotEmpty() -> {
|
||||
DirectUtils.directToQuestionDetail(
|
||||
mContext,
|
||||
questionId,
|
||||
mEntrance,
|
||||
path
|
||||
)
|
||||
}
|
||||
gameCollectionId.isNotEmpty() -> {
|
||||
DirectUtils.directToGameCollectionDetail(
|
||||
mContext,
|
||||
gameCollectionId,
|
||||
mEntrance,
|
||||
path
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommentItemViewHolder.bindComment(binding, mViewModelCommunity, comment, mEntrance, null)
|
||||
}
|
||||
|
||||
@ -5,8 +5,12 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.ethanhua.skeleton.Skeleton
|
||||
import com.gh.base.ToolBarActivity
|
||||
import com.gh.common.util.CommentHelper
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.common.syncpage.SyncDataEntity
|
||||
import com.gh.gamecenter.common.syncpage.SyncFieldConstants
|
||||
@ -26,19 +30,20 @@ import com.gh.gamecenter.qa.article.detail.CommentItemData
|
||||
import com.gh.gamecenter.qa.comment.CommentActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
class CommentConversationFragment : BaseCommentFragment<CommentItemData, CommentConversationViewModel>() {
|
||||
class CommentConversationFragment :
|
||||
BaseCommentFragment<CommentItemData, CommentConversationViewModel>() {
|
||||
private lateinit var mViewModel: CommentConversationViewModel
|
||||
private lateinit var mBinding: FragmentArticleDetailCommentBinding
|
||||
private var mAdapterCommunity: CommentConversationAdapter? = null
|
||||
|
||||
override fun getLayoutId() = R.layout.fragment_article_detail_comment
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mViewModel = provideListViewModel()
|
||||
super.onCreate(savedInstanceState)
|
||||
mViewModel.getComment()
|
||||
mViewModel.positionInOriginList = arguments?.getInt(EntranceConsts.KEY_POSITION)
|
||||
?: -1
|
||||
?: -1
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -48,20 +53,29 @@ class CommentConversationFragment : BaseCommentFragment<CommentItemData, Comment
|
||||
}
|
||||
|
||||
override fun getInflatedLayout(): View {
|
||||
return FragmentArticleDetailCommentBinding.inflate(LayoutInflater.from(requireContext()), null, false).apply { mBinding = this }.root
|
||||
return FragmentArticleDetailCommentBinding.inflate(
|
||||
LayoutInflater.from(requireContext()),
|
||||
null,
|
||||
false
|
||||
).apply { mBinding = this }.root
|
||||
}
|
||||
|
||||
override fun provideListAdapter(): ListAdapter<*> {
|
||||
return mAdapterCommunity
|
||||
?: CommentConversationAdapter(requireContext(), mViewModel, BaseCommentAdapter.AdapterType.SUB_COMMENT, mEntrance) {
|
||||
if (it.user.id == UserManager.getInstance().userId) {
|
||||
toast("不能回复自己")
|
||||
} else {
|
||||
startCommentActivity(it)
|
||||
}
|
||||
}.apply {
|
||||
mAdapterCommunity = this
|
||||
?: CommentConversationAdapter(
|
||||
requireContext(),
|
||||
mViewModel,
|
||||
BaseCommentAdapter.AdapterType.SUB_COMMENT,
|
||||
mEntrance
|
||||
) {
|
||||
if (it.user.id == UserManager.getInstance().userId) {
|
||||
toast("不能回复自己")
|
||||
} else {
|
||||
startCommentActivity(it)
|
||||
}
|
||||
}.apply {
|
||||
mAdapterCommunity = this
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
@ -72,27 +86,67 @@ class CommentConversationFragment : BaseCommentFragment<CommentItemData, Comment
|
||||
mViewModel.commentDetail?.reply = commentCount
|
||||
mViewModel.commentCount = commentCount
|
||||
mViewModel.load(LoadType.REFRESH)
|
||||
mBinding.toolbarContainer.commentDialogCountTv.text = "${mViewModel.commentDetail?.reply}条回复"
|
||||
SyncPageRepository.postSyncData(SyncDataEntity(mViewModel.commentId, SyncFieldConstants.ARTICLE_COMMENT_REPLY_COUNT, commentCount))
|
||||
mBinding.toolbarContainer.commentDialogCountTv.text =
|
||||
"${mViewModel.commentDetail?.reply}条回复"
|
||||
SyncPageRepository.postSyncData(
|
||||
SyncDataEntity(
|
||||
mViewModel.commentId,
|
||||
SyncFieldConstants.ARTICLE_COMMENT_REPLY_COUNT,
|
||||
commentCount
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mSkeletonScreen = Skeleton.bind(skeletonView).shimmer(false).load(R.layout.fragment_article_detail_comment_skeleton).show()
|
||||
mBinding.run {
|
||||
mSkeletonScreen = Skeleton.bind(skeletonView).shimmer(false)
|
||||
.load(R.layout.fragment_article_detail_comment_skeleton).show()
|
||||
|
||||
mBinding.inputContainer.bottomCommentIv.visibility = View.GONE
|
||||
mBinding.inputContainer.bottomCommentTv.visibility = View.GONE
|
||||
mBinding.inputContainer.bottomLikeIv.visibility = View.GONE
|
||||
mBinding.inputContainer.bottomLikeTv.visibility = View.GONE
|
||||
mBinding.inputContainer.bottomStarIv.visibility = View.GONE
|
||||
mBinding.inputContainer.bottomStarTv.visibility = View.GONE
|
||||
inputContainer.bottomCommentIv.visibility = View.GONE
|
||||
inputContainer.bottomCommentTv.visibility = View.GONE
|
||||
inputContainer.bottomLikeIv.visibility = View.GONE
|
||||
inputContainer.bottomLikeTv.visibility = View.GONE
|
||||
inputContainer.bottomStarIv.visibility = View.GONE
|
||||
inputContainer.bottomStarTv.visibility = View.GONE
|
||||
|
||||
mBinding.inputContainer.replyTv.setRoundedColorBackground(R.color.text_F0F0F0, 19F)
|
||||
mBinding.inputContainer.replyTv.setDebouncedClickListener {
|
||||
mViewModel.commentDetail?.let { startCommentActivity(it) }
|
||||
inputContainer.replyTv.setRoundedColorBackground(R.color.background, 19F)
|
||||
inputContainer.replyTv.setDebouncedClickListener {
|
||||
mViewModel.commentDetail?.let { startCommentActivity(it) }
|
||||
}
|
||||
|
||||
if (mViewModel.topCommentId.isNotBlank()) {
|
||||
initMenu(R.menu.menu_comment_detail)
|
||||
container.layoutParams = (container.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
topMargin = 0
|
||||
}
|
||||
toolbarContainer.root.visibility = View.GONE
|
||||
} else {
|
||||
toolbarContainer.commentCloseIv.setOnClickListener { requireActivity().finish() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(menuItem: MenuItem?) {
|
||||
super.onMenuItemClick(menuItem)
|
||||
if (menuItem?.itemId == R.id.menu_more) {
|
||||
mViewModel.run {
|
||||
val commentEntity = topItemData?.commentTop
|
||||
val actionMenuView = (requireActivity() as? ToolBarActivity)?.actionMenuView
|
||||
if (commentEntity != null && actionMenuView != null) {
|
||||
CommentHelper.showCommentDetailOptions(
|
||||
actionMenuView,
|
||||
commentEntity,
|
||||
articleId,
|
||||
communityId,
|
||||
questionId,
|
||||
videoId,
|
||||
gameCollectionId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
mBinding.toolbarContainer.commentCloseIv.setOnClickListener { requireActivity().finish() }
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -103,14 +157,17 @@ class CommentConversationFragment : BaseCommentFragment<CommentItemData, Comment
|
||||
mReuseNoConn?.visibility = View.GONE
|
||||
mListLoading?.visibility = View.GONE
|
||||
|
||||
val showKeyboard = arguments?.getBoolean(EntranceConsts.KEY_SHOW_KEYBOARD_IF_NEEDED)
|
||||
val showKeyboard =
|
||||
arguments?.getBoolean(EntranceConsts.KEY_SHOW_KEYBOARD_IF_NEEDED)
|
||||
?: false
|
||||
if (showKeyboard) {
|
||||
mBinding.inputContainer.replyTv.performClick()
|
||||
}
|
||||
|
||||
mBinding.inputContainer.replyTv.text = "回复:${mViewModel.commentDetail?.user?.name}"
|
||||
mBinding.toolbarContainer.commentDialogCountTv.text = "${mViewModel.commentDetail?.reply}条回复"
|
||||
mBinding.inputContainer.replyTv.text =
|
||||
"回复 @${mViewModel.commentDetail?.user?.name}"
|
||||
mBinding.toolbarContainer.commentDialogCountTv.text =
|
||||
"${mViewModel.commentDetail?.reply}条回复"
|
||||
AppExecutor.uiExecutor.executeWithDelay(Runnable {
|
||||
if ((mAdapterCommunity?.entityList?.size ?: 0) > 2) {
|
||||
mListRv.smoothScrollToPosition(1)
|
||||
@ -143,14 +200,17 @@ class CommentConversationFragment : BaseCommentFragment<CommentItemData, Comment
|
||||
|
||||
override fun provideListViewModel(): CommentConversationViewModel {
|
||||
return viewModelProvider(
|
||||
CommentConversationViewModel.Factory(
|
||||
HaloApp.getInstance().application,
|
||||
arguments?.getString(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.VIDEO_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.QUESTION_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_COMMUNITY_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.GAME_COLLECTION_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_COMMENT_ID) ?: ""))
|
||||
CommentConversationViewModel.Factory(
|
||||
HaloApp.getInstance().application,
|
||||
arguments?.getString(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.VIDEO_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.QUESTION_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_COMMUNITY_ID) ?: "",
|
||||
arguments?.getString(CommentActivity.GAME_COLLECTION_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_COMMENT_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_TOP_COMMENT_ID) ?: ""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
@ -166,38 +226,43 @@ class CommentConversationFragment : BaseCommentFragment<CommentItemData, Comment
|
||||
private fun startCommentActivity(comment: CommentEntity) {
|
||||
if (mViewModel.articleId.isNotEmpty()) {
|
||||
val intent = CommentActivity.getArticleCommentReplyIntent(
|
||||
requireContext(),
|
||||
mViewModel.articleId,
|
||||
mViewModel.commentDetail?.reply,
|
||||
true,
|
||||
comment.id ?: "",
|
||||
comment,
|
||||
true)
|
||||
requireContext(),
|
||||
mViewModel.articleId,
|
||||
mViewModel.commentDetail?.reply,
|
||||
true,
|
||||
comment.id ?: "",
|
||||
comment,
|
||||
true
|
||||
)
|
||||
startActivityForResult(intent, CommentActivity.REQUEST_CODE)
|
||||
} else if (mViewModel.videoId.isNotEmpty()) {
|
||||
val intent = CommentActivity.getVideoCommentReplyIntent(
|
||||
requireContext(),
|
||||
mViewModel.videoId,
|
||||
mViewModel.commentCount,
|
||||
comment.user.id == UserManager.getInstance().userId,
|
||||
true, true, comment
|
||||
requireContext(),
|
||||
mViewModel.videoId,
|
||||
mViewModel.commentCount,
|
||||
comment.user.id == UserManager.getInstance().userId,
|
||||
true, true, comment
|
||||
)
|
||||
startActivityForResult(intent, CommentActivity.REQUEST_CODE)
|
||||
} else if (mViewModel.questionId.isNotEmpty()) {
|
||||
val intent = CommentActivity.getQuestionCommentReplyIntent(requireContext(),
|
||||
mViewModel.questionId,
|
||||
"",
|
||||
mViewModel.commentCount,
|
||||
true,
|
||||
true,
|
||||
comment)
|
||||
val intent = CommentActivity.getQuestionCommentReplyIntent(
|
||||
requireContext(),
|
||||
mViewModel.questionId,
|
||||
"",
|
||||
mViewModel.commentCount,
|
||||
true,
|
||||
true,
|
||||
comment
|
||||
)
|
||||
startActivityForResult(intent, CommentActivity.REQUEST_CODE)
|
||||
} else if (mViewModel.gameCollectionId.isNotEmpty()) {
|
||||
val intent = CommentActivity.getGameCollectionCommentReplyIntent(requireContext(),
|
||||
val intent = CommentActivity.getGameCollectionCommentReplyIntent(
|
||||
requireContext(),
|
||||
mViewModel.gameCollectionId,
|
||||
arguments?.getString(EntranceConsts.KEY_COMMENT_ID) ?: "",
|
||||
mViewModel.commentCount,
|
||||
comment)
|
||||
comment
|
||||
)
|
||||
startActivityForResult(intent, CommentActivity.REQUEST_CODE)
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,32 +13,45 @@ import io.reactivex.Single
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import retrofit2.HttpException
|
||||
|
||||
class CommentConversationViewModel(application: Application,
|
||||
articleId: String = "",
|
||||
videoId: String = "",
|
||||
questionId: String = "",
|
||||
communityId: String = "",
|
||||
val gameCollectionId: String = "",
|
||||
var commentId: String = "")
|
||||
: BaseCommentViewModel(application, articleId, videoId, questionId, communityId) {
|
||||
class CommentConversationViewModel(
|
||||
application: Application,
|
||||
articleId: String = "",
|
||||
videoId: String = "",
|
||||
questionId: String = "",
|
||||
communityId: String = "",
|
||||
val gameCollectionId: String = "",
|
||||
var commentId: String = "",
|
||||
topCommentId: String = ""
|
||||
) : BaseCommentViewModel(application, articleId, videoId, questionId, communityId, topCommentId) {
|
||||
var commentDetail: CommentEntity? = null
|
||||
var positionInOriginList = -1
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<MutableList<CommentEntity>>? = null
|
||||
|
||||
override fun provideDataSingle(page: Int): Single<MutableList<CommentEntity>>? {
|
||||
val map = hashMapOf<String, Any>()
|
||||
if (topCommentId.isNotEmpty()) {
|
||||
map["top_comment_id"] = topCommentId
|
||||
}
|
||||
return when {
|
||||
articleId.isNotEmpty() -> {
|
||||
mApi.getCommunityArticleCommentReply(communityId, articleId, commentId, currentSortType.value, page)
|
||||
mApi.getCommunityArticleCommentReply(
|
||||
communityId,
|
||||
articleId,
|
||||
commentId,
|
||||
currentSortType.value,
|
||||
page,
|
||||
map
|
||||
)
|
||||
}
|
||||
videoId.isNotEmpty() -> {
|
||||
mApi.getVideoCommentReply(videoId, commentId, currentSortType.value, page)
|
||||
mApi.getVideoCommentReply(videoId, commentId, currentSortType.value, page, map)
|
||||
}
|
||||
questionId.isNotEmpty() -> {
|
||||
mApi.getQuestionCommentReply(questionId, commentId, currentSortType.value, page)
|
||||
mApi.getQuestionCommentReply(questionId, commentId, currentSortType.value, page, map)
|
||||
}
|
||||
gameCollectionId.isNotEmpty() -> {
|
||||
mApi.getGameCollectionCommentReply(gameCollectionId, commentId, page)
|
||||
mApi.getGameCollectionCommentReply(gameCollectionId, commentId, page, map)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
@ -62,49 +75,54 @@ class CommentConversationViewModel(application: Application,
|
||||
else -> null
|
||||
} ?: return
|
||||
single.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<CommentEntity>() {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onSuccess(data: CommentEntity) {
|
||||
commentDetail = data
|
||||
commentDetail?.floor = positionInOriginList
|
||||
commentCount = data.reply
|
||||
topItemData = CommentItemData(commentTop = data)
|
||||
loadResultLiveData.postValue(LoadResult.SUCCESS)
|
||||
mergeListData(mListLiveData.value, hasFilter = false)
|
||||
}
|
||||
.subscribe(object : BiResponse<CommentEntity>() {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onSuccess(data: CommentEntity) {
|
||||
commentDetail = data
|
||||
commentDetail?.floor = positionInOriginList
|
||||
commentCount = data.reply
|
||||
topItemData = CommentItemData(commentTop = data)
|
||||
loadResultLiveData.postValue(LoadResult.SUCCESS)
|
||||
mergeListData(mListLiveData.value, hasFilter = topCommentId.isNotBlank())
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (exception is HttpException && exception.code().toString().contains("404")) {
|
||||
loadResultLiveData.postValue(LoadResult.DELETED)
|
||||
} else {
|
||||
loadResultLiveData.postValue(LoadResult.NETWORK_ERROR)
|
||||
}
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (exception is HttpException && exception.code().toString().contains("404")) {
|
||||
loadResultLiveData.postValue(LoadResult.DELETED)
|
||||
} else {
|
||||
loadResultLiveData.postValue(LoadResult.NETWORK_ERROR)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun mergeResultLiveData() {
|
||||
mResultLiveData.addSource(mListLiveData) { mergeListData(it, hasFilter = false) }
|
||||
mResultLiveData.addSource(mListLiveData) { mergeListData(it, hasFilter = topCommentId.isNotBlank()) }
|
||||
}
|
||||
|
||||
|
||||
class Factory(private val application: Application,
|
||||
private val articleId: String = "",
|
||||
private val videoId: String = "",
|
||||
private val questionId: String = "",
|
||||
private val communityId: String = "",
|
||||
private val gameCollectionId: String = "",
|
||||
private val commentId: String) : ViewModelProvider.NewInstanceFactory() {
|
||||
class Factory(
|
||||
private val application: Application,
|
||||
private val articleId: String = "",
|
||||
private val videoId: String = "",
|
||||
private val questionId: String = "",
|
||||
private val communityId: String = "",
|
||||
private val gameCollectionId: String = "",
|
||||
private val commentId: String,
|
||||
private val topCommentId: String
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return CommentConversationViewModel(
|
||||
application = application,
|
||||
articleId = articleId,
|
||||
videoId = videoId,
|
||||
questionId = questionId,
|
||||
communityId = communityId,
|
||||
gameCollectionId = gameCollectionId,
|
||||
commentId = commentId) as T
|
||||
application = application,
|
||||
articleId = articleId,
|
||||
videoId = videoId,
|
||||
questionId = questionId,
|
||||
communityId = communityId,
|
||||
gameCollectionId = gameCollectionId,
|
||||
commentId = commentId,
|
||||
topCommentId = topCommentId
|
||||
) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,5 +111,23 @@ class NewQuestionDetailActivity : NormalActivity() {
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, path)
|
||||
return intent
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSpecifiedCommentIntent(
|
||||
context: Context,
|
||||
questionId: String,
|
||||
answerId: String,
|
||||
entrance: String,
|
||||
path: String
|
||||
): Intent {
|
||||
val intent = Intent(context, NewQuestionDetailActivity::class.java)
|
||||
intent.putExtra(EntranceConsts.KEY_ENTRANCE, mergeEntranceAndPath(entrance, path))
|
||||
intent.putExtra(EntranceConsts.KEY_QUESTIONS_ID, questionId)
|
||||
intent.putExtra(EntranceConsts.KEY_ANSWER_ID, answerId)
|
||||
intent.putExtra(EntranceConsts.KEY_TOP_COMMENT_ID, answerId)
|
||||
intent.putExtra(EntranceConsts.KEY_SCROLL_TO_COMMENT_AREA, true)
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, path)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,7 +452,8 @@ class NewQuestionDetailFragment :
|
||||
arguments?.getString(EntranceConsts.KEY_QUESTIONS_ID) ?: "",
|
||||
arguments?.getParcelable<CommunityEntity>(EntranceConsts.KEY_COMMUNITY_DATA)?.id ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_ANSWER_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_RECOMMEND_ID) ?: ""
|
||||
arguments?.getString(EntranceConsts.KEY_RECOMMEND_ID) ?: "",
|
||||
arguments?.getString(EntranceConsts.KEY_RECOMMEND_ID) ?: "",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ -40,13 +40,15 @@ class NewQuestionDetailViewModel(
|
||||
communityId: String = "",
|
||||
val answerId: String = "",
|
||||
val recommendId: String = "",
|
||||
topCommentId: String = "",
|
||||
) :
|
||||
BaseCommentViewModel(
|
||||
application,
|
||||
articleId = "",
|
||||
communityId = communityId,
|
||||
videoId = "",
|
||||
questionId = questionId
|
||||
questionId = questionId,
|
||||
topCommentId = topCommentId
|
||||
) {
|
||||
var questionRenderedLiveData = MutableLiveData<Boolean>()
|
||||
var questionPageFinishedLiveData = MutableLiveData<Boolean>()
|
||||
@ -221,7 +223,8 @@ class NewQuestionDetailViewModel(
|
||||
private val questionId: String = "",
|
||||
private val communityId: String = "",
|
||||
private val answerId: String = "",
|
||||
private val recommendId: String = ""
|
||||
private val recommendId: String = "",
|
||||
private val topCommentId: String = ""
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
@ -230,7 +233,8 @@ class NewQuestionDetailViewModel(
|
||||
questionId = questionId,
|
||||
communityId = communityId,
|
||||
answerId = answerId,
|
||||
recommendId = recommendId
|
||||
recommendId = recommendId,
|
||||
topCommentId = topCommentId
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,9 +45,10 @@ class ForumVideoDetailActivity : BaseActivity() {
|
||||
|
||||
fun getIntent(
|
||||
context: Context,
|
||||
videoId: String, bbsId: String
|
||||
videoId: String,
|
||||
bbsId: String
|
||||
): Intent {
|
||||
return getIntent(context, videoId, bbsId, "", false)
|
||||
return getIntent(context, videoId, bbsId, "", "", false)
|
||||
}
|
||||
|
||||
fun getIntent(
|
||||
@ -56,7 +57,7 @@ class ForumVideoDetailActivity : BaseActivity() {
|
||||
bbsId: String,
|
||||
scrollToComment: Boolean = false
|
||||
): Intent {
|
||||
return getIntent(context, videoId, bbsId, "", scrollToComment)
|
||||
return getIntent(context, videoId, bbsId, "", "", scrollToComment)
|
||||
}
|
||||
|
||||
fun getRecommendIntent(
|
||||
@ -65,7 +66,16 @@ class ForumVideoDetailActivity : BaseActivity() {
|
||||
bbsId: String,
|
||||
recommendId: String
|
||||
): Intent {
|
||||
return getIntent(context, videoId, bbsId, recommendId, false)
|
||||
return getIntent(context, videoId, bbsId, recommendId, "", false)
|
||||
}
|
||||
|
||||
fun getSpecifiedCommentIntent(
|
||||
context: Context,
|
||||
videoId: String,
|
||||
bbsId: String,
|
||||
topCommentId: String
|
||||
): Intent {
|
||||
return getIntent(context, videoId, bbsId, "", topCommentId, true)
|
||||
}
|
||||
|
||||
fun getIntent(
|
||||
@ -73,12 +83,14 @@ class ForumVideoDetailActivity : BaseActivity() {
|
||||
videoId: String,
|
||||
bbsId: String,
|
||||
recommendId: String = "",
|
||||
topCommentId: String = "",
|
||||
scrollToComment: Boolean = false
|
||||
): Intent {
|
||||
val intent = Intent(context, ForumVideoDetailActivity::class.java)
|
||||
intent.putExtra(EntranceConsts.KEY_VIDEO_ID, videoId)
|
||||
intent.putExtra(EntranceConsts.KEY_BBS_ID, bbsId)
|
||||
intent.putExtra(EntranceConsts.KEY_RECOMMEND_ID, recommendId)
|
||||
intent.putExtra(EntranceConsts.KEY_TOP_COMMENT_ID, topCommentId)
|
||||
if (scrollToComment) {
|
||||
intent.putExtra(PAGE_INDEX, 1)
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ class ForumVideoDetailFragment : BaseFragment_TabLayout() {
|
||||
private var mForumVideoEntity: ForumVideoEntity? = null
|
||||
private var mVideoId = ""
|
||||
private var mBbsId = ""
|
||||
private var mTopCommentId = ""
|
||||
private var mVideoDescFragment: VideoDescFragment? = null
|
||||
private var mVideoCommentFragment: VideoCommentFragment? = null
|
||||
private var mIsPortrait = false
|
||||
@ -100,7 +101,11 @@ class ForumVideoDetailFragment : BaseFragment_TabLayout() {
|
||||
})
|
||||
fragments.add(VideoCommentFragment().apply {
|
||||
arguments =
|
||||
bundleOf(EntranceConsts.KEY_VIDEO_ID to mVideoId, EntranceConsts.KEY_BBS_ID to mBbsId)
|
||||
bundleOf(
|
||||
EntranceConsts.KEY_VIDEO_ID to mVideoId,
|
||||
EntranceConsts.KEY_BBS_ID to mBbsId,
|
||||
EntranceConsts.KEY_TOP_COMMENT_ID to mTopCommentId
|
||||
)
|
||||
mVideoCommentFragment = this
|
||||
})
|
||||
}
|
||||
@ -113,6 +118,7 @@ class ForumVideoDetailFragment : BaseFragment_TabLayout() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mVideoId = arguments?.getString(EntranceConsts.KEY_VIDEO_ID) ?: ""
|
||||
mBbsId = arguments?.getString(EntranceConsts.KEY_BBS_ID) ?: ""
|
||||
mTopCommentId = arguments?.getString(EntranceConsts.KEY_TOP_COMMENT_ID) ?: ""
|
||||
super.onCreate(savedInstanceState)
|
||||
NewLogUtils.logVideoDetailClick("view_video_detail")
|
||||
}
|
||||
|
||||
@ -53,7 +53,13 @@ class VideoCommentFragment : LazyListFragment<CommentItemData, VideoCommentViewM
|
||||
}
|
||||
|
||||
override fun provideListViewModel(): VideoCommentViewModel {
|
||||
return viewModelProvider(VideoCommentViewModel.Factory(mVideoId, mBbsId))
|
||||
return viewModelProvider(
|
||||
VideoCommentViewModel.Factory(
|
||||
mVideoId,
|
||||
mBbsId,
|
||||
arguments?.getString(EntranceConsts.KEY_TOP_COMMENT_ID) ?: ""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onRealLayoutInflated(inflatedView: View) {
|
||||
|
||||
@ -12,12 +12,21 @@ import com.gh.gamecenter.qa.article.detail.CommentItemData
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.Observable
|
||||
|
||||
class VideoCommentViewModel(application: Application, videoId: String, bbsId: String) :
|
||||
BaseCommentViewModel(application, "", videoId, "", bbsId) {
|
||||
class VideoCommentViewModel(
|
||||
application: Application,
|
||||
videoId: String,
|
||||
bbsId: String,
|
||||
topCommentId: String
|
||||
) : BaseCommentViewModel(application, "", videoId, "", bbsId, topCommentId) {
|
||||
var videoDetail: ForumVideoEntity? = null
|
||||
val deleteCommentLiveData = MutableLiveData<Boolean>()
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<MutableList<CommentEntity>>? {
|
||||
val map = hashMapOf<String, Any>()
|
||||
map["sort"] = currentSortType.value
|
||||
if (topCommentId.isNotEmpty()) {
|
||||
map["top_comment_id"] = topCommentId
|
||||
}
|
||||
return mApi.getVideoCommentList(videoId, page, mapOf("sort" to currentSortType.value))
|
||||
}
|
||||
|
||||
@ -30,9 +39,13 @@ class VideoCommentViewModel(application: Application, videoId: String, bbsId: St
|
||||
itemDataList.add(CommentItemData(errorConnection = true))
|
||||
} else {
|
||||
var floor = 1
|
||||
list.forEach {
|
||||
it.floor = floor
|
||||
itemDataList.add(CommentItemData(commentNormal = it))
|
||||
list.forEachIndexed { index, commentEntity ->
|
||||
commentEntity.floor = floor
|
||||
if (topCommentId.isNotBlank() && index == 0) {
|
||||
commentEntity.isHighlight = true
|
||||
commentEntity.isForceExpand = true
|
||||
}
|
||||
itemDataList.add(CommentItemData(commentNormal = commentEntity))
|
||||
floor++
|
||||
}
|
||||
itemDataList.add(CommentItemData(footer = true))
|
||||
@ -46,10 +59,10 @@ class VideoCommentViewModel(application: Application, videoId: String, bbsId: St
|
||||
deleteCommentLiveData.postValue(true)
|
||||
}
|
||||
|
||||
class Factory(private val videoId: String, private val bbsId: String) :
|
||||
class Factory(private val videoId: String, private val bbsId: String, private val topCommentId: String) :
|
||||
ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return VideoCommentViewModel(HaloApp.getInstance().application, videoId, bbsId) as T
|
||||
return VideoCommentViewModel(HaloApp.getInstance().application, videoId, bbsId, topCommentId) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1489,7 +1489,8 @@ public interface ApiService {
|
||||
Observable<List<CommentEntity>> getCommunityArticleCommentList(@Path("community_id") String communityId,
|
||||
@Path("article_id") String articleId,
|
||||
@Query("sort") String type,
|
||||
@Query("page") int page);
|
||||
@Query("page") int page,
|
||||
@QueryMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取社区文章评论的对话列表.
|
||||
@ -1516,7 +1517,8 @@ public interface ApiService {
|
||||
@Path("article_id") String articleId,
|
||||
@Path("comment_id") String commentId,
|
||||
@Query("sort") String sort,
|
||||
@Query("page") int page);
|
||||
@Query("page") int page,
|
||||
@QueryMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 评论社区文章评论
|
||||
@ -3118,7 +3120,11 @@ public interface ApiService {
|
||||
* 获取问题评论(回答)的回复(评论)列表
|
||||
*/
|
||||
@GET("bbses/questions/{question_id}/comments/{comment_id}/replies")
|
||||
Single<List<CommentEntity>> getQuestionCommentReply(@Path("question_id") String questionId, @Path("comment_id") String commentId, @Query("sort") String sort, @Query("page") int page);
|
||||
Single<List<CommentEntity>> getQuestionCommentReply(@Path("question_id") String questionId,
|
||||
@Path("comment_id") String commentId,
|
||||
@Query("sort") String sort,
|
||||
@Query("page") int page,
|
||||
@QueryMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 点赞问题评论(回答)
|
||||
@ -3172,7 +3178,11 @@ public interface ApiService {
|
||||
* 获取视频评论回复
|
||||
*/
|
||||
@GET("videos/{video_id}/comments/{comment_id}/replies")
|
||||
Single<List<CommentEntity>> getVideoCommentReply(@Path("video_id") String videoId, @Path("comment_id") String commentId, @Query("sort") String sort, @Query("page") int page);
|
||||
Single<List<CommentEntity>> getVideoCommentReply(@Path("video_id") String videoId,
|
||||
@Path("comment_id") String commentId,
|
||||
@Query("sort") String sort,
|
||||
@Query("page") int page,
|
||||
@QueryMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 加精视频贴
|
||||
@ -3399,7 +3409,10 @@ public interface ApiService {
|
||||
* 获取游戏单评论的回复列表
|
||||
*/
|
||||
@GET("api_go/game_list/{game_list_id}/comment/{comment_id}/reply")
|
||||
Single<List<CommentEntity>> getGameCollectionCommentReply(@Path("game_list_id") String gameCollectionId, @Path("comment_id") String commentId, @Query("page") int page);
|
||||
Single<List<CommentEntity>> getGameCollectionCommentReply(@Path("game_list_id") String gameCollectionId,
|
||||
@Path("comment_id") String commentId,
|
||||
@Query("page") int page,
|
||||
@QueryMap Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 游戏单添加评论
|
||||
|
||||
Reference in New Issue
Block a user