Copy the source code of the jiandan application client.

Source: Internet
Author: User

Copy the source code of the jiandan application client.

Download project source code:

Http://code.662p.com/view/10654.html

 


<Ignore_js_op>
<Ignore_js_op>

 

 

 

Project Overview

From the above, we can also see that we use the Material Design style, but it is not pure, in order to be compatible with 4. version x. We use Theme. appCampat is compatible with themes, RecycleView, and CardView. The overall visual effect is more unified and beautiful. At the same time, to achieve the overall effect, use the open-source project material-Dialogs to implement the Material Design effect dialog box, which is reflected in the click to reply and improve the personal information function.

In addition to the interface, I chose Volley for the network request framework, because Volley optimized the network operations with small data volumes and frequent requests. It is suitable for this project, as a recommendation project of Google, it is now well-developed and proven by many projects, so it is quite reassuring. In addition, the scalability is very strong, and we can customize our own Request Parsing requirements. I believe that my friends who have read this project should have some feelings. The request classes under the com.socks.jiandan.net package have all been customized by me, easy to use. It is also important that Volley is implemented based on HttpURLConnection encapsulation after 2.3. By default, gzip compression is supported, and result caching is also supported in Versions later than 4.0, therefore, the performance and data transmission volume are greatly improved compared with HttpClient.

An important function in this project is to load images. Therefore, pay special attention to the image loading framework. The image loading framework I selected at the beginning was Fresco. It was very powerful because I have translated articles about Fresco features before, so I 'd like to give it a try. However, I still encountered a lot of problems in later use, so I had to temporarily abandon Fresco and switch to UIL. The reason is as follows:

  • The launch time is too short. Although it is powerful, it has not been tested yet and is not very mature. Fresco updated frequently. I started to use version 0.1.0. Later I encountered a problem when loading images. In this version, Fresco did not process images with 304 cached, therefore, an error occurs when loading such images. After I submit an issue to the Fresco project, they reply to me. Fresco has upgraded and fixed the problem in 0.2.0. Therefore, I think it will take some time for Fresco to test and improve it before it can be used in the production environment. Now, I do not recommend that you use it in projects.
  • Wrap_content is not supported. One important reason for giving up Fresco is that it does not support wrap_content. Fresco only supports match and fixed length and width. In this project, a large number of images with varying width and height must be displayed, because Fresco controls for displaying images are also customized by itself, it is difficult to define the controls. Without a better solution, I decided to temporarily abandon Fresco and switch to UIL. In this project, Fresco is used only for the profile picture on the comment list page, and UIL and custom controls are used in other places. The specific implementation scheme will be discussed below.

In the selection of IOC framework, butter knife has always been used for AFinal, but AFinal is bound during runtime, which will affect the performance. butter knife is bound during compilation and will not be affected. It is very convenient to use butter knife. In this project, I feel that I don't really need IOC. I just want to try it. I don't have to go into it.

When switching the network status, You need to register a network status listener in MainActivity to notify the currently displayed Fragment to switch the image loading mode when the network status changes, or the network status changes. In this case, you can use interfaces. Each Fragment implements an interface of MainActivity. When the network status changes, MainActivity calls the Fragment interface method. However, this is not only troublesome, but also increases coupling. For this reason, I used EventBus to complete this function, and the implementation is very simple. You can check the source code and the coupling degree is 0.

All data interfaces in this project are basically in Json format, so it is very important to select a good parsing framework. I have written three articles to introduce different Json parsing methods. Although Jackson is fast in parsing, gson is familiar with it, and the amount of data to be parsed is not large, performance differences are minimal, so I chose gson, which I am familiar. Some JSON files are also used in some parsing areas, so you can choose from them.

  • Json
  • Gson
  • Jackson

Http://android.662p.com/thread-6263-1-1.html


 

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.