Project Source Download:
Http://code.662p.com/view/10654.html
<ignore_js_op>
<ignore_js_op>
Overall introduction of the project
As can be seen from the above, we use the material design style, but not pure, in order to be compatible with the 4.x version, we use Theme.appcampat compatible themes, Recycleview and CardView to complete, From the overall visual effect to look more unified and beautiful. At the same time for the overall effect, the use of open source project Material-dialogs to achieve the material design effect of the dialog box, this in the click Reply, improve the personal information function point is reflected.
In addition to the interface, the network request framework I choose is volley, the reason is that the volley of small data volume, the request of the network operation is optimized, for this project is more appropriate, and as Google's recommended projects, now has been perfected more mature, after a lot of projects to verify the actual, So it's more reassuring. And extensibility is very strong, you can customize our own request resolution requirements, this is believed to have seen my project friends, should have feelings, in the com.socks.jiandan.net package of the request class have been my custom, easy to use. It is also important to note that the volley is based on the HttpURLConnection package implementation after 2.3, the default support gzip compression, after the 4.0 version, also supports the result cache, so in the performance and data transmission volume, compared to httpclient a great improvement.
One of the most important features in this project is loading images, so you need to pay special attention to the picture loading framework. Initially I chose the picture loading frame is fresco, because previously translated about fresco features of the article, feel very strong, so want to try. But in the later use, still encountered a lot of problems, so I have to temporarily give up fresco, instead of UIL. The reasons are as follows:
- Launch time is too short, although powerful, but has not been tested, not very mature. The fresco is updated very quickly, I began to use the time is 0.1.0 version, later in loading the picture when encountered problems, in this version, Fresco did not have 304 cached image processing, so when loading this kind of picture will fail, I give Fresco project submitted issue after they reply to me, Fresco has upgraded, in 0.2 .0 A problem fix was completed. So I think, Fresco still need a time to test and perfect, can be used in production environment, now I do not recommend that you use in the project
- Wrap_content is not supported. A very important reason to give up fresco is because it does not support Wrap_content,fresco only support match and fixed length width, in this project need to show a lot of width match, highly variable picture, because fresco display the picture of the control is also custom-made, So the custom control this road is also more difficult to go, in the absence of a better solution, I decided to temporarily abandon fresco, instead of UIL. In this project, only the avatar on the Comment list page is used by the fresco, and the other places are implemented using UIL and custom controls, and the implementation scenario I'll cover below.
In the IOC framework of choice, using butter knife, previously used afinal, but afinal belong to the runtime binding, will affect performance, butter knife is a compile-time binding, will not affect. It is very convenient to use butter knife and it is easy to use. In this project, I do not really feel the need for IOC, just a try, do not have to delve into.
In the completion of the network status switch function, you need to register a network state listener in Mainactivity, when the network status changes, notify the current display of the fragment switch the load mode of the picture, or to indicate the network status changes. In this demand, the use of interfaces can be done, each fragment to implement a mainactivity interface, when the network state changes, Mainactivity call Fragment interface method can be. But this is not only troublesome, and will increase the coupling, for this, I use Eventbus to complete this function, the implementation is very simple, we see the source code can be, coupling degree of 0.
All the data interfaces in this project are basically JSON format, so it is important to choose a good parsing framework. I've written three articles about the different parsing methods of JSON, although Jackson's parsing speed is fast, but Gson is really familiar with, and we have to parse the amount of data is not large, the performance of the difference is very small, so I chose my more familiar gson. In some parts of the resolution, some JSON is used, which is freely available to all.
Detailed Description: http://android.662p.com/thread-6263-1-1.html
Imitation fried egg Jiandan application Client source code