94 lines
3.2 KiB
Objective-C
94 lines
3.2 KiB
Objective-C
//
|
|
// XPRoomFacePresenter.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/3/9.
|
|
//
|
|
|
|
#import "XPRoomFacePresenter.h"
|
|
#import "Api.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "XPRoomFaceTool.h"
|
|
#import "ClientConfig.h"
|
|
#import "RoomFaceInfoModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "XPRoomFaceProtocol.h"
|
|
#import "NSArray+Safe.h"
|
|
|
|
@implementation XPRoomFacePresenter
|
|
|
|
///获取当前用户信息
|
|
- (void)getUserInfo {
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] getUserInfoSuccess:userInfo];
|
|
}showLoading:YES] uid:uid];
|
|
}
|
|
|
|
///普通表情
|
|
- (void)getRoomNormalFace {
|
|
NSDictionary * dic = [ClientConfig shareConfig].configInfo.faceInitData;
|
|
NSArray * originArray = [RoomFaceInfoModel modelsWithArray:dic[@"faces"]];
|
|
NSArray * sortArray = [self sortFaceInfosWithfaceInfoArr:originArray];
|
|
NSString * faceFile = [XPRoomFaceTool shareFaceTool].faceDirectory;
|
|
NSMutableArray * faceArray = [NSMutableArray array];
|
|
for (int i = 0; i< sortArray.count; i++) {
|
|
RoomFaceInfoModel * faceInfo = [sortArray safeObjectAtIndex1:i];
|
|
if (!faceInfo.isNobleFace && faceInfo.faceType == 1) {
|
|
NSString *faceName = [NSString stringWithFormat:@"%@_%ld_%ld",faceInfo.pinyin,faceInfo.fid,faceInfo.iconPos];
|
|
NSString *dirName = [NSString stringWithFormat:@"%@_%ld",faceInfo.pinyin,faceInfo.fid];
|
|
NSString *targetPath = [NSString stringWithFormat:@"%@/%@/%@",faceFile,dirName,faceName];
|
|
UIImage * faceImage = [UIImage imageWithContentsOfFile:targetPath];
|
|
if (faceImage) {
|
|
faceInfo.faceImage = faceImage;
|
|
}
|
|
[faceArray addObject:faceInfo];
|
|
}
|
|
}
|
|
[[self getView] getRoomNormalFaceListSuccess:faceArray];
|
|
}
|
|
|
|
|
|
/// 规则表情
|
|
- (void)getRoomNobelFace {
|
|
NSDictionary * dic = [ClientConfig shareConfig].configInfo.faceInitData;
|
|
NSArray * originArray = [RoomFaceInfoModel modelsWithArray:dic[@"vipFaces"]];
|
|
NSArray * sortArray = [self sortFaceInfosWithfaceInfoArr:originArray];
|
|
NSString * faceFile = [XPRoomFaceTool shareFaceTool].faceDirectory;
|
|
NSMutableArray * faceArray = [NSMutableArray array];
|
|
for (int i = 0; i< sortArray.count; i++) {
|
|
RoomFaceInfoModel * faceInfo = [sortArray safeObjectAtIndex1:i];
|
|
if (faceInfo.faceType == 1) {
|
|
NSString *faceName = [NSString stringWithFormat:@"%@_%ld_%ld",faceInfo.pinyin,faceInfo.fid,faceInfo.iconPos];
|
|
NSString *dirName = [NSString stringWithFormat:@"%@_%ld",faceInfo.pinyin,faceInfo.fid];
|
|
NSString *targetPath = [NSString stringWithFormat:@"%@/%@/%@",faceFile,dirName,faceName];
|
|
UIImage * faceImage = [UIImage imageWithContentsOfFile:targetPath];
|
|
if (faceImage) {
|
|
faceInfo.faceImage = faceImage;
|
|
}
|
|
[faceArray addObject:faceInfo];
|
|
}
|
|
}
|
|
[[self getView] getRoomVipFaceListSuccess:faceArray];
|
|
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
///排序
|
|
- (NSArray *)sortFaceInfosWithfaceInfoArr:(NSArray *)faceInfoArr {
|
|
NSMutableArray *temp = [NSMutableArray array];
|
|
NSMutableArray *temp2 = [NSMutableArray array]; //运气表情
|
|
for (RoomFaceInfoModel *item in faceInfoArr) {
|
|
if (item.resultCount <= 0) {
|
|
[temp addObject:item];
|
|
}else {
|
|
[temp2 addObject:item];
|
|
}
|
|
}
|
|
[temp addObjectsFromArray:temp2];
|
|
return temp;
|
|
}
|
|
|
|
@end
|