Skip to content

Instantly share code, notes, and snippets.

View Zimins's full-sized avatar
🏠
Working from home

Zimin Zimins

🏠
Working from home
View GitHub Profile
@Zimins
Zimins / normalFlow.kt
Created June 16, 2021 14:38
flow collect test
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
fun main(){
runBlocking {
println("main started")
val normalFlow = flow {
println("Flow starts emit")
emit(10)
@Zimins
Zimins / StateFlow.kt
Last active June 19, 2021 07:55
Part of StateFlow.kt(coroutines)
override suspend fun collect(collector: FlowCollector<T>) {
val slot = allocateSlot()
try {
if (collector is SubscribedFlowCollector) collector.onSubscription()
val collectorJob = currentCoroutineContext()[Job]
var oldState: Any? = null // previously emitted T!! | NULL (null -- nothing emitted yet)
// The loop is arranged so that it starts delivering current value without waiting first
while (true) {
// Here the coroutine could have waited for a while to be dispatched,
// so we use the most recent state here to ensure the best possible conflation of stale values
@Zimins
Zimins / futurebuilder.dart
Last active July 16, 2020 09:16
Flutter 의 compute 기능을 이용해서 ui blocking을 제거
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
@Zimins
Zimins / main.dart
Created April 12, 2020 08:26
1-3 Flutter Layout
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@Zimins
Zimins / main.dart
Created April 12, 2020 08:26
1-2 Flutter Layout
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@Zimins
Zimins / future.dart
Last active September 27, 2019 13:23
exampleForDartFuture
void main() {
print("main started");
requestApi().then((result) {
print(result);
});
print("main finished");
}
Future<String> requestApi() async {
return "result";
@Zimins
Zimins / main.dart
Last active December 19, 2018 15:54
flutter hero widget example
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@Zimins
Zimins / breakbyletter.md
Last active October 16, 2018 00:33
TextView extension : break string by letter
fun TextView.breakLetter() {
    // original Text
    var processingString = text.toString()
    var availableLetterCount = 0

    val stringBuilder = StringBuilder()

    while (availableLetterCount < processingString.length) {
 availableLetterCount =
@Zimins
Zimins / appshortcut.md
Last active April 17, 2018 02:56
appshortcut.md

App shortcuts

안드로이드 7.1 (25) 이상에서, 앱에 대한 바로가기 를 설정 가능합니다. 사용하는 런처에서 표시됩니다. 자주 사용하는 작업이나 권장되는 작업을 빨리 접근 할 수 있게 해줍니다. (Works 대응되어 있습니다.)

꾹 눌러서 표시 가능한데, 기존의 UX 와 겹쳐서 사람들이 많이 쓰는데는 시간이 걸릴 듯 합니다.

각 바로가기는 한개 또는 여러개의 intent 를 가지고 있습니다. 해당 intent 로 어떤 작업을 하게 할지 정할 수 있습니다.

  • 지도에서 특정 위치로 바로 이동
  • 친구에게 메시지 보내기
@Zimins
Zimins / FixedTransformerViewPager.java
Created January 10, 2018 06:22 — forked from fdoyle/FixedTransformerViewPager.java
PageTransform + padding on viewpager doesn't work. this fixes it
package com.foo.ui.view;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by fdoyle on 11/2/15.
*/