<commit_before>//
//  QPBaseTableTableViewController.swift
//  QHProject
//
//  Created by quickplain on 15/12/24.
//  Copyright © 2015年 quickplain. All rights reserved.
//

import UIKit
import FlatUIKit
import DZNEmptyDataSet

//private let imageError = UIImage(color: COLOR_CLEAR)//UIImage(named: "Cry")
//private let imageLoading = UIImage(color: COLOR_CLEAR)//UIImage(named: "Loading")

private let imageError = UIImage(named: "Cry") // UIImage(named: "Cry")
private let imageLoading = UIImage(named: "Loading")

let TIPS_LOADING = "加载中" // "加载中..."
let TIPS_LOAD_FAIL = "加载失败" // "加载失败"
let TIPS_TAP_RELOAD = "点击加载" // "点击重新加载"
let TIPS_NETWORK_EXCEPTION = "网络不是很给力,加载就失败了.."
let TIPS_CLEANING_CACHE = "正在清除缓存,请稍候"

public enum ImageType {
	case Loading
	case Error
}

extension UIViewController {
	func fixNavigationBarColor(animated: Bool) {
//        assertionFailure("lib not been imported")

		// FIXME:
//        self.navigationController?.navigationBar.translucentWith(COLOR_WHITE)
//        self.navigationController?.navigationBar.translucent = false
//
//        self.navigationController?.setNavigationBarHidden(false, animated: animated)
//        self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
	}
}

public typealias QPTableViewController = QPBaseTableViewController

public class QPBaseTableViewController: UITableViewController {

	public var controllerInfo = NSDictionary()

	public var page = 1
	private var shouldShowEmptyStatus: Bool = true
	private var statusText = TIPS_LOADING
	private var statusDesciption = TIPS_TAP_RELOAD
	private var statusImage = imageLoading

	public var shouldHideNavigationBar: Bool = false

	public override func viewWillAppear(animated: Bool) {

		// IQKeyboardManager.sharedManager().enable = false
		// IQKeyboardManager.sharedManager().enableAutoToolbar = false

		if shouldHideNavigationBar {

			self.navigationController?.setNavigationBarHidden(true, animated: animated)
		} else {

			fixNavigationBarColor(animated)
		}
		super.viewWillAppear(animated)
	}

	public override func viewWillDisappear(animated: Bool) {
		// if shouldHideNavigationBar {
		// self.navigationController?.setNavigationBarHidden(false, animated: animated)
		// self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
		//
		// }
		super.viewWillDisappear(animated)
	}

	override public func viewDidDisappear(animated: Bool) {
		super.viewDidDisappear(animated)
	}

	public func load() {
	}

	public override func viewDidLoad() {
		super.viewDidLoad()
		self.tableView.emptyDataSetSource = self;
		self.tableView.emptyDataSetDelegate = self;
		self.tableView.clearExtraLines()
//		self.setBackTitle("")
		request()
		load()
	}

	override public func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
		tableView.deselectRowAtIndexPath(indexPath, animated: true)
	}

	public func reloadData() {
		self.tableView.reloadData()
	}

	override public func scrollViewDidScroll(scrollView: UIScrollView) {
		self.view.endEditing(true)
	}

	override public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//		return super.tableView(tableView, cellForRowAtIndexPath: indexPath)
		let cell = cellForRow(atIndexPath: indexPath)
		if let qpCell = cell as? QPTableViewCell {
			qpCell.setup()
			qpCell.rootViewController = self
			qpCell.indexPath = indexPath
			return qpCell
		}<commit_msg>remove  	override public func scrollViewDidScroll(scrollView: UIScrollView) { -		self.view.endEditing(true) +//		self.view.endEditing(true)  	}<commit_after>//
//  QPBaseTableTableViewController.swift
//  QHProject
//
//  Created by quickplain on 15/12/24.
//  Copyright © 2015年 quickplain. All rights reserved.
//

import UIKit
import FlatUIKit
import DZNEmptyDataSet

//private let imageError = UIImage(color: COLOR_CLEAR)//UIImage(named: "Cry")
//private let imageLoading = UIImage(color: COLOR_CLEAR)//UIImage(named: "Loading")

private let imageError = UIImage(named: "Cry") // UIImage(named: "Cry")
private let imageLoading = UIImage(named: "Loading")

let TIPS_LOADING = "加载中" // "加载中..."
let TIPS_LOAD_FAIL = "加载失败" // "加载失败"
let TIPS_TAP_RELOAD = "点击加载" // "点击重新加载"
let TIPS_NETWORK_EXCEPTION = "网络不是很给力,加载就失败了.."
let TIPS_CLEANING_CACHE = "正在清除缓存,请稍候"

public enum ImageType {
	case Loading
	case Error
}

extension UIViewController {
	func fixNavigationBarColor(animated: Bool) {
//        assertionFailure("lib not been imported")

		// FIXME:
//        self.navigationController?.navigationBar.translucentWith(COLOR_WHITE)
//        self.navigationController?.navigationBar.translucent = false
//
//        self.navigationController?.setNavigationBarHidden(false, animated: animated)
//        self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
	}
}

public typealias QPTableViewController = QPBaseTableViewController

public class QPBaseTableViewController: UITableViewController {

	public var controllerInfo = NSDictionary()

	public var page = 1
	private var shouldShowEmptyStatus: Bool = true
	private var statusText = TIPS_LOADING
	private var statusDesciption = TIPS_TAP_RELOAD
	private var statusImage = imageLoading

	public var shouldHideNavigationBar: Bool = false

	public override func viewWillAppear(animated: Bool) {

		// IQKeyboardManager.sharedManager().enable = false
		// IQKeyboardManager.sharedManager().enableAutoToolbar = false

		if shouldHideNavigationBar {

			self.navigationController?.setNavigationBarHidden(true, animated: animated)
		} else {

			fixNavigationBarColor(animated)
		}
		super.viewWillAppear(animated)
	}

	public override func viewWillDisappear(animated: Bool) {
		// if shouldHideNavigationBar {
		// self.navigationController?.setNavigationBarHidden(false, animated: animated)
		// self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
		//
		// }
		super.viewWillDisappear(animated)
	}

	override public func viewDidDisappear(animated: Bool) {
		super.viewDidDisappear(animated)
	}

	public func load() {
	}

	public override func viewDidLoad() {
		super.viewDidLoad()
		self.tableView.emptyDataSetSource = self;
		self.tableView.emptyDataSetDelegate = self;
		self.tableView.clearExtraLines()
//		self.setBackTitle("")
		request()
		load()
	}

	override public func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
		tableView.deselectRowAtIndexPath(indexPath, animated: true)
	}

	public func reloadData() {
		self.tableView.reloadData()
	}

	override public func scrollViewDidScroll(scrollView: UIScrollView) {
//		self.view.endEditing(true)
	}

	override public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//		return super.tableView(tableView, cellForRowAtIndexPath: indexPath)
		let cell = cellForRow(atIndexPath: indexPath)
		if let qpCell = cell as? QPTableViewCell {
			qpCell.setup()
			qpCell.rootViewController = self
			qpCell.indexPath = indexPath
			return qpCell
		}
{'fraction_non_alphanumeric': 0.09890878567431449, 'fraction_numerical': 0.0030777839955232235, 'mean_word_length': 4.855036855036855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5709108', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2280, 'n_words': 470}