<commit_before>//
//  OttoZoomingScrollView.swift
//  OTTOPhotoBrowser
//
//  Created by <NAME> on 22/12/2016.
//  Copyright © 2016 CocoaPods. All rights reserved.
//

import UIKit

class OTTOZoomingScrollView: UIScrollView, UIScrollViewDelegate {
    
    var photo: OTTOPhoto? {
        didSet {
            displayImage()
        }
    }
    
    var padding: CGFloat = 0
    weak var photoBrowserView: OTTOPhotoBrowserView?
    private let activityIndicatorView: UIActivityIndicatorView
    private let tapView: UIView
    private let photoImageView: UIImageView
    private var isPinchoutDetected = false
    
    func prepareForReuse() {
        photo = nil
    }
    
    required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
    }
    
    init(photoBrowserView: OTTOPhotoBrowserView) {
        self.photoBrowserView = photoBrowserView
    
        activityIndicatorView = UIActivityIndicatorView()
        tapView = UIView(frame: CGRect.zero)
        photoImageView = UIImageView(frame: CGRect.zero)
        
        super.init(frame: CGRect.zero)
        
        activityIndicatorView.activityIndicatorViewStyle = .gray
        activityIndicatorView.hidesWhenStopped = true
        addSubview(activityIndicatorView)
        
        tapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        tapView.backgroundColor = UIColor.clear
        let tapViewSingleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleSingleTap(gestureRecognizer:)))
        let tapViewDoubleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(gestureRecognizer:)))
        tapViewDoubleTapRecognizer.numberOfTapsRequired = 2
        tapViewSingleTapRecognizer.require(toFail: tapViewDoubleTapRecognizer)
        tapView.addGestureRecognizer(tapViewSingleTapRecognizer)
        tapView.addGestureRecognizer(tapViewDoubleTapRecognizer)
        
        photoImageView.backgroundColor = UIColor.clear
        let imageViewSingleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleSingleTap(gestureRecognizer:)))
        let imageViewDoubleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(gestureRecognizer:)))
        imageViewDoubleTapRecognizer.numberOfTapsRequired = 2
        imageViewSingleTapRecognizer.require(toFail: imageViewDoubleTapRecognizer)
        photoImageView.isUserInteractionEnabled = true
        photoImageView.addGestureRecognizer(imageViewSingleTapRecognizer)
        photoImageView.addGestureRecognizer(imageViewDoubleTapRecognizer)
        addSubview(tapView)
        addSubview(photoImageView)
        
        backgroundColor = UIColor.clear
        delegate = self
        showsVerticalScrollIndicator = false
        showsHorizontalScrollIndicator = false
        decelerationRate = UIScrollViewDecelerationRateFast
        autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }
    
    func displayImage() {
        guard let photo = photo else {
            return
        }
        
        minimumZoomScale = 1
        maximumZoomScale = 1
        zoomScale = 1
        contentSize = CGSize.zero
        
        if let image = photoBrowserView?.imageForPhoto(photo: photo), image.size.width > 0, image.size.height > 0 {<commit_msg>Do not set content size to zero.<commit_after>//
//  OttoZoomingScrollView.swift
//  OTTOPhotoBrowser
//
//  Created by <NAME> on 22/12/2016.
//  Copyright © 2016 CocoaPods. All rights reserved.
//

import UIKit

class OTTOZoomingScrollView: UIScrollView, UIScrollViewDelegate {
    
    var photo: OTTOPhoto? {
        didSet {
            displayImage()
        }
    }
    
    var padding: CGFloat = 0
    weak var photoBrowserView: OTTOPhotoBrowserView?
    private let activityIndicatorView: UIActivityIndicatorView
    private let tapView: UIView
    private let photoImageView: UIImageView
    private var isPinchoutDetected = false
    
    func prepareForReuse() {
        photo = nil
    }
    
    required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
    }
    
    init(photoBrowserView: OTTOPhotoBrowserView) {
        self.photoBrowserView = photoBrowserView
    
        activityIndicatorView = UIActivityIndicatorView()
        tapView = UIView(frame: CGRect.zero)
        photoImageView = UIImageView(frame: CGRect.zero)
        
        super.init(frame: CGRect.zero)
        
        activityIndicatorView.activityIndicatorViewStyle = .gray
        activityIndicatorView.hidesWhenStopped = true
        addSubview(activityIndicatorView)
        
        tapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        tapView.backgroundColor = UIColor.clear
        let tapViewSingleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleSingleTap(gestureRecognizer:)))
        let tapViewDoubleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(gestureRecognizer:)))
        tapViewDoubleTapRecognizer.numberOfTapsRequired = 2
        tapViewSingleTapRecognizer.require(toFail: tapViewDoubleTapRecognizer)
        tapView.addGestureRecognizer(tapViewSingleTapRecognizer)
        tapView.addGestureRecognizer(tapViewDoubleTapRecognizer)
        
        photoImageView.backgroundColor = UIColor.clear
        let imageViewSingleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleSingleTap(gestureRecognizer:)))
        let imageViewDoubleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(gestureRecognizer:)))
        imageViewDoubleTapRecognizer.numberOfTapsRequired = 2
        imageViewSingleTapRecognizer.require(toFail: imageViewDoubleTapRecognizer)
        photoImageView.isUserInteractionEnabled = true
        photoImageView.addGestureRecognizer(imageViewSingleTapRecognizer)
        photoImageView.addGestureRecognizer(imageViewDoubleTapRecognizer)
        addSubview(tapView)
        addSubview(photoImageView)
        
        backgroundColor = UIColor.clear
        delegate = self
        showsVerticalScrollIndicator = false
        showsHorizontalScrollIndicator = false
        decelerationRate = UIScrollViewDecelerationRateFast
        autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }
    
    func displayImage() {
        guard let photo = photo else {
            return
        }
        
        minimumZoomScale = 1
        maximumZoomScale = 1
        zoomScale = 1
        
        if let image = photoBrowserView?.imageForPhoto(photo: photo), image.size.width > 0, image.size.height > 0 {
{'fraction_non_alphanumeric': 0.06714736367733214, 'fraction_numerical': 0.006008712633318311, 'mean_word_length': 3.140547263681592, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4664487', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1869, 'n_words': 338}