ruboto 1.1.2 → 1.2.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -6
  3. data/RELEASE_CANDICATE_DOC.md +5 -3
  4. data/RELEASE_DOC.md +32 -11
  5. data/Rakefile +86 -36
  6. data/assets/rakelib/ruboto.rake +33 -14
  7. data/assets/rakelib/ruboto.stdlib.rake +1 -1
  8. data/assets/res/layout/get_ruboto_core.xml +1 -2
  9. data/assets/src/RubotoService.java +19 -2
  10. data/assets/src/org/ruboto/JRubyAdapter.java +4 -0
  11. data/assets/src/org/ruboto/SplashActivity.java +17 -17
  12. data/assets/src/ruboto/base.rb +13 -4
  13. data/assets/src/ruboto/package.rb +12 -3
  14. data/assets/src/ruboto/service.rb +45 -8
  15. data/assets/src/ruboto/widget.rb +82 -39
  16. data/assets/test/src/test_helper.rb +4 -0
  17. data/lib/ruboto/commands/base.rb +29 -17
  18. data/lib/ruboto/sdk_versions.rb +1 -1
  19. data/lib/ruboto/util/emulator.rb +49 -33
  20. data/lib/ruboto/util/setup.rb +5 -1
  21. data/lib/ruboto/util/update.rb +68 -22
  22. data/lib/ruboto/util/xml_element.rb +5 -3
  23. data/lib/ruboto/version.rb +1 -1
  24. data/test/activity/call_super_activity.rb +2 -2
  25. data/test/activity/constants_activity.rb +51 -0
  26. data/test/activity/constants_activity_test.rb +18 -0
  27. data/test/activity/margins_activity.rb +12 -7
  28. data/test/activity/margins_activity_test.rb +10 -6
  29. data/test/activity/padding_activity.rb +15 -0
  30. data/test/activity/padding_activity_test.rb +41 -0
  31. data/test/activity/rss_activity.rb +42 -0
  32. data/test/activity/rss_activity_test.rb +35 -0
  33. data/test/activity/spinner_activity.rb +5 -5
  34. data/test/activity/spinner_activity_test.rb +6 -6
  35. data/test/activity/stack_activity.rb +7 -8
  36. data/test/activity/stack_activity_test.rb +7 -5
  37. data/test/activity/subclass_activity.rb +5 -5
  38. data/test/activity/subclass_activity_test.rb +8 -6
  39. data/test/app_test_methods.rb +8 -0
  40. data/test/arjdbc_test.rb +1 -1
  41. data/test/minimal_app_test.rb +12 -10
  42. data/test/rake_test.rb +2 -4
  43. data/test/ruboto_gen_test.rb +11 -9
  44. data/test/service_block_test.rb +112 -0
  45. data/test/{service_test.rb → service_gen_class_test.rb} +9 -4
  46. data/test/service_infile_class_test.rb +114 -0
  47. data/test/sqldroid_test.rb +1 -1
  48. data/test/test_helper.rb +39 -21
  49. metadata +11 -7
@@ -9,8 +9,25 @@ public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
9
9
  * Called at the start of onCreate() to prepare the Activity.
10
10
  */
11
11
  private void preOnCreate() {
12
- System.out.println("RubotoService onCreate(): " + getClass().getName());
13
- getScriptInfo().setRubyClassName(getClass().getSimpleName());
12
+ if (!getClass().getSimpleName().equals("RubotoService")) {
13
+ System.out.println("RubotoService preOnCreate(): " + getClass().getName());
14
+ getScriptInfo().setRubyClassName(getClass().getSimpleName());
15
+ JRubyAdapter.setUpJRuby(this);
16
+ }
17
+ }
18
+
19
+ private void preOnStartCommand(android.content.Intent intent) {
20
+ if (getClass().getSimpleName().equals("RubotoService")) {
21
+ System.out.println("RubotoService preOnStartCommand(): " + getClass().getName());
22
+ scriptInfo.setFromIntent(intent);
23
+ }
24
+ }
25
+
26
+ private void preOnBind(android.content.Intent intent) {
27
+ if (getClass().getSimpleName().equals("RubotoService")) {
28
+ System.out.println("RubotoService preOnBind(): " + getClass().getName());
29
+ scriptInfo.setFromIntent(intent);
30
+ }
14
31
  }
15
32
 
16
33
  THE_METHODS
@@ -303,6 +303,10 @@ public class JRubyAdapter {
303
303
  System.out.println("JRuby version: " + Class.forName("org.jruby.runtime.Constants", true, scriptingContainerClass.getClassLoader())
304
304
  .getDeclaredField("VERSION").get(String.class));
305
305
 
306
+ // TODO(uwe): Add a way to display startup progress.
307
+ put("$application_context", appContext.getApplicationContext());
308
+ runScriptlet("begin\n require 'environment'\nrescue LoadError => e\n puts e\nend");
309
+
306
310
  initialized = true;
307
311
  } catch (ClassNotFoundException e) {
308
312
  handleInitException(e);
@@ -46,7 +46,7 @@ public class SplashActivity extends Activity {
46
46
  }
47
47
 
48
48
  public void onResume() {
49
- Log.d("onResume: ");
49
+ Log.d("SplashActivity onResume: ");
50
50
  if (!JRubyAdapter.isInitialized() && receiver == null) {
51
51
  registerPackageInstallReceiver();
52
52
  }
@@ -54,7 +54,7 @@ public class SplashActivity extends Activity {
54
54
  }
55
55
 
56
56
  public void onPause() {
57
- Log.d("onPause: ");
57
+ Log.d("SplashActivity onPause: ");
58
58
  if (receiver != null) {
59
59
  unregisterReceiver(receiver);
60
60
  receiver = null;
@@ -63,7 +63,7 @@ public class SplashActivity extends Activity {
63
63
  }
64
64
 
65
65
  public void onDestroy() {
66
- Log.d("onDestroy: ");
66
+ Log.d("SplashActivity onDestroy: ");
67
67
  super.onDestroy();
68
68
  if (dialogCancelled) {
69
69
  System.runFinalizersOnExit(true);
@@ -77,7 +77,7 @@ public class SplashActivity extends Activity {
77
77
  public void run() {
78
78
  final boolean jrubyOk = JRubyAdapter.setUpJRuby(SplashActivity.this);
79
79
  if (jrubyOk) {
80
- Log.d("onResume: JRuby OK");
80
+ Log.d("SplashActivity onResume: JRuby OK");
81
81
  startUserActivity();
82
82
  } else {
83
83
  registerPackageInstallReceiver();
@@ -87,7 +87,7 @@ public class SplashActivity extends Activity {
87
87
  installDownload();
88
88
  } else {
89
89
  if (firstTime) {
90
- Log.d("onResume: Checking JRuby - IN UI thread");
90
+ Log.d("SplashActivity onResume: Checking JRuby - IN UI thread");
91
91
  try {
92
92
  setContentView(Class.forName(getPackageName() + ".R$layout").getField("get_ruboto_core").getInt(null));
93
93
  if (hasInternetPermission()) {
@@ -99,7 +99,7 @@ public class SplashActivity extends Activity {
99
99
  } else {
100
100
  Toast.makeText(SplashActivity.this,"Failed to initialize Ruboto Core.",Toast.LENGTH_LONG).show();
101
101
  try {
102
- TextView textView = (TextView) findViewById(Class.forName(getPackageName() + ".R$id").getField("text").getInt(null));
102
+ TextView textView = (TextView) findViewById(android.R.id.text1);
103
103
  textView.setText("Woops! Ruboto Core was installed, but it failed to initialize properly! I am not sure how to proceed from here. If you can, please file an error report at http://ruboto.org/");
104
104
  } catch (Exception e) {
105
105
  }
@@ -134,7 +134,7 @@ public class SplashActivity extends Activity {
134
134
  try {
135
135
  Thread.sleep(1000);
136
136
  } catch (InterruptedException ie) {
137
- Log.e("Interupted!");
137
+ Log.e("SplashActivity Interupted!");
138
138
  }
139
139
  }
140
140
  }
@@ -164,10 +164,10 @@ public class SplashActivity extends Activity {
164
164
  private void showProgress() {
165
165
  if (loadingDialog == null) {
166
166
  if (splash > 0) {
167
- Log.i("Showing splash");
167
+ Log.i("SplashActivity Showing splash");
168
168
  setContentView(splash);
169
169
  } else {
170
- Log.i("Showing progress");
170
+ Log.i("SplashActivity Showing progress");
171
171
  loadingDialog = ProgressDialog.show(this, null, "Starting...", true, true);
172
172
  loadingDialog.setCanceledOnTouchOutside(false);
173
173
  loadingDialog.setOnCancelListener(new OnCancelListener() {
@@ -183,10 +183,10 @@ public class SplashActivity extends Activity {
183
183
  private void showDownloadProgress(String message) {
184
184
  if (loadingDialog == null) {
185
185
  if (splash > 0) {
186
- Log.i("Showing splash");
186
+ Log.i("SplashActivity Showing splash");
187
187
  setContentView(splash);
188
188
  } else {
189
- Log.i("Showing progress");
189
+ Log.i("SplashActivity Showing progress");
190
190
  loadingDialog = new ProgressDialog(this);
191
191
  loadingDialog.setTitle(null);
192
192
  loadingDialog.setMessage(message);
@@ -210,7 +210,7 @@ public class SplashActivity extends Activity {
210
210
 
211
211
  private void hideProgress() {
212
212
  if (loadingDialog != null) {
213
- Log.d("Hide progress");
213
+ Log.d("SplashActivity Hide progress");
214
214
  loadingDialog.dismiss();
215
215
  loadingDialog = null;
216
216
  }
@@ -327,13 +327,13 @@ public class SplashActivity extends Activity {
327
327
  // EMXIF
328
328
 
329
329
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
330
- Log.d("onActivityResult: " + requestCode + ", " + resultCode + ", " + data);
331
- Log.d("onActivityResult: " + INSTALL_REQUEST_CODE + ", " + RESULT_OK + ", " + RESULT_CANCELED);
330
+ Log.d("SplashActivity onActivityResult: " + requestCode + ", " + resultCode + ", " + data);
331
+ Log.d("SplashActivity onActivityResult: " + INSTALL_REQUEST_CODE + ", " + RESULT_OK + ", " + RESULT_CANCELED);
332
332
  if (requestCode == INSTALL_REQUEST_CODE) {
333
333
  if (resultCode == RESULT_OK) {
334
- Log.d("onActivityResult: Install OK.");
334
+ Log.d("SplashActivity onActivityResult: Install OK.");
335
335
  } else if (resultCode == RESULT_CANCELED) {
336
- Log.d("onActivityResult: Install canceled.");
336
+ Log.d("SplashActivity onActivityResult: Install canceled.");
337
337
  // FIXME(uwe): Maybe show a dialog explaining that RubotoCore is needed and try again?
338
338
  deleteFile(RUBOTO_APK);
339
339
  if (!JRubyAdapter.isInitialized()) {
@@ -341,7 +341,7 @@ public class SplashActivity extends Activity {
341
341
  }
342
342
  // EMXIF
343
343
  } else {
344
- Log.e("onActivityResult: resultCode: " + resultCode);
344
+ Log.e("SplashActivity onActivityResult: resultCode: " + resultCode);
345
345
  }
346
346
  }
347
347
  super.onActivityResult(requestCode, resultCode, data);
@@ -11,18 +11,27 @@ require 'java'
11
11
  # Create convenience method for top-level android package so we do not need to prefix with 'Java::'.
12
12
  module Kernel
13
13
  def android
14
- JavaUtilities.get_package_module_dot_format('android')
14
+ Java::Android
15
15
  end
16
16
 
17
17
  alias :old_method_missing :method_missing
18
18
  def method_missing(method, *args, &block)
19
- return @ruboto_java_instance.send(method, *args, &block) if @ruboto_java_instance && @ruboto_java_instance.respond_to?(method)
19
+ if @ruboto_java_instance && @ruboto_java_instance.respond_to?(method)
20
+ return @ruboto_java_instance.send(method, *args, &block)
21
+ end
20
22
  old_method_missing(method, *args, &block)
21
23
  end
22
24
  end
23
25
 
24
- java_import 'android.R'
25
- AndroidIds = JavaUtilities.get_proxy_class('android.R$id')
26
+ class Java::Android::R
27
+ def self.attr
28
+ JavaUtilities.get_proxy_class("android.R$attr")
29
+ end
30
+ end
31
+
32
+ # FIXME(uwe): DEPRECATED(2014-07-29): Remove since we can access the value directly with "android.R.id", ie. "android.R.id.text1"
33
+ AndroidIds = android.R.id
34
+ # EMXIF
26
35
 
27
36
  module Ruboto
28
37
  CLASS_NAME_KEY = org.ruboto.ScriptInfo::CLASS_NAME_KEY
@@ -1,10 +1,19 @@
1
- $package = eval("Java::#{$package_name}")
1
+ $package = JavaUtilities.get_package_module_dot_format($package_name)
2
+ R = $package.R
2
3
 
4
+ class R
5
+ def self.attr
6
+ JavaUtilities.get_proxy_class("#{$package_name}.R$attr")
7
+ end
8
+ end
9
+
10
+ # FIXME(uwe): DEPRECATED(2014-07-29): Use R and R.id instead.
3
11
  module Ruboto
4
- java_import "#{$package_name}.R"
12
+ R = ::R
5
13
  begin
6
- Id = JavaUtilities.get_proxy_class("#{$package_name}.R$id")
14
+ Id = R.id
7
15
  rescue NameError
8
16
  Java::android.util.Log.d 'RUBOTO', 'no R$id'
9
17
  end
10
18
  end
19
+ # EMXIF
@@ -14,30 +14,67 @@ java_import 'org.ruboto.RubotoService'
14
14
 
15
15
  module Ruboto
16
16
  module Context
17
- def start_ruboto_service(global_variable_name='$service', klass=RubotoService, options={}, &block)
18
- # FIXME(uwe): Translate old positional signature to new options-based signature.
19
- # FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
17
+ def start_ruboto_service(class_name = nil, options = nil, &block)
20
18
  if options.nil?
21
- if global_variable_name.is_a?(Hash)
22
- options = global_variable_name
19
+ if class_name.is_a?(Hash)
20
+ options = class_name
21
+ class_name = nil
23
22
  else
24
23
  options = {}
25
24
  end
26
25
  end
26
+
27
+ # FIXME(uwe): Deprecated. Remove august 2014.
28
+ if options[:class_name]
29
+ puts "\nDEPRECATION: The ':class_name' option is deprecated. Put the class name in the first argument instead."
30
+ class_name_option = options.delete(:class_name)
31
+ class_name ||= class_name_option
32
+ end
33
+
34
+ java_class = options.delete(:java_class) || RubotoService
35
+ script_name = options.delete(:script)
36
+ extras = options.delete(:extras)
37
+ flags = options.delete(:flags)
38
+
39
+ raise "Unknown options: #{options}" unless options.empty?
40
+
41
+ if class_name.nil?
42
+ if block_given?
43
+ src_desc = source_descriptor(block)
44
+ class_name =
45
+ "#{java_class.name.split('::').last}_#{src_desc[0].split('/').last.gsub(/[.-]+/, '_')}_#{src_desc[1]}"
46
+ else
47
+ class_name = java_class.name.split('::').last
48
+ end
49
+ end
50
+
51
+ class_name = class_name.to_s
27
52
 
28
- class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split('/').last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
29
53
  if Object.const_defined?(class_name)
30
54
  Object.const_get(class_name).class_eval(&block) if block_given?
31
55
  else
32
56
  Object.const_set(class_name, Class.new(&block))
33
57
  end
58
+
34
59
  i = android.content.Intent.new
35
- i.setClass self, klass.java_class
60
+ i.setClass self, java_class.java_class
61
+ i.add_flags(flags) if flags
36
62
  i.putExtra(Ruboto::CLASS_NAME_KEY, class_name)
37
- i.putExtra(Ruboto::SCRIPT_NAME_KEY, options[:script]) if options[:script]
63
+ i.putExtra(Ruboto::SCRIPT_NAME_KEY, script_name) if script_name
64
+ extras.each { |k, v| i.putExtra(k.to_s, v) } if extras
65
+ puts "starting Ruboto service: #{i.inspect}"
38
66
  self.startService i
39
67
  self
40
68
  end
69
+
70
+ private
71
+
72
+ def source_descriptor(src_proc)
73
+ if (md = /^#<Proc:0x[0-9A-Fa-f-]+@(.+):(\d+)(?: \(lambda\))?>$/.match(src_proc.inspect))
74
+ filename, line = md.captures
75
+ return filename, line.to_i
76
+ end
77
+ end
41
78
  end
42
79
  end
43
80
 
@@ -17,8 +17,62 @@ require 'ruboto/activity'
17
17
 
18
18
  java_import 'android.view.View'
19
19
 
20
+ # Set an attribute value by name on the given target. This method is used by
21
+ # all the widget methods generated by "ruboto_import_widget" and
22
+ # "ruboto_import_widgets":
23
+ #
24
+ # button text: 'Click me!', layout: {weight: 1, gravity: :center}
25
+ #
26
+ # The attribute can be a public field, a JavaBean attribute, or a setter method.
27
+ #
28
+ # set_attribute button, :text, 'Click me!'
29
+ # set_attribute button.layout_attributes, :weight, 1
30
+ #
31
+ # The given attribute name can match the attribute name exactly or be accessed
32
+ # by the snake_case version of the attribute. It can also be accessed by the
33
+ # setter name, either snake_case or camelCase.
34
+ #
35
+ # set_attribute button, :textAlignment, android.view.View::TEXT_ALIGNMENT_CENTER
36
+ # set_attribute button, :text_alignment, android.view.View::TEXT_ALIGNMENT_CENTER
37
+ # set_attribute button, :set_text_alignment, android.view.View::TEXT_ALIGNMENT_CENTER
38
+ # set_attribute button, :setTextAlignment, android.view.View::TEXT_ALIGNMENT_CENTER
39
+ #
40
+ # You can use symbols as values for common constants. Currently constants for
41
+ # the following classes are enabled using symbols:
42
+ #
43
+ # * android.view.Gravity
44
+ # * android.view.ViewGroup::LayoutParams
45
+ # * android.widget.LinearLayout
46
+ # * android.widget.RelativeLayout
47
+ #
48
+ # set_attribute button, :text_alignment, :text_alignment_center
49
+ # set_attribute button.layout_attributes, :gravity, :center
50
+ # set_attribute button.layout_attributes, :width, :fill_parent
51
+ #
52
+ # Integer values in the range 0x80000000..0xFFFFFFFF are converted to a negative
53
+ # Integer value enabling setting of 4-byte color values as Ruby integer literals.
54
+ #
55
+ # set_attribute button, :background_color, 0x0000FF00
56
+ #
57
+ # You can use an array as a value for multi-value attributes like margins and
58
+ # padding.
59
+ #
60
+ # set_attribute button, :padding, [10, 20, 10, 30]
61
+ #
62
+ def set_attribute(target, k, v)
63
+ assign_method = "#{k}="
64
+ field_assign_method = "#{k.to_s.gsub(/(_)([a-z])/) { $2.upcase }}="
65
+ setter_method = "set#{k.to_s.gsub(/(^|_)([a-z])/) { $2.upcase }}"
66
+ method_name =
67
+ (target.respond_to?(assign_method) && assign_method) ||
68
+ (target.respond_to?(field_assign_method) && field_assign_method) ||
69
+ (target.respond_to?(setter_method) && setter_method) ||
70
+ k
71
+ invoke_with_converted_arguments(target, method_name, v)
72
+ end
73
+
20
74
  def invoke_with_converted_arguments(target, method_name, values)
21
- converted_values = [*values].map { |i| @@convert_constants[i] || i }
75
+ converted_values = [*values].map { |i| View.convert_constant(i) }
22
76
  scaled_values = converted_values.map.with_index do |v, i|
23
77
  v.is_a?(Integer) && v >= 0x80000000 && v <= 0xFFFFFFFF ?
24
78
  v.to_i - 0x100000000 : v
@@ -30,77 +84,66 @@ View.class_eval do
30
84
  @@convert_constants ||= {}
31
85
 
32
86
  def self.add_constant_conversion(from, to)
33
- @@convert_constants[from] = to
87
+ symbol = from.to_s.downcase.to_sym
88
+ if @@convert_constants.include?(symbol)
89
+ puts "WARNING: Overwriting symbol to constant conversion for #{symbol.inspect}: #{@@convert_constants[symbol].inspect} => #{to.inspect}"
90
+ end
91
+ @@convert_constants[symbol] = to
34
92
  end
35
93
 
36
94
  def self.convert_constant(from)
37
95
  return from unless from.is_a?(Symbol)
38
- @@convert_constants[from] or raise "Symbol #{from.inspect} doesn't have a corresponding View constant #{from.to_s.upcase}"
96
+ unless @@convert_constants.include?(from)
97
+ raise "Symbol #{from.inspect} doesn't have a corresponding View constant #{from.to_s.upcase}."
98
+ end
99
+ @@convert_constants[from]
39
100
  end
40
101
 
41
102
  def self.setup_constant_conversion
42
103
  (self.constants - self.superclass.constants).each do |i|
43
- View.add_constant_conversion i.downcase.to_sym, self.const_get(i)
104
+ View.add_constant_conversion i, self.const_get(i)
44
105
  end
45
106
  end
46
107
 
47
108
  def configure(context, params = {})
48
- if width = params.delete(:width)
109
+ if (width = params.delete(:width))
49
110
  getLayoutParams.width = View.convert_constant(width)
50
111
  puts "\nDEPRECATION: The ':width' option is deprecated. Use :layout => {:width => XX} instead."
51
112
  end
52
113
 
53
- if height = params.delete(:height)
114
+ if (height = params.delete(:height))
54
115
  getLayoutParams.height = View.convert_constant(height)
55
- puts "\nDEPRECATION: The ':height' option is deprecated. Use :height => {:width => XX} instead."
116
+ puts "\nDEPRECATION: The ':height' option is deprecated. Use :layout => {:height => XX} instead."
56
117
  end
57
118
 
58
- if margins = params.delete(:margins)
119
+ if (margins = params.delete(:margins))
59
120
  getLayoutParams.set_margins(*margins)
60
- puts "\nDEPRECATION: The ':margins' option is deprecated. Use :layout => {:margins => XX} instead."
121
+ puts "\nDEPRECATION: The ':margins' option is deprecated. Use :layout => {:margins => [L, T, R, B]} instead."
61
122
  end
62
123
 
63
- if layout = params.delete(:layout)
124
+ if (layout = params.delete(:layout))
64
125
  lp = getLayoutParams
65
- layout.each do |k, v|
66
- method_name = k.to_s
67
- if lp.respond_to?("#{k}=")
68
- method_name = "#{k}="
69
- elsif method_name.include?("_")
70
- method_name = method_name.gsub(/_([a-z])/){$1.upcase}
71
- method_name = "#{method_name}=" if lp.respond_to?("#{method_name}=")
72
- end
73
-
74
- invoke_with_converted_arguments(lp, method_name, v)
75
- end
126
+ layout.each { |k, v| set_attribute(lp, k, v) }
76
127
  end
77
128
 
78
- params.each do |k, v|
79
- setter_method = "set#{k.to_s.gsub(/(^|_)([a-z])/) { $2.upcase }}"
80
- assign_method = "#{k}="
81
- method_name = self.respond_to?(assign_method) ? assign_method :
82
- (self.respond_to?(setter_method) ? setter_method : k)
83
- invoke_with_converted_arguments(self, method_name, v)
84
- end
129
+ params.each { |k, v| set_attribute(self, k, v) }
85
130
  end
86
131
  end
87
132
 
88
133
  #
89
134
  # Load ViewGroup constants
90
135
  #
91
-
92
136
  java_import 'android.view.ViewGroup'
93
137
  ViewGroup::LayoutParams.constants.each do |i|
94
- View.add_constant_conversion i.downcase.to_sym, ViewGroup::LayoutParams.const_get(i)
138
+ View.add_constant_conversion i, ViewGroup::LayoutParams.const_get(i)
95
139
  end
96
140
 
97
141
  #
98
142
  # Load Gravity constants
99
143
  #
100
-
101
144
  java_import 'android.view.Gravity'
102
145
  Gravity.constants.each do |i|
103
- View.add_constant_conversion i.downcase.to_sym, Gravity.const_get(i)
146
+ View.add_constant_conversion i, Gravity.const_get(i)
104
147
  end
105
148
 
106
149
  #
@@ -190,15 +233,15 @@ def setup_list_view
190
233
  android.widget.ListView.class_eval do
191
234
  def configure(context, params = {})
192
235
  if (list = params.delete(:list))
193
- item_layout = params.delete(:item_layout) || R::layout::simple_list_item_1
236
+ item_layout = params.delete(:item_layout) || android.R::layout::simple_list_item_1
194
237
  params[:adapter] = android.widget.ArrayAdapter.new(context, item_layout, list)
195
238
  end
196
239
  super(context, params)
197
240
  end
198
241
 
199
242
  def reload_list(list)
200
- @adapter_list.clear
201
- @adapter_list.addAll(list)
243
+ adapter.clear
244
+ adapter.addAll(list)
202
245
  adapter.notifyDataSetChanged
203
246
  invalidate
204
247
  end
@@ -211,7 +254,7 @@ def setup_spinner
211
254
  def configure(context, params = {})
212
255
  if (list = params.delete(:list))
213
256
  item_layout = params.delete(:item_layout)
214
- params[:adapter] = android.widget.ArrayAdapter.new(context, item_layout || R::layout::simple_spinner_item, list)
257
+ params[:adapter] = android.widget.ArrayAdapter.new(context, item_layout || android.R::layout::simple_spinner_item, list)
215
258
  dropdown_layout = params.delete(:dropdown_layout)
216
259
  params[:adapter].setDropDownViewResource(dropdown_layout) if dropdown_layout
217
260
  end
@@ -219,9 +262,9 @@ def setup_spinner
219
262
  end
220
263
 
221
264
  def reload_list(list)
222
- @adapter.clear
223
- @adapter.addAll(list)
224
- @adapter.notifyDataSetChanged
265
+ adapter.clear
266
+ adapter.addAll(list)
267
+ adapter.notifyDataSetChanged
225
268
  invalidate
226
269
  end
227
270
  end