Skip to content

Instantly share code, notes, and snippets.

View abohomol's full-sized avatar

Anton Bohomol abohomol

  • San Francisco Bay Area
View GitHub Profile
@abohomol
abohomol / Kaa
Created February 15, 2018 13:52
import android.content.Context
import org.kaaproject.kaa.client.AndroidKaaPlatformContext
import org.kaaproject.kaa.client.BaseKaaClient
import org.kaaproject.kaa.client.logging.memory.MemLogStorage
import org.kaaproject.kaa.client.logging.strategies.RecordCountLogUploadStrategy
/*
* Implementation of In-Memory log storage with enlarged allocated space.
*/
class LargeMemLogStorage : MemLogStorage(MAX_STORAGE_SIZE_BYTES, MAX_BUCKET_SIZE_BYTES, MAX_BUCKET_RECORD_COUNT) {
@abohomol
abohomol / ExtensionsExample.kt
Last active October 25, 2018 11:22
Extensions example
fun View.hide() {
visibility = View.INVISIBLE
}
/* Now you can call the newly created method like this: */
val textView = TextView(context)
textView.hide()
@abohomol
abohomol / SQLiteExample.java
Last active October 25, 2018 11:23
SQLite example
db.query(TABLE_NAME, columns, query, null, null, null, null, null);
fun create(credentials: Credentials,
channel: CommunicationChannel = SecuredCommunicationChannel(),
loggingStrategy: LoggingStrategy = DefaultLoggingStrategy(),
host: String = Environment.PRODUCTION_HOST): Proxy {
...
}
/* This method could be called like this: */
public class SecuredCommunicationChannel {
private static volatile SecuredCommunicationChannel instance;
public static SecuredCommunicationChannel getInstance() {
if (instance == null) {
synchronized (SecuredCommunicationChannel.class) {
if (instance == null) {
instance = new SecuredCommunicationChannel();
}
object SecuredCommunicationChannel {
fun getChannelDescription(): String {
...
}
}
val desc = SecuredCommunicationChannel.getChannelDescription()
public inline fun CharSequence?.isNullOrEmpty(): Boolean {
...
}
public inline fun String?.orEmpty(): String {
...
}
public val CharSequence.indices: IntRange {
...
interface CommunicationChannel {
fun connect(credentials: Credentials)
fun disconnect()
fun getChannelDescription(): Description
}
data class Credentials(val secret: String, val key: String)
data class Description(
val numberOfPeers: Int,
interface UserService {
Single<UserProfile> getUserProfile();
Single<FinancialDetails> getFinancialDetails();
Completable finalizeOnboarding();
}