[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/norlight/Coding-iOS/master/Coding_iOS/Models/CodingTip.m [Back]  [Original]

//
//  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)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{
    // contenttarget_type 
    if ([_target_type isEqualToString:@"Depot"]) {//xxxplaymore
        _user_item = [HtmlMediaItem htmlMediaItemWithTypeATUser:[Login curLoginUser] mediaRange:NSMakeRange(0, 0)];
    }else if (_htmlMedia.mediaItems.count > 0) {
        _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) {
        for (HtmlMediaItem *item in _htmlMedia.mediaItems) {
            item.range = NSMakeRange(item.range.location - range.location, item.range.length);
        }
        [_htmlMedia.contentDisplay deleteCharactersInRange:NSMakeRange(0, range.location)];
    }
    _content = _htmlMedia.contentDisplay;
}

+ (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",
                       @"PullRequestBean" : @"0x49C9A7",
                       @"PullRequestComment" : @"0x49C9A7",
                       @"QcTask" : @"0x3C8CEA",
                       @"Task" : @"0x379FD3",
                       @"TaskComment" : @"0x379FD3",
                       @"Tweet" : @"0xFB8638",
                       @"TweetComment" : @"0xFB8638",
                       @"TweetLike" : @"0xFF5847",
                       @"User" : @"0x496AB3",
                       @"UserFollow" : @"0x3BBD79",
                       };
    });
    return color_dict;
}
@end

Web Proxy Viewer  |  New URL  |  Original Page