This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
did:3:kjzl6cwe1jw14a71oav2l5h7igau98c0sb3djyvlrmzbmlh9fcfawv3a4gtbgqi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | |
val buildToolsVersion: String by project | |
val kotlinVersion: String by extra | |
plugins { | |
id("com.android.library") | |
kotlin("multiplatform") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected fun <D> wrapResult(): SingleTransformer<D, ResultState<D>> = SingleTransformer { | |
it.map { d -> ResultState.Success(d) as ResultState<D> } | |
.onErrorReturn { e -> ResultState.Error(e, null) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A wrapper for database and network states. | |
*/ | |
sealed class ResultState<T> { | |
/** | |
* A state of [data] which shows that we know there is still an update to come. | |
*/ | |
data class Loading<T>(val data: T) : ResultState<T>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OperationLiveData<T>(private val operation: OperationLiveData<T>.() -> Unit) : MutableLiveData<T>() { | |
private var operated = AtomicBoolean(false) | |
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) { | |
super.observe(owner, observer) | |
operate() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Observable | |
fun <T> Observable<T>.applyIoScheduler() = applyScheduler(Schedulers.io()) | |
fun <T> Observable<T>.applyComputationScheduler() = applyScheduler(Schedulers.computation()) | |
private fun <T> Observable<T>.applyScheduler(scheduler: Scheduler) = | |
subscribeOn(scheduler).observeOn(AndroidSchedulers.mainThread()) | |
//Flowable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext { | |
// Android | |
minSdkVersion = 14 | |
targetSdkVersion = 28 | |
versionCode = 1 | |
versionName = "1.0" | |
androidCompileSdkVersion = 28 | |
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" | |
// Libraries | |
ankoVersion = '0.10.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$NDK" = "" ]; then | |
echo NDK variable not set, assuming ${HOME}/android-ndk | |
export NDK=${HOME}/android-ndk | |
fi | |
SYSROOT=$NDK/platforms/android-14/arch-arm | |
WORKING_DIR=`pwd` | |
# Expand the prebuilt/* path into the correct one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean grantSignaturePermission(String perm, PackageParser.Package pkg, | |
BasePermission bp, HashSet<String> origPermissions) { | |
boolean allowed; | |
allowed = (compareSignatures( | |
bp.packageSetting.signatures.mSignatures, pkg.mSignatures) | |
== PackageManager.SIGNATURE_MATCH) | |
|| (compareSignatures(mPlatformPackage.mSignatures, pkg.mSignatures) | |
== PackageManager.SIGNATURE_MATCH); | |
if (!allowed && (bp.protectionLevel | |
& PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) { |