-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathCodingTip.m
104 lines (97 loc) · 4.07 KB
/
CodingTip.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// CodingTip.m
// Coding_iOS
//
// Created by 王 原闯 on 14-9-2.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "CodingTip.h"
#import "Login.h"
@implementation CodingTip
- (void)setId:(NSNumber *)id{
if ([id isKindOfClass:[NSString class]]){
_id = @([(NSString *)id integerValue]);
}else{
_id = id;
}
}
- (void)setContent:(NSString *)content{
if (_content != content) {
_htmlMedia = [HtmlMedia htmlMediaWithString:content showType:MediaShowTypeImageAndMonkey];
_content = _htmlMedia.contentDisplay;
}
if (_target_type.length > 0) {
[self adjust];
}
}
- (void)setTarget_type:(NSString *)target_type{
_target_type = target_type;
if (_content.length > 0) {
[self adjust];
}
}
- (void)adjust{
//根据 content、target_type 去重组数据
if ([_target_type isEqualToString:@"Depot"]) {//您导入的仓库(xxx)成功。点击查看:<a>playmore</a>
_user_item = [HtmlMediaItem htmlMediaItemWithTypeATUser:[Login curLoginUser] mediaRange:NSMakeRange(0, 0)];
}else if ([_target_type isEqualToString:@"Task"] && _htmlMedia.mediaItems.count == 1){//任务提醒
_user_item = [HtmlMediaItem htmlMediaItemWithType:HtmlMediaItemType_CustomLink];
_user_item.linkStr = @"任务提醒";
_user_item.href = [(HtmlMediaItem *)_htmlMedia.mediaItems.firstObject href];
}else if ([_target_type isEqualToString:@"Tweet"] && _htmlMedia.mediaItems.count == 1){//冒泡推荐
_user_item = [HtmlMediaItem htmlMediaItemWithType:HtmlMediaItemType_CustomLink];
_user_item.linkStr = @"冒泡提醒";
_user_item.href = [(HtmlMediaItem *)_htmlMedia.mediaItems.firstObject href];
}else if ([_target_type isEqualToString:@"User"] && _htmlMedia.mediaItems.count <= 0){
_user_item = [HtmlMediaItem htmlMediaItemWithType:HtmlMediaItemType_CustomLink];
_user_item.linkStr = @"账号提醒";
}else{
_user_item = [_htmlMedia.mediaItems firstObject];
[_htmlMedia removeItem:_user_item];
}
if (_htmlMedia.mediaItems.count > 0) {
_target_item = [_htmlMedia.mediaItems lastObject];
[_htmlMedia removeItem:_target_item];
}
_target_type_ColorName = [[CodingTip p_color_dict] objectForKey:_target_type];
if (_target_type_ColorName.length <= 0) {
_target_type_ColorName = @"0x379FD3";
}
_target_type_imageName = [NSString stringWithFormat:@"tipIcon_%@", _target_type];
_content = [_htmlMedia.contentDisplay stringByReplacingOccurrencesOfString:@"团队" withString:@"企业"];
}
+ (NSDictionary *)p_color_dict{
static NSDictionary *color_dict = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
color_dict = @{
@"BranchMember" : @"0x1AB6D9",
@"CommitLineNote" : @"",
@"Depot" : @"",
@"MergeRequestBean" : @"0x4E74B7",
@"MergeRequestComment" : @"0x4E74B7",
@"Project" : @"0xF8BE46",
@"ProjectFileComment" : @"",
@"ProjectMember" : @"0x1AB6D9",
@"ProjectPayment" : @"",
@"ProjectTopic" : @"0x2FAEEA",
@"ProjectTweet" : @"0xFB8638",
@"ProjectTweetComment" : @"0xFB8638",
@"tweetReward" : @"0xFB8638",
@"TweetReward" : @"0xFB8638",
@"PullRequestBean" : @"0x49C9A7",
@"PullRequestComment" : @"0x49C9A7",
@"QcTask" : @"0x3C8CEA",
@"Task" : @"0x379FD3",
@"TaskComment" : @"0x379FD3",
@"Tweet" : @"0xFB8638",
@"TweetComment" : @"0xFB8638",
@"TweetLike" : @"0xFF5847",
@"User" : @"0x496AB3",
@"UserFollow" : @"0x0060FF",
@"ProjectTopicCommentVote": @"",
};
});
return color_dict;
}
@end