class DroidProj::Android::Resources
Attributes
app[RW]
drawables[RW]
Public Class Methods
new()
click to toggle source
# File lib/droidproj/res.rb, line 35 def initialize @drawables = ResourcesDrawables.new end
Public Instance Methods
[](key)
click to toggle source
# File lib/droidproj/res.rb, line 71 def [](key) self.drawables[key] end
drawable(name, &block)
click to toggle source
Public: DSL for creating new drawables in the resources
name - The String name of the drawable; this is what will be referred to
in your Java code
&block - A DSL block where you can setup aspects of the drawable
Examples
res.drawable 'my_image' do hdpi 'some_file.png', state_enabled: false end # => #<Android::Drawable> res.drawable 'my_image' do |drawable| drawable.hdpi 'some_file.png', state_enabled: false end # => #<Android::Drawable>
Returns the new Android::Drawable
instance
# File lib/droidproj/res.rb, line 57 def drawable(name, &block) drawable = DroidProj::Android::Drawable.new drawable.name = name @drawables << drawable case block.arity when 0 drawable.instance_eval &block when 1 block.call(drawable) end drawable end
filesystem_hash()
click to toggle source
Public: A Hash representing how the resources should be created in the
filesytem
Examples
res.filesystem_hash # => {drawable: ["drawable.xml"], drawable-hdpi: ["drawable.png"]}
Returns the Hash
# File lib/droidproj/res.rb, line 84 def filesystem_hash hash = { drawable: [] } self.drawables.each do |drawable| write_op = WriteOp.new write_op.at = drawable.name + ".xml" write_op.content = drawable.xml_string hash[:drawable] << write_op drawable.to_size_buckets.each do |size, drawable_states| drawable_states.each do |drawable_state| folder = (hash["drawable-#{size}".to_sym] ||= []) op = MoveOp.new op.from = drawable_state.file_path op.to = drawable_state.final_file_name folder << op end end end hash end