Skip to content

Instantly share code, notes, and snippets.

View boyan01's full-sized avatar

Bin boyan01

View GitHub Profile
@boyan01
boyan01 / scripts.sh
Last active June 17, 2021 09:08
flutter engine build
# macos
## debug
./flutter/tools/gn --unoptimized
ninja -C out/host_debug_unopt
## release
@boyan01
boyan01 / auto fit calculation
Created January 10, 2020 02:37
自适应屏幕宽高
private static int[] calculateAutoFitWidthHeight(Size parentSize, Size originSize) {
int width = parentSize.getWidth();
int height = parentSize.getHeight();
int originW = originSize.getWidth();
int originH = originSize.getHeight();
float v1 = height / ((float) originH);
float v2 = width / ((float) originW);
@boyan01
boyan01 / focus_grid_list.dart
Created June 25, 2019 05:55
reoder flutter grid list item paint sequence , make current focused index paint in the front
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class FocusGridView extends GridView {
FocusGridView.builder({
Key key,
Axis scrollDirection = Axis.vertical,
bool reverse = false,
ScrollController controller,
bool primary,
@boyan01
boyan01 / Recycler.kt
Last active March 11, 2018 12:05
让 RecyclerView 可以左滑删除
/**
* 让 RecyclerView 可以左滑删除
* @param onItemSwiped 响应左滑删除时的调用
* @param onItemRevoked 响应撤回删除时的调用
*/
private fun <T : Any> RecyclerView.setSwipeAble(
onItemSwiped: (position: Int) -> T,
onItemRevoked: (position: Int, value: T) -> Unit,
onItemMoved: (from: Int, to: Int) -> Boolean
) = ItemTouchHelper(object : ItemTouchHelper.Callback() {
@boyan01
boyan01 / LoadMoreDelegate.kt
Created March 6, 2018 08:13
下滑自动加载更多
class LoadMoreDelegate(private val onLoadMoreListener: OnLoadMoreListener) {
fun attach(recyclerView: RecyclerView) {
recyclerView.addOnScrollListener(LoadMoreListener(onLoadMoreListener))
}
class LoadMoreListener(
private val onLoadMoreListener: OnLoadMoreListener) : RecyclerView.OnScrollListener() {
@boyan01
boyan01 / CookieStore.kt
Last active August 25, 2017 04:29
缓存 OkHttp Cookie 到指定文件
/**
* author : SUMMERLY
* e-mail : yangbinyhbn@gmail.com
* time : 2017/8/23
* desc : 用于持续保存Cookie
*/
abstract class CookieStore {
abstract fun add(url: HttpUrl, cookie: Cookie)