Afinal and afinal frameworks

Source: Internet
Author: User

Afinal and afinal frameworks

1. annotation Function

1) Inheritance: FinalActivity (you need to copy afinal_0.5.1_bin.jar to lib)

2) @ ViewInject ()

public class AfinalActivity extends FinalActivity {    @ViewInject(id=R.id.bt_afinal_loadimage,click = "bt_afinal_loadimage_click")    private Button bt_afinal_loadimage;    .....}

  

2. image loading

FinalBitmap finalBitmap = FinalBitmap. create (this); // The finalBitmap of the image displayed by default when the network requests an image. configLoadingImage (R. drawable. atguigu_logo); // starts to load the finalBitmap image. display (iv, "http://img5.mtime.cn/mg/2016/10/11/160347.30270341.jpg ");

 

3. Request text data

FinalHttp finalHttp = new FinalHttp (); String url = "http://api.m.mtime.cn/PageSubArea/TrailerList.api"; finalHttp. get (url, new AjaxCallBack <Object> () {@ Overridepublic void onStart () {TV _afinal_result.setText ("Start loading"); super. onStart () ;}@ Overridepublic void onSuccess (Object o) {// display the result TV _afinal_result.setText (o. toString (); super. onSuccess (o) ;}@ Overridepublic void onFailure (Throwable t, int errorNo, String strMsg) {TV _afinal_result.setText ("loading failed"); super. onFailure (t, errorNo, strMsg );}});

  

4. File Download

FinalHttp finalHttp = new FinalHttp (); // request the address of the network resource String url = "http://vfx.mtime.cn/Video/2016/10/11/mp4/161011092841270064_480.mp4"; // store the video file to the local location String target = getFilesDir () + "/afinalmusic.mp4"; finalHttp. download (url, target, new AjaxCallBack <File> () {@ Overridepublic void onSuccess (File file File) {TV _afinal_result.setText ("File downloaded successfully"); super. onSuccess (file) ;}@ Overridepublic void onFailure (Throwable t, int errorNo, String strMsg) {TV _afinal_result.setText ("file Download failed"); super. onFailure (t, errorNo, strMsg) ;}@ Overridepublic void onStart () {TV _afinal_result.setText ("START download"); super. onStart ();}});

  

5. File Upload

FinalHttp finalHttp = new FinalHttp (); // String url = "http: // 192.168.0.103: 8080/FileUpload/FileUploadServlet "; ajaxParams params = new AjaxParams (); // obtain the local resource to be uploaded. try {params. put ("File", new File (getFilesDir () + "/afinalmusic.mp4");} catch (FileNotFoundException e) {e. printStackTrace ();} finalHttp. post (url, params, new AjaxCallBack <Object> () {@ Overridepublic void onStart () {TV _afinal_result.setText ("START upload"); super. onStart () ;}@ Overridepublic void onSuccess (Object o) {TV _afinal_result.setText ("uploaded successfully"); super. onSuccess (o) ;}@ Overridepublic void onFailure (Throwable t, int errorNo, String strMsg) {TV _afinal_result.setText ("Upload Failed"); super. onFailure (t, errorNo, strMsg );}});

  

 

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.