Skip to content

Instantly share code, notes, and snippets.

View Lzyct's full-sized avatar
:shipit:
Code Geek

Mudassir Lzyct

:shipit:
Code Geek
View GitHub Profile
@Lzyct
Lzyct / RepoTest.kt
Last active March 18, 2019 15:11
Sample Room DB with Rx
class RepoTest(private val testDao:TestDao){ //inject dao using Koin
fun insertTest(test:Test) : Single<Resource<String>> = testDao.insertTest(test)
. .subscribeOn(Schedulers.io())
.map<Resource<String>> { t -> Resource.Success(t.toString()) } // convert primary key value to String
.onErrorReturn { Resource.Failure(it) }
.observeOn(AndroidSchedulers.mainThread())
}
@Lzyct
Lzyct / whops.kt
Last active September 1, 2019 16:13
Sample create countdown timer
/**
* This sample count down timer
* for auction app when bid start and end
*/
private lateinit var countDownTimer: CountDownTimer
private var difference = 0L
private var isStart = false
private var startTime = "" // you can chage it with Date
private var endTime = ""
@Lzyct
Lzyct / sample.kt
Last active September 15, 2019 02:52
Save and Load Object in SharedPreference with Moshi
//save object as json
val adapter = Moshi.Builder().build().adapter(SavedObject::class.java)
val json = adapter.toJson(it.data?.body()?.result)
prefManager.saveString("Saved Object", json)
//load object
val objectJson = prefManager.getString("Saved Object")
val adapter = Moshi.Builder().build().adapter(SavedObject::class.java)
val result = adapter.fromJson(objectJson)
@Lzyct
Lzyct / sample.kt
Created September 20, 2019 15:05
Date Format for timestampz
//date format for timestampz
val formatInput = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
val formatOutput = "dd MMMM yyyy HH:mm:ss"
val sdfInput = SimpleDateFormat(formatInput, Locale("id", "ID"))
val sdfOutput = SimpleDateFormat(formatOutput, Locale("id", "ID"))
val date = sdfInput.parse(dataHome.apraisTime)
val newOutput = sdfOutput.format(date)
@Lzyct
Lzyct / ClearActivityStack.kt
Created September 22, 2019 13:10
Clear Activity Stack
startActivity(Intent(applicationContext, NextActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
})
@Lzyct
Lzyct / layout.kbd.json
Last active December 25, 2020 03:17 — forked from mmynsted/layout.kbd.json
Untitled Keyboard Layout
[
[
"Esc",
"!\n1",
"@\n2",
"#\n3",
"$\n4",
"%\n5",
"^\n6",
"&\n7",
@Lzyct
Lzyct / layout.kbd.json
Last active June 13, 2020 03:52 — forked from mmynsted/layout.kbd.json
Untitled Keyboard Layout
[
[
"app",
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
@Lzyct
Lzyct / downgradeflutter.md
Created August 12, 2020 09:13
Downgrade / Change Flutter SDK Version
@Lzyct
Lzyct / downgradeflutter.md
Last active August 12, 2020 09:14
Downgrade / Change Flutter SDK Version
@Lzyct
Lzyct / measure_size.dart
Created September 17, 2020 12:45
Get Measure SIze of Widget in Flutter
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
typedef void OnWidgetSizeChange(Size size);
class MeasureSize extends StatefulWidget {
final Widget child;
final OnWidgetSizeChange onChange;
const MeasureSize({