<commit_before>//
//  FavoritesTableViewController.swift
//  CorvallisBus
//
//  Created by <NAME> on 10/17/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit
import MapKit

class FavoritesTableViewController: UITableViewController {
    var favorites: [BusStop]?
    var arrivals: [Int : [BusArrival]]?
    var colors: [String : UIColor]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let cellNib = UINib(nibName: "FavoritesTableViewCell", bundle: NSBundle.mainBundle())
        self.tableView.registerNib(cellNib, forCellReuseIdentifier: "FavoritesTableViewCell")
        
        self.refreshControl = UIRefreshControl()
        self.refreshControl?.addTarget(self, action: "updateFavorites:", forControlEvents: .ValueChanged)
        
        // This observer causes updateFavorites to be called without further intervention
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateFavorites:",
            name: UIApplicationDidBecomeActiveNotification, object: UIApplication.sharedApplication())
        NSTimer.scheduledTimerWithTimeInterval(30, target: self, selector: "updateFavorites:",
            userInfo: nil, repeats: true)

        self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        self.updateFavorites(self)
    }
    
    deinit {
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func updateFavorites(sender: AnyObject) {
        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
        CorvallisBusService.favorites() {
            self.favorites = $0
            dispatch_async(dispatch_get_main_queue()) { self.tableView.reloadData() }
            self.updateArrivals()
        }<commit_msg>fixed network spinner when reopening map<commit_after>//
//  FavoritesTableViewController.swift
//  CorvallisBus
//
//  Created by <NAME> on 10/17/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit
import MapKit

class FavoritesTableViewController: UITableViewController {
    var favorites: [BusStop]?
    var arrivals: [Int : [BusArrival]]?
    var colors: [String : UIColor]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let cellNib = UINib(nibName: "FavoritesTableViewCell", bundle: NSBundle.mainBundle())
        self.tableView.registerNib(cellNib, forCellReuseIdentifier: "FavoritesTableViewCell")
        
        self.refreshControl = UIRefreshControl()
        self.refreshControl?.addTarget(self, action: "updateFavorites:", forControlEvents: .ValueChanged)
        
        // This observer causes updateFavorites to be called without further intervention
        NSTimer.scheduledTimerWithTimeInterval(30, target: self, selector: "updateFavorites:",
            userInfo: nil, repeats: true)

        self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateFavorites:",
            name: UIApplicationDidBecomeActiveNotification, object: nil)
        
        self.updateFavorites(self)
    }
    
    override func viewWillDisappear(animated: Bool) {
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func updateFavorites(sender: AnyObject) {
        UIApplication.sharedApplication().networkActivityIndicatorVisible = true
        CorvallisBusService.favorites() {
            self.favorites = $0
            dispatch_async(dispatch_get_main_queue()) { self.tableView.reloadData() }
            self.updateArrivals()
        }
{'fraction_non_alphanumeric': 0.09416096791162545, 'fraction_numerical': 0.006838506049447659, 'mean_word_length': 3.133695652173913, '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': '5992826', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1059, 'n_words': 208}