motion-assets-library 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -1
- data/lib/project/assets_library/data_sources/assets_data_source.rb +14 -0
- data/lib/project/assets_library/loader.rb +21 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9416c992c984c20be75b94e25de14015422b1b41
|
4
|
+
data.tar.gz: 4ba5af4191c8bf8783705561dd94b8e4eb4c4d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14d3e289b83faaead1cf6acec55d8e0f0ffdcd6cc610dfac1960cfd5fd0b249c67b9d0756450322ff2032a2f827be86151492f3964595db5b643596c9acafb8
|
7
|
+
data.tar.gz: 6e6c16e1e8a405334a09282ee77a4489671d8dea0f4e8e3e075b3dfacd084f055f7f7d19e0692ea9d93fa4a04297adacbd51e4c1610bbdb38831a3954b20517f
|
data/README.md
CHANGED
@@ -21,12 +21,27 @@ Implement the delegate method:
|
|
21
21
|
|
22
22
|
``` ruby
|
23
23
|
def did_load_assets(assets)
|
24
|
-
|
24
|
+
@assets = assets
|
25
25
|
|
26
26
|
colletion_view.reloadData
|
27
27
|
end
|
28
28
|
```
|
29
29
|
|
30
|
+
### Handling denied access to the Photo Library
|
31
|
+
|
32
|
+
Set a denied callback:
|
33
|
+
|
34
|
+
``` ruby
|
35
|
+
denied_callback = -> do
|
36
|
+
show_alert('Access to the Photo Library has been denied. Please update your privacy settings')
|
37
|
+
end
|
38
|
+
|
39
|
+
Motion::AssetsLibrary::Loader.new.tap do |loader|
|
40
|
+
loader.delegate = WeakRef.new(self)
|
41
|
+
loader.denied denied_callback
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
30
45
|
## Setup
|
31
46
|
|
32
47
|
Add this line to your application's Gemfile:
|
@@ -36,9 +36,23 @@ class Motion
|
|
36
36
|
def asset_loader
|
37
37
|
@_asset_loader ||= AssetsLibrary::Loader.new.tap do |loader|
|
38
38
|
loader.delegate = WeakRef.new(self)
|
39
|
+
loader.denied denied_callback
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
43
|
+
def denied_callback
|
44
|
+
-> { show_alert('Access to the Photo Library has been denied') }
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_alert(message)
|
48
|
+
UIAlertView.alloc.initWithTitle(
|
49
|
+
nil,
|
50
|
+
message: message,
|
51
|
+
delegate: nil,
|
52
|
+
cancelButtonTitle: 'Ok',
|
53
|
+
otherButtonTitles: nil).show
|
54
|
+
end
|
55
|
+
|
42
56
|
def did_load_assets(asset)
|
43
57
|
collection_view.reloadData
|
44
58
|
end
|
@@ -14,6 +14,22 @@ class Motion
|
|
14
14
|
failureBlock: album_failure_block)
|
15
15
|
end
|
16
16
|
|
17
|
+
def denied(callback)
|
18
|
+
@denied_callback = callback
|
19
|
+
end
|
20
|
+
|
21
|
+
def denied_callback
|
22
|
+
@denied_callback ||= -> { }
|
23
|
+
end
|
24
|
+
|
25
|
+
def access_denied?
|
26
|
+
[ALAuthorizationStatusDenied, ALAuthorizationStatusRestricted].include? authorization_status
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorization_status
|
30
|
+
ALAssetsLibrary.authorizationStatus
|
31
|
+
end
|
32
|
+
|
17
33
|
def reset_assets
|
18
34
|
@_assets = []
|
19
35
|
|
@@ -47,7 +63,11 @@ class Motion
|
|
47
63
|
end
|
48
64
|
|
49
65
|
def album_failure_block
|
50
|
-
lambda
|
66
|
+
lambda do |error|
|
67
|
+
p "Error: #{error.localizedDescription}"
|
68
|
+
|
69
|
+
denied_callback.call if access_denied?
|
70
|
+
end
|
51
71
|
end
|
52
72
|
|
53
73
|
def asset_block
|