Przeglądaj źródła

修改评论的顺序

zengjiebin 7 lat temu
rodzic
commit
109bfb7f6c

+ 5 - 1
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtGameComment.java

@@ -91,10 +91,11 @@ public class FgtGameComment extends BaseListFragment3<UserComment> {
         });
 
         //评论列表
-        AdpGcGameAppComment adapter = new AdpGcGameAppComment(list);
+        adapter = new AdpGcGameAppComment(list);
         adapter.addHeaderView(headerView);
         return adapter;
     }
+    private AdpGcGameAppComment adapter;
 
     @Override
     protected String getKey(int page, int per_page) {
@@ -125,6 +126,9 @@ public class FgtGameComment extends BaseListFragment3<UserComment> {
     }
     @Override
     public void notifyDataSetChanged() {
+        if(lastMessage != null && adapter != null){
+            adapter.setTotal(lastMessage.getTotal());
+        }
         super.notifyDataSetChanged();
         int totalCount = list.size();
         if(lastMessage != null && lastMessage.getTotal() > totalCount)

+ 14 - 1
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpArticleComment.java

@@ -42,6 +42,15 @@ public class AdpArticleComment extends BaseQuickAdapter<UserComment, BaseViewHol
         this.hasCommentDetail = hasCommentDetail;
         return this;
     }
+    private int total = 0;
+
+    public void setTotal(int total) {
+        this.total = total;
+    }
+
+    public int getTotal() {
+        return total;
+    }
 
     @Override
     protected void convert(BaseViewHolder helper, final UserComment item) {
@@ -62,7 +71,11 @@ public class AdpArticleComment extends BaseQuickAdapter<UserComment, BaseViewHol
         ViewUtil.setText(article_comment_num2, item.getLike());
         ViewUtil.setText(article_comment_num3, item.getExpression());
         ViewUtil.setText(article_comment_user_name, item.getNickname());
-        ViewUtil.setText(article_comment_time_tv, String.format(Locale.CHINA, "%d楼\u3000%s", position + 1, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm")));
+        if(total == 0){
+            ViewUtil.setText(article_comment_time_tv, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm"));
+        } else {
+            ViewUtil.setText(article_comment_time_tv, String.format(Locale.CHINA, "%d楼\u3000%s", total - position, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm")));
+        }
         //String.format(Locale.CHINA, "%d %d %d %d", position, helper.getAdapterPosition(), helper.getLayoutPosition(), helper.getOldPosition()));
         TextViewUtil.initIntroView(helper.itemView, item.getShowAll());
         ViewUtil.setVisibility(article_comment_num1, hasCommentDetail);

+ 14 - 1
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpGcGameAppComment.java

@@ -32,6 +32,15 @@ public class AdpGcGameAppComment extends BaseQuickAdapter<UserComment, BaseViewH
         super(R.layout.item_gc_game_app_comment, list);
     }
 
+    private int total = 0;
+
+    public void setTotal(int total) {
+        this.total = total;
+    }
+
+    public int getTotal() {
+        return total;
+    }
     @Override
     protected void convert(BaseViewHolder helper, final UserComment item) {
         int position = helper.getAdapterPosition() - getHeaderLayoutCount();
@@ -54,7 +63,11 @@ public class AdpGcGameAppComment extends BaseQuickAdapter<UserComment, BaseViewH
         game_app_comment_score.setProgress(item.getScore());
         game_app_comment_score.setMax(10);
         ViewUtil.setText(game_app_comment_user_name, item.getNickname());
-        ViewUtil.setText(game_app_comment_time_tv, String.format(Locale.CHINA, "%d楼\u3000%s", position + 1, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm")));
+        if(total == 0){
+            ViewUtil.setText(game_app_comment_time_tv, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm"));
+        } else {
+            ViewUtil.setText(game_app_comment_time_tv, String.format(Locale.CHINA, "%d楼\u3000%s", total - position, TimeUtil.TimeStamp2Date(item.getCreate_time(), "yyyy-MM-dd\u0020hh:mm")));
+        }
         //String.format(Locale.CHINA, "%d %d %d %d", position, helper.getAdapterPosition(), helper.getLayoutPosition(), helper.getOldPosition()));
         TextViewUtil.initIntroView(helper.itemView, item.getShowAll());
 

+ 6 - 1
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtArticleComment.java

@@ -50,6 +50,7 @@ import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -205,10 +206,11 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> implements
         this.article_id = article_id;
     }
 
+    private AdpArticleComment adapter;
     @Override
     protected RecyclerView.Adapter getAdapter() {
         //用户评论的回复列表
-        AdpArticleComment adapter = new AdpArticleComment(list);
+        adapter = new AdpArticleComment(list);
         adapter.addHeaderView(headerView);
         return adapter;
     }
@@ -357,6 +359,9 @@ public class FgtArticleComment extends BaseListFragment3<UserComment> implements
 
     @Override
     public void notifyDataSetChanged() {
+        if(lastMessage != null && adapter != null){
+            adapter.setTotal(lastMessage.getTotal());
+        }
         super.notifyDataSetChanged();
         int totalCount = list.size();
         if (lastMessage != null && lastMessage.getTotal() > totalCount)

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtVideoComment.java

@@ -28,6 +28,7 @@ import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
+import java.util.List;
 import java.util.Locale;
 
 import butterknife.BindView;
@@ -137,6 +138,9 @@ public class FgtVideoComment extends BaseListFragment4<UserComment> {
 
     @Override
     public void notifyDataSetChanged() {
+        if(lastMessage != null && adapter instanceof AdpArticleComment){
+            ((AdpArticleComment) adapter).setTotal(lastMessage.getTotal());
+        }
         super.notifyDataSetChanged();
         if (lastMessage != null)
             ViewUtil.setText(video_comment_title_tv, R.string.total_x_comment, String.valueOf(lastMessage.getTotal()));