Android Paging Library: how to show related item if it's not in local database yet and don't break paging?How do I add a library project to Android Studio?Firebase database how to create list from nodes like WhatsApp Chats pageAndroid Paging library doesn't fire loadAfter()showing a progress bar with android paging libraryUpdating PagedListAdapter after initial load to show latest network dataDownload only part of Database reference in Firebase?Relations in Room databaseIs it possible to implement realtime paging(aac library) with room?Efficient way to implement paging with caching data and favourites system in AndroidHow to sync local database with remote server using Android Paging Library?

What was the role of Commodore-West Germany?

Why does capacitance not depend on the material of the plates?

split large formula in align

print field before and after matching pattern of single line

List: Behavioural characteristics of key Ito processes used in finance

Only charge capacitor when button pushed then turn on LED momentarily with capacitor when button released

Probably terminated or laid off soon; confront or not?

Is there a way to improve my grade after graduation?

Remove ticks from chart labels

How to check a file was encrypted (really & correctly)

How and where to get you research work assessed for PhD?

Could an areostationary satellite help locate asteroids?

If the interviewer says "We have other interviews to conduct and then back to you in few days", is it a bad sign to not get the job?

Tile the chessboard with four-colored triominoes

Can attackers change the public key of certificate during the SSL handshake

The Game of the Century - why didn't Byrne take the rook after he forked Fischer?

The meaning of "scale" in "because diversions scale so easily wealth becomes concentrated"

Definitional equality of two propositions about propositional equality

Why do dragons like shiny stuff?

What is the probability of a biased coin coming up heads given that a liar is claiming that the coin came up heads?

Why did the US Airways Flight 1549 passengers stay on the wings?

Does the length of a password for Wi-Fi affect speed?

Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday

Write The Shortest Program To Check If A Binary Tree Is Balanced



Android Paging Library: how to show related item if it's not in local database yet and don't break paging?


How do I add a library project to Android Studio?Firebase database how to create list from nodes like WhatsApp Chats pageAndroid Paging library doesn't fire loadAfter()showing a progress bar with android paging libraryUpdating PagedListAdapter after initial load to show latest network dataDownload only part of Database reference in Firebase?Relations in Room databaseIs it possible to implement realtime paging(aac library) with room?Efficient way to implement paging with caching data and favourites system in AndroidHow to sync local database with remote server using Android Paging Library?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm writing chat app. Messages are load by pages (item keyed - message_id) using Android Paging Library. Also there is "reply" feature, which mean users can reply to any message in chat. In RecyclerView it should looks like that:



Part of message which was replied...
------------------------------------
Main message text


It is simple, when related message is already in local database. I can fetch all data from database and show it in app. But there can be situations when replied message is NOT in local database (for example, this is old message and we just installed app - database is empty). And message looks bad, until replied message won't be stored in local database:




------------------------------------
Main message text


What I've tried: if message's property reply_to is not null I load replied message from remote server by this id and store it in local database. Room react to changes and display all content fine. But this replied message become last in my messages array and BoundaryCallback load messages after that replied message skipping messages between REAL last message and that replied message.



For example, I have messages with ids 1..100.



(boundary callback makes initialLoad, say 20 items)
1 message
2 message
..
10 message with reply to 50 message (load message 50 and store it in db)
11 message
..
(early loaded messages)
..
20 message
(this should be end, but this is not because of 50 message which is stored in local database now)
50 message
(bounary callback makes loadAfter new items by key - message id)
51 message
..


So, we lost part of messages from 21 to 49.



Message room entity has following properties:



@Entity
class Message
var id: Int
var text: String
var reply_to: Int?



MessageModel is returned by Room by relation and used in PagedAdapter



class MessageModel 
var message: Message
var repliedMessage: Message



How can I show replied message and don't break paging?
How it should be done in right way?










share|improve this question
































    0















    I'm writing chat app. Messages are load by pages (item keyed - message_id) using Android Paging Library. Also there is "reply" feature, which mean users can reply to any message in chat. In RecyclerView it should looks like that:



    Part of message which was replied...
    ------------------------------------
    Main message text


    It is simple, when related message is already in local database. I can fetch all data from database and show it in app. But there can be situations when replied message is NOT in local database (for example, this is old message and we just installed app - database is empty). And message looks bad, until replied message won't be stored in local database:




    ------------------------------------
    Main message text


    What I've tried: if message's property reply_to is not null I load replied message from remote server by this id and store it in local database. Room react to changes and display all content fine. But this replied message become last in my messages array and BoundaryCallback load messages after that replied message skipping messages between REAL last message and that replied message.



    For example, I have messages with ids 1..100.



    (boundary callback makes initialLoad, say 20 items)
    1 message
    2 message
    ..
    10 message with reply to 50 message (load message 50 and store it in db)
    11 message
    ..
    (early loaded messages)
    ..
    20 message
    (this should be end, but this is not because of 50 message which is stored in local database now)
    50 message
    (bounary callback makes loadAfter new items by key - message id)
    51 message
    ..


    So, we lost part of messages from 21 to 49.



    Message room entity has following properties:



    @Entity
    class Message
    var id: Int
    var text: String
    var reply_to: Int?



    MessageModel is returned by Room by relation and used in PagedAdapter



    class MessageModel 
    var message: Message
    var repliedMessage: Message



    How can I show replied message and don't break paging?
    How it should be done in right way?










    share|improve this question




























      0












      0








      0








      I'm writing chat app. Messages are load by pages (item keyed - message_id) using Android Paging Library. Also there is "reply" feature, which mean users can reply to any message in chat. In RecyclerView it should looks like that:



      Part of message which was replied...
      ------------------------------------
      Main message text


      It is simple, when related message is already in local database. I can fetch all data from database and show it in app. But there can be situations when replied message is NOT in local database (for example, this is old message and we just installed app - database is empty). And message looks bad, until replied message won't be stored in local database:




      ------------------------------------
      Main message text


      What I've tried: if message's property reply_to is not null I load replied message from remote server by this id and store it in local database. Room react to changes and display all content fine. But this replied message become last in my messages array and BoundaryCallback load messages after that replied message skipping messages between REAL last message and that replied message.



      For example, I have messages with ids 1..100.



      (boundary callback makes initialLoad, say 20 items)
      1 message
      2 message
      ..
      10 message with reply to 50 message (load message 50 and store it in db)
      11 message
      ..
      (early loaded messages)
      ..
      20 message
      (this should be end, but this is not because of 50 message which is stored in local database now)
      50 message
      (bounary callback makes loadAfter new items by key - message id)
      51 message
      ..


      So, we lost part of messages from 21 to 49.



      Message room entity has following properties:



      @Entity
      class Message
      var id: Int
      var text: String
      var reply_to: Int?



      MessageModel is returned by Room by relation and used in PagedAdapter



      class MessageModel 
      var message: Message
      var repliedMessage: Message



      How can I show replied message and don't break paging?
      How it should be done in right way?










      share|improve this question
















      I'm writing chat app. Messages are load by pages (item keyed - message_id) using Android Paging Library. Also there is "reply" feature, which mean users can reply to any message in chat. In RecyclerView it should looks like that:



      Part of message which was replied...
      ------------------------------------
      Main message text


      It is simple, when related message is already in local database. I can fetch all data from database and show it in app. But there can be situations when replied message is NOT in local database (for example, this is old message and we just installed app - database is empty). And message looks bad, until replied message won't be stored in local database:




      ------------------------------------
      Main message text


      What I've tried: if message's property reply_to is not null I load replied message from remote server by this id and store it in local database. Room react to changes and display all content fine. But this replied message become last in my messages array and BoundaryCallback load messages after that replied message skipping messages between REAL last message and that replied message.



      For example, I have messages with ids 1..100.



      (boundary callback makes initialLoad, say 20 items)
      1 message
      2 message
      ..
      10 message with reply to 50 message (load message 50 and store it in db)
      11 message
      ..
      (early loaded messages)
      ..
      20 message
      (this should be end, but this is not because of 50 message which is stored in local database now)
      50 message
      (bounary callback makes loadAfter new items by key - message id)
      51 message
      ..


      So, we lost part of messages from 21 to 49.



      Message room entity has following properties:



      @Entity
      class Message
      var id: Int
      var text: String
      var reply_to: Int?



      MessageModel is returned by Room by relation and used in PagedAdapter



      class MessageModel 
      var message: Message
      var repliedMessage: Message



      How can I show replied message and don't break paging?
      How it should be done in right way?







      android kotlin android-room android-paging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 3:51







      LIFED

















      asked Mar 26 at 10:30









      LIFEDLIFED

      1091 silver badge10 bronze badges




      1091 silver badge10 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1














          I found a solution. In my case I have created additional table RepliedMessage (which is an absolute copy of Message) and I store replied messages in that table. Pagination works perfectly. We only need to keep RepliedMessages up to date.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354927%2fandroid-paging-library-how-to-show-related-item-if-its-not-in-local-database-y%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I found a solution. In my case I have created additional table RepliedMessage (which is an absolute copy of Message) and I store replied messages in that table. Pagination works perfectly. We only need to keep RepliedMessages up to date.






            share|improve this answer





























              1














              I found a solution. In my case I have created additional table RepliedMessage (which is an absolute copy of Message) and I store replied messages in that table. Pagination works perfectly. We only need to keep RepliedMessages up to date.






              share|improve this answer



























                1












                1








                1







                I found a solution. In my case I have created additional table RepliedMessage (which is an absolute copy of Message) and I store replied messages in that table. Pagination works perfectly. We only need to keep RepliedMessages up to date.






                share|improve this answer













                I found a solution. In my case I have created additional table RepliedMessage (which is an absolute copy of Message) and I store replied messages in that table. Pagination works perfectly. We only need to keep RepliedMessages up to date.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 29 at 5:22









                LIFEDLIFED

                1091 silver badge10 bronze badges




                1091 silver badge10 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354927%2fandroid-paging-library-how-to-show-related-item-if-its-not-in-local-database-y%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript