Skip to content

Instantly share code, notes, and snippets.

Mike Nakhimovich digitalbuddha

Block or report user

Report or block digitalbuddha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PipelinePersisterReactive.kt
val networkTrigger = Channel<Unit>(capacity = Channel.RENDEZVOUS)
val diskCommands = Channel<DiskCommand>(capacity = Channel.RENDEZVOUS)
launch {
// trigger first load
diskCommands.send(DiskCommand.ReadFirst)
}
val networkFlow = networkTrigger
.consumeAsFlow()
View sample.kt
class Mario(pipes:List<Pipeline>){
}
View RetroStore.kt
interface Api {
@GET("r/{subredditName}/new/.json")
@RefershOnStale
@Persister
fun subRedditStore(@Path("subredditName") subredditName: String): RetroStore<RedditData>
}
fun getData() {
View StoreCallAdapterFactory.kt
package com.jakewharton.retrofit2.adapter.kotlin.coroutines
import com.nytimes.android.external.store3.base.DiskRead
import com.nytimes.android.external.store3.base.DiskWrite
import com.nytimes.android.external.store3.base.Fetcher
import com.nytimes.android.external.store3.base.impl.RealStoreBuilder
import com.nytimes.android.external.store3.base.impl.Store
import com.nytimes.android.external.store3.base.impl.StoreBuilder
import com.nytimes.android.sample.data.remote.Persister
import com.nytimes.android.sample.data.remote.RefershOnStale
View RxPaging.kt
class RxPaging {
var page = 1
val cache = CacheBuilder.newBuilder().build<Any, Single<List<Single<Int>>>>()
@Test
fun getPages() {
val tab1 = pagedList().blockingGet().iterator()
val tab2 = pagedList().blockingGet().iterator()
@digitalbuddha
digitalbuddha / RoomStore.kt
Last active May 24, 2018
Store with Room
View RoomStore.kt
@Entity
data class User(
@PrimaryKey(autoGenerate = true) var uid: Int = 0,
val name: String,
val lastName: String)
@Dao
interface UserDao {
View gist:21ea4dcb8aa1c894ba0e0df02dc0801f
1. Create a bundle with Android Studio 3.2 alpha 15: Build->Build Bundles/Apks->Build Bundle
2. Download Bundle Tool https://github.com/google/bundletool/releases
3. Create bundletool.sh with contents:
#!/bin/bash
java -jar ~/downloads/bundletool.jar "$@"
5. Run equivalant of following command (or add to path and run just `bundletool`)
./bundletool.sh build-apks --bundle=/Users/mnakhi/projects/high-tops/app/build/outputs/bundle/debug/bundle.aab --output=/Users/mnakhi/projects/high-tops/debug2.apks --ks=PATHTOYOURKEY --ks-key-alias=YOURKEYALIAS
View rules.txt
-injars /home/mike/projects/wink-demo-android/library/build/intermediates/classes/release(**.class)
-injars /home/mike/projects/wink-demo-android/library/build/intermediates/transforms/mergeJavaRes/release/0.jar(!**.class)
-outjars /home/mike/projects/wink-demo-android/library/build/intermediates/transforms/proguard/release/0.jar
-libraryjars /home/mike/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.0.aar/0dcc15c5e84912bbd38089bf47f79dc6/jars/classes.jar(**.class)
-libraryjars /home/mike/.gradle/caches/transforms-1/files-1.1/recyclerview-v7-27.1.0.aar/2081647001ebfaa8b47970d209d73c43/jars/classes.jar(**.class)
-libraryjars /home/mike/.gradle/caches/transforms-1/files-1.1/play-services-ads-11.4.0.aar/ea990ffceac804b4d3cf95eaaa903438/jars/classes.jar(**.class)
-libraryjars /home/mike/.gradle/caches/transforms-1/files-1.1/android-database-sqlcipher-3.5.9.aar/4ff610a8024309757b4974af1c7d7607/jars/classes.jar(**.class)
-libraryjars /home/mike/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2
View holster.kt
//Main Idea: Rather than declaring subcomponents you declare Scopes which contain modules
//Holster is a processor which will generate a subcomponent for each scope and
//allows you to get a reference to each component through a generated Locator.
//Difference with Dagger Android is that we create the child/parent component
//relationship in the scope annotation rather than depending on @ContributesAndroidInjector/HasInjector
@MyActivityScope(ActivityModule::class, child=MyViewScope::class)
class MyActivity{
@inject aDep:ADep
onCreate(){ inject()) }
You can’t perform that action at this time.