Skip to content

Instantly share code, notes, and snippets.

🏠
Working

Ivan Terekhin JEuler

🏠
Working
Block or report user

Report or block JEuler

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
@JEuler
JEuler / reg_comments.txt
Created Sep 4, 2019
Regular to match comments.
View reg_comments.txt
"[^"\\]*(?:\\[\W\w][^"\\]*)*"|(\/\/.*)
View BaseActivityRx.kt
protected fun <T> subscribe(observable: Observable<T>?, observer: Observer<T>?, bind: Boolean = true) {
if (observable != null && observer != null) {
if (bind) {
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.bindToLifecycle(this)
.subscribe(observer)
} else {
observable
View BaseActivityRx.java
protected <T> void autoResubscribe(Observable<T> observable, ResubscriptionObserver<T> resubscriptionObserver) {
if (getObservableGroup() != null && observable != null) {
observable
.compose(getObservableGroup().<T>transform((String) resubscriptionObserver.resubscriptionTag()))
.compose(applySchedulers())
.subscribe(resubscriptionObserver);
}
}
@JEuler
JEuler / SendDataWorker.kt
Created Feb 25, 2019
SendData Worker example
View SendDataWorker.kt
class SendDataWorker(context: Context, params: WorkerParameters) : Worker(context, params), KoinComponent {
@SuppressLint("CheckResult")
override fun doWork(): Result {
val sendService: SendService? by inject()
val data = inputData.getString("data")
val dataInput = getGsonForJoda()?.fromJson(data, SomeDataClass::class.java)
return try {
val query = sendService?.sendData(dataInput)
?.blockingGet()
@JEuler
JEuler / SendDataJob.kt
Created Feb 25, 2019
Priority queue job example
View SendDataJob.kt
class SendDataJob(private val dataInput: SomeDataClass) :
Job(Params(1).requireNetwork().persist().groupBy(“tag”)), KoinComponent {
// job is queued, need to update local storage
override fun onAdded() {
}
@Throws(Throwable::class)
override fun onRun() {
val sendService: SendService? by inject()
sendService?.sendData(dataInput)
@JEuler
JEuler / build.gradle
Created Feb 1, 2019
Example of packing options
View build.gradle
packagingOptions {
exclude "lib/armeabi/libsnappydb-native.so"
exclude "lib/mips/libsnappydb-native.so"
exclude "lib/mips64/libsnappydb-native.so"
}
Exclude not very useful libs
@JEuler
JEuler / circle.yml
Created Jan 29, 2019
Basic Circle CI setup
View circle.yml
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-28-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
@JEuler
JEuler / ShowDebugKeyFingerprints.sh
Created May 9, 2018 — forked from j796160836/ShowDebugKeyFingerprints.sh
Show android debug key's fingerprints. (MD5 / SHA1 / SHA256)
View ShowDebugKeyFingerprints.sh
#!/bin/bash
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
@JEuler
JEuler / localizedActivity.kt
Created Feb 26, 2018
Class for the runtime switch of localization
View localizedActivity.kt
// Class for the runtime switch of localization
@SuppressLint("Registered")
open class LocalizedActivity : AppCompatActivity() {
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext((updateBaseContextLocale(newBase)))
}
private fun updateBaseContextLocale(context: Context): Context {
val language = PreferenceManager.getDefaultSharedPreferences(context).getString("languages", Locale.getDefault().language)
val locale = Locale(language)
@JEuler
JEuler / config.yml
Created Jan 3, 2018
basic circle ci 2.0 configuration for Android
View config.yml
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-26-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
You can’t perform that action at this time.