diff --git a/iOS.MediaDummy.xcodeproj/project.pbxproj b/iOS.MediaDummy.xcodeproj/project.pbxproj index fb39836..e84eb66 100644 --- a/iOS.MediaDummy.xcodeproj/project.pbxproj +++ b/iOS.MediaDummy.xcodeproj/project.pbxproj @@ -7,8 +7,11 @@ objects = { /* Begin PBXBuildFile section */ + AA26EDED1E509FAA00743918 /* VideoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA26EDEC1E509FAA00743918 /* VideoVC.swift */; }; + AA26EDEF1E50AA8500743918 /* PartyCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA26EDEE1E50AA8500743918 /* PartyCell.swift */; }; + AA26EDF11E50ABBF00743918 /* PartyRock.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA26EDF01E50ABBF00743918 /* PartyRock.swift */; }; AA5D11B01E501A6B003984E6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA5D11AF1E501A6B003984E6 /* AppDelegate.swift */; }; - AA5D11B21E501A6B003984E6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA5D11B11E501A6B003984E6 /* ViewController.swift */; }; + AA5D11B21E501A6B003984E6 /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA5D11B11E501A6B003984E6 /* MainVC.swift */; }; AA5D11B51E501A6B003984E6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA5D11B31E501A6B003984E6 /* Main.storyboard */; }; AA5D11B71E501A6B003984E6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AA5D11B61E501A6B003984E6 /* Assets.xcassets */; }; AA5D11BA1E501A6B003984E6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA5D11B81E501A6B003984E6 /* LaunchScreen.storyboard */; }; @@ -34,9 +37,12 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + AA26EDEC1E509FAA00743918 /* VideoVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoVC.swift; sourceTree = ""; }; + AA26EDEE1E50AA8500743918 /* PartyCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyCell.swift; sourceTree = ""; }; + AA26EDF01E50ABBF00743918 /* PartyRock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartyRock.swift; sourceTree = ""; }; AA5D11AC1E501A6B003984E6 /* iOS.MediaDummy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS.MediaDummy.app; sourceTree = BUILT_PRODUCTS_DIR; }; AA5D11AF1E501A6B003984E6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - AA5D11B11E501A6B003984E6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + AA5D11B11E501A6B003984E6 /* MainVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = ""; }; AA5D11B41E501A6B003984E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; AA5D11B61E501A6B003984E6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; AA5D11B91E501A6B003984E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -97,12 +103,15 @@ AA5D11AE1E501A6B003984E6 /* iOS.MediaDummy */ = { isa = PBXGroup; children = ( + AA5D11DD1E501AFA003984E6 /* Model */, + AA5D11DE1E501B05003984E6 /* View */, + AA5D11DF1E501B09003984E6 /* Controller */, + AA5D11E01E501B2E003984E6 /* Resources */, AA5D11AF1E501A6B003984E6 /* AppDelegate.swift */, - AA5D11B11E501A6B003984E6 /* ViewController.swift */, - AA5D11B31E501A6B003984E6 /* Main.storyboard */, AA5D11B61E501A6B003984E6 /* Assets.xcassets */, - AA5D11B81E501A6B003984E6 /* LaunchScreen.storyboard */, AA5D11BB1E501A6B003984E6 /* Info.plist */, + AA5D11B81E501A6B003984E6 /* LaunchScreen.storyboard */, + AA5D11B31E501A6B003984E6 /* Main.storyboard */, ); path = iOS.MediaDummy; sourceTree = ""; @@ -125,6 +134,38 @@ path = iOS.MediaDummyUITests; sourceTree = ""; }; + AA5D11DD1E501AFA003984E6 /* Model */ = { + isa = PBXGroup; + children = ( + AA26EDF01E50ABBF00743918 /* PartyRock.swift */, + ); + name = Model; + sourceTree = ""; + }; + AA5D11DE1E501B05003984E6 /* View */ = { + isa = PBXGroup; + children = ( + AA26EDEE1E50AA8500743918 /* PartyCell.swift */, + ); + name = View; + sourceTree = ""; + }; + AA5D11DF1E501B09003984E6 /* Controller */ = { + isa = PBXGroup; + children = ( + AA5D11B11E501A6B003984E6 /* MainVC.swift */, + AA26EDEC1E509FAA00743918 /* VideoVC.swift */, + ); + name = Controller; + sourceTree = ""; + }; + AA5D11E01E501B2E003984E6 /* Resources */ = { + isa = PBXGroup; + children = ( + ); + name = Resources; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -262,7 +303,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - AA5D11B21E501A6B003984E6 /* ViewController.swift in Sources */, + AA26EDF11E50ABBF00743918 /* PartyRock.swift in Sources */, + AA26EDED1E509FAA00743918 /* VideoVC.swift in Sources */, + AA5D11B21E501A6B003984E6 /* MainVC.swift in Sources */, + AA26EDEF1E50AA8500743918 /* PartyCell.swift in Sources */, AA5D11B01E501A6B003984E6 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -516,6 +560,7 @@ AA5D11D61E501A6B003984E6 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; AA5D11D71E501A6B003984E6 /* Build configuration list for PBXNativeTarget "iOS.MediaDummyTests" */ = { isa = XCConfigurationList; @@ -524,6 +569,7 @@ AA5D11D91E501A6B003984E6 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; AA5D11DA1E501A6B003984E6 /* Build configuration list for PBXNativeTarget "iOS.MediaDummyUITests" */ = { isa = XCConfigurationList; @@ -532,6 +578,7 @@ AA5D11DC1E501A6B003984E6 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/iOS.MediaDummy/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOS.MediaDummy/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..1d060ed 100644 --- a/iOS.MediaDummy/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/iOS.MediaDummy/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -59,6 +79,11 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { diff --git a/iOS.MediaDummy/Assets.xcassets/Contents.json b/iOS.MediaDummy/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/iOS.MediaDummy/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/Contents.json b/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/Contents.json new file mode 100644 index 0000000..0fd360d --- /dev/null +++ b/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "partybanner.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/partybanner.jpg b/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/partybanner.jpg new file mode 100644 index 0000000..e547c9f Binary files /dev/null and b/iOS.MediaDummy/Assets.xcassets/partybanner.imageset/partybanner.jpg differ diff --git a/iOS.MediaDummy/Base.lproj/LaunchScreen.storyboard b/iOS.MediaDummy/Base.lproj/LaunchScreen.storyboard index fdf3f97..4040406 100644 --- a/iOS.MediaDummy/Base.lproj/LaunchScreen.storyboard +++ b/iOS.MediaDummy/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,11 @@ - - + + + + + - + + @@ -21,7 +25,7 @@ - + diff --git a/iOS.MediaDummy/Base.lproj/Main.storyboard b/iOS.MediaDummy/Base.lproj/Main.storyboard index 273375f..8de7e84 100644 --- a/iOS.MediaDummy/Base.lproj/Main.storyboard +++ b/iOS.MediaDummy/Base.lproj/Main.storyboard @@ -1,14 +1,19 @@ - - + + + + + - + + + - + - + @@ -16,11 +21,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS.MediaDummy/Info.plist b/iOS.MediaDummy/Info.plist index d052473..483269c 100644 --- a/iOS.MediaDummy/Info.plist +++ b/iOS.MediaDummy/Info.plist @@ -41,5 +41,10 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/iOS.MediaDummy/PartyCell.swift b/iOS.MediaDummy/PartyCell.swift new file mode 100644 index 0000000..16a2669 --- /dev/null +++ b/iOS.MediaDummy/PartyCell.swift @@ -0,0 +1,51 @@ +// +// PartyCell.swift +// iOS.MediaDummy +// +// Created by Nguyễn Xuân Đạt on 2/12/17. +// Copyright © 2017 Nguyễn Xuân Đạt. All rights reserved. +// + +import UIKit + +class PartyCell: UITableViewCell { + + @IBOutlet weak var lblCellTitle: UILabel! + @IBOutlet weak var imgCellPreview: UIImageView! + + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + + func downloadImage(partyRock: PartyRock) { + let url = URL(string: partyRock.videoImage)! + DispatchQueue.global().async { + do { + let data = try Data(contentsOf: url) + + + DispatchQueue.global().sync { + self.imgCellPreview.image = UIImage(data: data) + } + } catch { + //handle the error + } + } + + + } + + func updateUI(partyRock: PartyRock) { + lblCellTitle.text = partyRock.videoTitle + downloadImage(partyRock: partyRock) + } + +} diff --git a/iOS.MediaDummy/PartyRock.swift b/iOS.MediaDummy/PartyRock.swift new file mode 100644 index 0000000..f42f812 --- /dev/null +++ b/iOS.MediaDummy/PartyRock.swift @@ -0,0 +1,39 @@ +// +// File.swift +// iOS.MediaDummy +// +// Created by Nguyễn Xuân Đạt on 2/12/17. +// Copyright © 2017 Nguyễn Xuân Đạt. All rights reserved. +// + +import Foundation + +class PartyRock { + private var _videoTitle: String! + private var _videoImage: String! + private var _videoURL: String! + + var videoTitle: String { + get { + return _videoTitle + } + } + + var videoImage: String { + get { + return _videoImage + } + } + + var videoURL: String { + get { + return _videoURL + } + } + + init(videoImage: String, videoURL: String, videoTitle: String) { + _videoTitle = videoTitle + _videoImage = videoImage + _videoURL = videoURL + } +} diff --git a/iOS.MediaDummy/ViewController.swift b/iOS.MediaDummy/ViewController.swift deleted file mode 100644 index 067b2a8..0000000 --- a/iOS.MediaDummy/ViewController.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ViewController.swift -// iOS.MediaDummy -// -// Created by Nguyễn Xuân Đạt on 2/12/17. -// Copyright © 2017 Nguyễn Xuân Đạt. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} -