Android development framework FastAndroid details, androidfastandroid
Project: https://github.com/huntermr/FastAndroid
For many beginners of Android development, there are many problems, such: image loading, OOM, network access, database operations, json parsing, and so on will go a lot of the way. For the purpose of leading beginners into the Android development path, the common development frameworks on the market are both complicated and difficult to understand, or the performance optimization is not good enough; therefore, the author has integrated open-source projects with good performance in all aspects on the market and added the mvp model, enabling beginners to develop robust and complete projects.
Project Introduction:
This framework integrates network access, database operations, image loading (no need to worry about OOM) and cache, json parsing, View Annotation
The project architecture adopts the MVP mode, which greatly decouples views and models. You can View the source code by using instructions in the project.
Integrated open-source projects:
Network Access: Volley, Xutils-http Module
Database: GreenDao (for how to use GreenDao, visit http://blog.csdn.net/ht_android/article/details/44782539)
Image loading and caching: universal-image-loader
Json parsing: Gson
View annotation: butterknife
Package Structure:
Com. android. volley: Volley related, added support for cookies
Com. example. android: Framework subject
Com. example. android. adapter: stores custom adapters.
Com. example. android. app: global configuration and files of the project
-- AppManager: Custom Activity stack management class
-- Constants: stores global variables.
-- MyApplication: Custom Application for initialization
-- Setting: Public parameter configuration, which encapsulates SharedPreferences
Com. example. android. async: stores custom AsyncTask
Com. example. android. base: stores base-class files.
-- BaseActivity: Base Activity. All activities are inherited and can be modified on your own.
-- BaseResponse: The base class response class, used to verify the server's response and parse data
-- IBaseView: All View interfaces inherit this interface for some common View operations.
Com.example.android.bean.net: Network Access bean
-- Request: network access request bean
-- Response: Network Access response bean
Com. example. android. dao: encapsulate database operations
Com. example. android. exception: exception capture class
Com. example. android. listener: stores the Presenter listener.
Com. example. android. model: interface for storing data logical processing
-- Impl: stores model implementation classes.
Com.example.android.net: network access related
-- NetCenter: encapsulates common network access operations and encapsulates all network interfaces for unified calls.
-- StringPostRequest: Custom Volley Request, method for receiving post parameters for rewrite
-- URLs: the Url access path.
Com. example. android. presenter: store Presenter
Com. example. android. ui: stores Activity and custom views.
-- Custom: stores custom views.
Com. example. android. utils: Common Tools
Com. example. android. view: stores the view Interface.
Com. lidroid. xutils: Xutils-http Module
Framework usage:
For the Mvp mode, the main purpose is to decouple and separate the logic. Otherwise, some beginners can easily write a lot of code in an Activity, and the maintainability of the Project is simply broken down.
Presenter:Write different Presenter for different modules. This class is similar to the Controller in mvc, But it ensures that the view and model cannot be accessed directly. The Presenter receives the View Interface and instantiates the Model. When the corresponding method in the Model is called, callback can be passed in.
View:Define the View interface, and then the Activity implements the methods in the interface, and instantiate the Presenter. The view Interface must be passed in during instantiation. When a user triggers an operation such as clicking a button, the user starts to call the corresponding methods of the Presenter for processing. After the processing of the Presenter is complete, the method that has implemented the View Interface is called.
Model:Receives the corresponding callback of the Presenter. After processing the data logic, call this callback to return data to the Presenter.
The above is the general usage of mvp in the framework. For other aspects, please refer to the source code or relevant materials.