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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-kapt' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'jacoco' | |
apply from: "$project.rootDir/tools/script-jacoco.gradle" | |
android { | |
// Code omitted for brevity |
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 static boolean isAndroidModule(Project project) { | |
boolean isAndroidLibrary = project.plugins.hasPlugin('com.android.library') | |
boolean isAndroidApp = project.plugins.hasPlugin('com.android.application') | |
return isAndroidLibrary || isAndroidApp | |
} | |
afterEvaluate { project -> | |
def projectName = project.name | |
if (isAndroidModule(project)) setupAndroidReporting() | |
else setupKotlinReporting() |
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
def setupKotlinReporting() { | |
jacocoTestReport { | |
dependsOn test | |
reports { | |
csv.enabled false // change if needed | |
xml.enabled false // change if needed | |
html { | |
enabled true | |
destination file("${buildDir}/coverage-report") | |
} |
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
afterEvaluate { project -> | |
def projectName = project.name | |
if (isAndroidModule(project)) setupAndroidReporting() | |
else setupKotlinReporting() | |
} |
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 static boolean isAndroidModule(Project project) { | |
boolean isAndroidLibrary = project.plugins.hasPlugin('com.android.library') | |
boolean isAndroidApp = project.plugins.hasPlugin('com.android.application') | |
return isAndroidLibrary || isAndroidApp | |
} |
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
/** | |
* How to run? | |
* | |
* App Module: | |
* ./gradlew app:testAppDebugUnitTestCoverage | |
* ./gradlew app:testBetaDebugUnitTestCoverage | |
* ./gradlew app:testProdDebugUnitTestCoverage | |
* | |
* Domain Module: | |
* ./gradlew domain:jacocoTestReport |
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 AuthenticationInterceptor @Inject constructor(baseUrl: String, jwtToken: String) : | |
Interceptor { | |
private var baseUrl: HttpUrl | |
private var jwtToken: String | |
companion object { | |
private const val LOG_TAG = "AuthenticationInterceptor:" | |
private const val AUTHORIZATION = "Authorization" | |
private const val BEARER = "Bearer" |
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
abstract class BaseViewModel: ViewModel() | |
{ | |
protected val _viewState: MutableLiveData<ViewState> = MutableLiveData() | |
// don't expose the MutableLiveData outside of the class | |
val viewState: LiveData<ViewState> | |
get() = _viewState // only getter / no setter | |
fun setViewState(viewState: ViewState){ |
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
fun <T> LiveData<T>.toFlowable(owner: LifecycleOwner): Flowable<T> = | |
Flowable.fromPublisher(LiveDataReactiveStreams.toPublisher(owner, this)) | |
fun <T> Flowable<T>.toLiveData(): LiveData<T> = LiveDataReactiveStreams.fromPublisher(this) |
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 ScopingFunctions { | |
fun main() { | |
val firstPerson = Person("Prokash", 28, "Programmer") | |
val secondPerson = Person("Elizabeth", 34, "Singer") | |
//Calls the specified function block with this value as its receiver and returns its result. | |
run { | |
if (firstPerson.age > secondPerson.age) firstPerson else secondPerson | |
}.printPerson() |