<commit_before>//
//  TimelineTableViewController.swift
//  MusicFav
//
//  Created by <NAME> on 8/30/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import ReactiveCocoa
import SwiftyJSON
import FeedlyKit
import MusicFeeder
import Box

class TimelineTableViewController: UITableViewController, TimelineTableViewCellDelegate {
    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    var player:     Player<PlayerObserver>? { get { return appDelegate.player }}
    let cellHeight: CGFloat = 200
    let reuseIdentifier = "TimelineTableViewCell"

    var indicator:    UIActivityIndicatorView!
    var reloadButton: UIButton!
    var observer:     Disposable?
    var onpuRefreshControl:  OnpuRefreshControl!
    var playerObserver: TimelinePlayerObserver!

    class TimelinePlayerObserver: PlayerObserver {
        let vc: TimelineTableViewController
        init(viewController: TimelineTableViewController) {
            vc = viewController
            super.init()
        }
        override func timeUpdated()      {}
        override func didPlayToEndTime() {}
        override func statusChanged() {
            vc.updateSelection(UITableViewScrollPosition.Middle)
            vc.updateCurrentTrack()
        }
        override func nextPlaylistRequested() {
            vc.playPlaylist(vc.nextPlaylist())
        }
        override func previousPlaylistRequested() {
            vc.playPlaylist(vc.previousPlaylist())
        }
        override func trackSelected(track: PlayerKitTrack, index: Int, playlist: PlayerKitPlaylist) {
            vc.updateTrack(track, index: index, playlist: playlist, playerState: vc.player!.currentState)
            vc.tableView?.reloadData()
        }
        override func trackUnselected(track: PlayerKitTrack, index: Int, playlist: PlayerKitPlaylist) {
            vc.updateTrack(track, index: index, playlist: playlist, playerState: PlayerState.Init)
            vc.tableView?.reloadData()
        }
    }

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override init(style: UITableViewStyle) {
        super.init(style: style)
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder:aDecoder)<commit_msg>Don't scroll when update selection of current playing item<commit_after>//
//  TimelineTableViewController.swift
//  MusicFav
//
//  Created by <NAME> on 8/30/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import ReactiveCocoa
import SwiftyJSON
import FeedlyKit
import MusicFeeder
import Box

class TimelineTableViewController: UITableViewController, TimelineTableViewCellDelegate {
    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    var player:     Player<PlayerObserver>? { get { return appDelegate.player }}
    let cellHeight: CGFloat = 200
    let reuseIdentifier = "TimelineTableViewCell"

    var indicator:    UIActivityIndicatorView!
    var reloadButton: UIButton!
    var observer:     Disposable?
    var onpuRefreshControl:  OnpuRefreshControl!
    var playerObserver: TimelinePlayerObserver!

    class TimelinePlayerObserver: PlayerObserver {
        let vc: TimelineTableViewController
        init(viewController: TimelineTableViewController) {
            vc = viewController
            super.init()
        }
        override func timeUpdated()      {}
        override func didPlayToEndTime() {}
        override func statusChanged() {
            vc.updateSelection(UITableViewScrollPosition.None)
            vc.updateCurrentTrack()
        }
        override func nextPlaylistRequested() {
            vc.playPlaylist(vc.nextPlaylist())
        }
        override func previousPlaylistRequested() {
            vc.playPlaylist(vc.previousPlaylist())
        }
        override func trackSelected(track: PlayerKitTrack, index: Int, playlist: PlayerKitPlaylist) {
            vc.updateTrack(track, index: index, playlist: playlist, playerState: vc.player!.currentState)
            vc.tableView?.reloadData()
        }
        override func trackUnselected(track: PlayerKitTrack, index: Int, playlist: PlayerKitPlaylist) {
            vc.updateTrack(track, index: index, playlist: playlist, playerState: PlayerState.Init)
            vc.tableView?.reloadData()
        }
    }

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override init(style: UITableViewStyle) {
        super.init(style: style)
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder:aDecoder)
{'fraction_non_alphanumeric': 0.08441701564910734, 'fraction_numerical': 0.005289839100727353, 'mean_word_length': 2.9222126188418325, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1678313', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1208, 'n_words': 289}