Body 1. Official website
Open source China Community afinal Project
2. Introduction
- Afinal is an android-SQLite Orm and IOC framework.
- It also encapsulates the HTTP framework in Android, making it easier to use and finalbitmap, regardless of the bitmap on Android
In the loading of the problem of oom and fast sliding when the picture loading position dislocation and so on.
- The purpose of afinal is to be concise and fast. The contract is larger than the configured way. Try to do everything in one line of code.
What is ORM?
Object-Relational mapping (English: Objects Relational Mapping, abbreviated ORM, or O/RM, or O/R Mapping) is a program technology that enables the conversion of data between different types of systems in an object-oriented programming language. In effect, it actually creates a "virtual object database" that can be used in a programming language.
See here for details.
What is the IOC?
Control inversion (inversion of the English abbreviation for IOC) is an important object-oriented programming principle to reduce the coupling problem of computer programs, and is also the core of the lightweight spring framework. Control reversals are generally divided into two types, dependency injection (Dependency injection, short di), and dependent lookup (Dependency lookup). The application of dependency injection is quite extensive.
See here for details.
3. The four modules currently afinal
- FINALDB module: The ORM Framework in Android, a line of code can be used for additional deletions and checks. Support one-to-many, many-to-one queries.
- Finalactivity module: The IOC framework in Android, which is fully annotated to enable UI binding and event binding. No need for Findviewbyid and Setclicklistener.
- Finalhttp module: Encapsulates HTTP data requests through httpclient, and supports AJAX-mode loading.
- Finalbitmap module: When loading the bitmap through Finalbitmap,imageview, there is no need to consider the phenomenon of image dislocation when the Oom and the Android container quickly slide during the bitmap loading process. Finalbitmap can configure the number of thread preempted threads, cache size, cache path, load display animation, etc. Finalbitmap's memory management uses the LRU algorithm, Not using weak references (after android2.3, Google has not recommended the use of weak references, android2.3 after the forced recovery of soft and weak references, details of the official Android document), better management bitmap memory. Finalbitmap can customize the downloader to extend other protocols to display network pictures, such as FTP. You can also customize the bitmap display, play animations when ImageView display pictures, and so on (default is the gradient animation display).
What is Ajax?
Ajax, "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), refers to a web development technique that creates interactive Web applications. AJAX enables Web pages to be updated asynchronously by exchanging small amounts of data in the background with the server. This means that you can update a part of a webpage without reloading the entire page.
See here for details.
What is the LRU algorithm?
LRU is the least recently used algorithm for least recently used. A page replacement algorithm for memory management, in which data blocks (memory blocks) that are not used in memory are called LRU, the operating system frees up space to load additional data based on what data belongs to the LRU and moves it out of memory.
See here for details.
4.FinalDB How to use
For more information about FINALDB, please click here
FinalDb db = FinalDb.create(this); new//这里需要注意的是User对象必须有id属性,或者有通过@ID注解的属性 user.setEmail("[email protected]"); user.setName("michael yang"); db.save(user);
5. How to use Finalactivity
- UI binding and event binding can be done in a fully annotated manner
- No need for Findviewbyid and Setclicklistener etc.
Public class afinaldemoactivity extends finalactivity { //No calls to Findviewbyid and Setonclicklistener etc. @ViewInject(id=r.id.button,click="Btnclick") button button;@ViewInject(Id=r.id.textview) TextView TextView; Public void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.main); } Public void Btnclick(View v) {Textview.settext ("Text Set Form button"); }}
What is a Java annotation?
- Annotations (Annotation), also called Meta data. A description of the code level. It is a feature introduced in JDK5.0 and later versions, with classes, interfaces, and enumerations at the same level. It can be declared in front of packages, classes, fields, methods, local variables, method parameters, and so on, to explain these elements, comments.
- Function Classification:
① Writing documents: Generating documents from the metadata identified in the code "generating document DOC Documents"
② Code Analysis: Parsing code with metadata identified in code "using reflection"
③ compile check: The metadata identified in the code allows the compiler to implement the basic compile check "Override"
See here for details.
6.FinalHttp How to use
Finalhttp fh =NewFinalhttp (); Fh.get ("Http://www.yangfuhai.com",NewAjaxcallback () {@Override Public void onloading(LongCountLongCurrent) {//Automatically callback once every 1 secondsTextview.settext (current+"/"+count); }@Override Public void onsuccess(String t) {Textview.settext (t==NULL?"NULL": t); }@Override Public void OnStart() {callback when HTTP request is started//}@Override Public void onfailure(Throwable T, String STRMSG) {//The callback when load fails}});
- Uploading files using finalhttp or submitting data to the server (POST method)
File upload to server, how to receive the server, please check here
Ajaxparamsparams=NewAjaxparams ();params. put ("username","Michael Yang");params. put ("Password","123456");params. put ("Email","[email protected]");params. put ("Profile_picture",NewFile ("/mnt/sdcard/pic.jpg"));//Upload files params. put ("Profile_picture2", InputStream);//Upload data stream params. put ("Profile_picture3",NewBytearrayinputstream (bytes));//Commit byte streamFinalhttp fh =NewFinalhttp (); Fh.post ("Http://www.yangfuhai.com",params,NewAjaxcallback () {@Override Public void onloading(LongCountLongCurrent) {Textview.settext (current+"/"+count);} @Override Public void onsuccess(String t) {Textview.settext (t==NULL?"NULL": t);} });
- To download a file using finalhttp:
Support breakpoint continuation, stop downloading task at any time or start task
Finalhttp fh =NewFinalhttp ();//Call the download method to start the downloadHttpHandler handler = Fh.download ("http://www.xxx.com/Download path/xxx.apk",//This is the path to download true,//true: The breakpoint continues to pass false: Continuous point continuation (new download) "/mnt/sdcard/testapk.apk",//This is the path saved to the local NewAjaxcallback () {@Override Public void onloading(LongCountLongCurrent) {Textview.settext ("Download Progress:"+current+"/"+count); }@Override Public void onsuccess(File t) {Textview.settext (t==NULL?"NULL": T.getabsolutefile (). toString ()); } });//Call the Stop () method to stop the downloadHandler.stop ();
7.FinalBitmap How to use
- Load network pictures on one line of code Fb.display (Imageview,url), more display overloads see Help documentation
PrivateGridView GridView;PrivateFinalbitmap FB;@Override protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (r.layout.images); gridview = (GridView) Findviewbyid (R.id.gridview); Gridview.setadapter (madapter); fb = Finalbitmap.create ( This);//Initialize the Finalbitmap moduleFb.configloadingimage (r.drawable.downloading);//Can be configured in other teens or not configured, and must call the init () function after configuration to take effect//fb.configbitmaploadthreadsize (int size)//fb.configbitmapmaxheight (bitmapheight)}///////////////////////////adapter getview//////////////////////////////////////////// PublicViewGetView(intPosition, View Convertview, ViewGroup parent) {ImageView IV;if(Convertview = =NULL{Convertview = View.inflate (bitmapcacheactivity). This, R.layout.image_item,NULL); iv = (ImageView) Convertview.findviewbyid (R.id.imageview); Iv.setscaletype (Scaletype.center_crop); Convertview.settag (iv); }Else{IV = (ImageView) convertview.gettag (); }//bitmap Load just this line of code, display and other overloads, see the source detailsFb.display (Iv,images.imageurls[position]);
8. Non-completion of the adjournment
"Afinal-Open source Android application Framework db module in detail" Stay tuned ~ ~ ~
afinal-Open Source Android application Framework Introduction