免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1917 | 回复: 1
打印 上一主题 下一主题

[Android] Coding android 客户端用到的一些开源库 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-11-27 11:00 |只看该作者 |倒序浏览
Coding android 客户端用到的一些开源库

开发用的是 Android Studio,虽然现在还是0.8.14beta版,但除了不支持NDK,编译速度感觉略慢一点点,就没有什么其它的大问题了,完全能满足项目的使用需求。而它相对于eclipse的好处就真的是太多了,首先是速度,再也没有eclipse那种卡卡的感觉了,再次,智能提示更智能,还有,用gradle做库依赖确实方便,就像xcode上的pod一样,这是项目中用到的一些第三方库:
  1. compile 'com.loopj.android:android-async-http:1.4.5'
  2.     compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
  3.     compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
  4.     compile 'se.emilsjolander:stickylistheaders:2.5.1'
  5.     compile 'de.hdodenhof:circleimageview:1.2.0'
  6.     compile 'com.android.support:appcompat-v7:20.0.0'
  7.     compile project(':photolibrary')
  8.     compile files('libs/android-viewbadger.jar')
  9.     compile 'com.belerweb:pinyin4j:2.5.0'
  10.     compile "org.androidannotations:androidannotations-api:3.0.1"
复制代码
  • compile 'com.loopj.android:android-async-http:1.4.5'


https://
github.com/loopj/android-async-http


封装了http请求,直接支持json,gzip压缩,相当省事。
  1. AsyncHttpClient client = new AsyncHttpClient();
  2.                 PersistentCookieStore cookieStore = new PersistentCookieStore(context);
  3.                 client.setCookieStore(cookieStore);
  4.                         client.post(url, params, new JsonHttpResponseHandler() {
  5.                     @Override
  6.                     public void onSuccess(int statusCode, Header[] headers, JSONObject response){
  7.                     }
  8.        
  9.                     public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {            
  10.                     }
  11.        
  12.                     @Override
  13.                     public void onFinish() {
  14.                     }
  15.         });
复制代码
  • compile 'com.astuetz:pagerslidingtabstrip:1.0.1'

左右滑动控件,做了一点修改,我的项目中主要实现了这两个效果



  • compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'

封装了图片请求,控件显示图片基本一句代码搞定
ImageLoader.getInstance().displayImage(url, imageView, options);

  • compile 'se.emilsjolander:stickylistheaders:2.5.1'

实现列表滑动的时候列表头不动的效果,而且单击表头可以收缩列表。

  • compile 'de.hdodenhof:circleimageview:1.2.0'

将图片显示为圆形,虽然自己写也很简单,但既然有现成的轮子,就懒得自己造了。

  • compile project(':photolibrary')


https://
github.com/chrisbanes/PhotoView


图片控件,支持双指放大缩小图片。

  • compile files('libs/android-viewbadger.jar')


https://
github.com/jgilfelt/android-viewbadger


实现提醒的小红点效果,支持自定义小红点的外观,相当有用。

  • compile 'com.belerweb:pinyin4j:2.5.0'

看名字也知道,根据汉字查拼音的库。

  • compile "org.androidannotations:androidannotations-api:3.0.1"


https://
github.com/excilys/androidannotations


一个神奇的项目,利用注解让大家少写代码。
官网上的的一个例子,少写了多少代码大家是估计的到的,
  1. @EActivity(R.layout.translate) // Sets content view to R.layout.translate
  2.                 public class TranslateActivity extends Activity {
  3.        
  4.                     @ViewById // Injects R.id.textInput
  5.                     EditText textInput;
  6.                
  7.                     @ViewById(R.id.myTextView) // Injects R.id.myTextView
  8.                     TextView result;
  9.                
  10.                     @AnimationRes // Injects android.R.anim.fade_in
  11.                     Animation fadeIn;
  12.                
  13.                     @Click // When R.id.doTranslate button is clicked
  14.                     void doTranslate() {
  15.                          translateInBackground(textInput.getText().toString());
  16.                     }
  17.                
  18.                     @Background // Executed in a background thread
  19.                     void translateInBackground(String textToTranslate) {
  20.                          String translatedText = callGoogleTranslate(textToTranslate);
  21.                          showResult(translatedText);
  22.                     }
  23.                
  24.                     @UiThread // Executed in the ui thread
  25.                     void showResult(String translatedText) {
  26.                          result.setText(translatedText);
  27.                          result.startAnimation(fadeIn);
  28.                     }
  29.        
  30.             // [...]
  31.                 }
复制代码
实现原理是生成了一个子类 TranslateActivity_,使用的时候不要用 TranslateActivity,用 TranslateActivity_ 代替,我用了之后感觉这个库最大的问题是如果哪里代码写错了,编译的错误信息太多,容易把人吓着,但其实错误还是很好找的。

论坛徽章:
6
CU大牛徽章
日期:2013-04-17 10:59:39CU大牛徽章
日期:2013-04-17 11:01:45CU大牛徽章
日期:2013-04-17 11:02:15CU大牛徽章
日期:2013-04-17 11:02:36CU大牛徽章
日期:2013-04-17 11:02:582015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2014-12-03 09:42 |只看该作者
mark备用,androidannotations还没用过,看起来能提高不少productivity
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP