Resource manager for android resources placed in the res folder of your app

Introduced properties

fun boolean(name: String): Bool

android :: ResourcesManager :: boolean

Get a Bool from resources
fun color(name: String): Int

android :: ResourcesManager :: color

Get a color from resources
init defaultinit(android_resources: NativeResources, app_package: String)

android :: ResourcesManager :: defaultinit

fun destroy

android :: ResourcesManager :: destroy

Deallocate global reference allocated by ResourcesManager
fun dimension(name: String): Int

android :: ResourcesManager :: dimension

Get a dimension from resources
fun integer(name: String): Int

android :: ResourcesManager :: integer

Get an Integer from resources
fun other_id(name: String, res_type: String): Int

android :: ResourcesManager :: other_id

Get and ID from a specific resource in res/res_type folder
fun raw_id(name: String): Int

android :: ResourcesManager :: raw_id

Get a resource ID from one resource in res/rawfolder
fun string(name: String): String

android :: ResourcesManager :: string

Get a String from resources

Redefined properties

redef type SELF: ResourcesManager

android $ ResourcesManager :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun boolean(name: String): Bool

android :: ResourcesManager :: boolean

Get a Bool from resources
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun color(name: String): Int

android :: ResourcesManager :: color

Get a color from resources
init defaultinit(android_resources: NativeResources, app_package: String)

android :: ResourcesManager :: defaultinit

fun destroy

android :: ResourcesManager :: destroy

Deallocate global reference allocated by ResourcesManager
fun dimension(name: String): Int

android :: ResourcesManager :: dimension

Get a dimension from resources
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun integer(name: String): Int

android :: ResourcesManager :: integer

Get an Integer from resources
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun other_id(name: String, res_type: String): Int

android :: ResourcesManager :: other_id

Get and ID from a specific resource in res/res_type folder
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun raw_id(name: String): Int

android :: ResourcesManager :: raw_id

Get a resource ID from one resource in res/rawfolder
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun string(name: String): String

android :: ResourcesManager :: string

Get a String from resources
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram android::ResourcesManager ResourcesManager core::Object Object android::ResourcesManager->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

android $ ResourcesManager
# Resource manager for android resources placed in the `res` folder of your app
class ResourcesManager
	# Native resources
	private var android_resources: NativeResources

	# The name of the app_package
	private var app_package: String

	private init native(res: NativeResources, app_package: String)
	do
		init(res.new_global_ref, app_package)
	end

	# Get a color from resources
	fun color(name: String): Int do
		sys.jni_env.push_local_frame(3)
		var return_value = android_resources.get_color(android_resources.get_identifier(name.to_java_string, "color".to_java_string, app_package.to_java_string))
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get a `Bool` from resources
	fun boolean(name: String): Bool do
		sys.jni_env.push_local_frame(3)
		var return_value = android_resources.get_boolean(android_resources.get_identifier(name.to_java_string, "bool".to_java_string, app_package.to_java_string))
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get a dimension from resources
	# A dimension is specified with a number followed by a unit of measure
	fun dimension(name: String): Int do
		sys.jni_env.push_local_frame(3)
		var return_value =  android_resources.get_dimension(android_resources.get_identifier(name.to_java_string, "dimen".to_java_string, app_package.to_java_string))
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get an `Integer` from resources
	fun integer(name: String): Int do
		sys.jni_env.push_local_frame(3)
		var return_value =  android_resources.get_integer(android_resources.get_identifier(name.to_java_string, "integer".to_java_string, app_package.to_java_string))
		sys.jni_env.pop_local_frame
		return return_value
	end


	# Get a `String` from resources
	fun string(name: String): String do
		sys.jni_env.push_local_frame(3)
		var return_value =  android_resources.get_string(android_resources.get_identifier(name.to_java_string, "string".to_java_string, app_package.to_java_string)).to_s
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get a resource ID from one resource in `res/raw`folder
	# you may use this to retrieve the id of a sound for example
	fun raw_id(name: String): Int do
		sys.jni_env.push_local_frame(3)
		var return_value = android_resources.get_identifier(name.to_java_string, "raw".to_java_string, app_package.to_java_string)
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get a drawable from `res/drawable` folder
	private fun drawable(name: String): NativeDrawable do
		sys.jni_env.push_local_frame(3)
		var return_value = android_resources.get_drawable(android_resources.get_identifier(name.to_java_string, "drawable".to_java_string, app_package.to_java_string))
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Get and ID from a specific resource in `res/res_type` folder
	fun other_id(name, res_type: String): Int do
		sys.jni_env.push_local_frame(3)
		var return_value = android_resources.get_identifier(name.to_java_string, res_type.to_java_string, app_package.to_java_string)
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Deallocate global reference allocated by ResourcesManager
	fun destroy do self.android_resources.delete_global_ref
end
lib/android/assets_and_resources.nit:210,1--292,3