RQQuestionModule.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // RQQuestionModule.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2022/1/11.
  6. //
  7. #import "RQQuestionModule.h"
  8. float progress = 0;
  9. @interface RQQuestionModule ()
  10. @property (nonatomic, readwrite, strong) NSString *downloadUrl;
  11. @end
  12. @implementation RQQuestionModule
  13. @def_singleton(RQQuestionModule);
  14. /// 更新题库
  15. - (void)rq_updateQuestion {
  16. @weakify(self)
  17. [[RQ_HTTP_Service getVersionList] subscribeNext:^(NSArray *arr) {
  18. if (!RQObjectIsNil(arr)) {
  19. if (arr.count > 0) {
  20. [[[arr.rac_sequence.signal deliverOnMainThread] filter:^BOOL(RQDictInfoModel *dictInfoModel) {
  21. return [dictInfoModel.dictLabel isEqualToString:[RQ_YDTQuestion_Module getCarTypeCNNameWithCarType:RQ_YDTQuestion_Module.carType]];
  22. }] subscribeNext:^(RQDictInfoModel *dictInfoModel) {
  23. @strongify(self)
  24. self.downloadUrl = dictInfoModel.dictValue;
  25. if (dictInfoModel.remark.integerValue > [RQ_YDTQuestion_Module getQuestionVersion]) {
  26. NSLog(@"更新!");
  27. [self rq_showDBUpdateView];
  28. } else {
  29. NSLog(@"不更新!");
  30. }
  31. }];
  32. }
  33. }
  34. } error:^(NSError * _Nullable error) {
  35. }];
  36. }
  37. - (void)rq_showDBUpdateView {
  38. RQUpdateView *dbUpdateView = [RQUpdateView updateView];
  39. dbUpdateView.questionUpdateViewType = RQQuestionUpdateViewType_LibDownload;
  40. dbUpdateView.downloadUrl = self.downloadUrl;
  41. QMUIModalPresentationViewController *dbModalViewController = [[QMUIModalPresentationViewController alloc] init];
  42. dbModalViewController.contentView = dbUpdateView;
  43. dbModalViewController.contentViewMargins = UIEdgeInsetsMake(0, 0, 0, 0);
  44. dbModalViewController.modal = YES;
  45. dbUpdateView.modalViewController = dbModalViewController;
  46. [dbModalViewController showWithAnimated:YES completion:nil];
  47. }
  48. - (void)rq_showAppUpdateView {
  49. RQUpdateView *appUpdateView = [RQUpdateView updateView];
  50. appUpdateView.questionUpdateViewType = RQQuestionUpdateViewType_Default;
  51. QMUIModalPresentationViewController *appModalViewController = [[QMUIModalPresentationViewController alloc] init];
  52. appModalViewController.contentView = appUpdateView;
  53. appModalViewController.contentViewMargins = UIEdgeInsetsMake(0, 0, 0, 0);
  54. appModalViewController.modal = YES;
  55. appUpdateView.modalViewController = appModalViewController;
  56. [appModalViewController showWithAnimated:YES completion:nil];
  57. }
  58. @end