{"id":18560814,"url":"https://github.com/harshshah6/firebase-pagination-offlinecapability","last_synced_at":"2026-04-30T09:32:18.622Z","repository":{"id":257408711,"uuid":"858174224","full_name":"Harshshah6/Firebase-Pagination-OfflineCapability","owner":"Harshshah6","description":"An example project of pagination with offline capability using firebase in android application, written in java","archived":false,"fork":false,"pushed_at":"2024-09-19T14:19:00.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-15T16:51:38.788Z","etag":null,"topics":["firebase","firebase-database","firebase-database-pagination","firebase-offline","java","pagination"],"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/Harshshah6.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-16T12:47:28.000Z","updated_at":"2024-09-19T14:20:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"449d83e8-489a-4be6-8a45-7f91aef9555e","html_url":"https://github.com/Harshshah6/Firebase-Pagination-OfflineCapability","commit_stats":null,"previous_names":["harshshah6/firebase-pagination-offlinecapability"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Harshshah6/Firebase-Pagination-OfflineCapability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harshshah6%2FFirebase-Pagination-OfflineCapability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harshshah6%2FFirebase-Pagination-OfflineCapability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harshshah6%2FFirebase-Pagination-OfflineCapability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harshshah6%2FFirebase-Pagination-OfflineCapability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Harshshah6","download_url":"https://codeload.github.com/Harshshah6/Firebase-Pagination-OfflineCapability/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harshshah6%2FFirebase-Pagination-OfflineCapability/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32460781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["firebase","firebase-database","firebase-database-pagination","firebase-offline","java","pagination"],"created_at":"2024-11-06T22:04:46.936Z","updated_at":"2026-04-30T09:32:18.598Z","avatar_url":"https://github.com/Harshshah6.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firebase-Pagination-OfflineCapability\nAn example project of pagination with offline capability using firebase in android application, written in java\n\n## Dependencies Used (external dependencies)\nFirebase core / realtime database dependency are not listed here, please include the core and db dependency before using below libraries.\n``` gradle\nimplementation 'com.firebaseui:firebase-ui-database:8.0.2'\nimplementation 'androidx.paging:paging-runtime:3.3.2'\n```\n\n## Instructions\n### Declaring and Initializing variables\nFirebase related variables :-\n```java\nFirebaseDatabase database = FirebaseDatabase.getInstance();\nDatabaseReference myRef = database.getReference(\"dummy\");\n```\n\nPaging related variables :-\n```java\nPagingConfig config = new PagingConfig(\n    10, // Item Load Limits \n    2, // Prefetch items limit before next load/scroll\n    false // Placeholders (Please refer official doc for more info)\n);\n```\n\n```java\n//Initialize Firebase Paging Options\nDatabasePagingOptions\u003cResponseModel\u003e options = new DatabasePagingOptions.Builder\u003cResponseModel\u003e() // ResponseModel = Model class of your response data\n    .setLifecycleOwner(this) //this = Context\n    .setQuery(myRef, config, ResponseModel.class) //myRef = DatabaseReference\n    .build();\n```\n\nAdapter for RecyclerView\n```java\n//ResponseModel = Model class\n//ViewHolder = ViewHolder class explicitly written by you\n//options = DatabasePagingOptions\u003c\u003e()\nFirebaseRecyclerPagingAdapter\u003cResponseModel, ViewHolder\u003e mAdapter = new FirebaseRecyclerPagingAdapter\u003cResponseModel, ViewHolder\u003e(options) {\n    @NonNull\n    @Override\n    public ViewHolder onCreateViewHolder (@NonNull ViewGroup parent,int viewType){\n    ...\n    }\n@Override\nprotected void onBindViewHolder (@NonNull ViewHolder holder,int position,@NonNull ResponseModel model){\n...\n}\n};\nrecyclerView.setAdapter(mAdapter); //setting adapter to RecyclerView\n```\n\nListening to the scroll and states\n```java\nmAdapter.addLoadStateListener(states -\u003e {\n    LoadState refresh = states.getRefresh();\n    LoadState append = states.getAppend();\n\n    if (refresh instanceof LoadState.Error || append instanceof LoadState.Error) {\n        // There might be some error\n        // Request to database error \n        // OR\n        // No Network Available\n    }\n    \n    if (append instanceof LoadState.Loading) {\n        //Next Items Loading....\n    }\n\n    if (append instanceof LoadState.NotLoading) {\n        LoadState.NotLoading notLoading = (LoadState.NotLoading) append;\n        if (notLoading.getEndOfPaginationReached()) {\n            // This indicates that the user has scrolled\n            // until the end of the data set.\n            return null;\n        }\n        if (refresh instanceof LoadState.NotLoading) {\n            // This indicates the most recent load\n            // has finished.\n            return null;\n        }\n    }\n    return null;\n});\n```\n\n## To Enable Offline Capabality\nIn the example app this code was added in \u003cu\u003eMyApplication.java\u003c/u\u003e class extending Application\n```java\n//enable firebase offline capabilities\nFirebaseDatabase.getInstance().setPersistenceEnabled(true);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshshah6%2Ffirebase-pagination-offlinecapability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshshah6%2Ffirebase-pagination-offlinecapability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshshah6%2Ffirebase-pagination-offlinecapability/lists"}