5712fa4184fc3351cc8b59d2110e94c94289e24d.svn-base 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package eVVM.apk.ui.My.examine;
  2. import com.allen.library.RxHttpUtils;
  3. import com.allen.library.interceptor.Transformer;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import eVVM.apk.api.ApiService;
  7. import eVVM.apk.common.MyDataObsever;
  8. import eVVM.apk.mvp.MvpModel;
  9. import eVVM.apk.ui.bean.VerificationCodeBean;
  10. /**
  11. * Created by Android Studio.
  12. * User: zbb
  13. * Date: 2019/6/7
  14. * Describe: ExamineModel
  15. */
  16. public class ExamineModel extends MvpModel<ExamineOnListener> {
  17. public ExamineModel() {
  18. }
  19. public void agreeProtocol(String userId) {
  20. Map<String, String> map = new HashMap<>();
  21. map.put("userId", userId);
  22. RxHttpUtils.createApi(ApiService.class)
  23. .agreeProtocol(map)
  24. .compose(Transformer.<VerificationCodeBean>switchSchedulers())
  25. .subscribe(new MyDataObsever<VerificationCodeBean>() {
  26. @Override
  27. protected void onError(String errorMsg) {
  28. getListener().onFail(errorMsg);
  29. }
  30. @Override
  31. protected void onSuccess(VerificationCodeBean verificationCodeBean) {
  32. if (verificationCodeBean.getCode() == 200) {
  33. getListener().onSucceed(verificationCodeBean);
  34. } else {
  35. getListener().onFail(verificationCodeBean.getMsg());
  36. }
  37. }
  38. });
  39. }
  40. public void failureReasons(String userId) {
  41. Map<String, String> map = new HashMap<>();
  42. map.put("userId", userId);
  43. RxHttpUtils.createApi(ApiService.class)
  44. .failureReasons(map)
  45. .compose(Transformer.<VerificationCodeBean>switchSchedulers())
  46. .subscribe(new MyDataObsever<VerificationCodeBean>() {
  47. @Override
  48. protected void onError(String errorMsg) {
  49. getListener().onFail(errorMsg);
  50. }
  51. @Override
  52. protected void onSuccess(VerificationCodeBean verificationCodeBean) {
  53. if (verificationCodeBean.getCode() == 200) {
  54. getListener().onfailmsgSucceed(verificationCodeBean);
  55. } else {
  56. getListener().onfailmsgFail(verificationCodeBean.getMsg());
  57. }
  58. }
  59. @Override
  60. protected boolean isHideToast() {
  61. return true;
  62. }
  63. });
  64. }
  65. }