assets/src/ruboto/widget.rb in ruboto-0.15.0 vs assets/src/ruboto/widget.rb in ruboto-0.16.0

- old
+ new

@@ -107,11 +107,11 @@ class_name = klass.java_class.name.split('.')[-1] end return unless klass - RubotoActivity.class_eval " + method_str = " def #{(class_name.to_s.gsub(/([A-Z])/) { '_' + $1.downcase })[1..-1]}(params={}) if force_style = params.delete(:default_style) rv = #{class_name}.new(self, nil, force_style) elsif api_key = params.delete(:apiKey) rv = #{class_name}.new(self, api_key) @@ -132,11 +132,18 @@ @view_parent = old_view_parent rv end " + RubotoActivity.class_eval method_str + # FIXME(uwe): Remove condition when we stop support for api level < 11 + if android.os.Build::VERSION::SDK_INT >= 11 + android.app.Fragment.class_eval method_str.gsub('self', 'activity') + end + # EMXIF + setup_list_view if class_name == :ListView setup_spinner if class_name == :Spinner setup_button if class_name == :Button setup_image_button if class_name == :ImageButton setup_linear_layout if class_name == :LinearLayout @@ -164,18 +171,16 @@ def setup_image_button # legacy end def setup_list_view - Java::android.widget.ListView.__persistent__ = true - Java::android.widget.ListView.class_eval do + android.widget.ListView.__persistent__ = true + android.widget.ListView.class_eval do def configure(context, params = {}) if (list = params.delete(:list)) - @adapter_list = Java::java.util.ArrayList.new - @adapter_list.addAll(list) item_layout = params.delete(:item_layout) || R::layout::simple_list_item_1 - params[:adapter] = Java::android.widget.ArrayAdapter.new(context, item_layout, @adapter_list) + params[:adapter] = android.widget.ArrayAdapter.new(context, item_layout, list) end super(context, params) end def reload_list(list) @@ -186,22 +191,17 @@ end end end def setup_spinner - Java::android.widget.Spinner.__persistent__ = true - Java::android.widget.Spinner.class_eval do - attr_reader :adapter, :adapter_list - + android.widget.Spinner.__persistent__ = true + android.widget.Spinner.class_eval do def configure(context, params = {}) - if params.has_key? :list - @adapter_list = Java::java.util.ArrayList.new - @adapter_list.addAll(params[:list]) - item_layout = params.delete(:item_layout) || R::layout::simple_spinner_item - @adapter = Java::android.widget.ArrayAdapter.new(context, item_layout, @adapter_list) - @adapter.setDropDownViewResource(params.delete(:dropdown_layout) || R::layout::simple_spinner_dropdown_item) - setAdapter @adapter - params.delete :list + if (list = params.delete(:list)) + item_layout = params.delete(:item_layout) + params[:adapter] = android.widget.ArrayAdapter.new(context, item_layout || R::layout::simple_spinner_item, list) + dropdown_layout = params.delete(:dropdown_layout) + params[:adapter].setDropDownViewResource(dropdown_layout) if dropdown_layout end super(context, params) end def reload_list(list)