{"id":24532919,"url":"https://github.com/microstream-one/example-android-recyclerview","last_synced_at":"2025-03-15T21:20:52.447Z","repository":{"id":36548475,"uuid":"225838936","full_name":"microstream-one/example-android-recyclerview","owner":"microstream-one","description":"Android Recyclerview with Microstream","archived":false,"fork":false,"pushed_at":"2022-03-14T10:41:38.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T10:18:48.829Z","etag":null,"topics":[],"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/microstream-one.png","metadata":{"files":{"readme":"README.md","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":"2019-12-04T10:20:49.000Z","updated_at":"2022-03-14T09:52:35.000Z","dependencies_parsed_at":"2022-08-08T15:30:38.543Z","dependency_job_id":null,"html_url":"https://github.com/microstream-one/example-android-recyclerview","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/microstream-one%2Fexample-android-recyclerview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microstream-one%2Fexample-android-recyclerview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microstream-one%2Fexample-android-recyclerview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microstream-one%2Fexample-android-recyclerview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microstream-one","download_url":"https://codeload.github.com/microstream-one/example-android-recyclerview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243791041,"owners_count":20348402,"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":[],"created_at":"2025-01-22T10:18:58.162Z","updated_at":"2025-03-15T21:20:52.386Z","avatar_url":"https://github.com/microstream-one.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example: Android Recyclerview with Microstream\n\nThis example shows how to effectively use Microstream storage with Android RecyclerView. RecyclerView is an effective way to implement a dynamic list of views. \nIt is often used by different socials networks to show comments or posts. \nhttps://developer.android.com/guide/topics/ui/layout/recyclerview\n\nFirst, you must add the Microstream repository into your project. So in build.gradle file for the whole project, add these lines:\n```gradle\nallprojects {\n    repositories {\n        google()\n        jcenter()\n        maven {\n            url 'https://repo.microstream.one/repository/maven-public/'\n        }\n    }\n}\n```\nand for the application, add the following dependencies:\n```gradle\nimplementation 'one.microstream:storage.embedded:02.02.00-MS-GA'\nimplementation 'one.microstream:storage.embedded.configuration:02.02.00-MS-GA'\nimplementation 'androidx.recyclerview:recyclerview:1.1.0'\nannotationProcessor \"one.microstream:base:02.02.00-MS-GA\"\n```\n\nThis example shows a list of fake customers with name and address. \nThe customers are created with JavaFaker library and are stored into a Microstream storage. \nWhen the view is scrolled, new entries are dynamically created either from existing customer instances loaded from storage or from \nnewly created ones that are stored on the fly. This example shows Microstream lazy loading functionality.\n\n```java\npackage one.microstream.android.data;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport one.microstream.reference.Lazy;\n\npublic class CustomerRoot {\n\n    private Map\u003cInteger, Lazy\u003cCustomer\u003e\u003e customerMap;\n\n    public CustomerRoot() {\n        customerMap = new HashMap\u003c\u003e();\n    }\n\n    public Map\u003cInteger, Lazy\u003cCustomer\u003e\u003e getCustomerMap() {\n        return customerMap;\n    }\n}\n```\nSo, the Application does not need to load all customers from the data store at once, but just the Lazy reference pointing to them. Only when the RecyclerView actually requires customer instances to show them on the display, will they be loaded from the data store if they are not loaded, yet.\nRecyclerView also offers the possibility to remove elements from the memory that are not displayed anymore. \nThe app just needs to call the clear() method on the Lazy reference.\nThis approach allows to show thousands of items on the screen without ruining the app's heap.\n\nThis project is ready to be built with Android studio.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrostream-one%2Fexample-android-recyclerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrostream-one%2Fexample-android-recyclerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrostream-one%2Fexample-android-recyclerview/lists"}