Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
manuelvicnt / AnAndroidApp.kt
Last active January 1, 2023 17:05
Hilt and AssistedInject working together in Hilt v2.28-alpha times - ViewModel version
// IMPORTANT! READ THIS FIRST
// Assisted Injection doesn't work with @HiltViewModel or @ViewModelInject
// Read more about the issue here: https://github.com/google/dagger/issues/2287
//
//
// AssistedInject and Hilt working together in v2.28-alpha times
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt
// As AssistedInject isn't part of Dagger yet, we cannot use in
// conjuction with @ViewModelInject
@yaraki
yaraki / CreateLiveData.kt
Created July 9, 2018 06:44
LiveData + Kotlin Coroutines
package io.github.yaraki.coroutineex
import android.arch.lifecycle.LiveData
import android.content.Context
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.channels.SendChannel
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
@almozavr
almozavr / jacoco.gradle
Last active January 5, 2021 12:37
Gradle Jacoco config for Android (3.x plugin) with kotlin and custom excludes support
apply plugin: "jacoco"
jacoco {
toolVersion = deps.test.jacocoVersion
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
import Foundation
import UIKit
class MySampleView :UIView{
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = UIColor.blue
}
@sys1yagi
sys1yagi / Usage.kt
Created May 12, 2017 04:28
Magic Data Binding inflate
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = parent.inflateBinding<ListItemCommentBinding>()
return ViewHolder(binding)
}
@ypresto
ypresto / init.lua
Last active March 1, 2018 14:22
英数キーとかかなキーとかを同時押しの時だけAltキーにするHammerspoonの設定
local pressedKeyTable = {}
-- TODO: Consider about consumed per keys is necessary or not.
local consumed = false
local keyCodeTable = {}
keyCodeTable[0x66] = true -- EISUU
keyCodeTable[0x68] = true -- KANA
eventtap = hs.eventtap.new({ hs.eventtap.event.types.keyDown, hs.eventtap.event.types.keyUp }, function(event)
local keyCode = event:getKeyCode()
if keyCodeTable[keyCode] == true then
@carloseduardosx
carloseduardosx / RealmAutoIncrement.java
Last active January 18, 2021 05:35
RealmAutoIncrement is a singleton which maintain the last id saved from each database model
package com.carlosedurdo.database;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import io.realm.Realm;
import io.realm.RealmObject;
/**
@jocollet
jocollet / RealmGsonParsing.java
Last active April 12, 2016 09:53
Example of TypeAdapters to convert json to Realm objects
// ref : https://gist.github.com/cmelchior/1a97377df0c49cd4fca9
private void initGson() {
Type tokenInt = new TypeToken<RealmList<RealmInt>>(){}.getType();
Type tokenString = new TypeToken<RealmList<RealmString>>(){}.getType();
Type tokenDate = new TypeToken<Date>(){}.getType();
mGson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss")
.setExclusionStrategies(new ExclusionStrategy() {
@Override
@umetsu
umetsu / ImageViewBindingAdapter.java
Last active May 9, 2017 00:28
Kotlin + DataBindingでハマったこと
public class ImageViewBindingAdapter {
@BindingAdapter("bind:imageUrl")
public static void loadImage(view: ImageView, url: String) {
Glide.with(view.context).load(url).into(view)
}
}