Project: Https://github.com/huntermr/FastAndroid
Foreword: For many Android development beginners, there are many places will make people headache, such as: Picture loading, OOM, network access, database operations, JSON parsing and so on because unfamiliar so will go a lot of fruitless. For the purpose of leading beginners to the Android development path, considering the common development framework found in the market, is either more complex or not good enough for performance optimization, so the author will be on the market in all aspects of the good performance of the Open source project integration, added the MVP model, So that beginners can develop a more robust and well-developed projects.
Project Description:
This framework integrates network access, database operations, picture loading (no need to worry about Oom) and caching, JSON parsing, view annotations
The project architecture uses the MVP model, great for view and model decoupling, the project with the use of instructions to view the source code can be
integrated Open-source projects:
Network access: Volley, Xutils-http module
Database: Greendao (for Greendao use, please visit http://blog.csdn.net/ht_android/article/details/44782539)
Picture loading and caching: Universal-image-loader
JSON parsing: Gson
View Annotations: Butterknife
Package Structure:
Com.android.volley:Volley related, added support for cookies
Com.example.android: Frame Body
Com.example.android.adapter: Store Custom Adapter
Com.example.android.app: Some of the global configuration and documentation for the project
--appmanager: Custom activity Stack Management class
--constants: Storing global variables
--myapplication: Custom application for initialization operations
--setting: Public parameter configuration, encapsulating the Sharedpreferences
Com.example.android.async: Store Custom Asynctask
Com.example.android.base: Storing base class files
--baseactivity: base class activity, all activity inherited from this, can be modified by itself
--baseresponse: base class response class for validating server responses and parsing data
--ibaseview: All view interfaces inherit this interface for some common view operations
Com.example.android.bean.net: Bean for network access
--request: Network access Request Bean
--response: Network access response bean
Com.example.android.dao: Encapsulating Database Operations
Com.example.android.exception: Exception Capture class
Com.example.android.listener: Storage of presenter monitoring
Com.example.android.model: Storing Data logic processing interface
--impl: Storing the Model implementation class
Com.example.android.net: Network access related
--netcenter: Encapsulates network access common operations, encapsulating all network interfaces in this package for unified invocation
--stringpostrequest: Custom volley request, replication receive post parameter method
--urls: Storing URL access paths
Com.example.android.presenter: Storage Presenter
Com.example.android.ui: Store activity, customize view, and more
--custom: Store a custom view
Com.example.android.utils: Common Tool class
Com.example.android.view: Storing the View interface
Com.lidroid.xutils:xutils-http Module
How to use the framework:
For the MVP model, the main purpose is to understand the decoupling, the logic is separated out, otherwise some beginners very easy to write a lot of code in an activity, the project maintainability is simply a crash.
Presenter: write different Presenter for different modules, this class is similar to the controller in MVC, but he can guarantee that there is no direct access between the view and the model. The view interface is received in presenter and the model is instantiated, and the callback can be passed in when the corresponding method in the model is called.
View: defines the interface of the view, then the activity implements the method in the interface and instantiates the presenter, which needs to be passed into the view interface when instantiated. When the user triggers an action, such as clicking a button, the corresponding method of presenter is called to proceed, and the method of implementing the view interface is called after the presenter processing is completed.
Model: receives the corresponding callback for the presenter, when the data logic is processed, the callback is called to return the data to presenter.
The above is about the framework of the approximate use of the MVP, other aspects please self-check the source code or access to relevant information.
Android Development Framework Fastandroid detailed