From 82a5f2285290136007df25d5e760cac42f8cef3a Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Tue, 14 Apr 2020 10:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B8=96=E5=AD=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 + .../data/main/forum/ForumMyRequest.java | 4 +- .../data/main/forum/ForumNewRequest.java | 11 ++- .../community/pocket/data/model/Active.java | 44 +++++++++ .../community/pocket/data/model/Complain.java | 24 +++++ .../community/pocket/data/model/Forum.java | 93 ++++++++++++------- .../pocket/data/model/ForumStatus.java | 10 ++ .../pocket/data/model/ForumType.java | 7 ++ .../com/community/pocket/data/model/Page.java | 62 +++++++++++++ .../pocket/ui/main/ui/forum/ForumPost.java | 32 +++++-- .../ui/main/ui/forum/my/ForumMyFragment.java | 11 ++- .../ui/main/ui/forum/my/ForumMyResponse.java | 9 +- .../ui/main/ui/forum/my/ForumMyViewModel.java | 4 +- .../main/ui/forum/news/ForumNewFragment.java | 10 +- .../main/ui/forum/news/ForumNewResponse.java | 9 +- .../main/ui/forum/news/ForumNewViewModel.java | 4 +- .../layout/main/layout/forum/layout/post.xml | 11 ++- app/src/main/res/values-en-rUS/strings.xml | 3 + app/src/main/res/values-zh-rCN/strings.xml | 3 + app/src/main/res/values/strings.xml | 3 + 20 files changed, 291 insertions(+), 65 deletions(-) create mode 100644 app/src/main/java/com/community/pocket/data/model/Active.java create mode 100644 app/src/main/java/com/community/pocket/data/model/Complain.java create mode 100644 app/src/main/java/com/community/pocket/data/model/ForumStatus.java create mode 100644 app/src/main/java/com/community/pocket/data/model/ForumType.java create mode 100644 app/src/main/java/com/community/pocket/data/model/Page.java diff --git a/app/build.gradle b/app/build.gradle index afb9760..c1fefcd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,7 @@ android { buildConfigField('String','API_HOST',"\""+RAP2_API_HOST+"\"") signingConfig=signingConfigs.debug + debuggable = true } release { @@ -53,6 +54,7 @@ android { buildConfigField('String','API_HOST',"\""+API_HOST+"\"") signingConfig=signingConfigs.debug + debuggable = true } } sourceSets { diff --git a/app/src/main/java/com/community/pocket/data/main/forum/ForumMyRequest.java b/app/src/main/java/com/community/pocket/data/main/forum/ForumMyRequest.java index 37d0809..2e067bd 100644 --- a/app/src/main/java/com/community/pocket/data/main/forum/ForumMyRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/forum/ForumMyRequest.java @@ -31,11 +31,11 @@ public class ForumMyRequest { * 加载我的帖子 */ @HttpRequest("/forum/my") - public void loadForumMy(MutableLiveData liveData) { + public void loadForumMy(MutableLiveData liveData, int page) { HttpUtil.getRequest(HttpUtil.Method.GET, new SimpleHttpParse(liveData).getInterface(ForumMyResponse.class), new FormBody.Builder() - .add("token", LocalToken.getToken()) + .add("currentPage", String.valueOf(page)) .add("username", LocalToken.getUsername()) .build()); } diff --git a/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java b/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java index 83b9d9e..b2f1248 100644 --- a/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java @@ -2,11 +2,14 @@ package com.community.pocket.data.main.forum; import androidx.lifecycle.MutableLiveData; +import com.community.pocket.data.model.ForumStatus; import com.community.pocket.ui.main.ui.forum.news.ForumNewResponse; import com.community.pocket.util.HttpRequest; import com.community.pocket.util.HttpUtil; import com.community.pocket.util.SimpleHttpParse; +import okhttp3.FormBody; + /** * 最新帖子列表数据接口 */ @@ -24,8 +27,12 @@ public class ForumNewRequest { } @HttpRequest("/forum/new") - public void loadForumNew(MutableLiveData liveData) { + public void loadForumNew(MutableLiveData liveData, int page) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData).getInterface(ForumNewResponse.class)); + new SimpleHttpParse(liveData).getInterface(ForumNewResponse.class), + new FormBody.Builder() + .add("status", ForumStatus.ok.name()) + .add("currentPage", String.valueOf(page)) + .build()); } } diff --git a/app/src/main/java/com/community/pocket/data/model/Active.java b/app/src/main/java/com/community/pocket/data/model/Active.java new file mode 100644 index 0000000..253dd12 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/Active.java @@ -0,0 +1,44 @@ +package com.community.pocket.data.model; + +public class Active { + //帖子id + private String id; + //活动开始时间 + private String activeStartTime; + //活动结束时间 + private String activeEndTime; + //活动信用分 + private String activeScore; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getActiveStartTime() { + return activeStartTime; + } + + public void setActiveStartTime(String activeStartTime) { + this.activeStartTime = activeStartTime; + } + + public String getActiveEndTime() { + return activeEndTime; + } + + public void setActiveEndTime(String activeEndTime) { + this.activeEndTime = activeEndTime; + } + + public String getActiveScore() { + return activeScore; + } + + public void setActiveScore(String activeScore) { + this.activeScore = activeScore; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/community/pocket/data/model/Complain.java b/app/src/main/java/com/community/pocket/data/model/Complain.java new file mode 100644 index 0000000..ff4d8b1 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/Complain.java @@ -0,0 +1,24 @@ +package com.community.pocket.data.model; + +public class Complain { + private String id; + + //投诉人 + private String complain; + + public String getComplain() { + return complain; + } + + public void setComplain(String complain) { + this.complain = complain; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/app/src/main/java/com/community/pocket/data/model/Forum.java b/app/src/main/java/com/community/pocket/data/model/Forum.java index e56ce11..ecd5bf6 100644 --- a/app/src/main/java/com/community/pocket/data/model/Forum.java +++ b/app/src/main/java/com/community/pocket/data/model/Forum.java @@ -2,51 +2,50 @@ package com.community.pocket.data.model; //帖子简介内容 public class Forum { - //帖子id + //帖子 private String id; - //发帖人头像 - private String headImg; - //发帖人 - private String username; - //发帖时间 - private Long time; //帖子标题 private String title; - //帖子内容 - private String content; //回复数 private Integer reply; + //帖子类型 + private ForumType forumType; + //缩略内容 + private String content; + //发帖人 + private String username; + //发帖时间 + private Long time; + //审核状态 + private ForumStatus status; - public String getId() { - return id; - } + //其他信息 + private Active activeDto; - public void setId(String id) { - this.id = id; - } + private Complain complainDto; - public String getHeadImg() { - return headImg; + public Active getActiveDto() { + return activeDto; } - public void setHeadImg(String headImg) { - this.headImg = headImg; + public void setActiveDto(Active activeDto) { + this.activeDto = activeDto; } - public String getUsername() { - return username; + public Complain getComplainDto() { + return complainDto; } - public void setUsername(String username) { - this.username = username; + public void setComplainDto(Complain complainDto) { + this.complainDto = complainDto; } - public Long getTime() { - return time; + public String getId() { + return id; } - public void setTime(Long time) { - this.time = time; + public void setId(String id) { + this.id = id; } public String getTitle() { @@ -57,6 +56,22 @@ public class Forum { this.title = title; } + public Integer getReply() { + return reply; + } + + public void setReply(Integer reply) { + this.reply = reply; + } + + public ForumType getForumType() { + return forumType; + } + + public void setForumType(ForumType forumType) { + this.forumType = forumType; + } + public String getContent() { return content; } @@ -65,11 +80,27 @@ public class Forum { this.content = content; } - public Integer getReply() { - return reply; + public String getUsername() { + return username; } - public void setReply(Integer reply) { - this.reply = reply; + public void setUsername(String username) { + this.username = username; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public ForumStatus getStatus() { + return status; + } + + public void setStatus(ForumStatus status) { + this.status = status; } } diff --git a/app/src/main/java/com/community/pocket/data/model/ForumStatus.java b/app/src/main/java/com/community/pocket/data/model/ForumStatus.java new file mode 100644 index 0000000..a3e9d74 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/ForumStatus.java @@ -0,0 +1,10 @@ +package com.community.pocket.data.model; + +/** + * 审核状态 + */ +public enum ForumStatus { + uncheck, + ok, + fail +} diff --git a/app/src/main/java/com/community/pocket/data/model/ForumType.java b/app/src/main/java/com/community/pocket/data/model/ForumType.java new file mode 100644 index 0000000..0d61754 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/ForumType.java @@ -0,0 +1,7 @@ +package com.community.pocket.data.model; + +public enum ForumType { + active, + topic, + complan +} diff --git a/app/src/main/java/com/community/pocket/data/model/Page.java b/app/src/main/java/com/community/pocket/data/model/Page.java new file mode 100644 index 0000000..d5f11d3 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/Page.java @@ -0,0 +1,62 @@ +package com.community.pocket.data.model; + +import java.util.List; + +//分页数据 +public class Page { + //总记录数 + private Long count; + //总页数 + private Long totalPage; + //当前页数 + private Long currentPage; + //数据集合 + private List list; + //分页大小 + private Integer pageSize; + + public Integer getPageSize() { + return pageSize; + } + + public Long getCount() { + return count; + } + + public Long getTotalPage() { + return totalPage; + } + + public Long getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Long currentPage) { + this.currentPage = currentPage; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public void setCount(Long count) { + this.count = count; + } + + public void setTotalPage(Long totalPage) { + this.totalPage = totalPage; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public boolean isEmpty() { + return this.count == 0; + } +} + diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java index 8b7f979..2859185 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java @@ -11,19 +11,20 @@ import android.widget.Toast; import com.community.pocket.R; import com.community.pocket.data.model.Forum; +import com.community.pocket.data.model.Page; import com.community.pocket.ui.BaseFragment; import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity; import com.community.pocket.util.Param; import org.xutils.view.annotation.ViewInject; -import java.util.List; - public abstract class ForumPost extends BaseFragment { + //显示发帖人 + protected abstract int showAuthor(); - protected abstract int own(); - + //显示审核状态 + protected abstract int showStatus(); @ViewInject(R.id.post_layout) private LinearLayout layout; @@ -31,22 +32,35 @@ public abstract class ForumPost extends BaseFragment { /** * 加载帖子数据 */ - protected void loadPost(List forumList) { + protected void loadPost(Page forumList) { if (forumList.isEmpty()) { Toast.makeText(getContext(), R.string.no_more_forum, Toast.LENGTH_LONG).show(); } else { - layout.removeAllViews(); - for (int i = 0; i < forumList.size(); i++) { - final Forum forum = forumList.get(i); + for (int i = 0; i < forumList.getList().size(); i++) { + final Forum forum = forumList.getList().get(i); View childView = View.inflate(getContext(), R.layout.post, null); + TextView status = childView.findViewById(R.id.check_status); + status.setVisibility(showStatus()); + switch (forum.getStatus()) { + case ok: + status.setText(R.string.forum_status_ok); + break; + case fail: + status.setText(R.string.forum_status_fail); + break; + case uncheck: + status.setText(R.string.forum_status_uncheck); + break; + } + TextView title = childView.findViewById(R.id.post_title); title.setText(forum.getTitle()); TextView content = childView.findViewById(R.id.post_content); content.setText(forum.getContent()); TextView author = childView.findViewById(R.id.poster); - author.setVisibility(own()); + author.setVisibility(showAuthor()); author.setText(getString(R.string.poster, forum.getUsername())); TextView postReply = childView.findViewById(R.id.post_reply); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyFragment.java index 83cd6cd..925605f 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyFragment.java @@ -29,7 +29,7 @@ public class ForumMyFragment extends ForumPost { viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumMyViewModel.class); - viewModel.loadForumMy(); + viewModel.loadForumMy(1); //监听我的帖子加载状态 viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), new Observer() { @@ -49,14 +49,19 @@ public class ForumMyFragment extends ForumPost { } @Override - protected int own() { + protected int showAuthor() { return View.GONE; } + @Override + protected int showStatus() { + return View.VISIBLE; + } + @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); - viewModel.loadForumMy(); + viewModel.loadForumMy(1); } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyResponse.java index 4bca3d4..ba2e9ea 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyResponse.java @@ -4,21 +4,20 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Forum; +import com.community.pocket.data.model.Page; import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; -import java.util.List; - public class ForumMyResponse extends Response { - private List forumList; + private Page forumList; - List getForumList() { + Page getForumList() { return forumList; } - public void setForumList(List forumList) { + public void setForumList(Page forumList) { this.forumList = forumList; } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyViewModel.java index 818f7cb..19c59f3 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyViewModel.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyViewModel.java @@ -15,8 +15,8 @@ public class ForumMyViewModel extends BaseViewModel { return forumMyResponse; } - void loadForumMy() { - getRequest().loadForumMy(forumMyResponse); + void loadForumMy(int page) { + getRequest().loadForumMy(forumMyResponse, page); } @Override diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java index 4b31720..bc0f51c 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java @@ -29,7 +29,7 @@ public class ForumNewFragment extends ForumPost { viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumNewViewModel.class); - viewModel.loadForumNew(); + viewModel.loadForumNew(1); //监听最新帖子请求状态 viewModel.getForumNewResponse().observe(getViewLifecycleOwner(), new Observer() { @@ -49,15 +49,19 @@ public class ForumNewFragment extends ForumPost { } @Override - protected int own() { + protected int showAuthor() { return View.VISIBLE; } + @Override + protected int showStatus() { + return View.GONE; + } @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); - viewModel.loadForumNew(); + viewModel.loadForumNew(1); } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewResponse.java index 9ee35f7..c7f0893 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewResponse.java @@ -4,18 +4,17 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Forum; +import com.community.pocket.data.model.Page; import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * 最新帖子响应实体 */ public class ForumNewResponse extends Response { - private List forumList; + private Page forumList; enum Msg implements CustomMessage { ok(R.string.load_forum_new_ok), @@ -35,11 +34,11 @@ public class ForumNewResponse extends Response { } } - List getForumList() { + Page getForumList() { return forumList; } - public void setForumList(List forumList) { + public void setForumList(Page forumList) { this.forumList = forumList; } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java index b01fe0c..6b184ba 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java @@ -17,8 +17,8 @@ public class ForumNewViewModel extends BaseViewModel { return forumNewResponse; } - void loadForumNew() { - getRequest().loadForumNew(forumNewResponse); + void loadForumNew(int page) { + getRequest().loadForumNew(forumNewResponse, page); } @Override diff --git a/app/src/main/res/layout/main/layout/forum/layout/post.xml b/app/src/main/res/layout/main/layout/forum/layout/post.xml index 5bf8bf4..a88e236 100644 --- a/app/src/main/res/layout/main/layout/forum/layout/post.xml +++ b/app/src/main/res/layout/main/layout/forum/layout/post.xml @@ -5,6 +5,15 @@ android:layout_height="match_parent" android:background="@drawable/border"> + + + app:layout_constraintTop_toBottomOf="@id/check_status" /> modify error please choose date date error + check ok + check fail + uncheck \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 5107a2c..e8c5834 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -172,4 +172,7 @@ 修改密码失败,原密码不正确 请选择预约日期 上门日期不能是%1s以前 + 审核通过 + 审核不通过 + 未审核 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dd76159..1af2f5e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -173,6 +173,9 @@ modify error please choose date date error + check ok + check fail + uncheck