droiuby 0.2.5 → 0.2.6

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: e29da43679c8c5f4829be9fb804d930d4190b4e1
4
- data.tar.gz: dce9cf4cd19f1076ab129b4c49657f84cdac18da
3
+ metadata.gz: d80b4b3f1f57823a9abc631a671014c10bd0c348
4
+ data.tar.gz: 90e65885732363c9438f60afd4ab7df3e52bef63
5
5
  SHA512:
6
- metadata.gz: faf1ae4a98f43b89e89e170b92047cabe49f17549b9f26feb3f69f353af097e4114397a25f1fd5a736d5afea8d7a17ea1f3e2afa3bbd85cf47d2b14cd510b650
7
- data.tar.gz: f0dd17e82be52f37edb4c945553c37f6ef4c75f549a9adc8ecbf0c5dd6a8a93907cdb24eba102f47a43e483c0db2c533abd4cf60968ce3ef09034b7f4601aba8
6
+ metadata.gz: 16365865f6071727185220870931377b1bfbfb3dfd845525527e0c72ae285c5c3bdf57be21975a2cfbcf1632e374a2cd00b460267b6973a2d4508023ea2c002c
7
+ data.tar.gz: 26e4a4f39e90ffd7bf3fab19fa22df52cb176c92b136f69a8186aab4313defe71bdffe311dae0438bcd6eb0d1850f7204dcaecfc3862de1b7bd5d3f0e20e0aa3
@@ -6,21 +6,21 @@ class Rect
6
6
  else
7
7
  @native = rect
8
8
  end
9
-
9
+
10
10
  end
11
-
11
+
12
12
  def native
13
13
  @native
14
14
  end
15
-
15
+
16
16
  def height
17
17
  @native.height
18
18
  end
19
-
19
+
20
20
  def width
21
21
  @native.width
22
22
  end
23
-
23
+
24
24
  def set(left, top, right, bottom)
25
25
  @native.set(left, top, right, bottom)
26
26
  end
@@ -34,103 +34,103 @@ class Paint
34
34
  def initialize
35
35
  @native = Java::android.graphics.Paint.new
36
36
  end
37
-
37
+
38
38
  def native
39
39
  @native
40
40
  end
41
-
41
+
42
42
  def alpha=(value)
43
43
  @native.setAlpha(Java::android.graphics.Color.parseColor(value))
44
44
  end
45
-
45
+
46
46
  def alpha
47
47
  @native.getAlpha
48
48
  end
49
-
49
+
50
50
  def color=(value)
51
51
  if (value.kind_of String)
52
52
  value = value.to_color
53
53
  end
54
54
  @native.setColor(value)
55
55
  end
56
-
56
+
57
57
  def color
58
58
  @native.getColor
59
59
  end
60
-
60
+
61
61
  def stroke_width=(width)
62
62
  @native.setStrokeWidth(width)
63
63
  end
64
-
64
+
65
65
  def stroke_width
66
66
  @native.getStrokeWidth
67
67
  end
68
68
  end
69
69
 
70
- class Canvas
71
-
70
+ class CanvasWrapper
71
+
72
72
  include JavaMethodHelper
73
73
  include Droiuby::ViewHelper
74
-
74
+
75
75
  java_fast_reader Java::android.graphics.Canvas, :width
76
76
  java_fast_reader Java::android.graphics.Canvas, :height
77
-
77
+
78
78
  java_native_method Java::android.graphics.Canvas, :drawColor, [Java::int]
79
79
  java_native_method Java::android.graphics.Canvas, :drawText, [Java::java.lang.String, Java::float, Java::float, Java::android.graphics.Paint]
80
80
  java_native_method Java::android.graphics.Canvas, :drawBitmap, [Java::android.graphics.Bitmap, Java::float, Java::float, Java::android.graphics.Paint]
81
81
  java_native_method Java::android.graphics.Canvas, :drawCircle, [Java::float, Java::float, Java::float, Java::android.graphics.Paint]
82
82
  java_native_method Java::android.graphics.Canvas, :drawLine, [Java::float, Java::float, Java::float, Java::float, Java::android.graphics.Paint]
83
83
  java_native_method Java::android.graphics.Canvas, :drawRoundRect, [Java::android.graphics.RectF, Java::float, Java::float, Java::android.graphics.Paint]
84
-
84
+
85
85
  def initialize(native)
86
86
  @native = native
87
87
  @paint = make_paint
88
88
  end
89
-
89
+
90
90
  def native
91
91
  @native
92
92
  end
93
-
93
+
94
94
  def make_paint
95
95
  Paint.new
96
96
  end
97
-
97
+
98
98
  def make_rect(left, top, right, bottom)
99
99
  Java::android.graphics.RectF.new(left, top, right, bottom)
100
100
  end
101
-
101
+
102
102
  def paint
103
103
  @paint
104
104
  end
105
-
105
+
106
106
  def paint=(p)
107
107
  @paint = p
108
108
  end
109
-
109
+
110
110
  def draw_color(value)
111
111
  if (value.kind_of? String)
112
112
  value = value.to_color
113
113
  end
114
-
114
+
115
115
  java_drawColor(value)
116
116
  end
117
-
117
+
118
118
  def text(msg, x, y, paint = nil)
119
119
  paint = @paint if paint.nil?
120
-
120
+
121
121
  java_drawText(msg, x, y, paint.native);
122
122
  end
123
-
123
+
124
124
  def circle(x, y, size, paint = nil)
125
125
  paint = @paint if paint.nil?
126
126
  java_drawCircle(x, y, size, paint.native);
127
127
  end
128
-
128
+
129
129
  def line(x, y, x1, y1, paint = nil)
130
130
  paint = @paint if paint.nil?
131
131
  java_drawLine(x, y, x1, y1, paint.native);
132
132
  end
133
-
133
+
134
134
  def bitmap(bitmap, x, y, paint = nil, options = {})
135
135
  paint = @paint if paint.nil?
136
136
  if bitmap.class == BitmapDrawableWrapper
@@ -139,9 +139,9 @@ class Canvas
139
139
  # native.drawBitmap(bitmap, x.to_f, y.to_f, paint.native)
140
140
  java_drawBitmap(bitmap, x.to_f, y.to_f, paint.native)
141
141
  end
142
-
142
+
143
143
  def round_rect(rect, x, y, paint = nil)
144
144
  paint = @paint if paint.nil?
145
- java_drawRoundRect(rect, x, y, paint.native)
146
- end
147
- end
145
+ java_drawRoundRect(rect, x, y, paint.native)
146
+ end
147
+ end
@@ -7,14 +7,14 @@ module Droiuby
7
7
  Droiuby::Wrappers::ProxyBuilder::InvocationHandler.new("#{package}$#{klass}", self).to_native
8
8
  end
9
9
  end
10
-
10
+
11
11
  class AutoWrap < AutoWrapBase
12
-
12
+
13
13
  def initialize(execution_bundle, auto_wrap_block)
14
14
  @execution_bundle = execution_bundle
15
15
  @auto_wrap_block = auto_wrap_block
16
16
  end
17
-
17
+
18
18
  def method_missing(meth, *args, &block)
19
19
  if meth.to_s =~ /^on(.+)$/
20
20
  wrapped_args = args.collect { |a|
@@ -27,21 +27,21 @@ module Droiuby
27
27
  # lookup.
28
28
  end
29
29
  end
30
-
31
-
30
+
31
+
32
32
  end
33
-
33
+
34
34
  class AutoWrapMultiple < AutoWrapBase
35
-
35
+
36
36
  def initialize(execution_bundle, impl_blocks = {})
37
37
  @execution_bundle = execution_bundle
38
38
  @auto_wrap_blocks = impl_blocks
39
39
  end
40
-
40
+
41
41
  def impl(method, &block)
42
42
  @auto_wrap_block["on#{meth.to_s.camelize}"] = block
43
43
  end
44
-
44
+
45
45
  def method_missing(meth, *args, &block)
46
46
  if meth.to_s =~ /^on(.+)$/
47
47
  wrapped_args = args.collect { |a|
@@ -55,18 +55,31 @@ module Droiuby
55
55
  end
56
56
  end
57
57
  end
58
-
58
+
59
59
  def on(event,&block)
60
60
  listener_ref = event.to_s.camelize
61
- self.native.send(:"setOn#{listener_ref}Listener",_listener("On#{listener_ref}Listener", &block))
61
+ case event.to_sym
62
+ when :touch
63
+ #convert return to boolean
64
+ wrapped_block = Proc.new { |*args| !!block.call(*args) }
65
+ else
66
+ wrapped_block = block
67
+ end
68
+ self.native.send(:"setOn#{listener_ref}Listener",_listener("On#{listener_ref}Listener", &wrapped_block))
62
69
  end
63
-
70
+
64
71
  protected
65
-
72
+
66
73
  def _listener(java_class, package = 'android.view.View' , &block)
67
- Droiuby::Wrappers::Listeners::AutoWrap.new(_execution_bundle, block).to_native(java_class, package)
74
+ puts "using dexmaker auto wrapper"
75
+ Proc.new { |*args|
76
+ wrapped_args = args.collect { |a|
77
+ wrap_native_view(a)
78
+ }
79
+ block.call(*wrapped_args)
80
+ }
68
81
  end
69
-
82
+
70
83
  end
71
84
  end
72
85
  end
@@ -1,36 +1,39 @@
1
1
  class SurfaceHolderWrapper
2
-
2
+
3
3
  include JavaMethodHelper
4
-
4
+
5
5
  java_native_method Java::com.droiuby.client.core.wrappers.SurfaceViewHolderWrapper, :lockCanvas, [], "java_lockCanvasVoid"
6
6
  java_native_method Java::com.droiuby.client.core.wrappers.SurfaceViewHolderWrapper, :lockCanvas, [Java::android.graphics.Rect], "java_lockCanvas"
7
7
  java_native_method Java::com.droiuby.client.core.wrappers.SurfaceViewHolderWrapper, :unlockCanvasAndPost, [Java::android.graphics.Canvas]
8
-
8
+
9
9
  def initialize(surface)
10
10
  @native = surface
11
11
  end
12
-
12
+
13
13
  def native
14
14
  @native
15
15
  end
16
-
16
+
17
17
  def lock(rect = nil, &block)
18
18
  if rect.nil?
19
19
  # canvas = Canvas.new(native.lockCanvas)
20
- canvas = Canvas.new(java_lockCanvasVoid)
20
+
21
+
22
+ canvas_lock = java_lockCanvasVoid
23
+ canvas = CanvasWrapper.new(canvas_lock)
21
24
  else
22
25
  # canvas = Canvas.new(native.lockCanvas(rect))
23
- canvas = Canvas.new(java_lockCanvas(rect.native))
26
+ canvas = CanvasWrapper.new(java_lockCanvas(rect.native))
24
27
  end
25
28
  block.call(canvas)
26
29
  # native.unlockCanvasAndPost(canvas.native)
27
30
  java_unlockCanvasAndPost(canvas.native)
28
31
  end
29
-
32
+
30
33
  end
31
34
 
32
35
  class SurfaceViewWrapper < ViewWrapper
33
-
36
+
34
37
  def initialize(view = nil)
35
38
  unless view.nil?
36
39
  @view = view
@@ -40,7 +43,7 @@ class SurfaceViewWrapper < ViewWrapper
40
43
  @builder = Java::com.droiuby.client.core.builder.ViewBuilder.new
41
44
  @builder.setContext(_current_activity)
42
45
  end
43
-
46
+
44
47
  def on(event, &block)
45
48
  case(event.to_sym)
46
49
  when :surface_created
@@ -53,5 +56,5 @@ class SurfaceViewWrapper < ViewWrapper
53
56
  super(event.to_sym, &block)
54
57
  end
55
58
  end
56
-
57
- end
59
+
60
+ 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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo
@@ -132,7 +132,7 @@ files:
132
132
  - lib/droiuby/wrappers/animation_listener_wrapper.rb
133
133
  - lib/droiuby/wrappers/async_wrapper.rb
134
134
  - lib/droiuby/wrappers/button_wrapper.rb
135
- - lib/droiuby/wrappers/canvas.rb
135
+ - lib/droiuby/wrappers/canvas_wrapper.rb
136
136
  - lib/droiuby/wrappers/collection/view_array.rb
137
137
  - lib/droiuby/wrappers/compound_button_wrapper.rb
138
138
  - lib/droiuby/wrappers/edit_text_wrapper.rb