<commit_before>//
//  LocationViewController.swift
//  Permissions
//
//  Created by <NAME> on 28/07/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import CoreLocation
import MapKit
import Operations

class LocationViewController: PermissionViewController {

    @IBOutlet var mapView: MKMapView!
    @IBOutlet var notDeterminedContainerView: UIView!
    @IBOutlet var accessDeniedViewContainer: UIView!
    @IBOutlet var resetLocationInstructionsView: UIView!
    @IBOutlet var getLocationButton: UIButton!
    @IBOutlet var requestLocationButton: UIButton!

    var location: CLLocation? = .None {
        didSet {
            if let location = location {
                dispatch_async(Queue.Main.queue) {
                    println("User location: \(location)")                    
//                    self.mapView.setCenterCoordinate(location.coordinate, animated: true)
                    self.mapView.setRegion(location.region, animated: true)
                }
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        title = NSLocalizedString("Location", comment: "Location")
    }

    override func viewWillAppear(animated: Bool) {
        determineAuthorizationStatus()
    }

    func determineAuthorizationStatus(silently: Bool = true) {

        // Create a simple block operation to set the state.
        let authorized = BlockOperation { (continueWithError: BlockOperation.ContinuationBlockType) in
            self.state = .Authorized
            self.mapView.showsUserLocation = true
            continueWithError(error: nil)
        }

        authorized.name = "Authorized Access"

        // Condition the operation so that it will only run if we have<commit_msg>[OPR-38]: Cleans up the location didSet observer.<commit_after>//
//  LocationViewController.swift
//  Permissions
//
//  Created by <NAME> on 28/07/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import CoreLocation
import MapKit
import Operations

class LocationViewController: PermissionViewController {

    @IBOutlet var mapView: MKMapView!
    @IBOutlet var notDeterminedContainerView: UIView!
    @IBOutlet var accessDeniedViewContainer: UIView!
    @IBOutlet var resetLocationInstructionsView: UIView!
    @IBOutlet var getLocationButton: UIButton!
    @IBOutlet var requestLocationButton: UIButton!

    var location: CLLocation? = .None {
        didSet {
            if let location = location {
                dispatch_async(Queue.Main.queue) {
                    self.mapView.setRegion(location.region, animated: true)
                }
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        title = NSLocalizedString("Location", comment: "Location")
    }

    override func viewWillAppear(animated: Bool) {
        determineAuthorizationStatus()
    }

    func determineAuthorizationStatus(silently: Bool = true) {

        // Create a simple block operation to set the state.
        let authorized = BlockOperation { (continueWithError: BlockOperation.ContinuationBlockType) in
            self.state = .Authorized
            self.mapView.showsUserLocation = true
            continueWithError(error: nil)
        }

        authorized.name = "Authorized Access"

        // Condition the operation so that it will only run if we have
{'fraction_non_alphanumeric': 0.08058823529411764, 'fraction_numerical': 0.007647058823529412, 'mean_word_length': 2.5170630816959667, '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': '5711029', 'n_tokens_mistral': 929, 'n_tokens_neox': 869, 'n_words': 243}