ResourcesHolder
Created by Anggrayudi on 11/03/2016.
Since version 0.0.5 the uses of this class is diverted. You don't need to avoid Java reflection by storing the internal resources you just retrieved to ResourcesHolder and send them via Broadcast, because this version does not use Java reflection anymore. Instead, you can use this class to store any objects you might need in other classes (like passing objects from activity to service) and send them via Broadcast.
Obsolete documentation (v0.0.4 and lower) A class that holds internal resources which are retrieved by InternalAccessor . We need to hold the resources we just retrieved, becauseInternalAccessor uses reflection, and Java reflection may slow down user's machine performance. Using reflection every time you reflect the same value is not a good practice. So, use this class instead. Also, you can use this class to holds non-internal resources, according to your needs.
An example to use this class is:
ResourcesHolder holder = new ResourcesHolder()
.putString("my_string_key", InternalAccessor.getString("accept"))
.putResourceId("my_res_id_key", InternalAccessor.getResourceId("drawable", "loading_tile_android");
// Retrieve the values from another place
holder.getString("my_string_key");
holder.getResourceId("my_res_id_key");
// If you plan to send 'holder' to another class via BroadcastReceiver or LocalBroadcastManager
Intent intent = new Intent(ResourcesHolder.ACTION_SEND_RESOURCES_HOLDER);
intent.putExtra("holder", holder);
// send via LocalBroadcastManager
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
// send via BroadcastReceiver
sendBroadcast(intent);
// Instead, you can do this in simple way
holder.sendBroadcast(this, "holder");
// or with this
holder.sendViaLocalBroadcastManager(this, "holder");
Constructors
ResourcesHolder
Link copied to clipboard
open fun ResourcesHolder()
Content copied to clipboard
Functions
containsKey
Link copied to clipboard
describeContents
Link copied to clipboard
getAsBoolean
Link copied to clipboard
getAsBooleanArray
Link copied to clipboard
getAsByteArray
Link copied to clipboard
getAsCharArray
Link copied to clipboard
getAsDouble
Link copied to clipboard
getAsDoubleArray
Link copied to clipboard
getAsFloat
Link copied to clipboard
getAsFloatArray
Link copied to clipboard
getAsIntArray
Link copied to clipboard
getAsInteger
Link copied to clipboard
getAsLongArray
Link copied to clipboard
getAsObject
Link copied to clipboard
getAsShort
Link copied to clipboard
getAsShortArray
Link copied to clipboard
getAsString
Link copied to clipboard
getAsStringArray
Link copied to clipboard
put
Link copied to clipboard
sendBroadcast
Link copied to clipboard
sendViaLocalBroadcastManager
Link copied to clipboard
valueSet
Link copied to clipboard
writeToParcel
Link copied to clipboard