Skip to content

Instantly share code, notes, and snippets.

@mrArtCore
mrArtCore / RxPermissionButtonClick.kt
Last active October 12, 2018 22:03
Rx Permission lifecycle handling wiht Disposables
// in some Activity
...
private val disposables: CompositeDisposable = NewCompDisposable()
...
override fun onCreate(...) { // yes, even in onCreate. Could listener be invoked after onStop ?
button.onClick { // your listener
disposables.add( // important step !!! should track subscription!
RxPermission().request(someParams)
.doOnSubscribe(button.disable())
.doOnNext(button.enable())
@mrArtCore
mrArtCore / proguard-project.txt
Created September 21, 2017 18:25 — forked from intrepid-ab/proguard-project.txt
Proguard Configuration for Android Library
# Save the obfuscation mapping to a file, so we can de-obfuscate any stack
# traces later on. Keep a fixed source file attribute and all line number
# tables to get line numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.
-printmapping out.map
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,EnclosingMethod
class LocationDelegate(val activity: Activity) {
companion object {
val locationPermission = arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION)
const val ACTION_TO_SETTINGS = Settings.ACTION_LOCATION_SOURCE_SETTINGS
const val GEO_REQUEST_CODE = 765
}
private val locationTurnOnObserver = PublishSubject.create<Boolean>()
@mrArtCore
mrArtCore / 0_reuse_code.js
Created September 6, 2016 07:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console