- 论坛徽章:
- 0
|
Coding android 客户端用到的一些开源库
开发用的是 Android Studio,虽然现在还是0.8.14beta版,但除了不支持NDK,编译速度感觉略慢一点点,就没有什么其它的大问题了,完全能满足项目的使用需求。而它相对于eclipse的好处就真的是太多了,首先是速度,再也没有eclipse那种卡卡的感觉了,再次,智能提示更智能,还有,用gradle做库依赖确实方便,就像xcode上的pod一样,这是项目中用到的一些第三方库:- compile 'com.loopj.android:android-async-http:1.4.5'
- compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
- compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
- compile 'se.emilsjolander:stickylistheaders:2.5.1'
- compile 'de.hdodenhof:circleimageview:1.2.0'
- compile 'com.android.support:appcompat-v7:20.0.0'
- compile project(':photolibrary')
- compile files('libs/android-viewbadger.jar')
- compile 'com.belerweb:pinyin4j:2.5.0'
- 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压缩,相当省事。- AsyncHttpClient client = new AsyncHttpClient();
- PersistentCookieStore cookieStore = new PersistentCookieStore(context);
- client.setCookieStore(cookieStore);
- client.post(url, params, new JsonHttpResponseHandler() {
- @Override
- public void onSuccess(int statusCode, Header[] headers, JSONObject response){
- }
-
- public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
- }
-
- @Override
- public void onFinish() {
- }
- });
复制代码- 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
一个神奇的项目,利用注解让大家少写代码。
官网上的的一个例子,少写了多少代码大家是估计的到的,- @EActivity(R.layout.translate) // Sets content view to R.layout.translate
- public class TranslateActivity extends Activity {
-
- @ViewById // Injects R.id.textInput
- EditText textInput;
-
- @ViewById(R.id.myTextView) // Injects R.id.myTextView
- TextView result;
-
- @AnimationRes // Injects android.R.anim.fade_in
- Animation fadeIn;
-
- @Click // When R.id.doTranslate button is clicked
- void doTranslate() {
- translateInBackground(textInput.getText().toString());
- }
-
- @Background // Executed in a background thread
- void translateInBackground(String textToTranslate) {
- String translatedText = callGoogleTranslate(textToTranslate);
- showResult(translatedText);
- }
-
- @UiThread // Executed in the ui thread
- void showResult(String translatedText) {
- result.setText(translatedText);
- result.startAnimation(fadeIn);
- }
-
- // [...]
- }
复制代码 实现原理是生成了一个子类 TranslateActivity_,使用的时候不要用 TranslateActivity,用 TranslateActivity_ 代替,我用了之后感觉这个库最大的问题是如果哪里代码写错了,编译的错误信息太多,容易把人吓着,但其实错误还是很好找的。 |
|