Skip to content

Instantly share code, notes, and snippets.

View ultraon's full-sized avatar

Vitalii ultraon

View GitHub Profile
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
fun main(args: Array<String>) {
println("a" to "b")
println("a" to "b" tre "c")
println("a" to "b" tre "c" fo "d")
println("a" to "b" tre "c" fo "d" fi "e")
println("a" to "b" tre "c" fo "d" fi "e" sik "f")
println("a" to "b" tre "c" fo "d" fi "e" sik "f" seva "g")
}
infix fun <A, B, C> Pair<A, B>.tre(c: C) = Triple(first, second, c)
@OleksandrKucherenko
OleksandrKucherenko / build.gradle
Last active April 11, 2022 21:06
repack AAR with different types of compatibility things, like: androidx vs support library, include/exclude/repackage aar during compilation
/** Copyright: 2019-*, Oleksandr Kucherenko (olku@artfulbits.se) */
apply plugin: 'com.android.library'
android {
/* ... default android lib OR app configuration ... */
}
configurations {
repack { transitive = false }
compatibility { transitive = false }
@johnybot
johnybot / TintableImageView.java
Created March 9, 2015 21:41
TintableImageView
public class TintableImageView extends ImageView {
private ColorStateList tint;
public TintableImageView(Context context) {
super(context);
}
public TintableImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@gtomek
gtomek / IoUtilsWithOkIo.java
Created February 10, 2016 10:55
Read files with Okio
/**
* Utils for I/O operations.
* <p/>
* Created by Tomek on 09/06/15.
*/
public class IoUtils {
/**
* Reads file and returns a String.
*
@hrach
hrach / channel.kt
Last active May 24, 2021 08:52
Kotlin Channels Debounce & Throttle
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.channels.produce
import kotlin.coroutines.experimental.CoroutineContext
fun <E> ReceiveChannel<E>.debounce(
wait: Long = 50,
context: CoroutineContext = DefaultDispatcher
): ReceiveChannel<E> = produce(context) {
@cdsap
cdsap / AndroidManifest.xml
Last active January 7, 2021 17:59
Example ManifestPlaceHolder
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapplication" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@AlexGladkov
AlexGladkov / Coroutines + Rx.swift
Last active December 16, 2020 08:50
Coroutines + Rx (Multiplatform + iOS Native)
import LMCustomerSDK // Your Kotlin Multiplatform Library
import RxSwift
struct RxAsyncResult<ResultElement: AnyObject> {
#if targetEnvironment(simulator)
let async: AsyncResult<ResultElement>
#else
let async: AsyncResult
#endif
/// Pack For XCode
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
@frogermcs
frogermcs / ActivityScope.java
Last active April 23, 2020 17:14
Sources for blog post "Dependency injection with Dagger 2 - the API"
@Scope
public @interface ActivityScope {
}