<commit_before>open class LoadingContainerPlugin: UIContainerPlugin {
    
    fileprivate var spinningWheel: UIActivityIndicatorView!
    
    public required init() {
        super.init()
    }
    
    open override var pluginName: String {
        return "spinner"
    }
    
    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    public required init(context: UIBaseObject) {
        super.init(context: context)
        self.spinningWheel = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
        addSubview(spinningWheel)
        isUserInteractionEnabled = false
    }

    override open func render() {
        addCenteringConstraints()
        bindEventListeners()
    }
    
    fileprivate func addCenteringConstraints() {
        translatesAutoresizingMaskIntoConstraints = false
        
        let widthConstraint = NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal,
            toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: spinningWheel.frame.width)
        addConstraint(widthConstraint)
        
        let heightConstraint = NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal,
            toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: spinningWheel.frame.height)
        addConstraint(heightConstraint)
        
        let xCenterConstraint = NSLayoutConstraint(item: self, attribute: .centerX,
            relatedBy: .equal, toItem: container, attribute: .centerX, multiplier: 1, constant: 0)
        container.addConstraint(xCenterConstraint)
        
        let yCenterConstraint = NSLayoutConstraint(item: self, attribute: .centerY,
            relatedBy: .equal, toItem: container, attribute: .centerY, multiplier: 1, constant: 0)
        container.addConstraint(yCenterConstraint)
    }
    
    fileprivate func bindEventListeners() {
        listenTo(container, eventName: ContainerEvent.buffering.rawValue) {[weak self] _ in
            self?.spinningWheel.startAnimating()
            Logger.logDebug("started animating spinning wheel", scope: self?.pluginName)
        }
        
        listenTo(container, eventName: ContainerEvent.play.rawValue, callback: stopAnimating)
        listenTo(container, eventName: ContainerEvent.ended.rawValue, callback: stopAnimating)
    }
    
    fileprivate func stopAnimating(_ userInfo: EventUserInfo) {
        spinningWheel.stopAnimating()
        Logger.logDebug("stoped animating spinning wheel", scope: self.pluginName)
    }
}<commit_msg>refactor(loading): extract code into method<commit_after>open class LoadingContainerPlugin: UIContainerPlugin {
    
    fileprivate var spinningWheel: UIActivityIndicatorView!
    
    public required init() {
        super.init()
    }
    
    open override var pluginName: String {
        return "spinner"
    }
    
    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    public required init(context: UIBaseObject) {
        super.init(context: context)
        self.spinningWheel = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
        addSubview(spinningWheel)
        isUserInteractionEnabled = false
    }

    override open func render() {
        addCenteringConstraints()
        bindEventListeners()
    }
    
    fileprivate func addCenteringConstraints() {
        translatesAutoresizingMaskIntoConstraints = false
        
        let widthConstraint = NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal,
            toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: spinningWheel.frame.width)
        addConstraint(widthConstraint)
        
        let heightConstraint = NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal,
            toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: spinningWheel.frame.height)
        addConstraint(heightConstraint)
        
        let xCenterConstraint = NSLayoutConstraint(item: self, attribute: .centerX,
            relatedBy: .equal, toItem: container, attribute: .centerX, multiplier: 1, constant: 0)
        container.addConstraint(xCenterConstraint)
        
        let yCenterConstraint = NSLayoutConstraint(item: self, attribute: .centerY,
            relatedBy: .equal, toItem: container, attribute: .centerY, multiplier: 1, constant: 0)
        container.addConstraint(yCenterConstraint)
    }

    fileprivate func bindEventListeners() {
        listenTo(container, eventName: ContainerEvent.buffering.rawValue, callback: startAnimating)
        listenTo(container, eventName: ContainerEvent.play.rawValue, callback: stopAnimating)
        listenTo(container, eventName: ContainerEvent.ended.rawValue, callback: stopAnimating)
    }

    fileprivate func startAnimating(_ userInfo: EventUserInfo) {
        spinningWheel.startAnimating()
        Logger.logDebug("started animating spinning wheel", scope: self.pluginName)
    }

    fileprivate func stopAnimating(_ userInfo: EventUserInfo) {
        spinningWheel.stopAnimating()
        Logger.logDebug("stoped animating spinning wheel", scope: self.pluginName)
    }
}
{'fraction_non_alphanumeric': 0.0824407039020658, 'fraction_numerical': 0.0022953328232593728, 'mean_word_length': 3.1565977742448332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '255161', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1367, 'n_words': 324}