<commit_before>	//
//  MediaZoomingScrollView.swift
//  MediaBrowser
//
//  Created by <NAME> on 2017. 9. 6..
//  Copyright © 2017년 <NAME>. All rights reserved.
//

import UIKit
import UICircularProgressRing

class MediaZoomingScrollView: UIScrollView, UIScrollViewDelegate, TapDetectingImageViewDelegate, TapDetectingViewDelegate {
    var index = 0
    var media: Media?
    weak var captionView: MediaCaptionView?
    weak var selectedButton: UIButton?
    weak var playButton: UIButton?
    var loadingIndicator = UICircularProgressRing(frame: CGRect(x: 140, y: 30, width: 40, height: 40))
    
    weak var mediaBrowser: MediaBrowser!
    var tapView = MediaTapDetectingView(frame: .zero) // for background taps
    var photoImageView = MediaTapDetectingImageView(frame: .zero)
    var loadingError: UIImageView?
    
    init(mediaBrowser: MediaBrowser) {
        super.init(frame: .zero)
        
        // Setup
        index = Int.max
        self.mediaBrowser = mediaBrowser
        
        // Tap view for background
        tapView = MediaTapDetectingView(frame: bounds)
        tapView.tapDelegate = self
        tapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        tapView.backgroundColor = .clear
        addSubview(tapView)
        
        // Image view
        photoImageView.tapDelegate = self
        photoImageView.contentMode = .center
        photoImageView.backgroundColor = .clear
        addSubview(photoImageView)
        
        // Loading indicator
        loadingIndicator.isUserInteractionEnabled = false
        loadingIndicator.autoresizingMask =
            [.flexibleLeftMargin, .flexibleTopMargin, .flexibleBottomMargin, .flexibleRightMargin]
        loadingIndicator.ringStyle = .ontop
        loadingIndicator.innerRingColor = UIColor.white
        loadingIndicator.outerRingColor = UIColor.gray
        loadingIndicator.innerRingWidth = 1
        loadingIndicator.outerRingWidth = 1

        addSubview(loadingIndicator)
        
        // Listen progress notifications
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(setProgressFromNotification),
            name: NSNotification.Name(rawValue: MEDIA_PROGRESS_NOTIFICATION),
            object: nil)
        
        // Setup
        delegate = self
        showsHorizontalScrollIndicator = false
        showsVerticalScrollIndicator = false
        decelerationRate = UIScrollView.DecelerationRate.fast
        autoresizingMask = [.flexibleWidth, .flexibleHeight]
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    deinit {<commit_msg>Update MediaZoomingScrollView.swift<commit_after>	//
//  MediaZoomingScrollView.swift
//  MediaBrowser
//
//  Created by <NAME> on 2017. 9. 6..
//  Copyright © 2017년 <NAME>. All rights reserved.
//

import UIKit
import UICircularProgressRing

class MediaZoomingScrollView: UIScrollView, UIScrollViewDelegate, TapDetectingImageViewDelegate, TapDetectingViewDelegate {
    var index = 0
    var media: Media?
    weak var captionView: MediaCaptionView?
    weak var selectedButton: UIButton?
    weak var playButton: UIButton?
    var loadingIndicator = UICircularProgressRing(frame: CGRect(x: 140, y: 30, width: 40, height: 40))
    
    weak var mediaBrowser: MediaBrowser!
    var tapView = MediaTapDetectingView(frame: .zero) // for background taps
    var photoImageView = MediaTapDetectingImageView(frame: .zero)
    var loadingError: UIImageView?
    
    init(mediaBrowser: MediaBrowser) {
        super.init(frame: .zero)
        
        // Setup
        index = Int.max
        self.mediaBrowser = mediaBrowser
        
        // Tap view for background
        tapView = MediaTapDetectingView(frame: bounds)
        tapView.tapDelegate = self
        tapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        tapView.backgroundColor = .clear
        addSubview(tapView)
        
        // Image view
        photoImageView.tapDelegate = self
        photoImageView.contentMode = .center
        photoImageView.backgroundColor = .clear
        addSubview(photoImageView)
        
        // Loading indicator
        loadingIndicator.isUserInteractionEnabled = false
        loadingIndicator.autoresizingMask =
            [.flexibleLeftMargin, .flexibleTopMargin, .flexibleBottomMargin, .flexibleRightMargin]
        loadingIndicator.style = .ontop
        loadingIndicator.innerRingColor = UIColor.white
        loadingIndicator.outerRingColor = UIColor.gray
        loadingIndicator.innerRingWidth = 1
        loadingIndicator.outerRingWidth = 1

        addSubview(loadingIndicator)
        
        // Listen progress notifications
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(setProgressFromNotification),
            name: NSNotification.Name(rawValue: MEDIA_PROGRESS_NOTIFICATION),
            object: nil)
        
        // Setup
        delegate = self
        showsHorizontalScrollIndicator = false
        showsVerticalScrollIndicator = false
        decelerationRate = UIScrollView.DecelerationRate.fast
        autoresizingMask = [.flexibleWidth, .flexibleHeight]
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    deinit {
{'fraction_non_alphanumeric': 0.07306536438767844, 'fraction_numerical': 0.008264462809917356, 'mean_word_length': 2.585858585858586, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6527882', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1452, 'n_words': 317}