全部产品

适配依赖

更新时间:2019-09-26 18:40:19

作为 AntUI 的外壳,AntUIShell 主要用去实现 AntUI 中第三方的协议,可以用于内嵌入 mPaaS 应用使用,并且减少 AntUI 对外界的依赖关系。

接口说明

AntUIShellObject.h

  1. //
  2. // AntUIShellObject.h
  3. // AntUIShell
  4. //
  5. #import <Foundation/Foundation.h>
  6. #import <AntUI/AntUI.h>
  7. @interface AntUIShellObject : NSObject<AUThirdPartyAdapter>
  8. @end

代码示例

  1. //
  2. // AntUIShellObject.m
  3. // AntUIShell
  4. //
  5. #import "AntUIShellObject.h"
  6. #import <APMonitor/APMonitor.h>
  7. #import <APMultimedia/APMultimedia.h>
  8. #import <MPBadgeService/MPBadgeService.h>
  9. @implementation AntUIShellObject
  10. #pragma mark ----AUThirdPartyAdapter
  11. /***********************************************************/
  12. //图片协议 APMultimedia
  13. /*
  14. 第三方适配下载图片接口
  15. 主要对多媒体接口进行包装,由第三方实现
  16. */
  17. - (NSString *)thirdPartyGetImage:(NSString *)identifier
  18. business:(NSString *)business
  19. zoom:(CGSize)size
  20. originalSize:(CGSize)originSize
  21. progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
  22. completion:(void (^)(UIImage *image, NSError *error))complete
  23. {
  24. return [[APImageManager manager] getImage:identifier business:business zoom:size originalSize:originSize progress:progress completion:complete];
  25. }
  26. /*
  27. 第三方适配 uiimageview 下载图片接口
  28. 由第三方去实现。
  29. */
  30. - (void)thirdPartypFromImageView:(UIImageView *)fromImgView
  31. setImageWithKey:(NSString *)key
  32. business:(NSString *)business
  33. placeholderImage:(UIImage *)placeholder
  34. zoom:(CGSize)zoom
  35. originalSize:(CGSize)originalSize
  36. progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
  37. completion:(void (^)(UIImage *image, NSError *error))complete
  38. {
  39. if(fromImgView && [fromImgView isKindOfClass:[UIImageView class]]) {
  40. [fromImgView setImageWithKey:key business:business placeholderImage:placeholder zoom:zoom originalSize:originalSize progress:progress completion:complete];
  41. }
  42. }
  43. /***********************************************************/
  44. //红点协议 MPBadgeService
  45. /*
  46. 初始化红点 View
  47. */
  48. - (UIView *) thirdPartyBadgeViewWithFrame:(CGRect)frame
  49. {
  50. return [[MPBadgeView alloc] initWithFrame:frame];
  51. }
  52. /*
  53. 红点设置 widgetId
  54. */
  55. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  56. widgetId:(NSString *) widgetId
  57. {
  58. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  59. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  60. tmpBadgeView.widgetId = widgetId;
  61. }
  62. }
  63. /*
  64. 注册红点 view 到 MPBadgeManager 管理者。
  65. */
  66. - (void) thirdPartyBadgeViewReg:(UIView *)badgeView
  67. {
  68. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  69. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  70. [[MPBadgeManager sharedInstance] registerBadgeView:tmpBadgeView];
  71. }
  72. }
  73. /**
  74. * 更新显示“红点”样式
  75. * @param badgeView 红点 View
  76. * @param badgeValue: @"." 显示红点
  77. * @"new" 显示 new
  78. * @"数字" 显示数字,大于 99 则显示图片 more(...)
  79. * @"惠"/"hui" 显示“惠”字
  80. * @"xin" 显示"新"字
  81. * nil 清除当前显示
  82. *
  83. * @return 无
  84. */
  85. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  86. updateValue:(NSString *)badgeValue
  87. {
  88. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  89. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  90. [tmpBadgeView updateBadgeValue:badgeValue];
  91. }
  92. }
  93. /*
  94. 提供业务监控红点控件刷新接口。
  95. widgetInfo 类型是 MPWidgetInfo
  96. */
  97. - (void) thirdPartyBadgeViewWith:(UIView *)badgeView
  98. updateBlock:(void(^)(id widgetInfo, BOOL isShow)) updateBlock
  99. {
  100. if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
  101. MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
  102. if(updateBlock) {
  103. tmpBadgeView.updateBlock = updateBlock;
  104. }
  105. }
  106. }
  107. /*
  108. 埋点协议 APMonitor
  109. */
  110. //按钮的 actionName 的埋点协议
  111. - (void) thirdPartySetButtonActionLog:(UIButton *)button
  112. actionNameLog:(NSString *)actionName
  113. {
  114. if(button && [button isKindOfClass:[UIButton class]]) {
  115. button.actionName = actionName;
  116. }
  117. }
  118. /*
  119. 通知协议 (AUCardMenu/AUFloatMenu)
  120. */
  121. /*
  122. AUCardMenu 注册退出登录的通知,保证退出登录 AUCardMenu 能够及时销毁
  123. */
  124. - (NSString *) thirdPartyCardMenuDismissNotiName
  125. {
  126. return @"SAAccountDidExitNotification";
  127. }
  128. /*
  129. AUFloatMenu 注册 alerView kShareTokenAlertViewShownNotification
  130. */
  131. - (NSString *) thirdPartyFloatMenuDismissFromAlertNotiName
  132. {
  133. return @"kShareTokenAlertViewShownNotification";
  134. }
  135. /*
  136. AUFloatMenu 注册 alerView SALoginAppWillStartNotification
  137. */
  138. - (NSString *) thirdPartyFloatMenuDismissFromLoginNotiName
  139. {
  140. return @"SALoginAppWillStartNotification";
  141. }
  142. @end