COCOFrame

COCOFrame是一個輕量級的開發框架,分FAT包和mini包.分別爲400K,及200K

1. Jar包大小:166K

2. 下載地址:http://download.csdn.net/detail/landehuxi/7673747

3. 解壓縮,項目導入COCOFrame.jar

4. 直接在代碼中使用S,F,U三個類即可.

(一)S 工具服務-service

 初始化:S.init(this); //如果繼承自BaseActivity則不用初始化.

 S.SDCardService SD卡服務(獲取SD卡路徑,獲取SD卡容量,)

 S.SMService 短信服務(編輯發送短信,靜默發送短信)

 S.AppService 應用級別服務 (應用啓動啓動Activity,殺死線程,獲取包名,獲取版本)

 S.EncryptService 加密服務(MD5加密, DES加密/解密,RES加密解密)

 S.DBService 數據庫服務

 S.DisplayService 顯示相關服務(屏幕寬高,像素,dp轉換調節屏幕亮度)

 S.EmailService 郵件服務(靜默發送郵件用戶編輯郵件帶附件的郵件)

 S.HttpService 網絡服務,目前爲空,直接採用F類的網絡請求方法即可.

 S.ImgService 圖片服務(濾鏡,灰度,獲取Bitmap,水印,放大縮小圖片)

 S.IOService 本地存儲服務(asset存儲,SD卡存儲,SP存儲)

 S.KeyBoradService(隱藏軟鍵盤,打開軟鍵盤,查看鍵盤狀態)

 S.PhoneService(獲取手機型號,獲取SIM卡信息,獲取電量,獲取內存大小,獲取手機品牌)

 S.ClearService 內存釋放清空服務(關閉流,回收Bitmap,回收Map,List,關閉數據庫遊標)

 S.StringService 字符串服務(集成TextUtils,數字轉文件體積,常用正則等)

 S.GPService 地理位置服務.(當前用戶所在國家,,,,街道,郵編,經緯度,經緯度計算)

 S.NetworkService 網絡服務(網絡類型,是否有網絡,應用的上行流量,下行流量)

 S.BatteryService 電池服務(電量,USB或直流電,電壓,溫度,電池品牌)

(二)F 極速開發-fast

初始化

F=new F(this); //如果繼承自BaseActivity可直接使用F

 基本使用方式

1.初始化控件,綁定監聽器

F.id(R.id.btnLogin).clicked(listener)

F.id(R.id.btnLogin).clicked(this, "loginMethod");

F.id(R.id.textView).text(“test”);//設置文字

F.id(R.id.imgView).image(Bitmap);//設置圖片.

F.id(R.id.imgView).image(“http://www.test.com/test.png”);//設置圖片.相同地址的圖片不會重複下載

F.id(R.id.imgView).image(“sdcard/test/test.png”);//設置圖片.

F.id(R.id.imgView).image(Drawable);//設置圖片.

F.id(R.id.imgView).image(id);//設置圖片.

F.id(R.id.imgView).image(File);//設置圖片.

F.id(R.id.ImageView).image(file, 300);//設置圖片寬是300像素. 減少此寬度可有效減少圖片內存佔用.

F.id(R.id.imgView).image(url,false,false,50,50,bitmpaHolder,0,1.5f);//設置圖片-多參數模式

圖片下載地址

忽略

是否緩存

圖片高度(決定了圖片大小,0爲原圖大小)

忽略

站位圖片,如果圖片因爲某種錯誤沒顯示,則用此圖代替.(:Bitmap bitmpaHolder=F.getCachedImage(android.R.drawable.star_on))

圖片出現時的效果(例如:F.FADE_IN)

寬高比率,同時決定了圖片整體寬高比

圖片壓縮處理:

ImageOptions options = new ImageOptions();
options.ratio = 1;//質量比率
options.anchor = 1.0;   //部分顯示圖片來達到縮小內存效果.  1.0顯示圖片頂端,  0顯示圖片中間,  -1.0顯示圖片底部  AQuery.ANCHOR_DYNAMIC動態
F.id(R.id.image).image(imageUrl, options);

2.發送網絡請求

F.progress(U.Dialog(this));//網絡請求增加等待效果

F.progress(F.id(R.id.Process)).download()//文件下載增加進度條.

AjaxCallback.setTimeout(15);//設置timeout,單位秒

覆蓋AjaxCallbacktimeout方法可以實現自己的網絡超時動作,如讀取緩存,友好提示等

發送網絡請求

(1)帶參數,不使用緩存,不使用映射.

HashMap < String,String > params = new HashMap < String,String > ();

params.put("formMap.USER_CODE", editName.getText().toString());

params.put("formMap.PASSWORD", editPassword.getText().toString());

F.progress(U.ViewWait(this).showWait()).ajax(URL_LOGIN, params, JSONObject.class, new AjaxCallback < JSONObject > () {@Override public void callback(String url, JSONObject json, AjaxStatus status) {

        try {

            String result = json.getString("result");

            String key = json.getString("key");

            JSONObject userinfo = json.getJSONObject("userinfo");

            if ("1000".equals(result)) {

                Toast.makeText(LoginActivity.this,"SthWrong!", Toast.LENGTH_LONG).show();

            } else {

                S.AppService.startAcvitity(LoginActivity.this, MainActivity.class);

                finish();

            }

        } catch(JSONException e) {

            e.printStackTrace();

        }

    }

});

}

 

(2)不帶參數,不緩存,映射本地方法jsonCallBack:

public void asyncJson(){

  String url="http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";

  aq.ajax(url, JSONObject.class, this, "jsonCallback");       

}  

public void jsonCallback(String url, JSONObject json, AjaxStatus status){

  if(json != null){

      //successful ajax call

  }else{

      //ajax error

  }

}

(3)使用緩存

參數說明:
F.CACHE_TIME_1H;//緩存一小時
F.CACHE_TIME_24H;//緩存一天
F.CACHE_TIME_30M;//緩存30分鐘
F.CACHE_TIME_DEFALUT;//框架默認
F.CACHE_TIME_UPDATA;//馬上更新
可自行設置時間,單位毫秒.
//例如緩存1小時,則接口首次請求成功後返回的data將被存儲,1小時內無論有無網絡,應用重啓,開關機等都將正常返回data,不會再次發送網絡請求.如果想馬上更新數據,可設置時間爲F.CACHE_TIME_UPDATA.會馬上獲取最新的接口數據.

F.ajax(url, params,JSONObject.class, F.CACHE_TIME_1H, new AjaxCallback<JSONObject>() {

          @Override

          public void callback(String url, JSONObject json, AjaxStatus status) {

              swipeRefreshLayout.setRefreshing(false);

              Debug.out(json);

          }

      });

(4)下載文件-無進度條

F.download(url,file,new AjaxCallback<File>() {

@Override

public void callback(String url, File file,

AjaxStatus status) {

//文件下載完畢的處理

}

});

 

(5)下載文件-有進度條

F.progress(F.id(R.id.process_DownApk).getProgressBar()).download(

URL_APK, apkFile, AjaxCallback<File>() {

@Override

public void callback(String url, File file,

AjaxStatus status) {

//文件下載完畢的處理

}

});

(6)上傳文件

String url = "http://www.test.com/upLoadFile.do";
Map<String, Object> params = new HashMap<String, Object>();
byte[] data = new byte[1000];
params.put("source", data);

File file = new File("test.png");

params.put("source", file);

F.ajax(url, params, JSONObject.class, this, "method");//method爲上傳成功後,調用的方法

Asynchronous Network
Permission
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Code
Supported Types

  • JSONObject
  • JSONArray
  • String (HTML, XML)
  • XmlDom (XML parsing)
  • XmlPullParser (Large XML files)
  • byte array
  • User defined custom type (Transformer)
JSON
public void asyncJson(){
       
        //perform a Google search in just a few lines of code
       
        String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";
       
        aq.ajax(url, JSONObject.class, new AjaxCallback<JSONObject>() {
                @Override
                public void callback(String url, JSONObject json, AjaxStatus status) {
                       
                       
                        if(json != null){
                               
                                //successful ajax call, show status code and json content
                                Toast.makeText(aq.getContext(), status.getCode() + ":" + json.toString(), Toast.LENGTH_LONG).show();
                       
                        }else{
                               
                                //ajax error, show error code
                                Toast.makeText(aq.getContext(), "Error:" + status.getCode(), Toast.LENGTH_LONG).show();
                        }
                }
        });
       
}
JSON (activity as callback)
public void asyncJson(){
       
        //perform a Google search in just a few lines of code
       
        String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";                     aq
        aq.ajax(url, JSONObject.class, this, "jsonCallback");
       
}
public void jsonCallback(String url, JSONObject json, AjaxStatus status){
       
        if(json != null){                              
                //successful ajax call          
        }else{                         
                //ajax error
        }
       
}
HTML/XML
//fetch Google's homepage in html
String url = "http://www.google.com";
aq.ajax(url, String.class, new AjaxCallback<String>() {
        @Override
        public void callback(String url, String html, AjaxStatus status) {
               
        }
       
});
XML Dom
public void xml_ajax(){                
        String url = "https://picasaweb.google.com/data/feed/base/featured?max-results=8";                      aq
        aq.ajax(url, XmlDom.class, this, "picasaCb");          
}
public void picasaCb(String url, XmlDom xml, AjaxStatus status){
        List<XmlDom> entries = xml.tags("entry");                      
        List<String> titles = new ArrayList<String>();
       
        String imageUrl = null;
       
        for(XmlDom entry: entries){
                titles.add(entry.text("title"));
                imageUrl = entry.tag("content", "type", "image/jpeg").attr("src");
        }
               
        aq.id(R.id.image).image(imageUrl);
       
}
XmlPullParser
public void callback(String url, XmlPullParser xpp, AjaxStatus status) {
       
        Map<String, String> images = new LinkedHashMap<String, String>();
        String currentTitle = null;
       
        try{
       
        int eventType = xpp.getEventType();
        while(eventType != XmlPullParser.END_DOCUMENT) {
         
                if(eventType == XmlPullParser.START_TAG){
                       
                        String tag = xpp.getName();
                       
                        if("title".equals(tag)){
                                currentTitle = xpp.nextText();
                        }else if("content".equals(tag)){
                                String imageUrl = xpp.getAttributeValue(0);
                                images.put(currentTitle, imageUrl);
                        }
                }
                eventType = xpp.next();
        }
       
        }catch(Exception e){
                AQUtility.report(e);
        }
       
        showResult(images, status);
       
}
bytes
//fetch a remote resource in raw bytes
String url = "http://www.vikispot.com/z/images/vikispot/android-w.png";
aq.ajax(url, byte[].class, new AjaxCallback<byte[]>() {
        @Override
        public void callback(String url, byte[] object, AjaxStatus status) {
                Toast.makeText(aq.getContext(), "bytes array:" + object.length, Toast.LENGTH_LONG).show();
        }
});
Bitmap
//fetch a remote resource in raw bitmap
String url = "http://www.vikispot.com/z/images/vikispot/android-w.png";
aq.ajax(url, Bitmap.class, new AjaxCallback<Bitmap>() {
        @Override
        public void callback(String url, Bitmap object, AjaxStatus status) {
               
        }
});
File
String url = "https://picasaweb.google.com/data/feed/base/featured?max-results=8";              aq
aq.progress(R.id.progress).ajax(url, File.class, new AjaxCallback<File>(){
       
        public void callback(String url, File file, AjaxStatus status) {
               
                if(file != null){
                        showResult("File:" + file.length() + ":" + file, status);
                }else{
                        showResult("Failed", status);
                }
        }
       
});
File Download
String url = "https://picasaweb.google.com/data/feed/base/featured?max-results=16";            
File ext = Environment.getExternalStorageDirectory();
File target = new File(ext, "aquery/myfolder/photos.xml");              aq
aq.progress(R.id.progress).download(url, target, new AjaxCallback<File>(){
       
        public void callback(String url, File file, AjaxStatus status) {
               
                if(file != null){
                        showResult("File:" + file.length() + ":" + file, status);
                }else{
                        showResult("Failed", status);
                }
        }
       
});
InputStream
String url = "https://picasaweb.google.com/data/feed/base/featured?max-results=8";              aq
aq.progress(R.id.progress).ajax(url, InputStream.class, new AjaxCallback<InputStream>(){
       
        public void callback(String url, InputStream is, AjaxStatus status) {
               
                if(is != null){
                        showResult("InputStream:" + is, status);
                }else{
                        showResult("Failed", status);
                }
        }
       
});
Custom Type
private static class Profile{
        public String id;
        public String name;            
}
private static class GsonTransformer implements Transformer{
        public <T> T transform(String url, Class<T> type, String encoding, byte[] data, AjaxStatus status) {                                   
                Gson g = new Gson();
                return g.fromJson(new String(data), type);
        }
}
public void async_transformer(){
       
        String url = "https://graph.facebook.com/205050232863343";                     
        GsonTransformer t = new GsonTransformer();
       
        aq.transformer(t).progress(R.id.progress).ajax(url, Profile.class, new AjaxCallback<Profile>(){                                
                public void callback(String url, Profile profile, AjaxStatus status) {                         
                        Gson gson = new Gson();
                        showResult("GSON Object:" + gson.toJson(profile), status);                             
                }                              
        });
   
}
Custom Type (Static Transformer)
  1. Native
  1. instance transformer()
  1. static setTransformer()
//set the static transformer when application starts
GsonTransformer t = new GsonTransformer();
AjaxCallback.setTransformer(t);
//any subsequent ajax calls will use the static transformer for custom types
String url = "https://graph.facebook.com/205050232863343";
aq.ajax(url, Profile.class, this, "callback");
Http POST
public void async_post(){
       
    //do a twiiter search with a http post
       
    String url = "http://search.twitter.com/search.json";
       
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("q", "androidquery");
       
    aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
        @Override
        public void callback(String url, JSONObject json, AjaxStatus status) {
               
            showResult(json);
           
        }
    });
       
}
Http POST (Multipart)
private void aync_multipart(){
       
        String url = "https://graph.facebook.com/me/photos";
       
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("message", "Message");
       
        //Simply put a byte[] to the params, AQuery will detect it and treat it as a multi-part post
        byte[] data = getImageData();
        params.put("source", data);
       
        //Alternatively, put a File or InputStream instead of byte[]
        //File file = getImageFile();          
        //params.put("source", file);
       
        AQuery aq = new AQuery(getApplicationContext());
        aq.auth(handle).ajax(url, params, JSONObject.class, this, "photoCb");
       
}
Http POST (Custom Entity)
public void async_post_entity() throws UnsupportedEncodingException{
       
    String url = "http://search.twitter.com/search.json";
       
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("q", "androidquery"));                                
        HttpEntity entity = new UrlEncodedFormEntity(pairs, "UTF-8");
   
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(AQuery.POST_ENTITY, entity);
   
    aq.progress(R.id.progress).ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
        @Override
        public void callback(String url, JSONObject json, AjaxStatus status) {
           
            showResult(json, status);
           
        }
    });
}
Long URL (2000+ length)
Caching
String url = "http://www.google.com";
//return a cached copy if the data is recently fetched within 15 minutes
long expire = 15 * 60 * 1000;
aq.ajax(url, String.class, expire, new AjaxCallback<String>() {
    @Override
    public void callback(String url, String html, AjaxStatus status) {                showResult
        showResult(html);
    }
       
});
Refresh Content
String url = "http://www.google.com";
long expire = -1;
aq.ajax(url, String.class, expire, new AjaxCallback<String>() {
    @Override
    public void callback(String url, String html, AjaxStatus status) {                showResult
        showResult(html);
    }
       
});
Invalidating Cache
public void callback(String url, JSONObject json, AjaxStatus status) {
   
        if(json != null){
                if("1".equals(json.optString("status"))){
                        //do something
                }else{
                        //we believe the request is a failure, don't cache it
                        status.invalidate();
                }
        }
}
Progress
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";                aq
aq.progress(R.id.progress).ajax(url, JSONObject.class, this, "jsonCb");
ProgressDialog dialog = new ProgressDialog(this);
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.setInverseBackgroundForced(false);
dialog.setCanceledOnTouchOutside(true);
dialog.setTitle("Sending...");
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";                aq
aq.progress(dialog).ajax(url, JSONObject.class, this, "jsonCb");
//Use activity's setProgressBarIndeterminateVisibility(show);
//Remember to call this before setContentView(): requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";          aq
aq.progress(this).ajax(url, JSONObject.class, this, "jsonCb");  
Activity Finished Detection
//using the activity as context will ensure no callback is called when activity is finished
AQuery aq = new AQuery(activity);
//using the application context will ensure the callback to be called as long as the application is running
AQuery aq = new AQuery(getApplicationContext());
Synchronous Call (Block)
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";
       
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();           cb
cb.url(url).type(JSONObject.class);                     aq
       
aq.sync(cb);
       
JSONObject jo = cb.getResult();
AjaxStatus status = cb.getStatus();
Ajax Status
public void callback(String url, JSONObject json, AjaxStatus status) {
   
    int source = status.getSource();
    int responseCode = status.getCode();
    long duration = status.getDuration();
    Date fetchedTime = status.getTime();
    String message = status.getMessage();
    String redirect = status.getRedirect();
    DefaultHttpClient client = status.getClient();
    //returns the html response when response code is not 2xx
    String errorResponse = status.getError();  
}
Advance
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();        cb
cb.url(url).type(JSONObject.class).weakHandler(this, "jsonCb").fileCache(true).expire(0);
aq.ajax(cb);
Http Headers
String url = "http://www.google.com";
AjaxCallback<String> cb = new AjaxCallback<String>();        cb
cb.url(url).type(String.class).weakHandler(this, "stringCb");
cb.header("Referer", "http://code.google.com/p/android-query/");
cb.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2");
aq.ajax(cb);
Http Cookies
String url = "http://www.androidquery.com/p/doNothing";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();           cb
cb.url(url).type(JSONObject.class).weakHandler(this, "cookieCb");
cb.cookie("hello", "world").cookie("foo", "bar");               aq
aq.ajax(cb);
Http Response Headers
status.getHeaders()
Http Response Cookies
status.getCookies();
Encoding (BETA)
       
//Using String.class type will attempt to detect the encoding of a page and transform it to utf-8
               
String url = "http://114.xixik.com/gb2312_big5/";
aq.progress(R.id.progress).ajax(url, String.class, 0, this, "encodingCb");
               
       
Maintenance
Clean Up
Simple
protected void onDestroy(){
       
        super.onDestroy();
       
        //clean the file cache when root activity exit
        //the resulting total cache size will be less than 3M  
        if(isTaskRoot()){
                AQUtility.cleanCacheAsync(this);
        }
}
Advance
protected void onDestroy(){
       
        super.onDestroy();
       
        if(isTaskRoot()){
                //clean the file cache with advance option
                long triggerSize = 3000000; //starts cleaning when cache size is larger than 3M
                long targetSize = 2000000;      //remove the least recently used files until cache size is less than 2M
                AQUtility.cleanCacheAsync(this, triggerSize, targetSize);
        }
       
}

Make sure the following permission is included in your manifest.

WRITE_EXTERNAL_STORAGE is required for temporary caching for large response types.

Asynchronous AJAX or RPC calls are simple with AQuery.

AQuery transform the data automatically base on the class type passed in the ajax method.

Supported types:

If there are native Android data types (without third party dependency) you want AQuery to support, please send us feedback.

Note that AQuery uses a weak reference to hold the handler for this method. This is to make sure an activity won't be memory leaked when it's terminated before the AJAX request finishes.

AQuery provide a light weight XML parser called XmlDom. javadoc

XmlDom is a specialized class for simple and easy XML parsing. It's designed to be used in basic Android api 4+ runtime without any dependency.

Example to parse Picasa's featured photos feed:

Related Blog: XML Parsing

For large XML response that cannot fit in memory, the XMLPullParser can be used to avoid memory issue.

If you can specify where to store the downloaded file with the download() method. Note that these files will not be deleted like cached files.

AQuery by default supports types that are native to Android. For app specific data types, you can assign a custom Transformer to the ajax call and convert the raw data to a desired type. The benefit of transformer is that it's run under the background thread (similar to the natively supported types), therefore minimizing CPU cycles and avoid blocking on the UI thread.

This example show how to use Gson to transform raw data to user defined types.

A stateless static default transformer can also be set with AjaxCallback.setTransformer().

Transformers are selected in the following priority:

AQuery support multipart post such as uploading an image to a service. Simply do a regular POST and put byte array, Inputstream, or File as one of the parameters.

If a custom entity is required, you can use the special AQuery.POST_ENTITY key name to pass in an HttpEntity object.

Url length shouldn't be longer than 2000 characters. (reference)

The http POST method might be used to get around this limit. For example, Google Chart allow a post method for requests that will run over 2000 characters long.

AQuery detects such case and automatically switch from GET to POST method if required.

Caching is easy with ajax requests. Just pass in an expire time as a parameter, and if the data is available, it will be served from the file cache instead of fetching over the network.

Passing expire time as -1 will ensure the content be refreshed immediately and to be file cached.

Calling the invalidate method of the AjaxStatus object will invalidate the url content so that it will not be cached. It's useful when http status is 200 but the object returned is invalid.

We can show the loading progress by using the progress() method. Pass in the progress bar id, or any other view id to the progress method, and the view will be shown or hide to display ajax progress.

AQuery will examine the initialization context and skip the ajax callback if an activity is already stopped before the aync task is completed. This behavior avoid unnecessary work and avoid modifying ui states that could be illegal (such as showing a dialog when an activity is not longer active).

If the ajax call is run outside of main thread, the sync() method can be used to block the calling thread until the ajax call is completed (or until it's timed out).

Fetch result synchronously:

Note that this will block the thread until the result is returned. The actual work will be done in another thread pool. Calling this method in Main/UI thread will cause an exception.

An AjaxStatus object is returned with any callback. This object holds some meta information regarding the aync task performed.

javadoc

The AQuery object provide various commonly used "ajax" methods. For more advanced (but less commonly used) features such as http header and authentication, AjaxCallback can be used directly to customize the requests.

Note: url and type are required parameters.

Use the header method to configure http request headers.

Use the cookie method to set http cookies.

Returns a list of headers. If the request is cached or a http multipart post, this method returns an empty list.

Returns a list of cookies. If the request is cached or a http multipart post, this method returns an empty list.

The default ajax callback uses UTF-8 to transform the object. If type String is specified and the content is html, AQuery will make a best-effort attempt to detect the encoding by inspecting the response header and the inline html META tag. If file cache is enabled, the content will be stored as UTF-8 bytes and subsequent read will not require encoding detection again.

If custom encoding is needed, uses the encoding() method to fix the encoding.

AQuery provides few utility functions to help you control ajax and caching behavior.

If you use file cache for images, regularly clean the cache dir when the application exits.


(三)U 界面控件-ui

出現等待效果: U.Dialog().showWait();

取消等待效果: U.Dialog().cancelWait();

獲取能顯示GIFView: U.View_Gif();

獲取顏色選擇器: U.View_SelectColor();

獲取圖片濾鏡: U.ImageView_filter();//使圖片變暗,變亮,飽和度變化,彩色變黑白

爲指定控件添加搖一搖監聽器: U.ListenShake(context, onShakeListener);

爲圖片增加手指縮放效果: U.ImageView_zoomTouch(view);

爲控件增加點擊效果(不需要圖片,淺色圖效果不明顯): U.View_click(view);

爲控件增加閃爍效果: U.view_toggle(view);

ListView增加下拉刷新效果:(需要COCOBuildcreateFolder任務支持)

1.<android.support.v4.widget.SwipeRefreshLayout

 android:id="@+id/coco_ListRefresh" 

 android:layout_width="match_parent"

 android:layout_height="match_parent" > 

2.implements OnRefreshListener;

3.SwipeRefreshLayout sp=U.Effect_pullRefresh(this,this);

4.sp.setRefreshing(false);

顯示確認Dialog: U.Dialog().showMakeSure();

顯示選擇Dialog: U.Dialog().showSelect();

採用反射強制Dialog能否退出:U.Dialog().cancelAble(boolean);

實現了多個View之間的滑動切換U.View_RLFlippe();

1. View_RLFlippe views=U.View_RLFlippe(Context);

2. views.addView(view1);

3. views.addView(view2);

4. views.addView(view3);

view1,view2,view3之間即可手機滑動切換.


時間有限,以上只粗略列出了COCOFrame小部分功能,使用方式很簡單,可自行下載jar包使用.

此貼將持續更新.

下載地址:http://download.csdn.net/detail/landehuxi/7673747

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章