- 
                Notifications
    
You must be signed in to change notification settings  - Fork 287
 
Lazily load list #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Lazily load list #350
Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8325a2c
              
                Code snippet for Compose doc at https://developer.android.com/quick-g…
              
              
                thedmail ccf9d11
              
                Adds empty Modifiers to function signatures that had no Modifiers bef…
              
              
                thedmail a9bbe00
              
                Apply Spotless
              
              
                thedmail 65fb7b5
              
                Corrects region tags for includecode widget.
              
              
                thedmail bd71f12
              
                Merge remote-tracking branch 'origin/lazily-load-list' into lazily-lo…
              
              
                thedmail f1ba73a
              
                Added sender and text to Message class.
              
              
                riggaroo 13a1642
              
                Merge branch 'main' into lazily-load-list
              
              
                riggaroo 4b1c549
              
                Apply Spotless
              
              
                riggaroo File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Because there's no actual message class anywhere that has a sender or text property, and this example was too complex for me to set something up idiomatically (at least in a time-efficient way).
If you feel it's necessary to have this in code, could I ask you to implement it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a simple class to represent the message structure is a common practice in DAC snippets. It helps make the code compile and snippets readable instead of the code being commented out.
While it's not strictly necessary for this particular example as you could just put a
Text("Lazy list text"), it could be a good opportunity to practice this pattern, as it's frequently used in other snippets and real-world scenarios.Would you be open to giving it a try? I'm happy to provide guidance and support if you need it.
Something like a dummy class like this would match this fake class:
data class Message(sender: String, text: String)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure--thank you for helping me learn!!
There's actually a reason why I didn't go ahead and create a data class as you're suggesting. What has me a little mixed-up are these lines:
lazyPagingItems = pager.flow.collectAsLazyPagingItems()
message = lazyPagingItems[index]
So I don't see how I can make message be an object of a new data class (such as I'd create) when it's already a variable set equal of LazyPagingItems type.
This was the complexity that stopped me from just defining my own class, and instead had me resort to commenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tyvm