Day18
Time : December 03th,2015 / Author : xiaomeixw
library
1.UI:
ChromeLikeSwipeLayout --- (From ashqal) : Pull down, and execute more action. [带贝塞尔曲线左右动画效果的下拉刷新].
android-card-slide-panel --- (From xmuSistone) : sliding around infinite loop. [模仿探探首页卡片左右滑动效果].
android-vertical-slide-view --- (From xmuSistone) : vertical slide to switch to the next fragment page, looks like vertical viewpager. [向下拖动加载下一页].
2.Logic:
android-task --- (From vRallev & Tag is AsyncTask) : A library to execute tasks in the background for Android. [后台异步线程调度].
public class MyActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Task myTask = new MyTask(); int taskId = TaskExecutor.getInstance().execute(myTask, this); } @TaskResult public void onResult(Integer result) { // handle result, this method gets called on the UI thread and only if the activity is visible } } public class MyTask extends Task<Integer> { @Override protected Integer execute() { return 5; } }
Android-scaex --- (From petitviolet & Tag is Utils-PatternMatch) : A library to execute tasks in the background for Android. [一些基础的正则表达式].
IF:
/** returns primitive value pattern **/ String result = IF.<String>x(false).then("hoge") .ElseIf(false).then("foo") .Else("bar"); assert result == "bar"; /** returns value the result of given method invoked **/ String result4 = IF.<String>x(false).then(new Action<String>() { @Override public String run() { return "hoge"; } }).ElseIf(true).then(new Action<String>() { @Override public String run() { return "foo"; } }).Else(new Action<String>() { @Override public String run() { Log.d(TAG, "in else condition!"); return "bar"; } });
Match:
/** pattern match by value condition **/ int target = 100; String result1 = Match.<String, Integer>x(target) .Case(target < 100).then("down") .Case(target > 100).then("up") .Case(target == 100).then("draw") .eval(); assert result1.equals("draw") == true;
/ lazy pattern-match using Function interface in Case / int result3 = Match.
x(100) .Case(String.class).then(1) .Case(Boolean.class).then(2) .Case(new Function.F1<Object, Boolean>() { @Override public Boolean apply(Object integer) { return integer == 100; } }).then(3) .Case(new Function.F1<Object, Boolean>() { @Override public Boolean apply(Object integer) { // not evaluate return integer == 999; } }).then(4) .Case(Integer.class).then(5) .eval();
assert result3 == 3;
JavaVerbalExpressions --- (From VerbalExpressions & Tag is Utils-PatternMatch) : Java regular expressions made easy. [正则表达式].
VerbalExpression testRegex = VerbalExpression.regex() .startOfLine().then("http").maybe("s") .then("://") .maybe("www.").anythingBut(" ") .endOfLine() .build(); // Create an example URL String url = "https://www.google.com"; // Use VerbalExpression's testExact() method to test if the entire string matches the regex testRegex.testExact(url); //True testRegex.toString(); // Outputs the regex used: // ^(?:http)(?:s)?(?:\:\/\/)(?:www\.)?(?:[^\ ]*)$
rxsnappy --- (From team-supercharge & Tag is NoSQL) : RxSnappy is a thread safe rxjava wrapper for the great SnappyDB fast key-value database for Android. [基于RXJava和SnappyDB优秀的NoSql数据操作方案].
1.Application onCreate():
RxSnappy.init(context);
2.Create RxSnappyClient:
RxSnappyClient rxSnappyClient = new RxSnappyClient();
3.Usage:
public Observable<FooResponse> getFooResponse(String token, BarRequest barRequest){ //Generate unique key final String key = RxSnappyUtils.generateKey("fooresponse", token, barRequest); //Look for in cache with a time interval (ms) //If the data in cache is older than 15 sec it throws an exception return rxSnappyClient.getObject(key, 15000L, FooResponse.class) .onErrorResumeNext(retrofitApi.getFooResponse(token, barRequest) .flatMap(fooResponse -> rxSnappyClient.setObject(key, fooResponse)); }
3.Architecture:
<p>
<img src="http://i.imgur.com/bMeNhxZ.png" width="150px" height="150px" align="left" hspace="15px" />
This is beta software. Bug reports and contribution are welcome, but caution should be exercised in deployment.
Whiskey is a Java HTTP library based on nio and intended especially to address the needs of Android mobile clients. It has no external dependencies.
The library shares some code with Netty's codec implementations, but adopts a client performance-focused approach to handling HTTP requests. It has also been developed specifically for support of newer protocols: SPDY, HTTP/2 and QUIC.
The application interface is designed to be extremely flexible, and supports both streaming and atomic operations, with both synchronous and asynchronous interaction.
The internals of the library are built to support lock-free and zero-copy operation, with most logic executing on a single internal run loop managing many sockets.
</p>
<img src="http://i.imgur.com/28DKVA3.png" width="90%">
article
Why I Don't Use Realm Anymore --- (From Author John Petitto blog http://johnpetitto.com/) --- [No Source]
If you haven’t heard of Realm before, it’s a mobile database technology for Android (iOS too). Opposed to SQLite, it allows you to work with data objects directly at the persistence layer. On top of that, there is a powerful functional-style query API and effort has been made to make it even faster than traditional SQLite operations. It was for these reasons I decided to give Realm a try. When I first used Realm around a year ago, my initial impressions were quite good. I needed to persist some user data locally on the phone, but it was a bit too complex for SharedPreferences. Realm allowed me to quickly and cleanly write the necessary code to do this. There was no need to write any of the extra cruft that would have been required with SQLite. The next project I worked on needed a sophisticated offline mode for when the user lacked a network connection. The data that I grabbed over the network would have to be stored locally on the phone. I decided to go all in with Realm and see how it would scale as my project grew.
[Translation:为什么我不再使用Realm].
Chinese Translation Address : Thanks To jcodecraeer
App-Demo
meiShi --- (From sungerk ) : Use some famous libraries build a video app dmo. [一个开源的视频类app-demo].
compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' compile 'com.squareup.okhttp:okhttp:2.5.0' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.github.bumptech.glide:okhttp-integration:1.3.1@aar' compile 'cn.bingoogolapple:bga-badgeview:1.0.2' compile 'com.github.traex.rippleeffect:library:1.3' compile 'com.soundcloud.android:android-crop:1.0.1@aar' compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
website
https://coding.net:A Chinese famous code management website like github [中国的GitHub].