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, because
InternalAccessor 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");