GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Flattening nested data · Issue #280 · firebase/FirebaseUI-Android

Flattening nested data #280

New issue
Copy link
New issue
Copy link
Closed
Closed
Flattening nested data#280
Copy link

Description

@ghost
ghost
opened on Sep 1, 2016

http://stackoverflow.com/questions/39258219/firebaserecycleradapter-with-2-childs?noredirect=1#comment65887443_39258219

If I have this Data Structure:

Database:
   X:{
     UserID:{
        UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
          x:"hello",
          y:"hey there!"
       }
        UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
          x:"what's up?",
          y:"Nothing Much"
       }
   }  
    UserID2:{
        UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
          x:"bye",
          y:"Have a nice day!"
       }
        UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
          x:"what's up?",
          y:"Nothing Much"
       }
   }  
}

And I'm trying to retrieve x and y into a FireBaseRecyclerAdapter, and it's not possible without making my own huge code. I'd love a feature like this; it'll make things much easier and will trim up my database.

Activity

  1. SUPERCILEX commented on Sep 6, 2016

    @SUPERCILEX
    SUPERCILEX
    on Sep 6, 2016
    Contributor
    More actions

    Check out this pull request: #276
    I think it could be what you are looking for: if you index your data, all you have to do is provide it a list of keys to get x and y. See the documentation: https://github.com/SUPERCILEX/FirebaseUI-Android/blob/7e2be3aed73735e3d4e1a318cf268a5c9db67475/database/README.md#using-firebaseui-with-indexed-data

    I think you would have to change your data structure to be something like this:

    message-keys: {
        uid1: {
            key1: true
            key2: true
        }
        uid2: {
            key1: true
            key2: true
        }
    }
    messages: {
        key1: {
            x: "bye"
            y: "Have a nice day!"
        }
        key2: {
            x: "what's up?"
            y: "Nothing Much"
        }
    }
    

    Then you would create a RecyclerView like so:

    new FirebaseRecyclerAdapter<Chat, ChatHolder>(Chat.class, android.R.layout.two_line_list_item, ChatHolder.class, ref.child("message-keys").child(uid), ref.child("messages"))

    Hope this helps!

  2. ghost closed this as completedon Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.