<commit_before>//
//  PairingViewController.swift
//  Trustline
//
//  Created by matt on 16/10/2015.
//  Copyright © 2015 amoriello.hutti. All rights reserved.
//

import UIKit

class PairingViewController: UIViewController, ReadKeyMaterialDelegate {
  var bleManager :BleManager2!
  var token :Token2!
  var keyMaterial = KeyMaterial()
  var settings = TrustLineSettings()
  
  
  override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
  }
  
  override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    bleManager = BleManager2(managerStateErrorHandler: self.bleManagerStateChange, keyMaterial: keyMaterial)

    if settings.isPaired {
      showMessage("Searching Token...", hideOnTap: false, showAnnimation: true)
      BleManagement.connectToPairedToken(bleManager, pairedDevice: settings.pairedDevice!, handler: { (token, error) in
        if let err = error {
          showError(error: err)
        } else {
          self.token = token!
          showMessage("Connected!", tapAction: {self.performSegueWithIdentifier("showNavigationSegue", sender: self)})
        }
      })
    }
  }
  

  @IBAction func onPairNewPushed(sender: AnyObject) {
    showMessage("Searching Tokens...", hideOnTap: false, showAnnimation: true)
    
    BleManagement.pairWithNewToken(bleManager) { (token, error) in
      if let err = error {
        showError(error: err)
      } else {
        self.token = token!
        showMessage("Token Paired and Ready", tapAction: {self.performSegueWithIdentifier("showQRGenerator", sender: self)})
      }
    }
  }<commit_msg>Using lambda expression simplified syntaxe<commit_after>//
//  PairingViewController.swift
//  Trustline
//
//  Created by matt on 16/10/2015.
//  Copyright © 2015 amoriello.hutti. All rights reserved.
//

import UIKit

class PairingViewController: UIViewController, ReadKeyMaterialDelegate {
  var bleManager :BleManager2!
  var token :Token2!
  var keyMaterial = KeyMaterial()
  var settings = TrustLineSettings()
  
  
  override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
  }
  
  override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    bleManager = BleManager2(managerStateErrorHandler: self.bleManagerStateChange, keyMaterial: keyMaterial)

    if settings.isPaired {
      showMessage("Searching Token...", hideOnTap: false, showAnnimation: true)
      BleManagement.connectToPairedToken(bleManager, pairedDevice: settings.pairedDevice!) { (token, error) in
        if let err = error {
          showError(error: err)
        } else {
          self.token = token!
          showMessage("Connected!", tapAction: {self.performSegueWithIdentifier("showNavigationSegue", sender: self)})
        }
      }
    }
  }
  

  @IBAction func onPairNewPushed(sender: AnyObject) {
    showMessage("Searching Tokens...", hideOnTap: false, showAnnimation: true)
    
    BleManagement.pairWithNewToken(bleManager) { (token, error) in
      if let err = error {
        showError(error: err)
      } else {
        self.token = token!
        showMessage("Token Paired and Ready", tapAction: {self.performSegueWithIdentifier("showQRGenerator", sender: self)})
      }
    }
  }
{'fraction_non_alphanumeric': 0.10191082802547771, 'fraction_numerical': 0.009099181073703366, 'mean_word_length': 3.2390745501285347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '508409', 'n_tokens_mistral': 1020, 'n_tokens_neox': 961, 'n_words': 233}