Skip to content

Instantly share code, notes, and snippets.

View MoshDev's full-sized avatar
🎯
Focusing

Mohammad Ersan MoshDev

🎯
Focusing
View GitHub Profile
@MoshDev
MoshDev / DebounceTest.kt
Created October 17, 2018 22:28 — forked from k-kagurazaka/DebounceTest.kt
RxJava debounce like operator implementation for kotlin coroutine
launch(UI) {
editText.onTextChanged()
.debounce(1, TimeUnit.SECONDS)
.consumeEach {
Log.d("DebounceTest", "value: $it")
}
}
}
fun EditText.onTextChanged(): ReceiveChannel<String> =
@MoshDev
MoshDev / ListAdapter.kt
Last active September 30, 2019 21:42
Gson List Adapter
import java.io.IOException
import java.util.ArrayList
import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
Future main() async {
final Iterable<Locale> supportedLocales = [Locale('en'), Locale('ar')];
await Langs.init(supportedLocales: supportedLocales, loadDeviceLanguage: true);
runApp(MyApp(supportedLocales: supportedLocales));
print(Langs.string('sample.item.name'));
print(Langs.string('name'));
}
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {