diff --git a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java index 95122cbbe4..58c26c3be3 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java @@ -3,6 +3,7 @@ package com.gh.gamecenter.adapter; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; +import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -143,16 +144,20 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { private void initCommentViewHolder(final CommentViewHolder holder, int position) { final CommentEntity commentEntity = mCommentList.get(position); - holder.commentLine.setVisibility(View.GONE); - holder.commentLineBottom.setVisibility(View.VISIBLE); + holder.commentLine.setVisibility(View.VISIBLE); + holder.commentLineBottom.setVisibility(View.GONE); CommentUtils.setCommentUserView(mContext, holder, commentEntity); CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime()); - if (commentEntity.getParent() != null) { - holder.commentContentTv.setText("@" + commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent()); + + holder.commentContentTv.setText(commentEntity.getContent()); + if (commentEntity.getParent() != null && !TextUtils.isEmpty(commentEntity.getParent().getUser().getName())) { + holder.quoteContainer.setVisibility(View.VISIBLE); + holder.quoteAuthorTv.setText(String.format("@%s", commentEntity.getParent().getUser().getName())); + holder.quoteContentTv.setText(commentEntity.getParent().getComment()); } else { - holder.commentContentTv.setText(commentEntity.getContent()); + holder.quoteContainer.setVisibility(View.GONE); } holder.commentLikeIv.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java index 67875b2140..44e0b01ac6 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; import android.text.Html; +import android.text.TextUtils; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; @@ -271,7 +272,6 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter { mContext.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(mContext, 34)); } -// viewHolder.thumb.setImageURI(mConcernEntity.getGameIcon()); ImageUtils.display(viewHolder.thumb, mConcernEntity.getGameIcon()); viewHolder.title.setText(mConcernEntity.getGameName()); NewsUtils.setNewsPublishOn(viewHolder.time, mConcernEntity.getTime()); @@ -369,11 +369,13 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter { return; } - if (commentEntity.getParent() != null) { - holder.commentContentTv.setText(StringUtils.buildString("回复", commentEntity.getParent().getUser().getName(), - ": ", commentEntity.getContent())); + holder.commentContentTv.setText(commentEntity.getContent()); + if (commentEntity.getParent() != null && !TextUtils.isEmpty(commentEntity.getParent().getUser().getName())) { + holder.quoteContainer.setVisibility(View.VISIBLE); + holder.quoteAuthorTv.setText(String.format("@%s", commentEntity.getParent().getUser().getName())); + holder.quoteContentTv.setText(commentEntity.getParent().getComment()); } else { - holder.commentContentTv.setText(commentEntity.getContent()); + holder.quoteContainer.setVisibility(View.GONE); } CommentUtils.setCommentUserView(mContext, holder, commentEntity); 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 84f13edb2b..479f2026da 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 @@ -1,6 +1,7 @@ package com.gh.gamecenter.adapter.viewholder; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; @@ -36,6 +37,13 @@ public class CommentViewHolder extends BaseRecyclerViewHolder { @BindView(R.id.comment_badge) public View commentBadge; + @BindView(R.id.comment_quote_container) + public ViewGroup quoteContainer; + @BindView(R.id.comment_quote_author_tv) + public TextView quoteAuthorTv; + @BindView(R.id.comment_quote_content_tv) + public TextView quoteContentTv; + public CommentViewHolder(View itemView) { super(itemView); } diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDetailTopViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDetailTopViewHolder.java deleted file mode 100644 index bf4bbcaa37..0000000000 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDetailTopViewHolder.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gh.gamecenter.adapter.viewholder; - -import android.view.View; -import android.widget.TextView; - -import com.facebook.drawee.view.SimpleDraweeView; -import com.gh.base.BaseRecyclerViewHolder; -import com.gh.gamecenter.R; - -import butterknife.BindView; - -/** - * Created by LGT on 2016/9/8. - */ -public class GameDetailTopViewHolder extends BaseRecyclerViewHolder { - - @BindView(R.id.gamedetail_iv_thumb) - public SimpleDraweeView gamedetailThumb; - @BindView(R.id.gamedetail_tv_name) - public TextView gamedetailName; - @BindView(R.id.gamedetail_tv_info) - public TextView gamedetailInfo; - @BindView(R.id.gamedetail_tv_concern) - public TextView gamedetailConcern; - - public GameDetailTopViewHolder(View itemView) { - super(itemView); - } - -} diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/NewsDetailGameViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/NewsDetailGameViewHolder.java new file mode 100644 index 0000000000..d30d75da5f --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/NewsDetailGameViewHolder.java @@ -0,0 +1,34 @@ +package com.gh.gamecenter.adapter.viewholder; + +import android.view.View; +import android.widget.TextView; + +import com.facebook.drawee.view.SimpleDraweeView; +import com.gh.base.BaseRecyclerViewHolder; +import com.gh.gamecenter.R; + +import butterknife.BindView; + +/** + * Created by LGT on 2016/9/8. + */ +public class NewsDetailGameViewHolder extends BaseRecyclerViewHolder { + + @BindView(R.id.game_iv_thumb) + public SimpleDraweeView gameThumb; + @BindView(R.id.game_tv_name) + public TextView gameName; + @BindView(R.id.game_tv_info) + public TextView gameInfo; + @BindView(R.id.game_tv_concern) + public TextView gameConcern; + @BindView(R.id.game_iv_libao) + public View libaoIcon; + @BindView(R.id.game_server_type) + public TextView gameServerType; + + public NewsDetailGameViewHolder(View itemView) { + super(itemView); + } + +} diff --git a/app/src/main/java/com/gh/gamecenter/entity/ArticleCommentParent.kt b/app/src/main/java/com/gh/gamecenter/entity/ArticleCommentParent.kt new file mode 100644 index 0000000000..c61e43f811 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/ArticleCommentParent.kt @@ -0,0 +1,13 @@ +package com.gh.gamecenter.entity + +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +data class ArticleCommentParent(val user: User = User(), + val comment: String = "") : Parcelable + +@Parcelize +data class User(val name: String = "") : Parcelable + + diff --git a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt index 4504f72e49..07a3c619bd 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt @@ -14,7 +14,7 @@ class CommentEntity() : Parcelable { var user: UserEntity = UserEntity() - var parent: CommentParentEntity? = null + var parent: ArticleCommentParent? = null @SerializedName("parent_user") var parentUser: CommentParentEntity? = null diff --git a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java index 388dbf027d..57788cbd37 100644 --- a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java +++ b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java @@ -12,16 +12,12 @@ import android.text.TextWatcher; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.ScrollView; import android.widget.TextView; -import com.facebook.drawee.view.SimpleDraweeView; import com.gh.common.constant.Config; import com.gh.common.util.CheckLoginUtils; import com.gh.common.util.DialogUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.ImageUtils; import com.gh.common.util.LoginUtils; import com.gh.common.util.PostCommentUtils; import com.gh.common.util.TimestampUtils; @@ -56,7 +52,6 @@ import java.util.List; import butterknife.BindView; import butterknife.OnClick; -import butterknife.OnTouch; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import retrofit2.HttpException; @@ -73,28 +68,12 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa @BindView(R.id.message_detail_rv) RecyclerView mMessageDetailRv; - @BindView(R.id.message_detail_user_rl) - RelativeLayout mMessageDetailUserRl; - @BindView(R.id.message_detail_comment_rl) - RelativeLayout mMessageDetailCommentRl; - @BindView(R.id.comment_user_icon) - SimpleDraweeView mMessageDetailIconDv; - @BindView(R.id.comment_user_name) - TextView mMessageDetailUserNameTv; - @BindView(R.id.comment_send) + @BindView(R.id.comment_send_btn) TextView mMessageDetailCommentSend; - @BindView(R.id.message_detail_comment_et) + @BindView(R.id.comment_et) EditText mMessageDetailEt; - @BindView(R.id.message_detail_comment_hint_rl) - RelativeLayout mMessageDetailCommentHintRl; - @BindView(R.id.message_detail_sv) - ScrollView mMessageDetailSv; - @BindView(R.id.message_detail_hint_line) - View mMessageDetailLine; @BindView(R.id.reuse_no_connection) LinearLayout mNoConnection; - @BindView(R.id.message_detail_close_comment) - View mColseCommentV; private LinearLayoutManager mLayoutManager; @@ -190,10 +169,6 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa }); mUserInfo = UserManager.getInstance().getUserInfoEntity(); - if (mUserInfo != null) { - ImageUtils.display(mMessageDetailIconDv, mUserInfo.getIcon()); - mMessageDetailUserNameTv.setText(mUserInfo.getName()); - } if (newsId != null && mConcernEntity == null) { getConcernDigest(); @@ -273,11 +248,9 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa }); } - @OnClick({R.id.message_detail_comment_hint_rl, R.id.reuse_no_connection}) + @OnClick({R.id.reuse_no_connection}) public void OnViewClick(View view) { - if (view.getId() == R.id.message_detail_comment_hint_rl) { - setSoftInput(true); - } else if (view.getId() == R.id.reuse_no_connection) { + if (view.getId() == R.id.reuse_no_connection) { if (newsId != null && mConcernEntity == null) { showNoConnection(false); } @@ -289,14 +262,9 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa if (isShow) { CheckLoginUtils.checkLogin(getContext(), () -> { Util_System_Keyboard.showSoftKeyboard(getContext(), mMessageDetailEt); - mMessageDetailCommentHintRl.setVisibility(View.GONE); - mMessageDetailLine.setVisibility(View.GONE); - mMessageDetailCommentRl.setVisibility(View.VISIBLE); - mMessageDetailUserRl.setVisibility(View.VISIBLE); mMessageDetailEt.setFocusable(true); mMessageDetailEt.setFocusableInTouchMode(true); mMessageDetailEt.requestFocus(); - mColseCommentV.setVisibility(View.VISIBLE); if (mCommentEntity != null && mCommentEntity.getUser() != null) { mMessageDetailEt.setHint(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); @@ -306,11 +274,6 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa }); } else { Util_System_Keyboard.hideSoftKeyboard(getActivity()); - mMessageDetailCommentHintRl.setVisibility(View.VISIBLE); - mMessageDetailLine.setVisibility(View.VISIBLE); - mMessageDetailCommentRl.setVisibility(View.GONE); - mMessageDetailUserRl.setVisibility(View.GONE); - mColseCommentV.setVisibility(View.GONE); if (mCommentEntity != null) { mCommentEntity = null; // 清空当前评论实体 @@ -320,15 +283,7 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa } } - @OnTouch(R.id.message_detail_close_comment) - public boolean OnRecyclerTouchListener() { - if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) { - setSoftInput(false); - } - return true; - } - - @OnClick(R.id.comment_send) + @OnClick(R.id.comment_send_btn) public void OnSendCommentListener() { final String content = mMessageDetailEt.getText().toString(); @@ -460,9 +415,6 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa if (newsId != null) { getConcernDigest(); } - if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) { - setSoftInput(false); - } } } @@ -471,10 +423,6 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa public void onEventMainThread(EBReuse reuse) { if (reuse.getType().equals(LOGIN_TAG)) { // 登入 mUserInfo = UserManager.getInstance().getUserInfoEntity(); - if (mUserInfo != null) { - ImageUtils.display(mMessageDetailIconDv, mUserInfo.getIcon()); - mMessageDetailUserNameTv.setText(mUserInfo.getName()); - } } } diff --git a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java index 5fce788ba8..0c108b3f0e 100644 --- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java @@ -9,6 +9,7 @@ import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; +import android.text.Layout; import android.text.TextUtils; import android.view.Gravity; import android.view.View; @@ -18,6 +19,7 @@ import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import com.gh.base.OnRequestCallBackListener; @@ -46,8 +48,8 @@ import com.gh.gamecenter.ViewImageActivity; import com.gh.gamecenter.WebActivity; import com.gh.gamecenter.adapter.viewholder.CommentViewHolder; import com.gh.gamecenter.adapter.viewholder.GameDetailNewsViewHolder; -import com.gh.gamecenter.adapter.viewholder.GameDetailTopViewHolder; import com.gh.gamecenter.adapter.viewholder.NewsDetailCommentListViewHolder; +import com.gh.gamecenter.adapter.viewholder.NewsDetailGameViewHolder; import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.CommentEntity; import com.gh.gamecenter.entity.CommentnumEntity; @@ -139,7 +141,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { return new NewsDetailContentViewHolder(view); case 1: view = mLayoutInflater.inflate(R.layout.newsdetail_item_game, parent, false); - return new GameDetailTopViewHolder(view); + return new NewsDetailGameViewHolder(view); case 2: view = mLayoutInflater.inflate(R.layout.gamedetail_item_news, parent, false); return new GameDetailNewsViewHolder(view); @@ -156,8 +158,8 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof NewsDetailContentViewHolder) { initNewsDetailContentViewHolder((NewsDetailContentViewHolder) holder); - } else if (holder instanceof GameDetailTopViewHolder) { - initGameDetailTopViewHolder((GameDetailTopViewHolder) holder); + } else if (holder instanceof NewsDetailGameViewHolder) { + initGameViewHolder((NewsDetailGameViewHolder) holder); } else if (holder instanceof GameDetailNewsViewHolder) { initNewsDetailNewsViewHolder((GameDetailNewsViewHolder) holder); } else if (holder instanceof NewsDetailCommentListViewHolder) { @@ -322,37 +324,81 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { } } - private void initGameDetailTopViewHolder(final GameDetailTopViewHolder viewHolder) { - ImageUtils.display(viewHolder.gamedetailThumb, mGameEntity.getIcon()); - viewHolder.gamedetailName.setText(mGameEntity.getName()); + private void initGameViewHolder(final NewsDetailGameViewHolder viewHolder) { + ImageUtils.display(viewHolder.gameThumb, mGameEntity.getIcon()); + viewHolder.gameName.setText(mGameEntity.getName()); if (mGameEntity.getApk() != null && mGameEntity.getApk().size() != 0) { for (int i = 0, size = mGameEntity.getApk().size(); i < size; i++) { ApkEntity apkEntity = mGameEntity.getApk().get(i); if ("9u".equals(apkEntity.getPlatform())) { - viewHolder.gamedetailInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize())); + viewHolder.gameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize())); break; } if (i == size - 1) { - viewHolder.gamedetailInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize())); + viewHolder.gameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize())); } } } if (mNewsDetailEntity.getMe() != null && mNewsDetailEntity.getMe().isGameConcerned()) { - viewHolder.gamedetailConcern.setText(R.string.cancel_concern); - viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.button_normal_border); - viewHolder.gamedetailConcern.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); + viewHolder.gameConcern.setText(R.string.cancel_concern); + viewHolder.gameConcern.setBackgroundResource(R.drawable.button_normal_border); + viewHolder.gameConcern.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); } else { - viewHolder.gamedetailConcern.setText(R.string.concern); - viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.button_normal_style); - viewHolder.gamedetailConcern.setTextColor(Color.WHITE); + viewHolder.gameConcern.setText(R.string.concern); + viewHolder.gameConcern.setBackgroundResource(R.drawable.button_normal_style); + viewHolder.gameConcern.setTextColor(Color.WHITE); } - viewHolder.gamedetailConcern.setOnClickListener(new View.OnClickListener() { + + if (mGameEntity.isLibaoExists()) { + viewHolder.libaoIcon.setVisibility(View.VISIBLE); + } else { + viewHolder.libaoIcon.setVisibility(View.GONE); + } + + String serverRemark = mGameEntity.getServerRemark(); + if (TextUtils.isEmpty(serverRemark)) { + String serverGenre = mGameEntity.getServerGenre(); + if (TextUtils.isEmpty(serverGenre)) { + viewHolder.gameServerType.setVisibility(View.GONE); + } else { + viewHolder.gameServerType.setVisibility(View.INVISIBLE); + viewHolder.gameServerType.setText(serverGenre); + viewHolder.gameServerType.setBackgroundResource(R.drawable.textview_yellow_bg); + } + } else { + viewHolder.gameServerType.setVisibility(View.INVISIBLE); + viewHolder.gameServerType.setText(serverRemark); + viewHolder.gameServerType.setBackgroundResource(R.drawable.textview_orange_up); + } + + viewHolder.gameName.post(() -> { + if (viewHolder.gameServerType.getVisibility() == View.INVISIBLE) { + int nameWidth = viewHolder.gameName.getWidth(); + int typeWidth = viewHolder.gameServerType.getWidth(); + + Layout layout = viewHolder.gameName.getLayout(); + if (layout != null) { + float lineRight = layout.getLineRight(layout.getLineCount() - 1); + int margin = DisplayUtils.dip2px(2); + if (nameWidth - lineRight > typeWidth + margin) { + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewHolder.gameServerType.getLayoutParams(); + layoutParams.leftMargin = (int) (lineRight + margin); + viewHolder.gameServerType.setLayoutParams(layoutParams); + } else { + viewHolder.gameName.setMinLines(layout.getLineCount() + 1); + } + viewHolder.gameServerType.setVisibility(View.VISIBLE); + } + } + }); + + viewHolder.gameConcern.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final TextView concern = ((TextView) v); CheckLoginUtils.checkLogin(mContext, () -> { String str = concern.getText().toString(); - viewHolder.gamedetailConcern.setEnabled(false); + viewHolder.gameConcern.setEnabled(false); if (mContext.getString(R.string.concern).equals(str)) { // 添加关注 ConcernUtils.INSTANCE.postConcernGameId(mContext, mGameEntity.getId() @@ -370,13 +416,13 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { concern.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); Utils.toast(mContext, R.string.concern_success); - viewHolder.gamedetailConcern.setEnabled(true); + viewHolder.gameConcern.setEnabled(true); } @Override public void onError() { Utils.toast(mContext, R.string.concern_failure); - viewHolder.gamedetailConcern.setEnabled(true); + viewHolder.gameConcern.setEnabled(true); } }); } else { @@ -402,20 +448,20 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { concern.setText(mContext.getString(R.string.concern)); concern.setBackgroundResource(R.drawable.button_normal_style); concern.setTextColor(Color.WHITE); - viewHolder.gamedetailConcern.setEnabled(true); + viewHolder.gameConcern.setEnabled(true); } @Override public void onError() { Utils.toast(mContext, R.string.cancel_concern_failure); - viewHolder.gamedetailConcern.setEnabled(true); + viewHolder.gameConcern.setEnabled(true); } }); } }, new DialogUtils.CancelListener() { @Override public void onCancel() { - viewHolder.gamedetailConcern.setEnabled(true); + viewHolder.gameConcern.setEnabled(true); } }); } @@ -504,13 +550,15 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { viewHolder.commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote())); holder.list.addView(contentView); - if (commentEntity.getParent() != null) { - viewHolder.commentContentTv.setText("回复" + commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent()); + viewHolder.commentContentTv.setText(commentEntity.getContent()); + if (commentEntity.getParent() != null && !TextUtils.isEmpty(commentEntity.getParent().getUser().getName())) { + viewHolder.quoteContainer.setVisibility(View.VISIBLE); + viewHolder.quoteAuthorTv.setText(String.format("@%s", commentEntity.getParent().getUser().getName())); + viewHolder.quoteContentTv.setText(commentEntity.getParent().getComment()); } else { - viewHolder.commentContentTv.setText(commentEntity.getContent()); + viewHolder.quoteContainer.setVisibility(View.GONE); } - NewsUtils.setNewsDetailTime(viewHolder.commentTimeTv, commentEntity.getTime()); @@ -541,7 +589,6 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { View view = new View(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT , DisplayUtils.dip2px(mContext, 1)); - params.setMargins(DisplayUtils.dip2px(mContext, 10), 0, DisplayUtils.dip2px(mContext, 10), 0); view.setLayoutParams(params); view.setBackgroundColor(ContextCompat.getColor(mContext, R.color.cutting_line)); linearLayout.addView(view); diff --git a/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java index f265a6d524..654be004d7 100644 --- a/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java @@ -8,15 +8,11 @@ import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.EditText; -import android.widget.RelativeLayout; -import android.widget.ScrollView; import android.widget.TextView; -import com.facebook.drawee.view.SimpleDraweeView; import com.gh.common.util.CheckLoginUtils; import com.gh.common.util.DialogUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.ImageUtils; import com.gh.common.util.LoginUtils; import com.gh.common.util.PostCommentUtils; import com.gh.gamecenter.NewsDetailActivity; @@ -25,8 +21,6 @@ import com.gh.gamecenter.adapter.CommentDetailAdapter; import com.gh.gamecenter.adapter.OnCommentCallBackListener; import com.gh.gamecenter.entity.CommentEntity; import com.gh.gamecenter.entity.MessageEntity; -import com.gh.gamecenter.entity.UserInfoEntity; -import com.gh.gamecenter.manager.UserManager; import com.gh.gamecenter.normal.NormalFragment; import com.lightgame.utils.Util_System_Keyboard; import com.lightgame.utils.Utils; @@ -34,8 +28,6 @@ import com.lightgame.utils.Utils; import org.json.JSONException; import org.json.JSONObject; -import java.io.IOException; - import butterknife.BindView; import butterknife.OnClick; import butterknife.OnTouch; @@ -45,38 +37,30 @@ import retrofit2.HttpException; * Created by CsHeng on 14/12/2017. *

* 评论详情页面-查看对话详情 - * TODO: 16/11/17 时间比较紧 先暂时这么做 最好发表评论那块和评论详情整合 */ public class CommentDetailFragment extends NormalFragment implements OnCommentCallBackListener { @BindView(R.id.comment_detail_rv) RecyclerView mRecyclerView; - @BindView(R.id.comment_detail_close_comment) - View mCommentDetailCloseComment; - @BindView(R.id.comment_detail_comment_et) + @BindView(R.id.comment_et) EditText mCommentDetailCommentEt; - @BindView(R.id.comment_user_icon) - SimpleDraweeView mCommentUserIcon; - @BindView(R.id.comment_user_name) - TextView mCommentUserName; - @BindView(R.id.comment_send) + @BindView(R.id.comment_send_btn) TextView mCommentSend; - @BindView(R.id.comment_detail_user_rl) - RelativeLayout mCommentDetailUserRl; - @BindView(R.id.comment_detail_comment_rl) - RelativeLayout mCommentDetailCommentRl; - @BindView(R.id.comment_detail_sv) - ScrollView mCommentDetailSv; @BindView(R.id.reuse_none_data) View mNoData; @BindView(R.id.reuse_tv_none_data) TextView mNoDataTv; @BindView(R.id.skip_article_detail_btn) TextView mSkipArticleDetail; + @BindView(R.id.comment_content_container) + View mCommentContentContainer; + @BindView(R.id.comment_line) + View mCommentLine; + @BindView(R.id.comment_detail_close_comment) + View mCommentDetailCloseComment; private Dialog mSendingDialog; - private UserInfoEntity mUserInfo; private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空 private CommentDetailAdapter mAdapter; @@ -114,13 +98,6 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa } }); - mUserInfo = UserManager.getInstance().getUserInfoEntity(); - if (mUserInfo != null) { - ImageUtils.display(mCommentUserIcon, mUserInfo.getIcon()); - mCommentUserName.setText(mUserInfo.getName()); - } - - // 显示原文跳转按钮 if (mArticle != null) { mSkipArticleDetail.setVisibility(View.VISIBLE); @@ -167,13 +144,13 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa @OnTouch(R.id.comment_detail_close_comment) public boolean OnRecyclerTouchListener() { - if (mCommentDetailCloseComment.getVisibility() == View.VISIBLE) { + if (mCommentContentContainer.getVisibility() == View.VISIBLE) { setSoftInput(false); } return true; } - @OnClick({R.id.comment_send}) + @OnClick({R.id.comment_send_btn}) public void OnSendCommentListener() { final String content = mCommentDetailCommentEt.getText().toString(); @@ -229,7 +206,8 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa if (isShow) { CheckLoginUtils.checkLogin(getContext(), () -> { Util_System_Keyboard.showSoftKeyboard(getContext(), mCommentDetailCommentEt); - mCommentDetailCommentRl.setVisibility(View.VISIBLE); + mCommentContentContainer.setVisibility(View.VISIBLE); + mCommentLine.setVisibility(View.VISIBLE); mCommentDetailCommentEt.setFocusable(true); mCommentDetailCommentEt.setFocusableInTouchMode(true); mCommentDetailCommentEt.requestFocus(); @@ -244,9 +222,9 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa } else { Util_System_Keyboard.hideSoftKeyboard(getContext(), mCommentDetailCommentEt); + mCommentContentContainer.setVisibility(View.GONE); + mCommentLine.setVisibility(View.GONE); mCommentDetailCloseComment.setVisibility(View.GONE); - - mCommentDetailCommentRl.setVisibility(View.GONE); if (mCommentEntity != null) { mCommentEntity = null; // 清空当前评论实体 mCommentDetailCommentEt.setHint(getString(R.string.message_detail_comment_hint)); diff --git a/app/src/main/res/drawable-xhdpi/ic_edit.png b/app/src/main/res/drawable-xhdpi/ic_edit.png index 878e0b30ad..f7d805bacf 100644 Binary files a/app/src/main/res/drawable-xhdpi/ic_edit.png and b/app/src/main/res/drawable-xhdpi/ic_edit.png differ diff --git a/app/src/main/res/layout/activity_news_detail.xml b/app/src/main/res/layout/activity_news_detail.xml index 487fea8929..9eafa1fcc9 100644 --- a/app/src/main/res/layout/activity_news_detail.xml +++ b/app/src/main/res/layout/activity_news_detail.xml @@ -55,11 +55,13 @@ android:id = "@+id/comment_icon" android:layout_width = "wrap_content" android:layout_height = "wrap_content" + android:layout_centerVertical = "true" android:src = "@drawable/ic_edit" /> - + + android:id="@+id/comment_line" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/cutting_line" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:layout_marginLeft="20dp" + android:layout_marginRight="10dp" + android:layout_marginTop="12dp"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + android:id="@+id/comment_line_bottom" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/cutting_line" + android:visibility="gone" + tools:visibility="visible" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_comment_detail.xml b/app/src/main/res/layout/fragment_comment_detail.xml index 82113e42b4..92e2033aaf 100644 --- a/app/src/main/res/layout/fragment_comment_detail.xml +++ b/app/src/main/res/layout/fragment_comment_detail.xml @@ -1,6 +1,5 @@ @@ -8,7 +7,7 @@ android:id = "@+id/skip_article_detail_btn" android:layout_width = "match_parent" android:layout_height = "40dp" - android:layout_marginBottom = "8dp" + android:layout_marginBottom = "7dp" android:layout_marginTop = "8dp" android:background = "@android:color/white" android:drawableLeft = "@drawable/article_link" @@ -18,13 +17,14 @@ android:singleLine = "true" android:textColor = "@color/theme" android:textSize = "13dp" - android:visibility = "visible" /> + android:visibility = "gone" /> - + android:layout_above = "@+id/comment_content_container" + android:visibility = "gone" /> + + android:layout_above = "@+id/comment_content_container" + android:background = "@drawable/shadow" + android:visibility = "gone" /> - + android:background = "@android:color/transparent" + android:visibility = "gone" > - - - + android:layout_height = "wrap_content" > + android:layout_height = "50dp" + android:layout_below = "@id/comment_line" + android:background = "@android:color/white" > - - - - +