Skip to content

Instantly share code, notes, and snippets.

View avenwu's full-sized avatar

Wu avenwu

View GitHub Profile
@avenwu
avenwu / dart-list-merge-extension.dart
Created July 1, 2020 10:35
Combine two list into one with cross order, example: [A,B,C], [D,E,F] => [A,D,B,E,C,F]
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 June 22, 2018 03:13
Download file with OkHttp3+RxJava2 with progress notification
@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())