From 75c332ade19ce4c38e5a38e5128d44562d20249e Mon Sep 17 00:00:00 2001 From: kehaoyuan Date: Fri, 14 Sep 2018 18:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV3.5-?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E8=AF=A6=E6=83=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/CommentDetailAdapter.java | 15 +- .../adapter/MessageDetailAdapter.java | 12 +- .../adapter/viewholder/CommentViewHolder.java | 8 + .../viewholder/GameDetailTopViewHolder.java | 30 --- .../viewholder/NewsDetailGameViewHolder.java | 34 +++ .../gamecenter/entity/ArticleCommentParent.kt | 13 + .../com/gh/gamecenter/entity/CommentEntity.kt | 2 +- .../message/MessageDetailFragment.java | 62 +---- .../newsdetail/NewsDetailAdapter.java | 101 +++++-- .../comment/CommentDetailFragment.java | 50 +--- app/src/main/res/drawable-xhdpi/ic_edit.png | Bin 1572 -> 351 bytes .../main/res/layout/activity_news_detail.xml | 2 + app/src/main/res/layout/comment_item.xml | 254 +++++++++++------- .../res/layout/fragment_comment_detail.xml | 106 +++----- .../res/layout/fragment_message_detail.xml | 159 ++++------- app/src/main/res/layout/gamedetail_body.xml | 19 +- .../main/res/layout/gamedetail_item_news.xml | 47 ++-- .../main/res/layout/newsdetail_item_game.xml | 89 ++++-- app/src/main/res/values/strings.xml | 2 +- 19 files changed, 517 insertions(+), 488 deletions(-) delete mode 100644 app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDetailTopViewHolder.java create mode 100644 app/src/main/java/com/gh/gamecenter/adapter/viewholder/NewsDetailGameViewHolder.java create mode 100644 app/src/main/java/com/gh/gamecenter/entity/ArticleCommentParent.kt 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 878e0b30ad01b0339761f80ead03d1c7f35ec0ee..f7d805bacf9bbad6b7db405fb0f8b810ca5009dc 100644 GIT binary patch literal 351 zcmeAS@N?(olHy`uVBq!ia0vp^N}9ba4!cXnlLl-utkFM8n7V zid&kUOGJ*p>-#HmQ-xOJt>x>nbGX6xVJ47yb{6Op$tI zTp~5)#f-n|hfNM@`0SEk-)Qw%Ff#M8&XZTy`knnHR9`$!?G-NlD8RBwpnQ7RpL5#3 zH1BN?ciXll?BXlVeXg0*c7(;>w0oxQInF-ad#&0$XYTKw`lPb& utNs1VjEb+~oklNTscNTo{YZ)B{J~fq?#AR`tz!cWI0jEwKbLh*2~7aiL7H&@ literal 1572 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m^Cs(B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuk*h0bFQqR!T z(!$6@N5ROz&`jUJQs2--*TB%qz|zXVPyq^*fVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD#PU%0_}#n6BP2AO_EVu8M)o`HUDF34YC)x{-2sR(CaRb3oXS&*t9 zlvu;MHs8T$Gwvl3x^(pPvJZ zy?~7TlKkR~`~n4MXHaaJD`@y8CTHe>1T{ec40Ug6QD#|cid#{Bt^zoOtTM5^x=oo!a^ddz!ObD2U zKumbz1#;lYKQ#}S=8J%dd*eBYg$xW#lRRA~)nQ<~(Bv7C|y{Ai#MO=j|%OS8h z&|gR(=?I6E#ABhyO&W{LS^XcyKhSNTu$yb1N%x`@Cq2$%ZzW2_*VAI%N6+NQ6&r1?31Rv7nd$koT{F%<|85Z5 zI#qL?C0p+Yl}G=|b}%k3u$g{(@2q!;H-jR34w(DAe<&t$M(?2fKc=}K44q>5Lr#9P z+@e%uveIF9#YFjSfBgiv7257*u6n3#a**vso8XP(yW>=1n?w1g2QlAiIe&rY{F9T5 zg>IdcU+bx5@Y*9r;F@XyU)%CKo0k^w_{3cIN!i%C)&KoZ&h&*=DW4hk9kja7B)#R? zzQcYNYkpekOzsWswBEqM_ftforPPP>qe$Li&lTY_GpG3KZkeFsyz%vd<_&B&cgf4O zU%RtpPli+d4BkiYe%|t2*0$ABMNi`U!LH9NG98~{ELqwPTg4no^N(;lN&zGY29#VrGuP=$iq&F z#Jee+jDa_+oLF!7I&>PJuPqP>+kE$hi^8KYkb*YHGvCF z3ng9n4CV$MeBYp}cj%Y8wdY)`w}pFlc2}<7HHr0ukl${R>243g&fa~sV{K_Y$6Eu9 zi8E)4WW2p(Gj*E#2PwPC|9X8=QN_%f`(ORrznFji^P;0BOx$v;Vw2V#-2N@_?5|n# zKfF-h_`ITh>e}Y2^qj`@l8Ta(liBaDY&&K>`)Bl|B}yBVE*$@%dVryQ?~$1b{Fj|U O<+i7*pUXO@geCxnU00p} 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" > - - - - +