Chapter II Design and reconstruction of the app framework

Source: Internet
Author: User
Tags local time

Response Standard Format:

{    "IsError":false,    "ErrorType": 0,    "errormessage": "Network Exception",     "result": ""}

{   "errormessage": "Network Exception",   "ErrorType": 0,   false,   " Result " : {      " Cinemaid ": 1,      " Cinemaname ":" Star Beauty "   }}

  Disadvantages of Ansytask:
    1. There is no flexibility to control the thread pool inside it.
    2. There is no method of exposing the cancellation request, which causes the task queue to block.
 How to use the thread pool +runnable+handler:The successful failure of the callback in the base class, the common processing to encapsulate, in fact, commonly used network framework such as volley,okhttp,ansy_http_client can be handled this way. If there is a special case, you can do special processing by overriding the callback inside the base class. There is also the Load Network Data dialog box can also be in the base class through the method to display, hidden control, such as in Onbefore () display, in OnError () or onfinish () and Onresponse () inside the dialog box to hide.  app data cache:
  1. In this regard, this book should be about interface optimization and network optimization knowledge:
  2. The data of an app page is returned through an interface, and there is no need to set up multiple interfaces to get it.
  3. cache processing of the returned data (only for [get] the data obtained , the data is not modified for [post]. Of course, before doing the cache, consider whether the current business is suitable for caching, such as some of the more expensive operations or page displays.
  4. The cache address is generally chosen as the SD card cache.
  5. The underlying package is based on the URL as a key to determine whether the cache exists, if present, to return the cached data, otherwise according to the URL to make the request.
 The app auto sign-in function realizes:
    1. Do not save the user name, password, or if you want to save it, be sure to encrypt it to handle it.
    2. Use of cookies (tokens) as an indication of user uniqueness. (That's how we do it.)
      1. user-related, with cookies, unrelated, server can control without checking cookies .
      2. Logout function, clear local cookie (token).
      3. The cookie expires, enters the login interface, and returns to the previous page for re-operation. (or it needs to be handled in the place of the underlying callback)
 prevent hackers from swiping libraries:The use of verification code for anti-brush, if the same IP frequently access the same interface, the login interface has entered a verification code, or pop-up code to enter the floating window.  time calibration, turn on gzip compression:How to update the local time and server times difference:https://github.com/icodeu/AppProgrammingSource/blob/master/2.5.2%20%E6%97%B6%E9%97%B4%E6%A0%A1%E5%87%86/ Androidlib/src/com/infrastructure/net/httprequest.java 

Chapter II Design and reconstruction of the app framework

Related Article

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.