@@ -79,21 +79,26 @@ class HistoryViewController: VideosViewController {
79
79
return nil
80
80
}
81
81
82
- override func saveToHistory( video: Video , atIndex index: Int ) {
83
- super. saveToHistory ( video, atIndex: index)
84
- // Reorder current displayed contents
85
- var reordered = self . videos
86
- reordered. removeAtIndex ( index)
87
- reordered. insert ( video, atIndex: 0 )
88
- self . videos = reordered
89
- }
90
-
91
82
// MARK: - UICollectionViewDelegate
92
83
93
84
override func collectionView( collectionView: UICollectionView , willDisplayCell cell: UICollectionViewCell , forItemAtIndexPath indexPath: NSIndexPath ) {
94
85
// History doesn't need pagination.
95
86
}
96
87
88
+ override func collectionView( collectionView: UICollectionView , didSelectItemAtIndexPath indexPath: NSIndexPath ) {
89
+ super. collectionView ( collectionView, didSelectItemAtIndexPath: indexPath)
90
+
91
+ let video = videos [ indexPath. row]
92
+ var reordered = videos
93
+ reordered. removeAtIndex ( indexPath. row)
94
+ reordered. insert ( video, atIndex: 0 )
95
+
96
+ // Reorder current displayed contents after the video player is presented.
97
+ dispatch_after ( dispatch_time ( DISPATCH_TIME_NOW, Int64 ( 0.5 * Double( NSEC_PER_SEC) ) ) , dispatch_get_main_queue ( ) ) {
98
+ self . videos = reordered
99
+ }
100
+ }
101
+
97
102
// MARK: - OverlayEnabled
98
103
99
104
private lazy var emptyStateOverlay : UIView = {
0 commit comments