How to realize the function of the circle of friends in the app seven quick implementation pull-up load friends circle function--arrow buckle technology Arrownock

Source: Internet
Author: User

How to realize the function of the circle of friends in the app seven quick implementation pull-up to load the Friends circle function

Logic Analysis:

Take out the last piece of data in the cache postlist postlist

A. If the lastpost exists, the data in the cache is present, then the closest latestpost to the lastpost time in the database is removed, and the server takes the limit bar (such as 10) data with their created_at as the critical query condition:

1. If the number of posts returned by the server is greater than 0, post is stored in the database and two query actions are required:


    • Query out the new like and comment: According to the latest like created_at in the local database and the latest comment created_at as Begin_time go to the server to get like and comment.



    • Query out the comment and like of the limit bar post obtained from the server: According to PostID from the server to query out comment and as, the loaded data into the database, and so all loaded, refresh the interface.


2. If the data returned by the server equals 0, the server does not have this intermediate data, the remaining data is taken from the local database, the limit bar data is removed from the local database, and then according to the latest like created_ in the local database At and the latest comment created_at as Begin_time go to the server to get like and comment, all loaded, refresh the interface.

B. If lastpost does not exist, the cache postlist no data, do not do any action, refresh the interface prompts no more messages.

Implementing the Logic code:

Take the Android system as an example:

    //  Get Next page post    private void getnextpagedata ()  {        Post lastPost = null;         Post latestPost = null;         if  (Null != postlist && !postlist.isempty ())  {             lastpost = postlist.get (PostList.size ()  - &NBSP;1);         }        //   If lastpost exists, obtain post        if  from the server (null !=  Lastpost)  {            // Remove the latestpost             that is closest to the lastpost time in the database Latestpost = posthelper.getlatestpostbytiMe (Lastpost.createdat);             map<string,  object> params = loadgetnextquerypostparams (lastpost,latestpost);             try {                 ansocial.sendrequest ("Posts/query.json",  ansocialmethod.get, params,                                                           new iansocialcallback ()  {                      @Override         &nbsP;            public void onsuccess ( Final jsonobject response)  {                         try {                              jsonobject meta =response.getjsonobject ("meta");                              int total = meta.getint ("Total");                              jsonarray postsjson= response.getjsonobject (" Response ")                                  .getjsonarray ("posts");                              //  if the number of post is greater than or equal to limit                              if  (total > 0)  {                                  //  Deposit Database                                   saveposttODB (Postsjson);                                  Postlist.addall (temppostlist);                                  //  based on the createdat          according to Latestlike and Latestcomment                         //  get like and comment                                  //  remove like and comment         according to PostID                          Loadlikeandcommentbylatestdata ();                                  } else {                                      //  Get Cache postlist lastpost time from database post      of limit quantity                                 getpostfromdbbytime (POST_LIMIT,  postList                                          .get (Postlist.size ()  - 1));                                      //  according to Latestlike and Latestcomment's createdat                                      //  get like and comment, refresh                                       Loadlikeandcommentbylatestdata (True);                                 }                          } catch  (exception e)  {                         }                      }                      @Override                      public void onfailure (Jsonobject response)  {                      }                });             } catch  (arrownockexception e)  {             }         }       //  If Lastpost does not exist, do nothing         else {            runonuithread ( New runnable ()  {                  @Override                  public void run ()  {                     mpullrefreshlistview.onrefreshcomplete ();                 }             });         }    }



How to implement the Circle of Friends feature in the App series article:

A brief analysis of the realization principle of circle of friends

Second, quickly realize the customization of user information

Three quick realization of two-way friend function

Four in the circle of friends to add the Send picture function

Five likes, comments attribute detailed analysis

The six-speed implementation of the pull-down load friend circle function

Seven fast implementation of pull-up load friends circle function

The logic and implementation of the eight page load function



This article from "Arrow Buckle technology Arrownock" blog, reproduced please contact the author!

How to realize the function of the circle of friends in the app seven quick implementation pull-up load friends circle function--arrow buckle technology Arrownock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.