This file contains hidden or 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 MyViewModel : ViewModel() { | |
| /** | |
| * Heavy operation that cannot be done in the Main Thread | |
| */ | |
| fun launchDataLoad() { | |
| viewModelScope.launch { | |
| sortList() | |
| // Modify UI | |
| } |
This file contains hidden or 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
| @MainThread | |
| final void clear() { | |
| mCleared = true; | |
| // Since clear() is final, this method is still called on mock | |
| // objects and in those cases, mBagOfTags is null. It'll always | |
| // be empty though because setTagIfAbsent and getTag are not | |
| // final so we can skip clearing it | |
| if (mBagOfTags != null) { | |
| for (Object value : mBagOfTags.values()) { | |
| // see comment for the similar call in setTagIfAbsent |
This file contains hidden or 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
| internal class CloseableCoroutineScope( | |
| context: CoroutineContext | |
| ) : Closeable, CoroutineScope { | |
| override val coroutineContext: CoroutineContext = context | |
| override fun close() { | |
| coroutineContext.cancel() | |
| } | |
| } |
This file contains hidden or 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 MyViewModel(dependency: ExternalDependency) : ViewModel() { | |
| fun run() { | |
| viewModelScope.launch { | |
| dependency.doStuff() | |
| } | |
| } | |
| } | |
| class MyViewModelTest { |
This file contains hidden or 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
| diff --git a/generate/src/main/resources/i18Languages.xsd b/generate/src/main/resources/i18Languages.xsd | |
| index 4e3fc1b..6825a20 100644 | |
| --- a/generate/src/main/resources/i18Languages.xsd | |
| +++ b/generate/src/main/resources/i18Languages.xsd | |
| @@ -134,6 +134,7 @@ | |
| <xsd:enumeration value="de-lu"/> | |
| <xsd:enumeration value="del"/> | |
| + <xsd:enumeration value="dheading"/> | |
| <xsd:enumeration value="den"/> |
This file contains hidden or 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 MainViewModelUnitTest { | |
| @get:Rule | |
| var coroutinesTestRule = CoroutinesTestRule() | |
| @Test | |
| fun test() { | |
| ... | |
| } | |
| } |
This file contains hidden or 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 MainViewModel(private val dependency: Any): ViewModel { | |
| fun sampleMethod() { | |
| viewModelScope.launch { | |
| val hashCode = dependency.hashCode() | |
| // TODO: do something with hashCode | |
| } | |
| } | |
| class MainViewModelUnitTest { |
This file contains hidden or 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
| allprojects { | |
| afterEvaluate { | |
| extensions.findByName('kapt')?.arguments { | |
| arg("dagger.formatGeneratedSource", "disabled") | |
| arg("dagger.gradle.incremental", "enabled") | |
| } | |
| } | |
| } |
This file contains hidden or 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
| @Provides | |
| fun provideNetworkPrinter() = NetworkPrinter() | |
| @Provides | |
| fun provideNetworkPrinter(): NetworkPrinter = NetworkPrinter() | |
| @Provides | |
| fun provideNetworkPrinter(): NetworkPrinter { | |
| return NetworkPrinter() | |
| } |
This file contains hidden or 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
| @Provides | |
| // configures a `Printer` | |
| fun providePrinter(): Printer = NetworkPrinter() | |
| @Provides | |
| // configures a `NetworkPrinter`, not a plain `Printer`! | |
| fun providePrinter() = NetworkPrinter() |
OlderNewer