android--Rapid Development Framework Afinal

Source: Internet
Author: User

Afinal Introduction
    • Afinal is an Android-SQLite ORM and IOC framework. It also encapsulates the HTTP framework in Android, making it easier to use;

    • With Finalbitmap, there is no need to consider the problem of Oom when the bitmap is loaded in Android and when the image loading position is misplaced when fast sliding.

    • 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.

Currently Afinal has four main modules:
  • 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).

The following permissions are required to use the Afinal rapid development Framework:

<uses-permission android:name= "Android.permission.INTERNET"/><uses-permission android:name= " Android.permission.WRITE_EXTERNAL_STORAGE "/>

    • The first one is to access the network

    • The second one is to visit sdcard

    • Access to the network is requested when the network image needs or HTTP data requests, access to SDcard is the need for picture caching.

Finaldb How to use

For more information about FINALDB, please click here

FINALDB db = Finaldb.create (this); User user = new user (); It is important to note that the user object must have an id attribute, or a property user.setemail ("[email protected]") with the @id annotation, user.setname ("Michael Yang");d B.save ( user);
Finalactivity How to use:
    • Fully annotated to enable UI binding and event binding

    • No Findviewbyid and Setclicklistener, etc.

public class Afinaldemoactivity extends Finalactivity {     //do not need to call the Findviewbyid and Setonclicklistener    @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");}    }

Finalhttp How to use: Normal Get method
Finalhttp fh = new Finalhttp (); Fh.get ("http://www.yangfuhai.com", new Ajaxcallback () {     @Override public    Void Onloading (Long count, long current) {//Every 1 seconds is automatically callback once Textview.settext (current+ "/" +count);    }     @Override public    void onsuccess (String t) {textview.settext (t==null? ") Null ": t);    }     @Override public    void OnStart () {////Start HTTP request callback    }     @Override public    void OnFailure (Throwable t, String strMsg) {//load failed when callback    }});

Uploading files using finalhttp or submitting data to the server (POST method)

File upload to server, how to receive the server, please check here

Ajaxparams params = new Ajaxparams ();  Params.put ("username", "Michael Yang");  Params.put ("Password", "123456");  Params.put ("Email", "[email protected]");  Params.put ("Profile_picture", New File ("/mnt/sdcard/pic.jpg")); Upload file  params.put ("Profile_picture2", inputstream);//Upload data stream  params.put ("Profile_picture3", new Bytearrayinputstream (bytes)); Commit byte stream   finalhttp fh = new Finalhttp ();  Fh.post ("http://www.yangfuhai.com", params, new Ajaxcallback () {@Overridepublic void onloading (Long count, long current {    Textview.settext (current+ "/" +count);} @Overridepublic 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 = new Finalhttp ();      Call the download method to start downloading    HttpHandler handler = fh.download ("http://www.xxx.com/Download Path/xxx.apk",//here 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    new Ajaxcallback () {      @Override Public      void Onloading (Long count, long current) {   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 downloading   handler.stop ();

Finalbitmap How to use

Load network pictures on one line of code Fb.display (Imageview,url), more display overloads see Help documentation

Private GridView GridView;    Private Finalbitmap 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 Finalbitmap module fb.configloadingimage (r.drawable.downloading);//You can configure other teenagers here, It is also possible to use the Init () function after configuration without configuration, only to take effect//fb.configbitmaploadthreadsize (int size)//fb.configbitmapmaxheight (bitmapheight)}/ Adapter getview////////////////////////////////////////////public View getView (int    Position, 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 there are other overloads, details view Source fb. Display (iv,images.imageurls[position]); 





android--Rapid Development Framework Afinal

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.