Top Level Namespace
Defined Under Namespace
Modules: Droiuby, JavaExtends, JavaMethodHelper, MissingHandler, MockObjects
Classes: Accelerometer, Activity, Animator, AnimatorListenerWrapper, Array, AssetHandler, AsyncWrapper, BigDecimal, BitmapDrawableWrapper, ButtonWrapper, CanvasWrapper, CompoundButtonWrapper, DroiubyApp, DroiubyFramework, EditTextWrapper, FalseClass, Fixnum, Hash, ImageButtonWrapper, IntentWrapper, Java, LinearLayoutWrapper, ListAdapterWrapper, ListViewWrapper, MockEnvironment, MockTemplateParser, MotionEventsWrapper, NilClass, Numeric, Object, Paint, PayloadWrapper, Preferences, Project, Rect, RunnableWrapper, String, SurfaceHolderWrapper, SurfaceViewWrapper, Symbol, TextViewWrapper, Thread, ThreadPoolWrapper, TrueClass, ViewArray, ViewGroupWrapper, ViewWrapper, WebViewWrapper
Instance Method Summary
collapse
-
#_active_bundles ⇒ Object
-
#_activity_builder ⇒ Object
-
#_add_error(error_message) ⇒ Object
-
#_container_payload ⇒ Object
-
#_current_activity ⇒ Object
-
#_current_app ⇒ Object
-
#_current_page ⇒ Object
-
#_current_page_url ⇒ Object
-
#_errors ⇒ Object
-
#_execution_bundle ⇒ Object
-
#_gc ⇒ Object
-
#_namespace ⇒ Object
-
#_nano_time ⇒ Object
-
#_P ⇒ Object
-
#_pool(&block) ⇒ Object
-
#_R(attr) ⇒ Object
-
#_rect(left = 0, top = 0, right = 0, bottom = 0) ⇒ Object
-
#_runtime ⇒ Object
-
#_scripting_container ⇒ Object
-
#_sleep(delay = 0) ⇒ Object
-
#_switch(bundle) ⇒ Object
-
#_thread(&block) ⇒ Object
-
#_time ⇒ Object
-
#after_partial_setup(view_group) ⇒ Object
-
#after_view_setup ⇒ Object
-
#Android ⇒ Object
-
#async ⇒ Object
-
#async_get(url, params = {}, options = {}, &block) ⇒ Object
-
#canvas(&block) ⇒ Object
-
#http_get(url, params = {}, options = {}) ⇒ Object
-
#launch(url) ⇒ Object
-
#log_debug(message = '', tag = 'ruby') ⇒ Object
-
#on_ui_thread(&block) ⇒ Object
-
#render(url, params = {}) ⇒ Object
-
#reverse_resolve(view_id) ⇒ Object
-
#set_content_view(view = nil) ⇒ Object
-
#set_mock_environment(environment = nil) ⇒ Object
-
#start_droiuby_plugins ⇒ Object
-
#surface(&block) ⇒ Object
-
#template(url) ⇒ Object
-
#toast(text = '', duration = :short) ⇒ Object
-
#V(selector = nil) ⇒ Object
-
#wrap_native(object) ⇒ Object
-
#wrap_native_view(view) ⇒ Object
#java_native_method, #java_native_method_on, #java_native_singleton, #java_native_singleton_on
Instance Method Details
#_active_bundles ⇒ Object
55
56
57
|
# File 'lib/droiuby/bootstrap.rb', line 55
def _active_bundles
Java::com.droiuby.client.core.ExecutionBundleFactory.listActiveBundles.collect { |i| i.to_s }
end
|
#_activity_builder ⇒ Object
43
44
45
|
# File 'lib/droiuby/bootstrap.rb', line 43
def _activity_builder
PayloadWrapper.java_getActivityBuilder
end
|
#_add_error(error_message) ⇒ Object
63
64
65
66
|
# File 'lib/droiuby/bootstrap.rb', line 63
def _add_error(error_message)
_execution_bundle.addError(error_message)
error_message
end
|
#_container_payload ⇒ Object
15
16
17
|
# File 'lib/droiuby/bootstrap.rb', line 15
def _container_payload
$container_payload
end
|
#_current_activity ⇒ Object
39
40
41
|
# File 'lib/droiuby/bootstrap.rb', line 39
def _current_activity
PayloadWrapper.java_getCurrentActivity
end
|
#_current_app ⇒ Object
31
32
33
|
# File 'lib/droiuby/bootstrap.rb', line 31
def _current_app
PayloadWrapper.java_getActiveApp
end
|
#_current_page ⇒ Object
19
20
21
|
# File 'lib/droiuby/bootstrap.rb', line 19
def _current_page
PayloadWrapper.java_getCurrentPage
end
|
#_current_page_url ⇒ Object
47
48
49
|
# File 'lib/droiuby/bootstrap.rb', line 47
def _current_page_url
_execution_bundle.getCurrentUrl
end
|
59
60
61
|
# File 'lib/droiuby/bootstrap.rb', line 59
def _errors
_execution_bundle.getScriptErrors.collect { |e| e.to_s }
end
|
#_execution_bundle ⇒ Object
35
36
37
|
# File 'lib/droiuby/bootstrap.rb', line 35
def _execution_bundle
PayloadWrapper.java_getExecutionBundle
end
|
#_namespace ⇒ Object
83
84
85
|
# File 'lib/droiuby/bootstrap.rb', line 83
def _namespace
_execution_bundle.getName
end
|
#_nano_time ⇒ Object
153
154
155
|
# File 'lib/droiuby/bootstrap.rb', line 153
def _nano_time
Droiuby::SystemWrapper.java_nanoTime
end
|
#_pool(&block) ⇒ Object
169
170
171
172
173
|
# File 'lib/droiuby/bootstrap.rb', line 169
def _pool(&block)
thread_pool = ThreadPoolWrapper.new
block.call(thread_pool)
thread_pool.start
end
|
68
69
70
|
# File 'lib/droiuby/bootstrap.rb', line 68
def _R(attr)
Java::com.droiuby.client.core.builder.ActivityBuilder.resolveResource(_current_activity, attr)
end
|
#_rect(left = 0, top = 0, right = 0, bottom = 0) ⇒ Object
29
30
31
|
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 29
def _rect(left = 0, top = 0, right = 0, bottom = 0)
Rect.new(nil, left, top, right, bottom)
end
|
27
28
29
|
# File 'lib/droiuby/bootstrap.rb', line 27
def _runtime
_scripting_container.getProvider.getRuntime
end
|
#_scripting_container ⇒ Object
23
24
25
|
# File 'lib/droiuby/bootstrap.rb', line 23
def _scripting_container
PayloadWrapper.java_getContainer
end
|
#_sleep(delay = 0) ⇒ Object
161
162
163
|
# File 'lib/droiuby/bootstrap.rb', line 161
def _sleep(delay = 0)
Droiuby::SystemWrapper.java_sleep(delay)
end
|
#_switch(bundle) ⇒ Object
72
73
74
75
76
|
# File 'lib/droiuby/bootstrap.rb', line 72
def _switch(bundle)
bundle = Java::com.droiuby.client.core.ExecutionBundleFactory.getBundle(bundle)
$container_payload = bundle.getPayload
true
end
|
#_thread(&block) ⇒ Object
165
166
167
|
# File 'lib/droiuby/bootstrap.rb', line 165
def _thread(&block)
Java::com.droiuby.client.core.wrappers.ThreadWrapper.new(block, _execution_bundle)
end
|
157
158
159
|
# File 'lib/droiuby/bootstrap.rb', line 157
def _time
Droiuby::SystemWrapper.java_currentTimeMillis
end
|
#after_partial_setup(view_group) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/droiuby/preload.rb', line 24
def after_partial_setup(view_group)
$droiuby_plugins.each do |plugin|
puts "plugin attach #{plugin.class.to_s}"
plugin.after_partial_setup(view_group)
end unless $droiuby_plugins.blank?
end
|
#after_view_setup ⇒ Object
17
18
19
20
21
22
|
# File 'lib/droiuby/preload.rb', line 17
def after_view_setup
$droiuby_plugins.each do |plugin|
puts "plugin attach #{plugin.class.to_s}"
plugin.after_view_setup
end unless $droiuby_plugins.blank?
end
|
228
229
230
|
# File 'lib/droiuby/bootstrap.rb', line 228
def Android
Droiuby::Android
end
|
259
260
261
|
# File 'lib/droiuby/bootstrap.rb', line 259
def async
AsyncWrapper.new
end
|
#async_get(url, params = {}, options = {}, &block) ⇒ Object
263
264
265
266
267
268
269
|
# File 'lib/droiuby/bootstrap.rb', line 263
def async_get(url, params = {}, options ={}, &block)
async.perform {
http_get(url, params, options)
}.done { |result|
block.call result
}
end
|
#canvas(&block) ⇒ Object
223
224
225
226
|
# File 'lib/droiuby/bootstrap.rb', line 223
def canvas(&block)
auto_wrap_block = Proc.new { |v| block.call(Canvas.new(v))}
wrap_native_view(Java::com.droiuby.client.core.wrappers.ViewWrapper.new(auto_wrap_block, _execution_bundle))
end
|
#http_get(url, params = {}, options = {}) ⇒ Object
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
# File 'lib/droiuby/bootstrap.rb', line 271
def http_get(url, params = {}, options = {})
encoded_params = []
params.each do |k,v|
encoded_params << "#{k.to_s}=#{CGI::escape(v.to_s)}"
end
url_string = url
if encoded_params.size > 0
url_string = "#{url}?#{encoded_params.join('&')}"
end
Java::com.droiuby.client.core.utils.Utils.load(_current_activity, url_string, _execution_bundle);
end
|
#launch(url) ⇒ Object
87
88
89
|
# File 'lib/droiuby/bootstrap.rb', line 87
def launch(url)
Java::com.droiuby.client.core.DroiubyLauncher.launch(_current_activity, url)
end
|
#log_debug(message = '', tag = 'ruby') ⇒ Object
131
132
133
134
|
# File 'lib/droiuby/bootstrap.rb', line 131
def log_debug(message = '', tag = 'ruby')
Droiuby::SystemWrapper.java_d(tag.to_s, message.to_s)
nil
end
|
#on_ui_thread(&block) ⇒ Object
#render(url, params = {}) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/droiuby/bootstrap.rb', line 109
def render(url, params = {})
http_method = Java::com.droiuby.client.core.utils.Utils::HTTP_GET
if params[:method] && (params[:method] == :post)
http_method = Java::com.droiuby.client.core.utils.Utils::HTTP_POST
end
new_activity = params[:activity] ? true : false;
async.perform {
Java::com.droiuby.client.core.DroiubyLauncher.loadPage(_current_activity, _execution_bundle, url, http_method)
}.done { |result|
if new_activity
Java::com.droiuby.client.core.DroiubyLauncher.startNewActivity(_current_activity, result)
else
Java::com.droiuby.client.core.DroiubyLauncher.runController(_current_activity, _execution_bundle, page)
after_view_setup
end
}
end
|
#reverse_resolve(view_id) ⇒ Object
51
52
53
|
# File 'lib/droiuby/bootstrap.rb', line 51
def reverse_resolve(view_id)
_activity_builder.reverseLookupId(view_id)
end
|
#set_content_view(view = nil) ⇒ Object
#set_mock_environment(environment = nil) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/droiuby/spec/helper.rb', line 93
def set_mock_environment(environment = nil)
puts "new environment"
if environment.nil?
doc = Nokogiri.XML(File.read('config.droiuby'))
title = ''
params = {}
doc.css('app_descriptor').tap do |e|
%w[name description base_url main framework].each do |attr|
params[attr.to_sym] = e.css(attr).first.content
end
end
$mock_environment = MockEnvironment.new(params)
else
$mock_environment = environment
end
$mock_environment
end
|
#start_droiuby_plugins ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/droiuby/preload.rb', line 2
def start_droiuby_plugins
puts "starting plugins"
$droiuby_plugins = []
puts "loading plugins"
Droiuby::Plugins.descendants.each { |klass|
puts "plugin -> #{klass.to_s}"
$droiuby_plugins << klass.new
}
$droiuby_plugins.each do |plugin|
puts "plugin attach #{plugin.class.to_s}"
plugin.after_bootstrap
end unless $droiuby_plugins.blank?
end
|
#surface(&block) ⇒ Object
217
218
219
220
221
|
# File 'lib/droiuby/bootstrap.rb', line 217
def surface(&block)
s = SurfaceViewWrapper.new
block.call(s)
s
end
|
#template(url) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/droiuby/bootstrap.rb', line 101
def template(url)
async.perform {
}.done { |result|
}
end
|
#toast(text = '', duration = :short) ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/droiuby/bootstrap.rb', line 136
def toast(text = '', duration = :short)
j_duration = Java::android.widget.Toast::LENGTH_SHORT
j_duration = case(duration)
when :short
Java::android.widget.Toast::LENGTH_SHORT
when :long
Java::android.widget.Toast::LENGTH_LONG
end
Java::android.widget.Toast.makeText(_current_activity, text, j_duration).show();
end
|
#wrap_native(object) ⇒ Object
211
212
213
214
215
|
# File 'lib/droiuby/bootstrap.rb', line 211
def wrap_native(object)
if (object.class == Java::android.content.Intent)
return IntentWrapper.new(object)
end
end
|
#wrap_native_view(view) ⇒ Object