Browse Source

Fix comments

Infinite 3 years ago
parent
commit
3f76ac646e

+ 7 - 3
app/src/main/java/club/thepenguins/android/activities/PostActivity.java

@@ -79,7 +79,7 @@ public class PostActivity extends AppCompatActivity {
         image = getIntent().getStringExtra("image");
         image = getIntent().getStringExtra("image");
         link = getIntent().getStringExtra("link");
         link = getIntent().getStringExtra("link");
 
 
-        loader = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
+        loader = findViewById(R.id.shimmer_view_container);
 
 
         postData = new ArrayList<>();
         postData = new ArrayList<>();
         comments = new ArrayList<>();
         comments = new ArrayList<>();
@@ -221,7 +221,8 @@ public class PostActivity extends AppCompatActivity {
                 .build();
                 .build();
 
 
         APIService service = retrofit.create(APIService.class);
         APIService service = retrofit.create(APIService.class);
-        Call<List<Comments>> call = service.getPostComments(id);
+        Call<List<Comments>> call = service.getPostComments(id, "parent", "asc", "50");
+        System.out.println(id);
 
 
 
 
         call.enqueue(new retrofit2.Callback<List<Comments>>() {
         call.enqueue(new retrofit2.Callback<List<Comments>>() {
@@ -230,7 +231,10 @@ public class PostActivity extends AppCompatActivity {
 
 
                 for (int i = 0; i < response.body().size(); i++) {
                 for (int i = 0; i < response.body().size(); i++) {
 
 
-                    comments.add(new CommentModel(response.body().get(i).getAuthorAvatarUrls().get96(), response.body().get(i).getAuthorName(), response.body().get(i).getDate(), response.body().get(i).getContent().getRendered()));
+                    comments.add(new CommentModel(response.body().get(i).getAuthorAvatarUrls().get96(),
+                            response.body().get(i).getAuthorName(),
+                            response.body().get(i).getDate(),
+                            response.body().get(i).getContent().getRendered()));
 
 
                     System.out.println(response.body().get(i).getContent());
                     System.out.println(response.body().get(i).getContent());
                 }
                 }

+ 4 - 1
app/src/main/java/club/thepenguins/android/api/APIService.java

@@ -28,7 +28,10 @@ public interface APIService {
     Call<List<Posts>> getAuthorPosts(@Query("author") String id);
     Call<List<Posts>> getAuthorPosts(@Query("author") String id);
 
 
     @GET("wp-json/wp/v2/comments")
     @GET("wp-json/wp/v2/comments")
-    Call<List<Comments>> getPostComments(@Query("post") String id);
+    Call<List<Comments>> getPostComments(@Query("post") String id,
+                                         @Query("orderby") String orderby,
+                                         @Query("order") String order,
+                                         @Query("per_page") String perPage);
 
 
     @GET("wp-json/wp/v2/categories")
     @GET("wp-json/wp/v2/categories")
     Call<List<Category>> getCategories();
     Call<List<Category>> getCategories();

+ 26 - 1
app/src/main/java/club/thepenguins/android/data/CommentModel.java

@@ -2,7 +2,16 @@ package club.thepenguins.android.data;
 
 
 public class CommentModel {
 public class CommentModel {
 
 
-    private String image, author, time, content;
+    private String image, author, time, content, parent, child;
+
+    public CommentModel(String image, String author, String time, String content, String parent, String child) {
+        this.image = image;
+        this.author = author;
+        this.time = time;
+        this.content = content;
+        this.parent = parent;
+        this.child = child;
+    }
 
 
     public CommentModel(String image, String author, String time, String content) {
     public CommentModel(String image, String author, String time, String content) {
 
 
@@ -49,4 +58,20 @@ public class CommentModel {
     public void setImage(String image) {
     public void setImage(String image) {
         this.image = image;
         this.image = image;
     }
     }
+
+    public String getParent() {
+        return parent;
+    }
+
+    public void setParent(String parent) {
+        this.parent = parent;
+    }
+
+    public String getChild() {
+        return child;
+    }
+
+    public void setChild(String child) {
+        this.child = child;
+    }
 }
 }

+ 1 - 1
app/src/main/res/values-night/colors.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <resources>
-    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimary">#2196F3</color>
     <color name="colorPrimaryDark">#303F9F</color>
     <color name="colorPrimaryDark">#303F9F</color>
     <color name="colorAccent">#F77000</color>
     <color name="colorAccent">#F77000</color>
     <color name="daynight_textcolor">#FF8222</color>
     <color name="daynight_textcolor">#FF8222</color>

+ 1 - 1
app/src/main/res/values/colors.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <resources>
-    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimary">#0000FF</color>
     <color name="colorPrimaryDark">#303F9F</color>
     <color name="colorPrimaryDark">#303F9F</color>
     <color name="colorAccent">#FF4081</color>
     <color name="colorAccent">#FF4081</color>
     <color name="daynight_textcolor">#0044cc</color>
     <color name="daynight_textcolor">#0044cc</color>

+ 0 - 0
git