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.
*/