Skip to content

Instantly share code, notes, and snippets.

@avenwu
avenwu / dart-list-merge-extension.dart
Created Jul 1, 2020
Combine two list into one with cross order, example: [A,B,C], [D,E,F] => [A,D,B,E,C,F]
View dart-list-merge-extension.dart
import 'dart:math';
extension ListExtension<R> on List<R> {
// combine two list
// [A,B,C], [D,E,F] => [A,D,B,E,C,F]
List<R> merge(List<R> list) {
List<R> output = [];
var minLength = min(length, list.length);
var maxLength = max(length, list.length);
@avenwu
avenwu / OkHttpDownloadProgress.java
Created Jun 22, 2018
Download file with OkHttp3+RxJava2 with progress notification
View OkHttpDownloadProgress.java
@RunWith(AndroidJUnit4.class)
public class DownloadSample {
private Service mService;
public DownloadSample() {
Retrofit retrofit = new Retrofit.Builder()
.client(new OkHttpClient())
.baseUrl("https://github.com")
.addConverterFactory(GsonConverterFactory.create())