     }
     
 }
+
+// MARK: - UITableViewDelegate
+extension DHNewsViewController: UITableViewDelegate, UITableViewDataSource {
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return (dataController?.newsDataSource?.count)! > 0 ? (dataController?.newsDataSource?.count)! : 0
+    }
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return kNewsTableViewCellHeight
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell: DHNewsTableViewCell = tableView.dequeueReusableCell(withIdentifier: kNewsCellReuseIdentifier, for: indexPath) as! DHNewsTableViewCell
+        if (dataController?.newsDataSource?.count)! > 0 {
+            let newsModel = dataController?.newsDataSource?[indexPath.row] as! DHNewsModel
+            let cellViewModel: DHNewsCellViewModel = DHNewsCellViewModel.init(newsModel: newsModel)
+            cell.bindDataWithViewModel(viewModel: cellViewModel)
+            if #available(iOS 9.0, *) {
+                if traitCollection.forceTouchCapability == .available {
+                    registerForPreviewing(with: self, sourceView: cell)
+                }
+            } else {
+                // Fallback on earlier versions
+            }
+        }
+        return cell
+    }
+    
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true)
+        let cell: DHNewsTableViewCell = tableView.cellForRow(at: indexPath) as! DHNewsTableViewCell
+        loadToDetailVCWithNewsModel(newsModel: cell.newsModel!)
+    }
+}
+
+// MARK: - UIViewControllerPreviewingDelegate
+extension DHNewsViewController: UIViewControllerPreviewingDelegate {
+    @available(iOS 9.0, *)
+    func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
+        let newsDetailVC: DHNewsDetailViewController = DHNewsDetailViewController()
+        if previewingContext.sourceRect.size.height == 80 {
+            let cell = previewingContext.sourceView as! DHNewsTableViewCell
+            newsDetailVC.newsModel = cell.newsModel
+        } else {
+            let banner = previewingContext.sourceView as! DHBanner
+            newsDetailVC.newsModel = banner.newsModel
+        }
+        return newsDetailVC
+    }
+    
+    @available(iOS 9.0, *)
+    func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
+        navigationController?.pushViewController(viewControllerToCommit, animated: true)
+    }
+}

        navigationController?.pushViewController(newsDetailVC, animated: true)
    }
    
    @available(iOS 9.0, *)
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        let newsDetailVC: DHNewsDetailViewController = DHNewsDetailViewController()
        if previewingContext.sourceRect.size.height == 80 {
            let cell = previewingContext.sourceView as! DHNewsTableViewCell
            newsDetailVC.newsModel = cell.newsModel
        } else {
            let banner = previewingContext.sourceView as! DHBanner
            newsDetailVC.newsModel = banner.newsModel
        }
        return newsDetailVC
    }
    
    @available(iOS 9.0, *)
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
        navigationController?.pushViewController(viewControllerToCommit, animated: true)
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return (dataController?.newsDataSource?.count)! > 0 ? (dataController?.newsDataSource?.count)! : 0
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return kNewsTableViewCellHeight
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell: DHNewsTableViewCell = tableView.dequeueReusableCell(withIdentifier: kNewsCellReuseIdentifier, for: indexPath) as! DHNewsTableViewCell
        if (dataController?.newsDataSource?.count)! > 0 {
            let newsModel = dataController?.newsDataSource?[indexPath.row] as! DHNewsModel
            let cellViewModel: DHNewsCellViewModel = DHNewsCellViewModel.init(newsModel: newsModel)
            cell.bindDataWithViewModel(viewModel: cellViewModel)
            if #available(iOS 9.0, *) {
                if traitCollection.forceTouchCapability == .available {
                    registerForPreviewing(with: self, sourceView: cell)
                }
            } else {
                // Fallback on earlier versions
            }
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let cell: DHNewsTableViewCell = tableView.cellForRow(at: indexPath) as! DHNewsTableViewCell
        loadToDetailVCWithNewsModel(newsModel: cell.newsModel!)
    }
    
    func refreshStateChange(control: UIRefreshControl) {
        control.endRefreshing()
    }

import MJRefresh
import SafariServices

class DHNewsViewController: UIViewController {

    var dataController: DHNewsDataController?
    var headerView: DHHeaderView?
    var tableView: UITableView?
    var loadingView: DHLoadingView?
    
// MARK: - Data Handler and View Renderer
    func handleNewsData() {
        DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
            self.tableView?.mj_header.endRefreshing()
