<commit_before>//
//  MainTunesViewController.swift
//  sway
//
//  Created by <NAME> on 10/15/15.
//  Copyright © 2015 VCH. All rights reserved.
//

import UIKit

let tuneToDetailSegue = "TuneToDetailSegue"

class MainTunesViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, TuneViewCellDelegate {

    @IBOutlet weak var tableView: UITableView!
    var searchBar: UISearchBar!

    var refreshControl:UIRefreshControl!
    var tunes:[Tune]?

    var selectedTune: Tune?
    
    override func viewDidLoad() {
        
        super.viewDidLoad()

        addRefreshControl()
        renderTunes()
        
        tableView.registerNib(UINib(nibName: tuneViewCell, bundle: nil), forCellReuseIdentifier: tuneViewCell)

        tableView.delegate = self
        tableView.dataSource = self
        
        tableView.rowHeight = UITableViewAutomaticDimension
        tableView.estimatedRowHeight = 400
        
        searchBar = UISearchBar()
        searchBar.showsCancelButton = false
        searchBar.sizeToFit()
        searchBar.delegate = self
    
        automaticallyAdjustsScrollViewInsets = false
        definesPresentationContext = true
        parentViewController?.navigationItem.titleView = searchBar

    }
    
    override func viewWillAppear(animated: Bool) {
        searchBar.hidden = false
    }
    
    override func viewWillDisappear(animated: Bool) {
        searchBar.hidden = true
        
    }
    
    private func renderTunes() {
        ParseAPI.sharedInstance.getAllRecordings() { (tunes: [Tune]?, error: NSError?) -> () in
            dispatch_async(dispatch_get_main_queue(), {
                if tunes != nil {
                    self.tunes = tunes
                    self.tableView.reloadData()
                }
            })
        }
    }
    
    private func addRefreshControl() {<commit_msg>Ensure modifications for tunes is reflected when returning back to the main tunes view<commit_after>//
//  MainTunesViewController.swift
//  sway
//
//  Created by <NAME> on 10/15/15.
//  Copyright © 2015 VCH. All rights reserved.
//

import UIKit

let tuneToDetailSegue = "TuneToDetailSegue"

class MainTunesViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate, TuneViewCellDelegate {

    @IBOutlet weak var tableView: UITableView!
    var searchBar: UISearchBar!

    var refreshControl:UIRefreshControl!
    var tunes:[Tune]?

    var selectedTune: Tune?
    
    override func viewDidLoad() {
        
        super.viewDidLoad()

        addRefreshControl()
        
        tableView.registerNib(UINib(nibName: tuneViewCell, bundle: nil), forCellReuseIdentifier: tuneViewCell)

        tableView.delegate = self
        tableView.dataSource = self
        
        tableView.rowHeight = UITableViewAutomaticDimension
        tableView.estimatedRowHeight = 400
        
        searchBar = UISearchBar()
        searchBar.showsCancelButton = false
        searchBar.sizeToFit()
        searchBar.delegate = self
    
        automaticallyAdjustsScrollViewInsets = false
        definesPresentationContext = true
        parentViewController?.navigationItem.titleView = searchBar
    }
    
    override func viewWillAppear(animated: Bool) {
        searchBar.hidden = false
        renderTunes()
    }
    
    override func viewWillDisappear(animated: Bool) {
        searchBar.hidden = true
        
    }
    
    private func renderTunes() {
        ParseAPI.sharedInstance.getAllRecordings() { (tunes: [Tune]?, error: NSError?) -> () in
            dispatch_async(dispatch_get_main_queue(), {
                if tunes != nil {
                    self.tunes = tunes
                    self.tableView.reloadData()
                }
            })
        }
    }
    
    private func addRefreshControl() {
{'fraction_non_alphanumeric': 0.0778816199376947, 'fraction_numerical': 0.006749740394600207, 'mean_word_length': 2.312983662940671, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1346760', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1059, 'n_words': 225}