droiuby 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3a0cc71bad460a486ed7042b545f4aebf250c98
|
4
|
+
data.tar.gz: 8155a874c47d1eb924f8e754ae27b8d6271be675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3574a9b9813cc441fb367de3742fed98d1a0f704e7b6661bdd807ef87aea704746974a8448c6fe1407847cd9a19aa6a1f8fa57337073323cde01612a095ed60
|
7
|
+
data.tar.gz: adb09e0b18867b63ad45d7c5a8e2067ad2ec6c9230d05a6551094dcb59bd717ef67fa5e8588cdf4aacd8958c8c0aa9660fb8c7cce0a5c9057df6327dbdca268c
|
data/lib/droiuby/bootstrap.rb
CHANGED
@@ -91,9 +91,21 @@ end
|
|
91
91
|
def set_content_view(view = nil)
|
92
92
|
if view.nil?
|
93
93
|
Java::com.droiuby.client.core.DroiubyLauncher.setPage(_current_activity, _execution_bundle, _current_page)
|
94
|
+
elsif view.kind_of? Integer
|
95
|
+
_current_activity.setContentView(view)
|
96
|
+
elsif view.kind_of? String
|
97
|
+
_current_activity.setContentView( V(view) )
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
101
|
+
def template(url)
|
102
|
+
async.perform {
|
103
|
+
|
104
|
+
}.done { |result|
|
105
|
+
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
97
109
|
def render(url, params = {})
|
98
110
|
http_method = Java::com.droiuby.client.core.utils.Utils::HTTP_GET
|
99
111
|
if params[:method] && (params[:method] == :post)
|
@@ -218,6 +230,9 @@ def Android
|
|
218
230
|
end
|
219
231
|
|
220
232
|
def V(selectors = nil)
|
233
|
+
|
234
|
+
return _R(selectors) if _activity_builder.nil?
|
235
|
+
|
221
236
|
if selectors.nil? # Get root node if nil
|
222
237
|
view = _activity_builder.getRootView
|
223
238
|
elsif (selectors == 'top')
|
@@ -0,0 +1,108 @@
|
|
1
|
+
class Animator
|
2
|
+
|
3
|
+
def initialize(target)
|
4
|
+
@animator_set = Java::android.animation.AnimatorSet.new
|
5
|
+
@mode = :together
|
6
|
+
@animators = []
|
7
|
+
@target = target
|
8
|
+
@done = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def animator_set
|
12
|
+
@animator_set
|
13
|
+
end
|
14
|
+
|
15
|
+
def animators
|
16
|
+
@animators
|
17
|
+
end
|
18
|
+
|
19
|
+
def native
|
20
|
+
@animator_set
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(name, *args, &block)
|
24
|
+
anim = Java::android.animation.ObjectAnimator.ofFloat(@target.native, name.to_s.camelize(:lower), args[0], args[1]);
|
25
|
+
if args[2] && args[2].kind_of?(Hash)
|
26
|
+
duration = args[2][:duration]
|
27
|
+
anim.setDuration(duration)
|
28
|
+
end
|
29
|
+
@animators << anim
|
30
|
+
anim
|
31
|
+
end
|
32
|
+
|
33
|
+
def sequentially
|
34
|
+
@mode = :one_after_the_other
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def together
|
39
|
+
@mode = :together
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def before(animation)
|
44
|
+
Java::android.animation.AnimatorSet.new.tap { |s|
|
45
|
+
s.play(to_animator(animation)).before(self.animator_set)
|
46
|
+
} if @done
|
47
|
+
end
|
48
|
+
|
49
|
+
def after(animation)
|
50
|
+
s = Java::android.animation.AnimatorSet.new.tap { |s|
|
51
|
+
s.play(to_animator(animation)).after(self.animator_set)
|
52
|
+
} if @done
|
53
|
+
end
|
54
|
+
|
55
|
+
def wait(milliseconds)
|
56
|
+
Java::android.animation.AnimatorSet.new.tap { |s|
|
57
|
+
s.play(self.animator_set).after(milliseconds.to_i)
|
58
|
+
} if @done
|
59
|
+
end
|
60
|
+
|
61
|
+
def with(animation)
|
62
|
+
Java::android.animation.AnimatorSet.new.tap { |s|
|
63
|
+
s.play(to_animator(animation)).with(self.animator_set)
|
64
|
+
} if @done
|
65
|
+
end
|
66
|
+
|
67
|
+
def together
|
68
|
+
@mode = :together
|
69
|
+
end
|
70
|
+
|
71
|
+
def one_after_the_other
|
72
|
+
@mode = :one_after_the_other
|
73
|
+
end
|
74
|
+
|
75
|
+
def done
|
76
|
+
@done = true
|
77
|
+
case @mode
|
78
|
+
when :together
|
79
|
+
@animator_set.playTogether(*@animators)
|
80
|
+
when :one_after_the_other
|
81
|
+
@animator_set.playSequentially(*@animators)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def start
|
86
|
+
@animator_set.start
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def on(event, &block)
|
91
|
+
@animation_listener = @animation_listener || AnimatorListenerWrapper.new
|
92
|
+
if [:cancel, :start, :end, :repeat ].include?(event)
|
93
|
+
@animation_listener.set_block(event, &Proc.new { |v| block.call(wrap_native_view(v))})
|
94
|
+
self.native.addListener(@animation_listener.to_native)
|
95
|
+
end
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
protected
|
100
|
+
|
101
|
+
def to_animator(animation)
|
102
|
+
animator = animation
|
103
|
+
if animation.kind_of? Animator
|
104
|
+
animator = animation.animator_set
|
105
|
+
end
|
106
|
+
animator
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class AnimatorListenerWrapper
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@native = Java::com.droiuby.wrappers::AnimatorListenerRubyWrapper.new(_execution_bundle, self)
|
5
|
+
@blocks = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_block(sym, &block)
|
9
|
+
@blocks[sym.to_sym] = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def onAnimationStart
|
13
|
+
@block[:start].call if @block.has_key? :start
|
14
|
+
end
|
15
|
+
|
16
|
+
def onAnimationEnd
|
17
|
+
@block[:end].call if @block.has_key? :end
|
18
|
+
end
|
19
|
+
|
20
|
+
def onAnimationCancel
|
21
|
+
@block[:cancel].call if @block.has_key? :cancel
|
22
|
+
end
|
23
|
+
|
24
|
+
def onAnimationRepeat
|
25
|
+
@block[:repeat].call if @block.has_key? :repeat
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_native
|
29
|
+
@native
|
30
|
+
end
|
31
|
+
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
class ListViewWrapper < ViewGroupWrapper
|
2
|
-
|
3
|
-
def initialize(
|
4
|
-
|
2
|
+
|
3
|
+
def initialize(view = nil)
|
4
|
+
if view.nil?
|
5
|
+
@view = Java::android.widget.ListView.new(_current_activity)
|
6
|
+
else
|
7
|
+
super(view)
|
8
|
+
end
|
5
9
|
end
|
6
|
-
|
10
|
+
|
7
11
|
def set_adapter(adapter)
|
8
12
|
@native.setAdapter(adapter.native)
|
9
13
|
end
|
10
|
-
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droiuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Emmanuel Dayo
|
@@ -145,7 +145,8 @@ files:
|
|
145
145
|
- lib/droiuby/support/utils.rb
|
146
146
|
- lib/droiuby/wrappers/accelerometer.rb
|
147
147
|
- lib/droiuby/wrappers/activity.rb
|
148
|
-
- lib/droiuby/wrappers/
|
148
|
+
- lib/droiuby/wrappers/animator.rb
|
149
|
+
- lib/droiuby/wrappers/animator_listener_wrapper.rb
|
149
150
|
- lib/droiuby/wrappers/async_wrapper.rb
|
150
151
|
- lib/droiuby/wrappers/button_wrapper.rb
|
151
152
|
- lib/droiuby/wrappers/canvas_wrapper.rb
|
@@ -1,141 +0,0 @@
|
|
1
|
-
class AnimatorListenerWrapper
|
2
|
-
|
3
|
-
def initialize
|
4
|
-
@native = Java::com.droiuby.wrappers::AnimatorListenerRubyWrapper.new(_execution_bundle, self)
|
5
|
-
@blocks = {}
|
6
|
-
end
|
7
|
-
|
8
|
-
def set_block(sym, &block)
|
9
|
-
@blocks[sym.to_sym] = block
|
10
|
-
end
|
11
|
-
|
12
|
-
def onAnimationStart
|
13
|
-
@block[:start].call if @block.has_key? :start
|
14
|
-
end
|
15
|
-
|
16
|
-
def onAnimationEnd
|
17
|
-
@block[:end].call if @block.has_key? :end
|
18
|
-
end
|
19
|
-
|
20
|
-
def onAnimationCancel
|
21
|
-
@block[:cancel].call if @block.has_key? :cancel
|
22
|
-
end
|
23
|
-
|
24
|
-
def onAnimationRepeat
|
25
|
-
@block[:repeat].call if @block.has_key? :repeat
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_native
|
29
|
-
@native
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
#Wrap the android animation API
|
35
|
-
class Animator
|
36
|
-
def initialize(target)
|
37
|
-
@animator_set = Java::android.animation.AnimatorSet.new
|
38
|
-
@mode = :together
|
39
|
-
@animators = []
|
40
|
-
@target = target
|
41
|
-
@done = false
|
42
|
-
end
|
43
|
-
|
44
|
-
def animator_set
|
45
|
-
@animator_set
|
46
|
-
end
|
47
|
-
|
48
|
-
def animators
|
49
|
-
@animators
|
50
|
-
end
|
51
|
-
|
52
|
-
def native
|
53
|
-
@animator_set
|
54
|
-
end
|
55
|
-
|
56
|
-
def method_missing(name, *args, &block)
|
57
|
-
anim = Java::android.animation.ObjectAnimator.ofFloat(@target.native, name.to_s.camelize(:lower), args[0], args[1]);
|
58
|
-
if args[2] && args[2].kind_of?(Hash)
|
59
|
-
duration = args[2][:duration]
|
60
|
-
anim.setDuration(duration)
|
61
|
-
end
|
62
|
-
@animators << anim
|
63
|
-
anim
|
64
|
-
end
|
65
|
-
|
66
|
-
def sequentially
|
67
|
-
@mode = :one_after_the_other
|
68
|
-
self
|
69
|
-
end
|
70
|
-
|
71
|
-
def together
|
72
|
-
@mode = :together
|
73
|
-
self
|
74
|
-
end
|
75
|
-
|
76
|
-
def before(animation)
|
77
|
-
Java::android.animation.AnimatorSet.new.tap { |s|
|
78
|
-
s.play(to_animator(animation)).before(self.animator_set)
|
79
|
-
} if @done
|
80
|
-
end
|
81
|
-
|
82
|
-
def after(animation)
|
83
|
-
s = Java::android.animation.AnimatorSet.new.tap { |s|
|
84
|
-
s.play(to_animator(animation)).after(self.animator_set)
|
85
|
-
} if @done
|
86
|
-
end
|
87
|
-
|
88
|
-
def wait(milliseconds)
|
89
|
-
Java::android.animation.AnimatorSet.new.tap { |s|
|
90
|
-
s.play(self.animator_set).after(milliseconds.to_i)
|
91
|
-
} if @done
|
92
|
-
end
|
93
|
-
|
94
|
-
def with(animation)
|
95
|
-
Java::android.animation.AnimatorSet.new.tap { |s|
|
96
|
-
s.play(to_animator(animation)).with(self.animator_set)
|
97
|
-
} if @done
|
98
|
-
end
|
99
|
-
|
100
|
-
def together
|
101
|
-
@mode = :together
|
102
|
-
end
|
103
|
-
|
104
|
-
def one_after_the_other
|
105
|
-
@mode = :one_after_the_other
|
106
|
-
end
|
107
|
-
|
108
|
-
def done
|
109
|
-
@done = true
|
110
|
-
case @mode
|
111
|
-
when :together
|
112
|
-
@animator_set.playTogether(*@animators)
|
113
|
-
when :one_after_the_other
|
114
|
-
@animator_set.playSequentially(*@animators)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def start
|
119
|
-
@animator_set.start
|
120
|
-
self
|
121
|
-
end
|
122
|
-
|
123
|
-
def on(event, &block)
|
124
|
-
@animation_listener = @animation_listener || AnimatorListenerWrapper.new
|
125
|
-
if [:cancel, :start, :end, :repeat ].include?(event)
|
126
|
-
@animation_listener.set_block(event, Proc.new { |v| block.call(wrap_native_view(v))})
|
127
|
-
self.native.addListener(@animation_listener.to_native)
|
128
|
-
end
|
129
|
-
self
|
130
|
-
end
|
131
|
-
|
132
|
-
protected
|
133
|
-
|
134
|
-
def to_animator(animation)
|
135
|
-
animator = animation
|
136
|
-
if animation.kind_of? Animator
|
137
|
-
animator = animation.animator_set
|
138
|
-
end
|
139
|
-
animator
|
140
|
-
end
|
141
|
-
end
|