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
interface UserService {
suspend fun getProfile(): UserProfile
suspend fun getFinancialDetails(): FinancialDetails
suspend fun finalizeOnboarding()
}
interface UserService {
Single<UserProfile> getUserProfile();
Single<FinancialDetails> getFinancialDetails();
Completable finalizeOnboarding();
}
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,
public inline fun CharSequence?.isNullOrEmpty(): Boolean {
...
}
public inline fun String?.orEmpty(): String {
...
}
public val CharSequence.indices: IntRange {
...
val desc = SecuredCommunicationChannel.getChannelDescription()
object SecuredCommunicationChannel {
fun getChannelDescription(): String {
...
}
}
public class SecuredCommunicationChannel {
private static volatile SecuredCommunicationChannel instance;
public static SecuredCommunicationChannel getInstance() {
if (instance == null) {
synchronized (SecuredCommunicationChannel.class) {
if (instance == null) {
instance = new SecuredCommunicationChannel();
}
fun create(credentials: Credentials,
channel: CommunicationChannel = SecuredCommunicationChannel(),
loggingStrategy: LoggingStrategy = DefaultLoggingStrategy(),
host: String = Environment.PRODUCTION_HOST): Proxy {
...
}
/* This method could be called like this: */
@abohomol
abohomol / SQLiteExample.java
Last active October 25, 2018 11:23
SQLite example
db.query(TABLE_NAME, columns, query, null, null, null, null, null);
@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()