<commit_before>//
//  IndexViewCell.swift
//  travelMapMvvm
//
//  Created by green on 15/8/26.
//  Copyright (c) 2015年 travelMapMvvm. All rights reserved.
//

import UIKit
import ReactiveCocoa

/**
 * 攻略Cell 
 */
class StrategyCell: UITableViewCell, ReactiveView  {

    // 攻略图片
    @IBOutlet private weak var strategyPic: UIImageView!
    
    // 攻略名称
    @IBOutlet private weak var strategyNameL: UILabel!
    
    // 攻略创建日期
    @IBOutlet private weak var dateL: UILabel!
    
    // 攻略访问量
    @IBOutlet private weak var visiteNumL: UILabel!
    
    // 小编头像
    @IBOutlet private weak var authorHeadC: GCircleControl!
    
    // 小编名称
    @IBOutlet private weak var authorNameL: UILabel!
    
    // MARK: - init
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        selectionStyle = UITableViewCellSelectionStyle.None
        strategyPic.layer.masksToBounds = true
        strategyPic.layer.cornerRadius = 8
    }
    
    // MARK: - ReactiveView
    
    func bindViewModel(viewModel: AnyObject) {
        
        if let viewModel = viewModel as? StrategyModel {
            
            // 重用时重置图片
            self.rac_prepareForReuseSignal.subscribeNext {
                (next: AnyObject!) -> () in
                
                self.authorHeadC.image = UIImage()
                self.strategyPic.image = nil
            }
            
            strategyNameL.text = viewModel.title == nil ? "" : "\(viewModel.title)"
            dateL.text         = viewModel.createTime == nil ? "" : "\(viewModel.createTime)"
            visiteNumL.text    = viewModel.visitNumber == nil ? "" : "\(viewModel.visitNumber)"
            authorNameL.text   = viewModel.author == nil ? "" : "\(viewModel.author)"
            
            // 加载小编头像
            if !self.loadLocalAuthorPic(viewModel) {
                
                self.loadNetAuthorPic(viewModel)
            }
            
            // 加载攻略图片
            if !self.loadLocalStrategyPic(viewModel) {
                
                self.loadNetStrategyPic(viewModel)
            }
            
        }
    }
    
    // MARK: - 图片加载
    
    /**
     * 内存加载小编图片<commit_msg>fix optional text show<commit_after>//
//  IndexViewCell.swift
//  travelMapMvvm
//
//  Created by green on 15/8/26.
//  Copyright (c) 2015年 travelMapMvvm. All rights reserved.
//

import UIKit
import ReactiveCocoa

/**
 * 攻略Cell 
 */
class StrategyCell: UITableViewCell, ReactiveView  {

    // 攻略图片
    @IBOutlet private weak var strategyPic: UIImageView!
    
    // 攻略名称
    @IBOutlet private weak var strategyNameL: UILabel!
    
    // 攻略创建日期
    @IBOutlet private weak var dateL: UILabel!
    
    // 攻略访问量
    @IBOutlet private weak var visiteNumL: UILabel!
    
    // 小编头像
    @IBOutlet private weak var authorHeadC: GCircleControl!
    
    // 小编名称
    @IBOutlet private weak var authorNameL: UILabel!
    
    // MARK: - init
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        selectionStyle = UITableViewCellSelectionStyle.None
        strategyPic.layer.masksToBounds = true
        strategyPic.layer.cornerRadius = 8
    }
    
    // MARK: - ReactiveView
    
    func bindViewModel(viewModel: AnyObject) {
        
        if let viewModel = viewModel as? StrategyModel {
            
            // 重用时重置图片
            self.rac_prepareForReuseSignal.subscribeNext {
                (next: AnyObject!) -> () in
                
                self.authorHeadC.image = UIImage()
                self.strategyPic.image = nil
            }
            
            strategyNameL.text = viewModel.title
            dateL.text         = viewModel.createTime
            visiteNumL.text    = viewModel.visitNumber == nil ? "" : "\(viewModel.visitNumber!)"
            authorNameL.text   = viewModel.author
            
            // 加载小编头像
            if !self.loadLocalAuthorPic(viewModel) {
                
                self.loadNetAuthorPic(viewModel)
            }
            
            // 加载攻略图片
            if !self.loadLocalStrategyPic(viewModel) {
                
                self.loadNetStrategyPic(viewModel)
            }
            
        }
    }
    
    // MARK: - 图片加载
    
    /**
     * 内存加载小编图片
{'fraction_non_alphanumeric': 0.089668157213462, 'fraction_numerical': 0.004706989879971758, 'mean_word_length': 1.511820330969267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6343192', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1383, 'n_words': 246}