motion-assets-library 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3633cf26f6c7037696ca2ec5601588fd14d94a80
4
- data.tar.gz: 00b355138600626ccba4df0bbd200d4771b26ba6
3
+ metadata.gz: 6011f54a1d4faf41397d337b39a3f2197609a154
4
+ data.tar.gz: d3ebbcaf62ef6ffbcffcdf606966814a0dcb101f
5
5
  SHA512:
6
- metadata.gz: d2415865906e9841d62c0ad0425ea562a5cca6c5efd7e82f20cb36becd6eb449a8f43598ba2088b68004b8d2aec7eabb39175deb90c9e6b875d51b833284ba1f
7
- data.tar.gz: 7adf72433abdbc6f84a0fc4c78561366b13f90f0b6c842c840b99842fe67ffb7b63ee1c57ea9674564d22e5f51abbf1ef363cdbc9421b6e1352b7c20bc05d33d
6
+ metadata.gz: 125b585a339e3f0b747661af8ad21259b6759105cc466ffc215a3ed2142d1a46a81689b15e8974df2849cd0e98ebfee0a25f1202d5cc65470bf61b2f83ae402c
7
+ data.tar.gz: 60d4152b1742b92f95eb1cda0bcacc0a6c718d30f254c807f1820cc72df49d0de7802e3d58e86962c4456fbba9a10cf6b297e3a46e689167a16f582a162a5073
data/README.md CHANGED
@@ -8,7 +8,7 @@ Instantiate a loader and set a delegate:
8
8
 
9
9
  ``` ruby
10
10
  Motion::AssetsLibrary::Loader.new.tap do |loader|
11
- loader.delegate = self
11
+ loader.delegate = WeakRef.new(self)
12
12
  end
13
13
  ```
14
14
 
@@ -0,0 +1,47 @@
1
+ class Motion
2
+ class AssetsLibrary
3
+ class AssetsDataSource
4
+ attr_accessor :collection_view
5
+
6
+ def initialize(collection_view)
7
+ self.collection_view = collection_view
8
+
9
+ register_cells
10
+
11
+ asset_loader.load_assets
12
+ end
13
+
14
+ def register_cells
15
+ collection_view.registerClass(
16
+ cell_class,
17
+ forCellWithReuseIdentifier: cell_class::IDENTIFIER)
18
+ end
19
+
20
+ def cell_class
21
+ AssetsLibrary::AssetCell
22
+ end
23
+
24
+ def collectionView(collection_view, numberOfItemsInSection: section)
25
+ asset_loader.assets.count
26
+ end
27
+
28
+ def collectionView(collection_view, cellForItemAtIndexPath: index_path)
29
+ collection_view.dequeueReusableCellWithReuseIdentifier(cell_class::IDENTIFIER, forIndexPath: index_path).tap do |cell|
30
+ asset = asset_loader.assets[index_path.row]
31
+
32
+ cell.reset_with_asset(asset)
33
+ end
34
+ end
35
+
36
+ def asset_loader
37
+ @_asset_loader ||= AssetsLibrary::Loader.new.tap do |loader|
38
+ loader.delegate = WeakRef.new(self)
39
+ end
40
+ end
41
+
42
+ def did_load_assets(asset)
43
+ collection_view.reloadData
44
+ end
45
+ end
46
+ end
47
+ end
@@ -28,7 +28,7 @@ class Motion
28
28
 
29
29
  def listen_to_asset_library
30
30
  self.observer = notification_center.addObserver(
31
- WeakRef.new(self),
31
+ self,
32
32
  selector: 'asset_library_did_change:',
33
33
  name: ALAssetsLibraryChangedNotification,
34
34
  object: nil)
@@ -0,0 +1,27 @@
1
+ class Motion
2
+ class AssetsLibrary
3
+ class AssetCell < UICollectionViewCell
4
+ IDENTIFIER = 'AssetCellIdentifier'
5
+
6
+ attr_accessor :image_view
7
+
8
+ def initWithFrame(frame)
9
+ super.tap do |cell|
10
+ cell.add_image_view
11
+ end
12
+ end
13
+
14
+ def reset_with_asset(asset)
15
+ image_view.image = UIImage.imageWithCGImage(asset.thumbnail)
16
+ end
17
+
18
+ protected
19
+
20
+ def add_image_view
21
+ self.image_view = UIImageView.alloc.initWithFrame([[0, 0], [105, 105]]).tap do |image_view|
22
+ contentView.addSubview(image_view)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ class Motion
2
+ class AssetsLibrary
3
+ class AssetsCollectionView < UICollectionView
4
+ def initWithFrame(frame, collectionViewLayout: layout)
5
+ super.tap do |collection_view|
6
+ collection_view.dataSource = _data_source
7
+ end
8
+ end
9
+
10
+ protected
11
+
12
+ def _data_source
13
+ @_data_source ||= AssetsLibrary::AssetsDataSource.new(WeakRef.new(self))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  class Motion
2
2
  class AssetsLibrary
3
- VERSION = '1.0'
3
+ VERSION = '1.0.1'
4
4
  DelegateMethodUnimplemented = Class.new(RuntimeError)
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-assets-library
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devon Blandin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -34,7 +34,10 @@ files:
34
34
  - README.md
35
35
  - lib/motion-assets-library.rb
36
36
  - lib/project/assets_library/asset_wrapper.rb
37
+ - lib/project/assets_library/data_sources/assets_data_source.rb
37
38
  - lib/project/assets_library/loader.rb
39
+ - lib/project/assets_library/views/asset_cell.rb
40
+ - lib/project/assets_library/views/assets_collection_view.rb
38
41
  - lib/project/assets_library.rb
39
42
  homepage: https://github.com/dblandin/motion-assets-library
40
43
  licenses: