Skip to content

Instantly share code, notes, and snippets.

View jemshit's full-sized avatar
👑
Solving Problems

Jemshit Iskanderov jemshit

👑
Solving Problems
View GitHub Profile
import com.jakewharton.rxrelay2.BehaviorRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class ColdReactiveDataExpiration {
// Problems to solve:
// 1- UI components should be notified when data is updated
@jemshit
jemshit / AndroidResourceProvider.kt
Last active May 10, 2022 16:34
Android Resource Provider for Presenter in MVP
import android.content.Context
import android.support.annotation.*
import android.support.v4.content.ContextCompat
import interface_adapters.ResourceProvider
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton
@Singleton
class AndroidResourceProvider
@jemshit
jemshit / MediaPlayerStateMachine.kt
Last active March 16, 2022 15:48
Android MediaPlayer has internal state of its own, but there is no get method for it. State diagram is here: https://developer.android.com/images/mediaplayer_state_diagram.gif. Invocation of method that is not allowed at current state results in exception. To avoid such exception and track states of MediaPlayer, MediaPlayerStateMachine is writte…
import android.util.Log
fun emptyMPStateMachineLogger(tag: String, message: String) {
// NoOp
}
fun defaultMPStateMachineLogger(tag: String, message: String) {
Log.d(tag, message)
}