作为 AntUI 的外壳,AntUIShell 主要用于实现 AntUI 中第三方的协议,可以用于内嵌入 mPaaS 的应用使用,并且减少 AntUI 对外界的依赖关系。
接口说明
AntUIShellObject.h
//
// AntUIShellObject.h
// AntUIShell
//
#import <Foundation/Foundation.h>
#import <AntUI/AntUI.h>
@interface AntUIShellObject : NSObject<AUThirdPartyAdapter>
@end
代码示例
//
// AntUIShellObject.m
// AntUIShell
//
#import "AntUIShellObject.h"
#import <APMonitor/APMonitor.h>
#import <APMultimedia/APMultimedia.h>
#import <MPBadgeService/MPBadgeService.h>
@implementation AntUIShellObject
#pragma mark ----AUThirdPartyAdapter
/***********************************************************/
//图片协议 APMultimedia
/*
第三方适配下载图片接口
主要对多媒体接口进行包装,由第三方实现
*/
- (NSString *)thirdPartyGetImage:(NSString *)identifier
business:(NSString *)business
zoom:(CGSize)size
originalSize:(CGSize)originSize
progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
completion:(void (^)(UIImage *image, NSError *error))complete
{
return [[APImageManager manager] getImage:identifier business:business zoom:size originalSize:originSize progress:progress completion:complete];
}
/*
第三方适配 uiimageview 下载图片接口
由第三方去实现。
*/
- (void)thirdPartypFromImageView:(UIImageView *)fromImgView
setImageWithKey:(NSString *)key
business:(NSString *)business
placeholderImage:(UIImage *)placeholder
zoom:(CGSize)zoom
originalSize:(CGSize)originalSize
progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
completion:(void (^)(UIImage *image, NSError *error))complete
{
if(fromImgView && [fromImgView isKindOfClass:[UIImageView class]]) {
[fromImgView setImageWithKey:key business:business placeholderImage:placeholder zoom:zoom originalSize:originalSize progress:progress completion:complete];
}
}
/***********************************************************/
//红点协议 MPBadgeService
/*
初始化红点 View
*/
- (UIView *) thirdPartyBadgeViewWithFrame:(CGRect)frame
{
return [[MPBadgeView alloc] initWithFrame:frame];
}
/*
红点设置 widgetId
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
widgetId:(NSString *) widgetId
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
tmpBadgeView.widgetId = widgetId;
}
}
/*
注册红点 view 到 MPBadgeManager 管理者。
*/
- (void) thirdPartyBadgeViewReg:(UIView *)badgeView
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
[[MPBadgeManager sharedInstance] registerBadgeView:tmpBadgeView];
}
}
/**
* 更新显示“红点”样式
* @param badgeView 红点 View
* @param badgeValue: @"." 显示红点
* @"new" 显示 new
* @"数字" 显示数字,大于 99 则显示图片 more(...)
* @"惠"/"hui" 显示“惠”字
* @"xin" 显示"新"字
* nil 清除当前显示
*
* @return 无
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
updateValue:(NSString *)badgeValue
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
[tmpBadgeView updateBadgeValue:badgeValue];
}
}
/*
提供业务监控红点控件刷新接口。
widgetInfo 类型是 MPWidgetInfo
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
updateBlock:(void(^)(id widgetInfo, BOOL isShow)) updateBlock
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
if(updateBlock) {
tmpBadgeView.updateBlock = updateBlock;
}
}
}
/*
埋点协议 APMonitor
*/
//按钮的 actionName 的埋点协议
- (void) thirdPartySetButtonActionLog:(UIButton *)button
actionNameLog:(NSString *)actionName
{
if(button && [button isKindOfClass:[UIButton class]]) {
button.actionName = actionName;
}
}
/*
通知协议 (AUCardMenu/AUFloatMenu)
*/
/*
AUCardMenu 注册退出登录的通知,保证退出登录 AUCardMenu 能够及时销毁
*/
- (NSString *) thirdPartyCardMenuDismissNotiName
{
return @"SAAccountDidExitNotification";
}
/*
AUFloatMenu 注册 alerView kShareTokenAlertViewShownNotification
*/
- (NSString *) thirdPartyFloatMenuDismissFromAlertNotiName
{
return @"kShareTokenAlertViewShownNotification";
}
/*
AUFloatMenu 注册 alerView SALoginAppWillStartNotification
*/
- (NSString *) thirdPartyFloatMenuDismissFromLoginNotiName
{
return @"SALoginAppWillStartNotification";
}
@end
文档内容是否对您有帮助?