|
@@ -1,21 +1,16 @@
|
|
|
package com.sheep.gamegroup.view.fragment;
|
|
package com.sheep.gamegroup.view.fragment;
|
|
|
|
|
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.v7.widget.AppCompatRatingBar;
|
|
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
-import android.widget.ImageView;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
|
-import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
|
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
|
|
-import com.sheep.gamegroup.absBase.BaseListActivity2;
|
|
|
|
|
-import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
|
|
import com.sheep.gamegroup.model.api.ApiService;
|
|
import com.sheep.gamegroup.model.api.ApiService;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.UserComment;
|
|
import com.sheep.gamegroup.model.entity.UserComment;
|
|
@@ -23,13 +18,11 @@ import com.sheep.gamegroup.model.entity.UserCommentDetail;
|
|
|
import com.sheep.gamegroup.model.entity.UserCommentReply;
|
|
import com.sheep.gamegroup.model.entity.UserCommentReply;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
|
-import com.sheep.gamegroup.util.DataUtil;
|
|
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.RefreshUtil;
|
|
import com.sheep.gamegroup.util.RefreshUtil;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
-import com.sheep.gamegroup.util.TextViewUtil;
|
|
|
|
|
-import com.sheep.gamegroup.util.ViewUtil;
|
|
|
|
|
|
|
+import com.sheep.gamegroup.util.viewHelper.UserCommentHelper;
|
|
|
import com.sheep.gamegroup.view.adapter.AdpUserCommentReply;
|
|
import com.sheep.gamegroup.view.adapter.AdpUserCommentReply;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
@@ -60,6 +53,7 @@ public class FgtUserCommentDetail extends BaseListFragment3<UserCommentReply> {
|
|
|
SmartRefreshLayout refresh;
|
|
SmartRefreshLayout refresh;
|
|
|
@BindView(R.id.bottom)
|
|
@BindView(R.id.bottom)
|
|
|
RelativeLayout bottom;
|
|
RelativeLayout bottom;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
TitleBarUtils.getInstance().setTitle(mView, "回复详情")
|
|
TitleBarUtils.getInstance().setTitle(mView, "回复详情")
|
|
@@ -95,88 +89,49 @@ public class FgtUserCommentDetail extends BaseListFragment3<UserCommentReply> {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-// ------------------------------start header------------------------------------
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // ------------------------------start header------------------------------------
|
|
|
|
|
+ private UserCommentHelper headerViewHelper;
|
|
|
|
|
+
|
|
|
private LinearLayout user_comment_detail_game_ll;
|
|
private LinearLayout user_comment_detail_game_ll;
|
|
|
- private TextView user_comment_detail_game_name;
|
|
|
|
|
- private ImageView user_comment_detail_game_icon;
|
|
|
|
|
- private ImageView user_comment_detail_user_avatar;
|
|
|
|
|
- private TextView user_comment_detail_user_name;
|
|
|
|
|
- private TextView user_comment_detail_user_publish_time;
|
|
|
|
|
- private AppCompatRatingBar user_comment_detail_user_publish_score;
|
|
|
|
|
- private TextView user_comment_detail_num1;
|
|
|
|
|
- private TextView user_comment_detail_num2;
|
|
|
|
|
- private TextView user_comment_detail_num3;
|
|
|
|
|
//初始化headerView
|
|
//初始化headerView
|
|
|
private void initHeaderView() {
|
|
private void initHeaderView() {
|
|
|
- headerView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.header_user_comment_detail, null);
|
|
|
|
|
-
|
|
|
|
|
- user_comment_detail_game_ll = headerView.findViewById(R.id.user_comment_detail_game_ll);
|
|
|
|
|
- user_comment_detail_game_name = headerView.findViewById(R.id.user_comment_detail_game_name);
|
|
|
|
|
- user_comment_detail_game_icon = headerView.findViewById(R.id.user_comment_detail_game_icon);
|
|
|
|
|
- user_comment_detail_user_avatar = headerView.findViewById(R.id.user_comment_detail_user_avatar);
|
|
|
|
|
- user_comment_detail_user_name = headerView.findViewById(R.id.user_comment_detail_user_name);
|
|
|
|
|
- user_comment_detail_user_publish_time = headerView.findViewById(R.id.user_comment_detail_user_publish_time);
|
|
|
|
|
- user_comment_detail_user_publish_score = headerView.findViewById(R.id.user_comment_detail_user_publish_score);
|
|
|
|
|
- user_comment_detail_num1 = headerView.findViewById(R.id.user_comment_detail_num1);
|
|
|
|
|
- user_comment_detail_num2 = headerView.findViewById(R.id.user_comment_detail_num2);
|
|
|
|
|
- user_comment_detail_num3 = headerView.findViewById(R.id.user_comment_detail_num3);
|
|
|
|
|
- }
|
|
|
|
|
- //加载数据
|
|
|
|
|
- private void loadHeaderViewData(final UserComment user_comment){
|
|
|
|
|
- user_comment_detail_game_ll.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View view) {
|
|
|
|
|
- //点击游戏
|
|
|
|
|
- if(user_comment != null)
|
|
|
|
|
- Jump2View.getInstance().goPlayGameDetail(activity, user_comment.getApp_id());
|
|
|
|
|
- else
|
|
|
|
|
- G.showToast(R.string.loading_data);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- user_comment_detail_user_publish_score.setMax(10);
|
|
|
|
|
- user_comment_detail_user_publish_score.setProgress(user_comment.getScore());
|
|
|
|
|
- ViewUtil.setText(user_comment_detail_num1, user_comment.getComment());
|
|
|
|
|
- ViewUtil.setText(user_comment_detail_num2, user_comment.getLike());
|
|
|
|
|
- ViewUtil.setText(user_comment_detail_num3, user_comment.getExpression());
|
|
|
|
|
- ViewUtil.setText(user_comment_detail_game_name, user_comment.getApp_name());
|
|
|
|
|
- ViewUtil.setText(user_comment_detail_user_name, user_comment.getNickname());
|
|
|
|
|
- user_comment_detail_user_publish_time.setText(DateUtil.getTimeText(user_comment.getCreate_time()));
|
|
|
|
|
- ViewUtil.setGameImage(user_comment_detail_game_icon, user_comment.getApp_icon());
|
|
|
|
|
- ViewUtil.setAvatar(user_comment_detail_user_avatar, user_comment.getAvatar());
|
|
|
|
|
- TextViewUtil.initIntroView(headerView, user_comment.getShowAll(), "全文");
|
|
|
|
|
|
|
+ headerViewHelper = new UserCommentHelper(R.layout.header_user_comment_detail);
|
|
|
|
|
+ user_comment_detail_game_ll = headerViewHelper.getRootView().findViewById(R.id.user_comment_detail_game_ll);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// ------------------------------end header------------------------------------
|
|
|
|
|
|
|
+ // ------------------------------end header------------------------------------
|
|
|
//用户评论一个用户对游戏的评论
|
|
//用户评论一个用户对游戏的评论
|
|
|
private void commitContent(String content) {
|
|
private void commitContent(String content) {
|
|
|
- if(TestUtil.isDev()) G.showToast("评论内容:" + content);
|
|
|
|
|
- if(content.isEmpty()){
|
|
|
|
|
|
|
+ if (TestUtil.isDev()) G.showToast("评论内容:" + content);
|
|
|
|
|
+ if (content.isEmpty()) {
|
|
|
G.showToast("评论内容不能为空");
|
|
G.showToast("评论内容不能为空");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
// 发表评论
|
|
// 发表评论
|
|
|
ApiJSONUtil.postGameUserUserComment(user_comment_id, false, content)
|
|
ApiJSONUtil.postGameUserUserComment(user_comment_id, false, content)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
- G.showToast(baseMessage);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
|
|
- G.showToast(baseMessage);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//输入框
|
|
//输入框
|
|
|
private EditText bottom_user_comment_detail_input;
|
|
private EditText bottom_user_comment_detail_input;
|
|
|
|
|
|
|
|
- private View headerView;
|
|
|
|
|
private View footerView;
|
|
private View footerView;
|
|
|
|
|
|
|
|
private int user_comment_id;
|
|
private int user_comment_id;
|
|
|
|
|
+
|
|
|
public void setUser_comment_id(int user_comment_id) {
|
|
public void setUser_comment_id(int user_comment_id) {
|
|
|
this.user_comment_id = user_comment_id;
|
|
this.user_comment_id = user_comment_id;
|
|
|
}
|
|
}
|
|
@@ -187,11 +142,12 @@ public class FgtUserCommentDetail extends BaseListFragment3<UserCommentReply> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private AdpUserCommentReply adapter;
|
|
private AdpUserCommentReply adapter;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected RecyclerView.Adapter getAdapter() {
|
|
protected RecyclerView.Adapter getAdapter() {
|
|
|
//用户评论的回复列表
|
|
//用户评论的回复列表
|
|
|
adapter = new AdpUserCommentReply(list);
|
|
adapter = new AdpUserCommentReply(list);
|
|
|
- adapter.addHeaderView(headerView);
|
|
|
|
|
|
|
+ adapter.addHeaderView(headerViewHelper.getRootView());
|
|
|
return adapter;
|
|
return adapter;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -207,12 +163,22 @@ public class FgtUserCommentDetail extends BaseListFragment3<UserCommentReply> {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected List<UserCommentReply> resolveData(BaseMessage baseMessage, int page) {
|
|
protected List<UserCommentReply> resolveData(BaseMessage baseMessage, int page) {
|
|
|
- UserCommentDetail userCommentDetail = baseMessage.getData(UserCommentDetail.class);
|
|
|
|
|
- if(page == 0){
|
|
|
|
|
|
|
+ final UserCommentDetail userCommentDetail = baseMessage.getData(UserCommentDetail.class);
|
|
|
|
|
+ if (page == 0) {
|
|
|
adapter.setUserComment(userCommentDetail.getUser_comment());
|
|
adapter.setUserComment(userCommentDetail.getUser_comment());
|
|
|
- loadHeaderViewData(userCommentDetail.getUser_comment());
|
|
|
|
|
|
|
+ headerViewHelper.loadHeaderViewData(userCommentDetail.getUser_comment());
|
|
|
|
|
+ user_comment_detail_game_ll.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View view) {
|
|
|
|
|
+ //点击游戏
|
|
|
|
|
+ if(userCommentDetail.getUser_comment() != null)
|
|
|
|
|
+ Jump2View.getInstance().goPlayGameDetail(activity, userCommentDetail.getUser_comment().getApp_id());
|
|
|
|
|
+ else
|
|
|
|
|
+ G.showToast(R.string.loading_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- if(userCommentDetail != null && userCommentDetail.getUser_comment_reply() != null && userCommentDetail.getUser_comment_reply().getReply_list() != null)
|
|
|
|
|
|
|
+ if (userCommentDetail != null && userCommentDetail.getUser_comment_reply() != null && userCommentDetail.getUser_comment_reply().getReply_list() != null)
|
|
|
return userCommentDetail.getUser_comment_reply().getReply_list();
|
|
return userCommentDetail.getUser_comment_reply().getReply_list();
|
|
|
return ListUtil.emptyList();
|
|
return ListUtil.emptyList();
|
|
|
}
|
|
}
|
|
@@ -224,12 +190,12 @@ public class FgtUserCommentDetail extends BaseListFragment3<UserCommentReply> {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void updateEmptyView() {
|
|
protected void updateEmptyView() {
|
|
|
- if(adapter != null){
|
|
|
|
|
- if(list.isEmpty()) {
|
|
|
|
|
- if(footerView.getParent() == null)//未添加尾部view
|
|
|
|
|
|
|
+ if (adapter != null) {
|
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
|
+ if (footerView.getParent() == null)//未添加尾部view
|
|
|
adapter.addFooterView(footerView);
|
|
adapter.addFooterView(footerView);
|
|
|
} else {
|
|
} else {
|
|
|
- if(footerView.getParent() != null)//已经添加尾部view
|
|
|
|
|
|
|
+ if (footerView.getParent() != null)//已经添加尾部view
|
|
|
adapter.removeFooterView(footerView);
|
|
adapter.removeFooterView(footerView);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|