{"id":16162550,"url":"https://github.com/sunsided/android-utils","last_synced_at":"2025-05-07T07:22:30.723Z","repository":{"id":2642251,"uuid":"3631724","full_name":"sunsided/android-utils","owner":"sunsided","description":"Android utility library with math voodoo and object caching","archived":false,"fork":false,"pushed_at":"2012-03-05T21:56:37.000Z","size":485,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"development","last_synced_at":"2025-03-31T07:34:25.282Z","etag":null,"topics":["android","caching","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunsided.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-05T21:44:14.000Z","updated_at":"2025-03-02T14:48:24.000Z","dependencies_parsed_at":"2022-08-29T12:50:39.430Z","dependency_job_id":null,"html_url":"https://github.com/sunsided/android-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fandroid-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fandroid-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fandroid-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fandroid-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/android-utils/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831471,"owners_count":21810810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","caching","java"],"created_at":"2024-10-10T02:30:44.537Z","updated_at":"2025-05-07T07:22:30.680Z","avatar_url":"https://github.com/sunsided.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About this library\n\nFirst of all, this is a work in progress. Second, it's a helper library for Android projects.\n\nWhat this library intents to achieve is:\n\n* Provide a foundation for multimedia Android projects, i.e. games\n* Nothing more.\n\n## The object cache\n\nTo avoid the problems that arise with rapid object creation and the garbage collection (for instance in the context of\nscene graphs where rapid matrix and vector multiplication is needed) a caching mini-framework is provided.\n\nIt consists of a thread local object cache that creates objects on the fly if needed and recycles existing objects\nwhere it can.\n\n### Integrate the cache\n\nCreate a singleton field:\n\n```Java\n    public static final IObjectCache\u003cMatrix4\u003e Cache = new ThreadLocalObjectCache\u003cMatrix4\u003e(new ObjectFactory\u003cMatrix4\u003e() {\n        @NotNull @Override\n        public Matrix4 createNew() {\n            return new Matrix4();\n        }\n    });\n```\n\nand maybe some convenience methods:\n\n```Java\n    @NotNull\n    public static Matrix4 createNew() {\n        Matrix4 matrix = Cache.getOrCreate(); // this instance may be uninitialized, i.e. dirty\n        return matrix.toUnit();               // clean it up\n    }\n\n    public static void recycle(@NotNull Matrix4 matrix) {\n        Cache.registerElement(matrix);\n    }\n\n    public void recycle() {\n        Cache.registerElement(this);\n    }\n```\n\n### Request an object from the cache\n\n```Java\n    Matrix4 officialWay = Matrix4.Cache.getOrCreate();\n    Matrix4 convenientWay = Matrix4.createNew();\n```\n\n### When done, recycle the object\n\n```Java\n    // official way\n    Matrix4.Cache.recycle(matrix);\n\n    // convenient way\n    matrix.recycle();\n```\n\nAs soon as the object is recycled, it can be reused.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fandroid-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fandroid-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fandroid-utils/lists"}