Skip to content

Commit

Permalink
Merge pull request #48 from huiping192/hotfix/bug-fix
Browse files Browse the repository at this point in the history
Hotfix/bug fix
  • Loading branch information
huiping192 committed Sep 12, 2015
2 parents be2c0ca + 2bd43f0 commit 79a0984
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ extension CombinedBannerViewController: UICollectionViewDataSource {
return cell
}

cell.thunmbnailImageView.image = nil

let firstImageUrlString = video.highThumbnailUrl ?? video.thumbnailUrl
let secondImageUrlString = video.thumbnailUrl
loadVideoImage(video.videoId, imageUrlString: firstImageUrlString, secondImageUrlString: secondImageUrlString) {
Expand Down Expand Up @@ -117,10 +115,6 @@ extension CombinedBannerViewController: UICollectionViewDataSource {
}

extension CombinedBannerViewController: UICollectionViewDelegateFlowLayout {
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath){

}

func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
guard let video = video(indexPath) , imageLoadingOperation = imageLoadingOperationDictionary[video.videoId] else {
return
Expand All @@ -139,6 +133,7 @@ extension CombinedBannerViewController: UICollectionViewDelegateFlowLayout {
}
navigationController?.pushViewController(instantiateVideoDetailViewController(video.videoId), animated: true)
}

func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
guard let realVideoList = realVideoList else {
return
Expand All @@ -155,9 +150,9 @@ extension CombinedBannerViewController: UICollectionViewDelegateFlowLayout {
indexPath = NSIndexPath(forItem: Int(scrollView.contentOffset.x / scrollView.frame.width), inSection: 0)
}

let currentPage = indexPath.item - 1
let currentPage = indexPath.item
let video = realVideoList[currentPage]
videoImagePageControl.currentPage = currentPage
videoImagePageControl.currentPage = currentPage - 1
currentVideoTitleLabel.text = video.title
}

Expand Down
41 changes: 21 additions & 20 deletions LolTube/Module/Search/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class SearchViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

searchTypeSegmentedControl.setTitle(NSLocalizedString("Video", comment: ""), forSegmentAtIndex: 0)
searchTypeSegmentedControl.setTitle(NSLocalizedString("Channel", comment: ""), forSegmentAtIndex: 1)
searchTypeSegmentedControl.setTitle(NSLocalizedString("Playlist", comment: ""), forSegmentAtIndex: 2)


if traitCollection.horizontalSizeClass == .Regular && traitCollection.verticalSizeClass == .Regular {
navigationItem.title = NSLocalizedString("Search", comment: "")
let searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: 260, height: 44.0))
Expand Down Expand Up @@ -146,10 +151,17 @@ class SearchViewController: UIViewController {

@IBAction func suggestionWardTapped(suggestionWardButton:UIButton) {
searchBar.resignFirstResponder()

let searchText = suggestionWardButton.titleForState(.Normal)!

let searchText = suggestionWardButton.titleForState(.Normal)
searchBar.text = searchText
search(searchText)
}

private func search(searchText:String?){
guard let searchText = searchText else {
return
}

EventTracker.trackSearch(searchText)

searchSuggestionView.alpha = 0.0
searchContentView.alpha = 1.0
Expand All @@ -158,8 +170,11 @@ class SearchViewController: UIViewController {
configureSearchVideoListViewController(searchText)
}

var currentViewController = self.currentViewController as? Searchable
currentViewController!.searchText = searchText
let childVcs:[UIViewController?] = [searchVideoListViewController,searchChannelListViewController,searchPlaylistsViewController]
childVcs.map{$0 as? Searchable}.forEach{
(var searchable) -> Void in
searchable?.searchText = searchText
}
}
}

Expand All @@ -169,24 +184,10 @@ extension SearchViewController: UISearchBarDelegate{
return true
}
func searchBarSearchButtonClicked(searchBar: UISearchBar) {

searchBar.resignFirstResponder()
searchBar.showsCancelButton = false

guard let searchText = searchBar.text else {
return
}
EventTracker.trackSearch(searchText)

searchSuggestionView.alpha = 0.0
searchContentView.alpha = 1.0

if self.currentViewController == nil {
configureSearchVideoListViewController(searchText)
}

var currentViewController = self.currentViewController as? Searchable
currentViewController!.searchText = searchText
search(searchBar.text)
}

func searchBarCancelButtonClicked(searchBar: UISearchBar) {
Expand Down
25 changes: 12 additions & 13 deletions LolTube/Module/Top/TopViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ class TopViewController: UIViewController {
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

self.videosCollectionView.collectionViewLayout.invalidateLayout()
coordinator.animateAlongsideTransition({
[unowned self]_ in
self.videosCollectionView.reloadData()
self.videosCollectionView.reloadData()

coordinator.animateAlongsideTransition(nil, completion: {
_ in
self.layoutCollectionViewSize()

}, completion:nil)

})


}

Expand Down Expand Up @@ -107,24 +108,23 @@ class TopViewController: UIViewController {

let successBlock:(() -> Void) = {
[weak self] in

self?.configureTopView()
self?.videosCollectionView.reloadData()
self?.layoutCollectionViewSize()

self?.stopLoadingAnimation()

Async.main{
UIView.animateWithDuration(0.1) {
[weak self] in
self?.mainScrollView.alpha = 1.0
}
UIView.animateWithDuration(0.1) {
self?.mainScrollView.alpha = 1.0
}
}

let failureBlock:((NSError) -> Void) = {
[weak self]error in
self?.showError(error)
self?.stopLoadingAnimation()
self?.mainScrollView.alpha = 1.0
}

viewModel.update(successBlock, failure: failureBlock)
Expand Down Expand Up @@ -161,7 +161,6 @@ class TopViewController: UIViewController {
// MARK: view cconfiguration
private func layoutCollectionViewSize() {
Async.main{
[unowned self] in
self.collectionHeightConstraint.constant = self.videosCollectionView.contentSize.height
self.videosCollectionView.layoutIfNeeded()
}
Expand Down Expand Up @@ -361,7 +360,7 @@ extension TopViewController: UICollectionViewDelegateFlowLayout {
}

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize{
return section == collectionView.numberOfSections() - 1 ? CGSizeZero : CGSize(width: collectionView.frame.width, height: 12)
return section == collectionView.numberOfSections() - 1 ? CGSizeZero : CGSize(width: collectionView.frame.width, height: 8)
}

}
Expand Down
22 changes: 18 additions & 4 deletions LolTube/Service/ChannelService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class ChannelService: NSObject {
case Sp4zie = "UCmtQGojT9O2LVzVIVKDGEjw"
case MiDOrAFK = "UCnoSiiatisjE3RbM7DgdFmA"
case TheCarry = "UCTkeYBsxfJcsqi9kMbqLsfA"

// chinese channels

case LeagueofLegendsTW = "UCekadoaN7x7g7FlmKg13jWg"
case FåntäsyZ = "UCDgtlI_erc41UoqaeD816Kg"
case 英雄聯盟最新資訊 = "UC_iOMGX-tdJKvjPEvy8z7Fw"
case 云之彼岸LOL = "UCk2_iV0Q1EPbOiJ6aOOLbZw"
case 云之彼岸LOL = "UCk2_iV0Q1EPbOiJ6aOOLbZw"
case 最強聯盟BestLeague = "UCtMM6QD3n-jCjUfvflarboA"
case 最強聯盟爆笑集錦x直播頻 = "UCNooNOGnABoxyDwHuQAH92w"
case R大 = "UCcUrfKffo1wjIZ_GMKgPEqQ"
Expand All @@ -59,9 +59,15 @@ class ChannelService: NSObject {
case SKTT1FakerSoloQueue = "UCXJ2HbqZ7b-L6G9rWyPFfow"
case GarenaTaiwan = "UCCqnLewexMM7LwGzqpMpPrA"
case SivHD中譯版 = "UCgO0J4fCNTyU-PibDiNEFjQ"
case ahqESportsClub = "UChXDO6h-vhSyoQQMz9vQ6YQ"
case GG3B0 = "UClN448pkRACE6X0NNGzGQtg"
case Dinter = "UC0SkNQXPJ60hKEFubOz0fDA"
case 烏啦啦 = "UCjvjMvoMY1GgXc04VntTZhg"
case HongKongEsportsLtd = "UCMwKmIVf-ZT7eQTkof6IzPw"

// korean channels
case RangmalTV = "UCc_7XbnN1bTFMhquCKt3ngA"

static func englishChannels() -> [DefaultChannel]{
return [
.LeagueofLegends,
Expand Down Expand Up @@ -91,6 +97,7 @@ class ChannelService: NSObject {
static func chineseChannels() -> [DefaultChannel]{
return [
.LeagueofLegendsTW,
.LoLEsports,
.FåntäsyZ,
.英雄聯盟最新資訊,
.云之彼岸LOL,
Expand All @@ -105,7 +112,14 @@ class ChannelService: NSObject {
.英雄聯盟日常,
.SKTT1FakerSoloQueue,
.GarenaTaiwan,
.SivHD中譯版
.SivHD中譯版,
.ahqESportsClub,
.GG3B0,
.Dinter,
.烏啦啦,
.HongKongEsportsLtd,
.OPLOLReplay,
.EpicSkillshot
]
}

Expand Down
12 changes: 6 additions & 6 deletions LolTube/StoryBoard/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="zba-lz-CV3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="zba-lz-CV3">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
Expand Down Expand Up @@ -898,7 +898,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="q87-ZK-g0W">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q87-ZK-g0W">
<rect key="frame" x="0.0" y="64" width="600" height="487"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cWl-kr-h8k" userLabel="top banner View">
Expand Down Expand Up @@ -951,7 +951,7 @@
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="8" id="Led-wQ-uJf">
<size key="itemSize" width="150" height="130"/>
<size key="headerReferenceSize" width="320" height="44"/>
<size key="footerReferenceSize" width="0.0" height="12"/>
<size key="footerReferenceSize" width="0.0" height="8"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
Expand Down Expand Up @@ -1114,7 +1114,7 @@
</connections>
</collectionReusableView>
<collectionReusableView key="sectionFooterView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="footerView" id="gbb-PG-8nK" customClass="TopVideoCollectionFooterView" customModule="LolTube" customModuleProvider="target">
<rect key="frame" x="0.0" y="174" width="600" height="12"/>
<rect key="frame" x="0.0" y="174" width="600" height="8"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aDq-kO-wD4" userLabel="Top Space View">
Expand All @@ -1126,7 +1126,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vHb-x9-lRh" userLabel="Bot Space View">
<rect key="frame" x="0.0" y="11" width="600" height="1"/>
<rect key="frame" x="0.0" y="7" width="600" height="1"/>
<animations/>
<color key="backgroundColor" red="0.87493738619999994" green="0.87382725449999998" blue="0.89321848999999998" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
Expand Down
6 changes: 5 additions & 1 deletion LolTube/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@
"SearchChannelEmptyData" = "No channels found.";
"SearchPlaylistEmptyData" = "No playlist found.";

"Search" = "Search";
"Search" = "Search";

"Video" = "Video";
"Channel" = "Channel";
"Playlist" = "Playlist";
6 changes: 5 additions & 1 deletion LolTube/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@
"SearchChannelEmptyData" = "一致するチャンネルはありませんでした。";
"SearchPlaylistEmptyData" = "一致する再生リストはありませんでした。";

"Search" = "検索";
"Search" = "検索";

"Video" = "動画";
"Channel" = "チャンネル";
"Playlist" = "再生リスト";
6 changes: 5 additions & 1 deletion LolTube/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@
"SearchChannelEmptyData" = "没搜索到任何相关频道。";
"SearchPlaylistEmptyData" = "没搜索到任何相关播放列表。";

"Search" = "搜索";
"Search" = "搜索";

"Video" = "视频";
"Channel" = "频道";
"Playlist" = "播放列表";
5 changes: 4 additions & 1 deletion LolTube/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
"SearchChannelEmptyData" = "沒搜索到任何相關頻道。";
"SearchPlaylistEmptyData" = "沒搜索到任何相關播放清單。";

"Search" = "搜索";
"Search" = "搜索";
"Video" = "影片";
"Channel" = "頻道";
"Playlist" = "播放清單";

0 comments on commit 79a0984

Please sign in to comment.