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

import UIKit
import AVKit
import QuartzCore
import SDWebImage

func floorcgf(x: CGFloat) -> CGFloat {
    return CGFloat(floorf(Float(x)))
}

/// MediaBrwoser is based in UIViewController, UIScrollViewDelegate and UIActionSheetDelegate. So you can push, or make modal.
@objcMembers public class MediaBrowser: UIViewController, AVPlayerViewControllerDelegate {
    internal let padding = CGFloat(0.0)

    // Data
    internal var mediaCount = -1
    internal var mediaArray = [Media?]()
    internal var thumbMedias = [Media?]()
    /// Provided via init
	internal var fixedMediasArray: [Media]?
	
	// Views
	internal var pagingScrollView = UIScrollView()
	
	// Paging & layout
	internal var visiblePages = Set<MediaZoomingScrollView>()
    internal var recycledPages = Set<MediaZoomingScrollView>()
	internal var currentPageIndex = 0
    internal var previousPageIndex = Int.max
    internal var previousLayoutBounds = CGRect.zero
	internal var pageIndexBeforeRotation = 0
	
	// Navigation & controls
	internal var toolbar = UIToolbar()
	internal var controlVisibilityTimer: Timer?
	internal var previousButton: UIBarButtonItem?
    internal var nextButton: UIBarButtonItem?
    internal var actionButton: UIBarButtonItem?
    internal var doneButton: UIBarButtonItem?
    
    // Grid
    internal var gridController: MediaGridViewController?
    internal var gridPreviousLeftNavItem: UIBarButtonItem?
    internal var gridPreviousRightNavItem: UIBarButtonItem?
    
    // Appearance
    internal var previousNavigationBarHidden = false
    internal var previousNavigationBarTranslucent = false
    internal var previousNavigationBarStyle = UIBarStyle.default
    internal var previousNavigationBarTextColor: UIColor?
    internal var previousNavigationBarBackgroundColor: UIColor?
    internal var previousNavigationBarTintColor: UIColor?
    internal var previousViewControllerBackButton: UIBarButtonItem?
    internal var previousStatusBarStyle: UIStatusBarStyle = .lightContent

    // Video
    lazy internal var currentVideoPlayerViewController: AVPlayerViewController = {
        if #available(iOS 9.0, *) {
            $0.delegate = self
        }
        return $0
    }(AVPlayerViewController())
    internal var currentVideoIndex = 0
    internal var currentVideoLoadingIndicator: UIActivityIndicatorView?

    var activityViewController: UIActivityViewController?

    /// Paging Scroll View Background Color for MediaBrowser
    public var scrollViewBackgroundColor = UIColor.black

    /// UINavigationBar Translucent for MediaBrowser
    public var navigationBarTranslucent = true
    
    /// UINavigationBar Text Color for MediaBrowser
    public var navigationBarTextColor = UIColor.white
    
    /// UINavigationBar Background Color for MediaBrowser
    public var navigationBarBackgroundColor = UIColor.black
    
    /// UINavigationBar Tint Color for MediaBrowser
    public var navigationBarTintColor = UIColor.black.withAlphaComponent(0.5)

    /// UINavigationBar Style for MediaBrowser
    public var navigationBarStyle = UIBarStyle.black

    /// UIStatusBarStyle for MediaBrowser
    public var statusBarStyle: UIStatusBarStyle = .lightContent
    
    /// UIToolBar Text Color for MediaBrowser
    public var toolbarTextColor = UIColor.white
    
    /// UIToolBar Tint Color for MediaBrowser
    public var toolbarBarTintColor = UIColor.black.withAlphaComponent(0.5)
    
    /// UIToolBar Tint Background for MediaBrowser
    public var toolbarBackgroundColor = UIColor.black
    
    /// MediaBrowser has belonged to viewcontroller
    public var hasBelongedToViewController = false
    
    /// Check viewcontroller based status bar apperance
    public var isVCBasedStatusBarAppearance = false
    
    /// Hide or show status bar
    public var statusBarShouldBeHidden = false
    
    /// Display action button (share)
    public var displayActionButton = true
    
    /// Display action button (share)
    public var actionButtonImage:UIImage?
    
    /// Make status bar not hide
    public var leaveStatusBarAlone = false
    
    /// Perform layout
	public var performingLayout = false
    
    /// Support rotating
	public var rotating = false
    
    /// Active as in it's in the view heirarchy
    public var viewIsActive = false
    
    /// Save previous status bar style to return when push
    public var didSavePreviousStateOfNavBar = false
    
    /// Stop specific layout being triggered
    public var skipNextPagingScrollViewPositioning = false
    
    /// View has appeared initially<commit_msg>Just comment changes.<commit_after>//
//  MediaBrowser.swift
//  MediaBrowser
//
//  Created by <NAME> on 2017. 9. 6..
//  Copyright © 2017년 <NAME>. All rights reserved.
//

import UIKit
import AVKit
import QuartzCore
import SDWebImage

func floorcgf(x: CGFloat) -> CGFloat {
    return CGFloat(floorf(Float(x)))
}

/// MediaBrwoser is based in UIViewController, UIScrollViewDelegate and UIActionSheetDelegate. So you can push, or make modal.
@objcMembers public class MediaBrowser: UIViewController, AVPlayerViewControllerDelegate {
    internal let padding = CGFloat(0.0)

    // Data
    internal var mediaCount = -1
    internal var mediaArray = [Media?]()
    internal var thumbMedias = [Media?]()
    /// Provided via init
	internal var fixedMediasArray: [Media]?
	
	// Views
	internal var pagingScrollView = UIScrollView()
	
	// Paging & layout
	internal var visiblePages = Set<MediaZoomingScrollView>()
    internal var recycledPages = Set<MediaZoomingScrollView>()
	internal var currentPageIndex = 0
    internal var previousPageIndex = Int.max
    internal var previousLayoutBounds = CGRect.zero
	internal var pageIndexBeforeRotation = 0
	
	// Navigation & controls
	internal var toolbar = UIToolbar()
	internal var controlVisibilityTimer: Timer?
	internal var previousButton: UIBarButtonItem?
    internal var nextButton: UIBarButtonItem?
    internal var actionButton: UIBarButtonItem?
    internal var doneButton: UIBarButtonItem?
    
    // Grid
    internal var gridController: MediaGridViewController?
    internal var gridPreviousLeftNavItem: UIBarButtonItem?
    internal var gridPreviousRightNavItem: UIBarButtonItem?
    
    // Appearance
    internal var previousNavigationBarHidden = false
    internal var previousNavigationBarTranslucent = false
    internal var previousNavigationBarStyle = UIBarStyle.default
    internal var previousNavigationBarTextColor: UIColor?
    internal var previousNavigationBarBackgroundColor: UIColor?
    internal var previousNavigationBarTintColor: UIColor?
    internal var previousViewControllerBackButton: UIBarButtonItem?
    internal var previousStatusBarStyle: UIStatusBarStyle = .lightContent

    // Video
    lazy internal var currentVideoPlayerViewController: AVPlayerViewController = {
        if #available(iOS 9.0, *) {
            $0.delegate = self
        }
        return $0
    }(AVPlayerViewController())
    internal var currentVideoIndex = 0
    internal var currentVideoLoadingIndicator: UIActivityIndicatorView?

    var activityViewController: UIActivityViewController?

    /// Paging Scroll View Background Color for MediaBrowser
    public var scrollViewBackgroundColor = UIColor.black

    /// UINavigationBar Translucent for MediaBrowser
    public var navigationBarTranslucent = true
    
    /// UINavigationBar Text Color for MediaBrowser
    public var navigationBarTextColor = UIColor.white
    
    /// UINavigationBar Background Color for MediaBrowser
    public var navigationBarBackgroundColor = UIColor.black
    
    /// UINavigationBar Tint Color for MediaBrowser
    public var navigationBarTintColor = UIColor.black.withAlphaComponent(0.5)

    /// UINavigationBar Style for MediaBrowser
    public var navigationBarStyle = UIBarStyle.black

    /// UIStatusBarStyle for MediaBrowser
    public var statusBarStyle: UIStatusBarStyle = .lightContent
    
    /// UIToolBar Text Color for MediaBrowser
    public var toolbarTextColor = UIColor.white
    
    /// UIToolBar Tint Color for MediaBrowser
    public var toolbarBarTintColor = UIColor.black.withAlphaComponent(0.5)
    
    /// UIToolBar Tint Background for MediaBrowser
    public var toolbarBackgroundColor = UIColor.black
    
    /// MediaBrowser has belonged to viewcontroller
    public var hasBelongedToViewController = false
    
    /// Check viewcontroller based status bar apperance
    public var isVCBasedStatusBarAppearance = false
    
    /// Hide or show status bar
    public var statusBarShouldBeHidden = false
    
    /// Display action button (share)
    public var displayActionButton = true
    
    /// Image can added actionbutton
    public var actionButtonImage:UIImage?
    
    /// Make status bar not hide
    public var leaveStatusBarAlone = false
    
    /// Perform layout
	public var performingLayout = false
    
    /// Support rotating
	public var rotating = false
    
    /// Active as in it's in the view heirarchy
    public var viewIsActive = false
    
    /// Save previous status bar style to return when push
    public var didSavePreviousStateOfNavBar = false
    
    /// Stop specific layout being triggered
    public var skipNextPagingScrollViewPositioning = false
    
    /// View has appeared initially
{'fraction_non_alphanumeric': 0.059921518718846115, 'fraction_numerical': 0.005090677696468342, 'mean_word_length': 3.386046511627907, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4016230', 'n_tokens_mistral': 2496, 'n_tokens_neox': 2427, 'n_words': 793}