diff --git a/app/src/main/java/com/community/pocket/data/adapter/VisitorAdpter.java b/app/src/main/java/com/community/pocket/data/adapter/VisitorAdpter.java index 353e417..28c5cdd 100644 --- a/app/src/main/java/com/community/pocket/data/adapter/VisitorAdpter.java +++ b/app/src/main/java/com/community/pocket/data/adapter/VisitorAdpter.java @@ -31,8 +31,8 @@ public class VisitorAdpter extends ArrayAdapter { this.dataList = dataList; for (VisitorPeople people : this.dataList) { - this.list.add(people.getName()); - this.map.put(people.getName(), people); + this.list.add(people.getUsername()); + this.map.put(people.getUsername(), people); } addAll(this.list); diff --git a/app/src/main/java/com/community/pocket/data/main/garbage/GarbageSortingRequest.java b/app/src/main/java/com/community/pocket/data/main/garbage/GarbageSortingRequest.java index ecca190..9c82821 100644 --- a/app/src/main/java/com/community/pocket/data/main/garbage/GarbageSortingRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/garbage/GarbageSortingRequest.java @@ -3,7 +3,6 @@ package com.community.pocket.data.main.garbage; import androidx.lifecycle.MutableLiveData; -import com.community.pocket.R; import com.community.pocket.ui.main.ui.garbage.sorting.GarbageSortingResponse; import com.community.pocket.util.HttpRequest; import com.community.pocket.util.HttpUtil; @@ -31,7 +30,7 @@ public class GarbageSortingRequest { @HttpRequest("/garbage/sorting") public void search(MutableLiveData liveData, String name) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData, R.string.garbage_search_ok, null).getInterface(GarbageSortingResponse.class), + new SimpleHttpParse(liveData).getInterface(GarbageSortingResponse.class), new FormBody.Builder().add("name", name).build()); } } diff --git a/app/src/main/java/com/community/pocket/data/main/garbage/GarbageWasteRequest.java b/app/src/main/java/com/community/pocket/data/main/garbage/GarbageWasteRequest.java index abe9de4..79b02a1 100644 --- a/app/src/main/java/com/community/pocket/data/main/garbage/GarbageWasteRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/garbage/GarbageWasteRequest.java @@ -2,7 +2,6 @@ package com.community.pocket.data.main.garbage; import androidx.lifecycle.MutableLiveData; -import com.community.pocket.R; import com.community.pocket.ui.main.ui.garbage.waste.GarbageWasteResponse; import com.community.pocket.util.HttpRequest; import com.community.pocket.util.HttpUtil; @@ -30,14 +29,14 @@ public class GarbageWasteRequest { @HttpRequest("/garbage/waste") public void searchDefault(MutableLiveData liveData) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData, R.string.garbage_waste_search_ok, R.string.garbage_waste_search_ok).getInterface(GarbageWasteResponse.class)); + new SimpleHttpParse(liveData).getInterface(GarbageWasteResponse.class)); } //检索废品 @HttpRequest("/garbage/waste/query") public void search(MutableLiveData liveData, String name) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData, R.string.garbage_waste_search_ok, R.string.garbage_waste_search_ok).getInterface(GarbageWasteResponse.class), + new SimpleHttpParse(liveData).getInterface(GarbageWasteResponse.class), new FormBody.Builder().add("name", name).build()); } diff --git a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorMyRequest.java b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorMyRequest.java index 3f54890..39e6da4 100644 --- a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorMyRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorMyRequest.java @@ -2,12 +2,14 @@ package com.community.pocket.data.main.visitor; import androidx.lifecycle.MutableLiveData; -import com.community.pocket.R; +import com.community.pocket.data.model.LocalToken; import com.community.pocket.ui.main.ui.visitor.my.VisitorMyResponse; import com.community.pocket.util.HttpRequest; import com.community.pocket.util.HttpUtil; import com.community.pocket.util.SimpleHttpParse; +import okhttp3.FormBody; + /** * 我的访客请求接口 */ @@ -30,6 +32,10 @@ public class VisitorMyRequest { @HttpRequest("/visitor/my") public void loadMy(MutableLiveData liveData) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData, R.string.load_visitor_my_ok, R.string.load_visitor_my_fail).getInterface(VisitorMyResponse.class)); + new SimpleHttpParse(liveData).getInterface(VisitorMyResponse.class), + new FormBody.Builder() + .add("username", LocalToken.getUsername()) + .add("token", LocalToken.getToken()) + .build()); } } diff --git a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorRequest.java b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorRequest.java index 6b85053..b8e357c 100644 --- a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorRequest.java @@ -30,14 +30,16 @@ public class VisitorRequest { //访客预约 @HttpRequest("/visitor/visitor") - public void appointment(MutableLiveData liveData, String appointment, String chooseTime, String notes) { + public void appointment(MutableLiveData liveData, String appointment, String chooseDate, String chooseTime, String notes) { HttpUtil.getRequest(HttpUtil.Method.POST, new SimpleHttpParse(liveData).getInterface(VisitorResponse.class), new FormBody.Builder() .add("appointment", appointment) + .add("chooseDate", chooseDate) .add("chooseTime", chooseTime) .add("notes", notes) .add("token", LocalToken.getToken()) + .add("username", LocalToken.getUsername()) .build()); } @@ -46,7 +48,10 @@ public class VisitorRequest { public void searchPeople(MutableLiveData liveData, String name) { HttpUtil.getRequest(HttpUtil.Method.GET, new SimpleHttpParse(liveData).getInterface(VisitorPeopleResponse.class), - new FormBody.Builder().add("name", name).build()); + new FormBody.Builder() + .add("name", name) + .add("username", LocalToken.getUsername()) + .build()); } diff --git a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorReservationRequest.java b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorReservationRequest.java index 1dd3ba1..9faa73c 100644 --- a/app/src/main/java/com/community/pocket/data/main/visitor/VisitorReservationRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/visitor/VisitorReservationRequest.java @@ -2,12 +2,14 @@ package com.community.pocket.data.main.visitor; import androidx.lifecycle.MutableLiveData; -import com.community.pocket.R; +import com.community.pocket.data.model.LocalToken; import com.community.pocket.ui.main.ui.visitor.reservation.VisitorReservationResponse; import com.community.pocket.util.HttpRequest; import com.community.pocket.util.HttpUtil; import com.community.pocket.util.SimpleHttpParse; +import okhttp3.FormBody; + /** * 我的预约请求接口 */ @@ -30,7 +32,11 @@ public class VisitorReservationRequest { @HttpRequest("/visitor/reservation") public void loadReservation(MutableLiveData liveData) { HttpUtil.getRequest(HttpUtil.Method.GET, - new SimpleHttpParse(liveData, R.string.load_visitor_my_ok, R.string.load_visitor_my_fail).getInterface(VisitorReservationResponse.class)); + new SimpleHttpParse(liveData).getInterface(VisitorReservationResponse.class), + new FormBody.Builder() + .add("username", LocalToken.getUsername()) + .add("token", LocalToken.getToken()) + .build()); } } diff --git a/app/src/main/java/com/community/pocket/data/model/MyVisitor.java b/app/src/main/java/com/community/pocket/data/model/MyVisitor.java new file mode 100644 index 0000000..35706d7 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/MyVisitor.java @@ -0,0 +1,22 @@ +package com.community.pocket.data.model; + +/** + * 我的访客 + */ +public class MyVisitor extends Visitor { + //访客人 + private String username; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @Override + public String getName() { + return username; + } +} diff --git a/app/src/main/java/com/community/pocket/data/model/Visitor.java b/app/src/main/java/com/community/pocket/data/model/Visitor.java index a4ba181..497f29a 100644 --- a/app/src/main/java/com/community/pocket/data/model/Visitor.java +++ b/app/src/main/java/com/community/pocket/data/model/Visitor.java @@ -3,15 +3,10 @@ package com.community.pocket.data.model; /** * 访客信息 */ -public class Visitor { - private String name; +public abstract class Visitor { private long time; private String notes; - public void setName(String name) { - this.name = name; - } - public void setTime(long time) { this.time = time; } @@ -20,10 +15,6 @@ public class Visitor { this.notes = notes; } - public String getName() { - return name; - } - public long getTime() { return time; } @@ -31,4 +22,6 @@ public class Visitor { public String getNotes() { return notes; } + + public abstract String getName(); } diff --git a/app/src/main/java/com/community/pocket/data/model/VisitorPeople.java b/app/src/main/java/com/community/pocket/data/model/VisitorPeople.java index b0a82ea..0ab3c41 100644 --- a/app/src/main/java/com/community/pocket/data/model/VisitorPeople.java +++ b/app/src/main/java/com/community/pocket/data/model/VisitorPeople.java @@ -6,15 +6,15 @@ import java.util.List; * 检索预约人 */ public class VisitorPeople { - private String name; + private String username; private List time; - public String getName() { - return name; + public String getUsername() { + return username; } - public void setName(String name) { - this.name = name; + public void setUsername(String username) { + this.username = username; } public List getTime() { diff --git a/app/src/main/java/com/community/pocket/data/model/VisitorReservation.java b/app/src/main/java/com/community/pocket/data/model/VisitorReservation.java new file mode 100644 index 0000000..0bae777 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/VisitorReservation.java @@ -0,0 +1,23 @@ +package com.community.pocket.data.model; + +/** + * 我的预约 + */ +public class VisitorReservation extends Visitor { + + //预约对象 + private String appointment; + + public String getAppointment() { + return appointment; + } + + public void setAppointment(String appointment) { + this.appointment = appointment; + } + + @Override + public String getName() { + return appointment; + } +} diff --git a/app/src/main/java/com/community/pocket/ui/BaseFragment.java b/app/src/main/java/com/community/pocket/ui/BaseFragment.java index 8c1d58f..0dd390b 100644 --- a/app/src/main/java/com/community/pocket/ui/BaseFragment.java +++ b/app/src/main/java/com/community/pocket/ui/BaseFragment.java @@ -10,7 +10,7 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.xutils.x; @@ -31,7 +31,7 @@ public abstract class BaseFragment extends Fragment { } //校验token失败跳转到登陆页 - protected > boolean invalidToken(T t) { + protected > boolean invalidToken(T t) { return t.getMessage() != null && t.getMessage().getMsg() == R.string.invalid_token; } diff --git a/app/src/main/java/com/community/pocket/ui/login/LoginResponse.java b/app/src/main/java/com/community/pocket/ui/login/LoginResponse.java index 500f3ae..71cdb6c 100644 --- a/app/src/main/java/com/community/pocket/ui/login/LoginResponse.java +++ b/app/src/main/java/com/community/pocket/ui/login/LoginResponse.java @@ -4,7 +4,7 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Token; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; /** * 登陆响应结果 */ -public class LoginResponse extends ToastResponse { +public class LoginResponse extends Response { private Token token; public Token getToken() { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java index 6427e14..61395e8 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java @@ -4,7 +4,7 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.ForumContent; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -15,7 +15,7 @@ import java.util.List; * 帖子详情数据管理 * */ -public class ForumDataResponse extends ToastResponse { +public class ForumDataResponse extends Response { private List forumContentList; List getForumContentList() { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/hot/ForumHotResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/hot/ForumHotResponse.java index a58cfdb..146b3b8 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/hot/ForumHotResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/hot/ForumHotResponse.java @@ -2,7 +2,7 @@ package com.community.pocket.ui.main.ui.forum.hot; import com.community.pocket.R; import com.community.pocket.data.model.Hot; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; /** * 热榜信息响应体 */ -public class ForumHotResponse extends ToastResponse { +public class ForumHotResponse extends Response { private Hot hot; public Hot getHot() { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumNoticeResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumNoticeResponse.java index 6e94985..b33dd2b 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumNoticeResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumNoticeResponse.java @@ -4,7 +4,7 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Notice; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ import java.util.List; /** * 公告信息响应体 */ -public class ForumNoticeResponse extends ToastResponse { +public class ForumNoticeResponse extends Response { private List noticeList; @@ -35,7 +35,7 @@ public class ForumNoticeResponse extends ToastResponse } } - public List getNoticeList() { + List getNoticeList() { return noticeList; } 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 2f65d7a..4bca3d4 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,17 +4,17 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Forum; -import com.community.pocket.ui.main.ui.share.ToastResponse; +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 ToastResponse { +public class ForumMyResponse extends Response { private List forumList; - public List getForumList() { + List getForumList() { return forumList; } 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 835872c..9ee35f7 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,7 +4,7 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.Forum; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ import java.util.List; /** * 最新帖子响应实体 */ -public class ForumNewResponse extends ToastResponse { +public class ForumNewResponse extends Response { private List forumList; enum Msg implements CustomMessage { @@ -35,7 +35,7 @@ public class ForumNewResponse extends ToastResponse { } } - public List getForumList() { + List getForumList() { return forumList; } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostResponse.java index 14281c9..9dd0a12 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostResponse.java @@ -3,7 +3,7 @@ package com.community.pocket.ui.main.ui.forum.post; import androidx.annotation.StringRes; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; /** * 发帖请求结果 */ -public class ForumPostResponse extends ToastResponse { +public class ForumPostResponse extends Response { enum Msg implements CustomMessage { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/QueryUserResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/QueryUserResponse.java index f8f10ea..afc1697 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/QueryUserResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/QueryUserResponse.java @@ -3,7 +3,7 @@ package com.community.pocket.ui.main.ui.forum.post; import androidx.annotation.StringRes; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ import java.util.List; /** * 查询用户结果 */ -public class QueryUserResponse extends ToastResponse { +public class QueryUserResponse extends Response { private List peopleList; diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingFragment.java index 6211ccc..c9b06dc 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingFragment.java @@ -18,6 +18,7 @@ import com.community.pocket.data.model.GarbageSorting; import com.community.pocket.ui.BaseFragment; import com.community.pocket.ui.listener.MyTextChange; import com.community.pocket.ui.main.ui.share.MyAutoCompleteTextView; +import com.community.pocket.ui.main.ui.share.Response; import org.xutils.view.annotation.ContentView; import org.xutils.view.annotation.ViewInject; @@ -62,12 +63,10 @@ public class GarbageSortingFragment extends BaseFragment { return; } - if (garbageSortingResponse.getSuccess() != null) { - initSearch(garbageSortingResponse.getBody()); - } + garbageSortingResponse.toast(getContext()); - if (garbageSortingResponse.getError() != null) { - garbageSortingResponse.fail(getContext()); + if (garbageSortingResponse.getResult() == Response.Result.OK) { + initSearch(garbageSortingResponse.getGarbageSortings()); } } }); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingResponse.java index e164a90..186f487 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingResponse.java @@ -1,9 +1,40 @@ package com.community.pocket.ui.main.ui.garbage.sorting; +import androidx.annotation.StringRes; + +import com.community.pocket.R; import com.community.pocket.data.model.GarbageSorting; 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 GarbageSortingResponse extends Response> { +public class GarbageSortingResponse extends Response { + private List garbageSortings; + + List getGarbageSortings() { + return garbageSortings; + } + + public void setGarbageSortings(List garbageSortings) { + this.garbageSortings = garbageSortings; + } + + enum Msg implements CustomMessage { + ok(R.string.garbage_search_ok); + + private Integer msg; + + Msg(@StringRes Integer msg) { + this.msg = msg; + } + + @NotNull + @Override + public Integer getMsg() { + return msg; + } + } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteFragment.java index 994b3e1..58e64b9 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteFragment.java @@ -16,7 +16,6 @@ import androidx.lifecycle.ViewModelProvider; import com.community.pocket.R; import com.community.pocket.data.adapter.GarbageWasteAdpter; -import com.community.pocket.data.model.GarbageWaste; import com.community.pocket.data.model.GarbageWasteManage; import com.community.pocket.data.model.GarbageWastePrice; import com.community.pocket.ui.BaseFragment; @@ -68,12 +67,10 @@ public class GarbageWasteFragment extends BaseFragment { return; } - if (garbageWasteResponse.getSuccess() != null) { - initDefault(garbageWasteResponse.getBody()); - } + garbageWasteResponse.toast(getContext()); - if (garbageWasteResponse.getError() != null) { - garbageWasteResponse.fail(getContext()); + if (garbageWasteResponse.getResult() == Response.Result.OK) { + initDefault(garbageWasteResponse.getDefaultList(), garbageWasteResponse.getGarbageWasteManage()); } } }); @@ -86,11 +83,10 @@ public class GarbageWasteFragment extends BaseFragment { return; } + garbageWasteResponse.toast(getContext()); if (garbageWasteResponse.getResult() == Response.Result.OK) { - initSearch(garbageWasteResponse.getBody()); - } else { - garbageWasteResponse.fail(getContext()); + initSearch(garbageWasteResponse.getSearchList()); } } }); @@ -117,17 +113,16 @@ public class GarbageWasteFragment extends BaseFragment { /** * 检索默认废品信息 * - * @param waste 废品信息 */ - private void initDefault(GarbageWaste waste) { - GarbageWasteManage manage = waste.getGarbageWasteManage(); + private void initDefault(List priceList, GarbageWasteManage manage) { + name.setText(getString(R.string.garbage_waste_name, manage.getName())); mobie.setText(getString(R.string.garbage_waste_mobie, manage.getMobie())); layout.removeAllViews(); addHead(); - List priceList = waste.getDefaultList(); + for (GarbageWastePrice price : priceList) { addItem(price); } @@ -166,16 +161,15 @@ public class GarbageWasteFragment extends BaseFragment { /** * 检索废品回收信息 * - * @param waste 废品信息 */ - private void initSearch(GarbageWaste waste) { + private void initSearch(List searchList) { // 设置适配器 if (garbageWasteAdpter == null) { - garbageWasteAdpter = new GarbageWasteAdpter(waste.getSearchList(), getContext()); + garbageWasteAdpter = new GarbageWasteAdpter(searchList, getContext()); // 将适配器与当前AutoCompleteTextView控件绑定 searchPrice.setAdapter(garbageWasteAdpter); } else { - garbageWasteAdpter.addAll(waste.getSearchList()); + garbageWasteAdpter.addAll(searchList); } myAutoCompleteTextView.refreshDropList(); } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteResponse.java index e355cd8..6fad570 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteResponse.java @@ -1,7 +1,62 @@ package com.community.pocket.ui.main.ui.garbage.waste; -import com.community.pocket.data.model.GarbageWaste; +import com.community.pocket.data.model.GarbageWasteManage; +import com.community.pocket.data.model.GarbageWastePrice; import com.community.pocket.ui.main.ui.share.Response; +import com.community.pocket.util.CustomMessage; -public class GarbageWasteResponse extends Response { +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class GarbageWasteResponse extends Response { + + enum Msg implements CustomMessage { + ; + + private Integer msg; + + Msg(Integer msg) { + this.msg = msg; + } + + @NotNull + @Override + public Integer getMsg() { + return msg; + } + } + + //默认价格信息 + private List defaultList; + + //检索价格信息 + private List searchList; + + //管理员信息 + private GarbageWasteManage garbageWasteManage; + + List getDefaultList() { + return defaultList; + } + + public void setDefaultList(List defaultList) { + this.defaultList = defaultList; + } + + List getSearchList() { + return searchList; + } + + public void setSearchList(List searchList) { + this.searchList = searchList; + } + + GarbageWasteManage getGarbageWasteManage() { + return garbageWasteManage; + } + + public void setGarbageWasteManage(GarbageWasteManage garbageWasteManage) { + this.garbageWasteManage = garbageWasteManage; + } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoResponse.java index f082e59..79d601d 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoResponse.java @@ -4,7 +4,7 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.MyInfo; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -14,11 +14,11 @@ import org.jetbrains.annotations.NotNull; * 个人信息响应结果 * */ -public class InfoResponse extends ToastResponse { +public class InfoResponse extends Response { private MyInfo myInfo; - public MyInfo getMyInfo() { + MyInfo getMyInfo() { return myInfo; } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/share/Response.java b/app/src/main/java/com/community/pocket/ui/main/ui/share/Response.java index ed153b3..c92da13 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/share/Response.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/share/Response.java @@ -3,36 +3,22 @@ package com.community.pocket.ui.main.ui.share; import android.content.Context; import android.widget.Toast; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; - import com.community.pocket.R; +import com.community.pocket.util.CustomMessage; /** * 响应体父类 * * @param */ -public abstract class Response { - //成功描述 - @Nullable - @Deprecated - private Integer success; - //失败描述 - @Nullable - @Deprecated - private Integer error; +public abstract class Response { //描述参数 private Object[] args; - @Deprecated - // TODO 废弃 - //响应体 - private T body; - //响应信息 private T message; + //操作结果 private Result result; public T getMessage() { @@ -51,45 +37,7 @@ public abstract class Response { this.result = result; } - @Nullable - @Deprecated - // TODO 废弃 - public Integer getSuccess() { - return success; - } - - @Deprecated - // TODO 废弃 - public void setSuccess(@Nullable @StringRes Integer success) { - this.success = success; - } - - @Nullable - @Deprecated - // TODO 废弃 - public Integer getError() { - return error; - } - - @Deprecated - // TODO 废弃 - public void setError(@Nullable @StringRes Integer error) { - this.error = error; - } - - @Deprecated - // TODO 废弃 - public T getBody() { - return body; - } - - @Deprecated - // TODO 废弃 - public void setBody(T body) { - this.body = body; - } - - Object[] getArgs() { + private Object[] getArgs() { return args; } @@ -97,21 +45,14 @@ public abstract class Response { this.args = args; } - public void ok(Context context) { - if (success != null) { - Toast.makeText(context, context.getString(success, args), Toast.LENGTH_SHORT).show(); - } - } - - public void fail(Context context) { - if (error != null) { - Toast.makeText(context, context.getString(error, args), Toast.LENGTH_LONG).show(); + public void toast(Context context) { + if (getMessage() != null) { + Toast.makeText(context, context.getString(getMessage().getMsg(), getArgs()), getResult() == Result.OK ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show(); } else { - Toast.makeText(context, context.getString(R.string.unknow_error), Toast.LENGTH_LONG).show(); + Toast.makeText(context, R.string.unknow_error, Toast.LENGTH_LONG).show(); } } - public enum Result { OK, FAIL diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/share/ToastResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/share/ToastResponse.java deleted file mode 100644 index 08f4131..0000000 --- a/app/src/main/java/com/community/pocket/ui/main/ui/share/ToastResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.community.pocket.ui.main.ui.share; - -import android.content.Context; -import android.widget.Toast; - -import com.community.pocket.R; -import com.community.pocket.util.CustomMessage; - -/** - * 弹窗响应 - * - * @param - */ -@Deprecated -// TODO 废弃 -public abstract class ToastResponse extends Response { - - @Deprecated - // TODO 废弃 - public void toast(Context context) { - if (getMessage() != null) { - Toast.makeText(context, context.getString(getMessage().getMsg(), getArgs()), getResult() == Result.OK ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show(); - } else { - Toast.makeText(context, R.string.unknow_error, Toast.LENGTH_LONG).show(); - } - } -} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorFragment.java index 9d7c98e..a8337ec 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorFragment.java @@ -23,7 +23,7 @@ import org.xutils.view.annotation.ViewInject; public class VisitorFragment extends MainFragment { //访客预约按钮 - @ViewInject(R.id.visitor_visitor) + @ViewInject(R.id.visitor_reservation) private Button myBtn; @Override @@ -34,7 +34,7 @@ public class VisitorFragment extends MainFragment { @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override public void onClick(View v) { - my(v); + reservation(v); } }); } @@ -48,16 +48,16 @@ public class VisitorFragment extends MainFragment { } //跳转到我的预约界面 - @Event(value = R.id.visitor_reservation) @RequiresApi(api = Build.VERSION_CODES.KITKAT) - private void reservation(View view) { + public void reservation(View view) { ctrl().navigate(R.id.visitorReservationFragment); changeColor(view); } //跳转到我的访客界面 + @Event(value = R.id.visitor_visitor) @RequiresApi(api = Build.VERSION_CODES.KITKAT) - public void my(View view) { + private void my(View view) { ctrl().navigate(R.id.visitorMyFragment); changeColor(view); } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java index 5f68753..6a6f2fe 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java @@ -52,7 +52,7 @@ public abstract class VisitorMyVisitor extends BaseFragment { /** * 初始化数据 */ - protected void loadData(List visitors) { + protected void loadData(List visitors) { for (final Visitor visitor : visitors) { createTextView(visitor.getName()); createTextView(DateFormat.format(getString(R.string.dateformat), visitor.getTime())); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java index 77e7087..dce2deb 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java @@ -3,12 +3,15 @@ package com.community.pocket.ui.main.ui.visitor.appointment; import android.os.Build; import android.os.Bundle; import android.text.Editable; +import android.text.TextWatcher; +import android.text.format.DateFormat; import android.view.View; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -44,6 +47,15 @@ public class VisitorAppointmentFragment extends BaseFragment { @ViewInject(R.id.appointment) private AutoCompleteTextView appointment; + @ViewInject(R.id.chooseDate) + private EditText chooseDate; + + //日期格式提示 + @ViewInject(R.id.tip) + private TextView tip; + + private String today; + //预约时间 @ViewInject(R.id.choose_time) private Spinner chooseTime; @@ -73,6 +85,7 @@ public class VisitorAppointmentFragment extends BaseFragment { ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_word_top, R.id.show_word_bottom}, R.id.notes, view); showWordCount.showCount(); + appointmentViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorViewModel.class); myAutoCompleteTextView = new MyAutoCompleteTextView(appointment, appointmentViewModel); @@ -89,6 +102,14 @@ public class VisitorAppointmentFragment extends BaseFragment { appointment.setError(getString(visitorFormState.getAppointmentError(), PropertiesUtil.getIntValue("username.length"))); } + if (visitorFormState.getDateError() != null) { + if (visitorFormState.getDateError() == R.string.visitor_invalid_date) { + chooseDate.setError(getString(visitorFormState.getDateError(), today)); + } else { + chooseDate.setError(getString(visitorFormState.getDateError())); + } + } + if (visitorFormState.getNotesError() != null) { notes.setError(getString(visitorFormState.getNotesError())); } @@ -108,7 +129,7 @@ public class VisitorAppointmentFragment extends BaseFragment { if (visitorResponse.getResult() == Response.Result.OK) { VisitorFragment visitorFragment = getParentFragment(2); Button button = Objects.requireNonNull(visitorFragment.getView()).findViewById(R.id.visitor_reservation); - visitorFragment.my(button); + visitorFragment.reservation(button); } } }); @@ -141,7 +162,7 @@ public class VisitorAppointmentFragment extends BaseFragment { return; } if (visitorAdpter != null && visitorAdpter.containsKey(s.toString())) { - appointmentViewModel.appointmentDataChanged(appointment.getText(), notes.getText()); + appointmentViewModel.appointmentDataChanged(appointment.getText(), chooseDate.getText(), today, notes.getText()); initTime(s); return; } @@ -151,13 +172,18 @@ public class VisitorAppointmentFragment extends BaseFragment { } }); - notes.addTextChangedListener(new MyTextChange() { + + TextWatcher textWatcher = new MyTextChange() { @Override public void afterTextChanged(Editable s) { - appointmentViewModel.appointmentDataChanged(appointment.getText(), notes.getText()); + appointmentViewModel.appointmentDataChanged(appointment.getText(), chooseDate.getText(), today, notes.getText()); } - }); + }; + chooseDate.addTextChangedListener(textWatcher); + notes.addTextChangedListener(textWatcher); + + initTip(); } @@ -193,7 +219,14 @@ public class VisitorAppointmentFragment extends BaseFragment { */ @Event(value = R.id.submit) private void submit(View view) { - appointmentViewModel.appointment(appointment.getText().toString(), chooseTime.getSelectedItem().toString(), notes.getText().toString()); + appointmentViewModel.appointment(appointment.getText().toString(), chooseDate.getText().toString(), chooseTime.getSelectedItem().toString(), notes.getText().toString()); + } + + //初始化日期提示 + private void initTip() { + String format = PropertiesUtil.getValue("date.pattern"); + today = DateFormat.format(format, System.currentTimeMillis()).toString(); + tip.setText(getString(R.string.dateformat_tip, format, today)); } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorFormState.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorFormState.java index 44f7faa..781e356 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorFormState.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorFormState.java @@ -9,12 +9,15 @@ class VisitorFormState { @Nullable private Integer appointmentError; @Nullable + private Integer dateError; + @Nullable private Integer notesError; private boolean isDataValid; - VisitorFormState(@Nullable Integer appointmentError, @Nullable Integer notesError) { + VisitorFormState(@Nullable Integer appointmentError, @Nullable Integer dateError, @Nullable Integer notesError) { this.appointmentError = appointmentError; + this.dateError = dateError; this.notesError = notesError; } @@ -22,6 +25,11 @@ class VisitorFormState { this.isDataValid = isDataValid; } + @Nullable + Integer getDateError() { + return dateError; + } + @Nullable Integer getAppointmentError() { return appointmentError; diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorPeopleResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorPeopleResponse.java index fdcb69c..d1d71b5 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorPeopleResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorPeopleResponse.java @@ -4,14 +4,14 @@ import androidx.annotation.StringRes; import com.community.pocket.R; import com.community.pocket.data.model.VisitorPeople; -import com.community.pocket.ui.main.ui.share.ToastResponse; +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 VisitorPeopleResponse extends ToastResponse { +public class VisitorPeopleResponse extends Response { private List visitorPeopleList; diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorResponse.java index be2bd2b..1f1de1e 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorResponse.java @@ -1,7 +1,7 @@ package com.community.pocket.ui.main.ui.visitor.appointment; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -9,11 +9,12 @@ import org.jetbrains.annotations.NotNull; /** * 访客接口请求结果 */ -public class VisitorResponse extends ToastResponse { +public class VisitorResponse extends Response { enum Msg implements CustomMessage { ok(R.string.visitor_appointment_ok), - fail(R.string.visitor_appointment_fail); + fail(R.string.visitor_appointment_fail), + token(R.string.invalid_token); private Integer msg; diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorViewModel.java index 93f7347..f39695f 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorViewModel.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorViewModel.java @@ -38,8 +38,8 @@ public class VisitorViewModel extends BaseViewModel implements S } //访客预约 - void appointment(String appointment, String chooseTime, String notes) { - getRequest().appointment(visitorResponse, appointment, chooseTime, notes); + void appointment(String appointment, String chooseDate, String chooseTime, String notes) { + getRequest().appointment(visitorResponse, appointment, chooseDate, chooseTime, notes); } //检索预约人 @@ -48,11 +48,15 @@ public class VisitorViewModel extends BaseViewModel implements S } //校验访客预约表单 - void appointmentDataChanged(Editable appointment, Editable notes) { + void appointmentDataChanged(Editable appointment, Editable chooseDate, String today, Editable notes) { if (!ValidUtil.usernamevalid(appointment.toString())) { - visitorFormState.setValue(new VisitorFormState(R.string.invalid_username, null)); + visitorFormState.setValue(new VisitorFormState(R.string.invalid_username, null, null)); + } else if (!ValidUtil.dateValid(chooseDate.toString())) { + visitorFormState.setValue(new VisitorFormState(null, R.string.invalid_date, null)); + } else if (!ValidUtil.before(today, chooseDate.toString())) { + visitorFormState.setValue(new VisitorFormState(null, R.string.visitor_invalid_date, null)); } else if (!ValidUtil.notesValid(notes.toString())) { - visitorFormState.setValue(new VisitorFormState(null, R.string.invalid_notes)); + visitorFormState.setValue(new VisitorFormState(null, null, R.string.invalid_notes)); } else { visitorFormState.setValue(new VisitorFormState(true)); } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyFragment.java index 807f6fc..db73e33 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyFragment.java @@ -10,6 +10,7 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import com.community.pocket.R; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.ui.main.ui.visitor.VisitorMyVisitor; import org.xutils.view.annotation.ContentView; @@ -39,12 +40,10 @@ public class VisitorMyFragment extends VisitorMyVisitor { return; } - if (visitorMyResponse.getSuccess() != null) { - loadData(visitorMyResponse.getBody()); - } + visitorMyResponse.toast(getContext()); - if (visitorMyResponse.getError() != null) { - Toast.makeText(getContext(), visitorMyResponse.getError(), Toast.LENGTH_SHORT).show(); + if (visitorMyResponse.getResult() == Response.Result.OK) { + loadData(visitorMyResponse.getVisitorList()); } } }); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyResponse.java index 88da34e..1f382af 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyResponse.java @@ -1,9 +1,42 @@ package com.community.pocket.ui.main.ui.visitor.my; -import com.community.pocket.data.model.Visitor; +import androidx.annotation.StringRes; + +import com.community.pocket.R; +import com.community.pocket.data.model.MyVisitor; 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 VisitorMyResponse extends Response> { +public class VisitorMyResponse extends Response { + private List visitorList; + + List getVisitorList() { + return visitorList; + } + + public void setVisitorList(List visitorList) { + this.visitorList = visitorList; + } + + enum Msg implements CustomMessage { + ok(R.string.load_visitor_my_ok), + fail(R.string.load_visitor_my_fail), + token(R.string.invalid_token); + + private Integer msg; + + Msg(@StringRes Integer msg) { + this.msg = msg; + } + + @NotNull + @Override + public Integer getMsg() { + return msg; + } + } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationFragment.java index 09d026f..1240a04 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationFragment.java @@ -10,6 +10,7 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import com.community.pocket.R; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.ui.main.ui.visitor.VisitorMyVisitor; import org.xutils.view.annotation.ContentView; @@ -39,12 +40,10 @@ public class VisitorReservationFragment extends VisitorMyVisitor { return; } - if (visitorReservationResponse.getSuccess() != null) { - loadData(visitorReservationResponse.getBody()); - } + visitorReservationResponse.toast(getContext()); - if (visitorReservationResponse.getError() != null) { - Toast.makeText(getContext(), visitorReservationResponse.getError(), Toast.LENGTH_SHORT).show(); + if (visitorReservationResponse.getResult() == Response.Result.OK) { + loadData(visitorReservationResponse.getVisitorList()); } } }); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationResponse.java index 97b0b28..b5578b8 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationResponse.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationResponse.java @@ -1,9 +1,45 @@ package com.community.pocket.ui.main.ui.visitor.reservation; -import com.community.pocket.data.model.Visitor; +import androidx.annotation.StringRes; + +import com.community.pocket.R; +import com.community.pocket.data.model.VisitorReservation; 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 VisitorReservationResponse extends Response> { +/** + * 我的预约信息 + */ +public class VisitorReservationResponse extends Response { + private List visitorList; + + List getVisitorList() { + return visitorList; + } + + public void setVisitorList(List visitorList) { + this.visitorList = visitorList; + } + + enum Msg implements CustomMessage { + ok(R.string.load_visitor_reservation_ok), + fail(R.string.load_visitor_reservation_fail), + token(R.string.invalid_token); + + private Integer msg; + + Msg(@StringRes Integer msg) { + this.msg = msg; + } + + @NotNull + @Override + public Integer getMsg() { + return msg; + } + } } diff --git a/app/src/main/java/com/community/pocket/ui/register/RegisterResponse.java b/app/src/main/java/com/community/pocket/ui/register/RegisterResponse.java index 0accf5a..ac3b731 100644 --- a/app/src/main/java/com/community/pocket/ui/register/RegisterResponse.java +++ b/app/src/main/java/com/community/pocket/ui/register/RegisterResponse.java @@ -3,7 +3,7 @@ package com.community.pocket.ui.register; import androidx.annotation.StringRes; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; /** * 注册结果 */ -public class RegisterResponse extends ToastResponse { +public class RegisterResponse extends Response { /** * 响应类型 diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdResponse.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdResponse.java index 0bb1e5e..4ef4039 100644 --- a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdResponse.java +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdResponse.java @@ -3,7 +3,7 @@ package com.community.pocket.ui.resetpwd; import androidx.annotation.StringRes; import com.community.pocket.R; -import com.community.pocket.ui.main.ui.share.ToastResponse; +import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.CustomMessage; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; /** * 重置密码结果 */ -public class ResetPwdResponse extends ToastResponse { +public class ResetPwdResponse extends Response { enum Msg implements CustomMessage { step1_ok(R.string.resetpwd_step1_ok), diff --git a/app/src/main/java/com/community/pocket/util/SimpleHttpParse.java b/app/src/main/java/com/community/pocket/util/SimpleHttpParse.java index 9c3fc6c..632f434 100644 --- a/app/src/main/java/com/community/pocket/util/SimpleHttpParse.java +++ b/app/src/main/java/com/community/pocket/util/SimpleHttpParse.java @@ -1,6 +1,5 @@ package com.community.pocket.util; -import androidx.annotation.StringRes; import androidx.lifecycle.MutableLiveData; import org.jetbrains.annotations.NotNull; @@ -17,23 +16,6 @@ public class SimpleHttpParse + app:layout_constraintBottom_toBottomOf="parent"> - + app:layout_constraintBottom_toBottomOf="parent"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml b/app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml index e86117a..0d567e7 100644 --- a/app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml +++ b/app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml @@ -6,89 +6,126 @@ android:layout_height="match_parent" tools:context=".ui.main.ui.visitor.appointment.VisitorAppointmentFragment"> - - - + android:layout_height="match_parent" + android:fillViewport="true"> + android:orientation="vertical"> - + android:layout_gravity="center_vertical"> - + - + - + - + - + + + + + + + + + + + + +