parent
9183754134
commit
faa7dc331d
@ -0,0 +1,38 @@ |
||||
package com.community.pocket.data.model; |
||||
|
||||
public class LocalToken { |
||||
private final String token; |
||||
private final Long time; |
||||
private final String username; |
||||
|
||||
private static volatile LocalToken instance; |
||||
|
||||
public static LocalToken getInstance(Token token) { |
||||
if (instance == null) { |
||||
instance = new LocalToken(token.getToken(), token.getTime(), token.getUsername()); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
public static LocalToken getInstance() { |
||||
return instance; |
||||
} |
||||
|
||||
private LocalToken(String token, Long time, String username) { |
||||
this.token = token; |
||||
this.time = time; |
||||
this.username = username; |
||||
} |
||||
|
||||
public static String getToken() { |
||||
return instance.token; |
||||
} |
||||
|
||||
public static Long getTime() { |
||||
return instance.time; |
||||
} |
||||
|
||||
public static String getUsername() { |
||||
return instance.username; |
||||
} |
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.forum.data; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.main.forum.ForumDataRequest; |
||||
|
||||
public class ForumDataViewModelFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(ForumDataViewModel.class)) { |
||||
return (T) new ForumDataViewModel(ForumDataRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -1,12 +1,32 @@ |
||||
package com.community.pocket.ui.main.ui.forum.post; |
||||
|
||||
import com.community.pocket.ui.main.ui.share.Response; |
||||
import androidx.annotation.StringRes; |
||||
|
||||
import java.util.List; |
||||
import com.community.pocket.R; |
||||
import com.community.pocket.ui.main.ui.share.ToastResponse; |
||||
import com.community.pocket.util.CustomMessage; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
/** |
||||
* 检索投诉人响应结果 |
||||
* 发帖请求结果 |
||||
*/ |
||||
public class ForumPostResponse extends Response<List<String>> { |
||||
public class ForumPostResponse extends ToastResponse<ForumPostResponse.Msg> { |
||||
|
||||
|
||||
enum Msg implements CustomMessage { |
||||
ok(R.string.forum_post_ok), |
||||
fail(R.string.forum_post_fail); |
||||
private Integer msg; |
||||
|
||||
Msg(@StringRes Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
@NotNull |
||||
@Override |
||||
public Integer getMsg() { |
||||
return msg; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,27 +1,23 @@ |
||||
package com.community.pocket.ui.main.ui.forum.post; |
||||
|
||||
import androidx.lifecycle.MutableLiveData; |
||||
import androidx.lifecycle.ViewModel; |
||||
|
||||
import com.community.pocket.data.main.forum.ForumPostRequest; |
||||
import com.community.pocket.ui.main.ui.share.BaseViewModel; |
||||
|
||||
//发送帖子UI数据管理
|
||||
abstract class ForumPostViewModel extends ViewModel { |
||||
abstract class ForumPostViewModel extends BaseViewModel<ForumPostRequest> { |
||||
|
||||
|
||||
//请求接口状态
|
||||
//发帖请求状态
|
||||
MutableLiveData<ForumPostResponse> forumPostResponse = new MutableLiveData<>(); |
||||
|
||||
//请求接口处理
|
||||
ForumPostRequest forumPostRequest; |
||||
|
||||
MutableLiveData<ForumPostResponse> getForumPostResponse() { |
||||
return forumPostResponse; |
||||
} |
||||
|
||||
ForumPostViewModel(ForumPostRequest forumPostRequest) { |
||||
this.forumPostRequest = forumPostRequest; |
||||
@Override |
||||
protected ForumPostRequest getRequest() { |
||||
return ForumPostRequest.getInstance(); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -1,25 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.forum.post; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.main.forum.ForumPostRequest; |
||||
|
||||
|
||||
public class ForumPostViewModelFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(ForumPostActiveViewModel.class)) { |
||||
return (T) new ForumPostActiveViewModel(ForumPostRequest.getInstance()); |
||||
} else if (modelClass.isAssignableFrom(ForumPostTopicViewModel.class)) { |
||||
return (T) new ForumPostTopicViewModel(ForumPostRequest.getInstance()); |
||||
} else if (modelClass.isAssignableFrom(ForumPostComplainViewModel.class)) { |
||||
return (T) new ForumPostComplainViewModel(ForumPostRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@ |
||||
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.util.CustomMessage; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 查询用户结果 |
||||
*/ |
||||
public class QueryUserResponse extends ToastResponse<QueryUserResponse.Msg> { |
||||
|
||||
private List<String> peopleList; |
||||
|
||||
|
||||
List<String> getPeopleList() { |
||||
return peopleList; |
||||
} |
||||
|
||||
public void setPeopleList(List<String> peopleList) { |
||||
this.peopleList = peopleList; |
||||
} |
||||
|
||||
enum Msg implements CustomMessage { |
||||
ok(R.string.search_complain_name); |
||||
private Integer msg; |
||||
|
||||
Msg(@StringRes Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
@NotNull |
||||
@Override |
||||
public Integer getMsg() { |
||||
return msg; |
||||
} |
||||
} |
||||
} |
@ -1,12 +1,47 @@ |
||||
package com.community.pocket.ui.main.ui.info; |
||||
|
||||
import androidx.annotation.StringRes; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.data.model.MyInfo; |
||||
import com.community.pocket.ui.main.ui.share.Response; |
||||
import com.community.pocket.ui.main.ui.share.ToastResponse; |
||||
import com.community.pocket.util.CustomMessage; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
|
||||
/** |
||||
* 个人信息响应结果 |
||||
* |
||||
*/ |
||||
public class InfoResponse extends Response<MyInfo> { |
||||
public class InfoResponse extends ToastResponse<InfoResponse.Msg> { |
||||
|
||||
private MyInfo myInfo; |
||||
|
||||
public MyInfo getMyInfo() { |
||||
return myInfo; |
||||
} |
||||
|
||||
public void setMyInfo(MyInfo myInfo) { |
||||
this.myInfo = myInfo; |
||||
} |
||||
|
||||
enum Msg implements CustomMessage { |
||||
ok(R.string.load_info_ok), |
||||
fail(R.string.load_info_fail), |
||||
modify_pwd_ok(R.string.modify_pwd_ok), |
||||
modify_pwd_fail(R.string.modify_pwd_fail); |
||||
|
||||
private Integer msg; |
||||
|
||||
Msg(@StringRes Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
@NotNull |
||||
@Override |
||||
public Integer getMsg() { |
||||
return msg; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,20 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.info; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.main.info.InfoRequest; |
||||
|
||||
public class InfoViewModelFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(InfoViewModel.class)) { |
||||
return (T) new InfoViewModel(InfoRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.main.visitor.VisitorRequest; |
||||
|
||||
public class VisitorAppointmentFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(VisitorViewModel.class)) { |
||||
return (T) new VisitorViewModel(VisitorRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
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.util.CustomMessage; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class VisitorPeopleResponse extends ToastResponse<VisitorPeopleResponse.Msg> { |
||||
|
||||
private List<VisitorPeople> visitorPeopleList; |
||||
|
||||
List<VisitorPeople> getVisitorPeopleList() { |
||||
return visitorPeopleList; |
||||
} |
||||
|
||||
public void setVisitorPeopleList(List<VisitorPeople> visitorPeopleList) { |
||||
this.visitorPeopleList = visitorPeopleList; |
||||
} |
||||
|
||||
enum Msg implements CustomMessage { |
||||
ok(R.string.visitor_appointment_people_ok), |
||||
fail(R.string.visitor_appointment_people_fail); |
||||
|
||||
private Integer msg; |
||||
|
||||
Msg(@StringRes Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
public void setMsg(Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
@NotNull |
||||
@Override |
||||
public Integer getMsg() { |
||||
return msg; |
||||
} |
||||
} |
||||
} |
@ -1,12 +1,30 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import com.community.pocket.data.model.VisitorPeople; |
||||
import com.community.pocket.ui.main.ui.share.Response; |
||||
import com.community.pocket.R; |
||||
import com.community.pocket.ui.main.ui.share.ToastResponse; |
||||
import com.community.pocket.util.CustomMessage; |
||||
|
||||
import java.util.List; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
/** |
||||
* 访客接口请求结果 |
||||
*/ |
||||
public class VisitorResponse extends Response<List<VisitorPeople>> { |
||||
public class VisitorResponse extends ToastResponse<VisitorResponse.Msg> { |
||||
|
||||
enum Msg implements CustomMessage { |
||||
ok(R.string.visitor_appointment_ok), |
||||
fail(R.string.visitor_appointment_fail); |
||||
|
||||
private Integer msg; |
||||
|
||||
Msg(Integer msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
@NotNull |
||||
@Override |
||||
public Integer getMsg() { |
||||
return msg; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,20 +0,0 @@ |
||||
package com.community.pocket.ui.register; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.register.RegisterRequest; |
||||
|
||||
public class RegisterViewModelFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(RegisterViewModel.class)) { |
||||
return (T) new RegisterViewModel(RegisterRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -1,20 +0,0 @@ |
||||
package com.community.pocket.ui.resetpwd; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.data.resetpwd.ResetPwdRequest; |
||||
|
||||
public class ResetPwdViewModelFactory implements ViewModelProvider.Factory { |
||||
@NonNull |
||||
@Override |
||||
@SuppressWarnings("unchecked") |
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { |
||||
if (modelClass.isAssignableFrom(ResetPwdViewModel.class)) { |
||||
return (T) new ResetPwdViewModel(ResetPwdRequest.getInstance()); |
||||
} else { |
||||
throw new IllegalArgumentException("Unknown ViewModel class"); |
||||
} |
||||
} |
||||
} |
@ -1,10 +0,0 @@ |
||||
package com.community.pocket.util; |
||||
|
||||
//TODO 测试类
|
||||
public enum Valid { |
||||
empty_err, |
||||
password_err, |
||||
password_diff_err, |
||||
ok, |
||||
fail |
||||
} |
Loading…
Reference in new issue