This is a sample project demonstrating the use of the Reflective Drawable Loader Library.
The library (and code) can be found here: https://github.com/alt236/Reflective-Drawable-Loader---Android
Project Description
---
Were you ever in a situation where you had to access Drawables based on their names (for example if the Drawable names are stored in a DB) and you had to write long lookup tables converting the names into R.drawable.ids? And maintaining them?
This library is offering a way around it by using reflection to access the Drawable directly by name. You only need to include them as normal into your Res folder tree. It has been benchmarked at up to 5x faster than the platform's Resources.getIdentifier() method.
It is using LRU caching to mitigate the reflection time overhead for both reflection "hits" and "misses".
</div> <div jsname="WJz9Hc" style="display:none">นี้เป็นโครงการตัวอย่างแสดงให้เห็นถึงการใช้สะท้อนแสง drawable Loader ห้องสมุด
ห้องสมุด (และรหัส) สามารถพบได้ที่นี่: https://github.com/alt236/Reflective-Drawable-Loader---Android
รายละเอียดโครงการ
---
มีคุณเคยอยู่ในสถานการณ์ที่คุณมีการเข้าถึง Drawables ขึ้นอยู่กับชื่อของพวกเขา (ตัวอย่างเช่นถ้าชื่อ drawable จะถูกเก็บไว้ในฐานข้อมูล) และคุณต้องเขียนตารางการค้นหายาวแปลงชื่อเป็น R.drawable.ids? และการบำรุงรักษาได้อย่างไร
ห้องสมุดนี้จะเสนอวิธีรอบโดยใช้สะท้อนการเข้าถึง drawable โดยตรงโดยใช้ชื่อ คุณจะต้องรวมถึงพวกเขาตามปกติเป็นต้นไม้โฟลเดอร์ละเอียดของคุณ จะได้รับการวัดประสิทธิผลที่สูงถึง 5 เท่าเร็วกว่า Resources.getIdentifier () วิธีแพลตฟอร์ม
จะใช้แคช LRU เพื่อลดค่าใช้จ่ายในเวลาสะท้อนทั้งสะท้อน "ความนิยม" และ "คิดถึง"</div> <div class="show-more-end">