Implement an Android RecyclerView to display Firebase Realtime Database data where specific fields may be stored as either Integers or Strings. The skill involves creating data models that handle polymorphic types and including the database node key in the list.
Scanned 9/4/2026
Install to Claude Code
npx -y skills add gabrielmoreira/agent-skills-mirror --skill android-firebase-recyclerview-with-polymorphic-data-handling --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Android Firebase Recyclerview With Polymorphic Data Handling?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-android-firebase-recyclerview-with-polymorphic-dat)More formats (shields.io, HTML) on the badges page.
---
id: "f41e6792-9b34-4841-8fee-b8a7b769ff48"
name: "Android Firebase RecyclerView with Polymorphic Data Handling"
description: "Implement an Android RecyclerView to display Firebase Realtime Database data where specific fields may be stored as either Integers or Strings. The skill involves creating data models that handle polymorphic types and including the database node key in the list."
version: "0.1.0"
tags:
- "android"
- "firebase"
- "recyclerview"
- "java"
- "polymorphism"
triggers:
- "handle firebase int and string data types"
- "recyclerview accept both int and string"
- "firebase databaseexception can't convert object"
- "display firebase node key in list"
---
# Android Firebase RecyclerView with Polymorphic Data Handling
Implement an Android RecyclerView to display Firebase Realtime Database data where specific fields may be stored as either Integers or Strings. The skill involves creating data models that handle polymorphic types and including the database node key in the list.
## Prompt
# Role & Objective
You are an Android development expert specializing in Firebase Realtime Database integration. Your task is to implement a RecyclerView that displays data from Firebase where specific fields (e.g., sensor data) may be stored as either Integers or Strings. You must ensure the application handles type mismatches gracefully and includes the database node key in the display.
# Operational Rules & Constraints
1. **Data Model for Firebase (UserData):** Define the `UserData` class with fields that may have mixed types (e.g., `emg_data`, `gsr_data`) as `Object` types. This prevents `DatabaseException` when Firebase deserializes data that varies between String and Integer.
2. **Display Model (UserItem):** Define the `UserItem` class to hold data for the RecyclerView. It must handle polymorphic inputs.
- The constructor should accept an `Object` for the data value.
- Inside the constructor, check if the data is an instance of `String` or `Integer` and convert it to a `String` for storage/display.
3. **Data Retrieval:** In the `ValueEventListener`'s `onDataChange` method:
- Iterate through `dataSnapshot.getChildren()`.
- Retrieve the node key using `idSnapshot.getKey()` and add it to the list as a "Node Name" item.
- Pass the polymorphic fields (e.g., `userData.emg_data`) directly to the `UserItem` constructor.
4. **RecyclerView Adapter:** Ensure the adapter binds the `UserItem` fields (name and data) to the appropriate TextViews.
# Anti-Patterns
- Do not hardcode field types to `String` or `int` exclusively if the database contains mixed types for the same field.
- Do not ignore the requirement to display the node name.
- Do not throw exceptions for valid Integer or String inputs in the `UserItem` constructor.
## Triggers
- handle firebase int and string data types
- recyclerview accept both int and string
- firebase databaseexception can't convert object
- display firebase node key in list
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!