Last active
November 23, 2017 06:37
-
-
Save hilfritz/c34aaaacef191830ff80cd9b72cc8e6f to your computer and use it in GitHub Desktop.
Android Kotlin Clean Arch Boilerplates
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
| ------------------------------------------------------------------- | |
| ------------------------build.gradle------------------------------- | |
| ------------------------------------------------------------------- | |
| /** | |
| * RxJava2 and RxAndroid2 gradle setup | |
| implementation 'com.android.support:design:26.1.0' | |
| compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.5' | |
| compile 'io.reactivex.rxjava2:rxandroid:2.0.1' | |
| */ | |
| ------------------------------------------------------------------- | |
| ------------------------AndroidTest.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| /** | |
| * Base class for Robolectric data layer tests. | |
| * Inherit from this class to create a test. | |
| * see: https://fernandocejas.com/2017/02/03/android-testing-with-kotlin/ | |
| * gradle setup below: | |
| testCompile "org.robolectric:robolectric:3.4.2" | |
| testCompile 'junit:junit:4.12' | |
| testCompile "com.nhaarman:mockito-kotlin:1.5.0" | |
| testImplementation 'junit:junit:4.12' | |
| androidTestImplementation 'com.android.support.test:runner:1.0.1' | |
| androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | |
| */ | |
| @RunWith(RobolectricTestRunner::class) | |
| @Config(constants = BuildConfig::class, | |
| application = AndroidTest.ApplicationStub::class, | |
| sdk = intArrayOf(22)) | |
| abstract class AndroidTest { | |
| fun context(): Context { | |
| return RuntimeEnvironment.application | |
| } | |
| fun cacheDir(): File { | |
| return context().cacheDir | |
| } | |
| internal class ApplicationStub : Application() | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------BaseActivity.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| open class BaseActivity: AppCompatActivity(){ | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------BaseFragment.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| open class BaseFragment : Fragment(){ | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------BasePresenter.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| interface BasePresenter<BaseView> { | |
| /** | |
| * must be called only once | |
| * - onCreateView()/onCreate() | |
| */ | |
| fun init(view: BaseView, bgThread: Scheduler, mainThread: Scheduler) | |
| /** | |
| * also called only once | |
| */ | |
| fun populate() | |
| /** | |
| * LIFECYCLE EVENTS | |
| */ | |
| fun destroyEvent() | |
| fun onStartEvent() | |
| fun onStopEvent() | |
| fun onResumeEvent() | |
| fun onPauseEvent() | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------BaseUseCase.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| interface BaseUseCase { | |
| fun run() | |
| fun destroy() | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------BaseUseView.kt----------------------------- | |
| ------------------------------------------------------------------- | |
| interface BaseView { | |
| fun getActivityContext():Context //try not to use this | |
| } | |
| ------------------------------------------------------------------- | |
| ------------------------.gitignore----------------------------- | |
| ------------------------------------------------------------------- | |
| # Created by https://www.gitignore.io/api/git,java,test,gradle,android,firebase,androidstudio | |
| ### Android ### | |
| # Built application files | |
| *.apk | |
| *.ap_ | |
| # Files for the ART/Dalvik VM | |
| *.dex | |
| # Java class files | |
| *.class | |
| # Generated files | |
| bin/ | |
| gen/ | |
| out/ | |
| # Gradle files | |
| .gradle/ | |
| build/ | |
| # Local configuration file (sdk path, etc) | |
| local.properties | |
| # Proguard folder generated by Eclipse | |
| proguard/ | |
| # Log Files | |
| *.log | |
| # Android Studio Navigation editor temp files | |
| .navigation/ | |
| # Android Studio captures folder | |
| captures/ | |
| # Intellij | |
| *.iml | |
| .idea/workspace.xml | |
| .idea/tasks.xml | |
| .idea/gradle.xml | |
| .idea/dictionaries | |
| .idea/libraries | |
| # External native build folder generated in Android Studio 2.2 and later | |
| .externalNativeBuild | |
| # Freeline | |
| freeline.py | |
| freeline/ | |
| freeline_project_description.json | |
| ### Android Patch ### | |
| gen-external-apklibs | |
| ### AndroidStudio ### | |
| # Covers files to be ignored for android development using Android Studio. | |
| # Built application files | |
| # Files for the ART/Dalvik VM | |
| # Java class files | |
| # Generated files | |
| # Gradle files | |
| .gradle | |
| # Signing files | |
| .signing/ | |
| # Local configuration file (sdk path, etc) | |
| # Proguard folder generated by Eclipse | |
| # Log Files | |
| # Android Studio | |
| /*/build/ | |
| /*/local.properties | |
| /*/out | |
| /*/*/build | |
| /*/*/production | |
| *.ipr | |
| *~ | |
| *.swp | |
| # Android Patch | |
| # External native build folder generated in Android Studio 2.2 and later | |
| # NDK | |
| obj/ | |
| # IntelliJ IDEA | |
| *.iws | |
| /out/ | |
| # User-specific configurations | |
| .idea/libraries/ | |
| .idea/.name | |
| .idea/compiler.xml | |
| .idea/copyright/profiles_settings.xml | |
| .idea/encodings.xml | |
| .idea/misc.xml | |
| .idea/modules.xml | |
| .idea/scopes/scope_settings.xml | |
| .idea/vcs.xml | |
| .idea/jsLibraryMappings.xml | |
| .idea/datasources.xml | |
| .idea/dataSources.ids | |
| .idea/sqlDataSources.xml | |
| .idea/dynamic.xml | |
| .idea/uiDesigner.xml | |
| # OS-specific files | |
| .DS_Store | |
| .DS_Store? | |
| ._* | |
| .Spotlight-V100 | |
| .Trashes | |
| ehthumbs.db | |
| Thumbs.db | |
| # Legacy Eclipse project files | |
| .classpath | |
| .project | |
| # Mobile Tools for Java (J2ME) | |
| .mtj.tmp/ | |
| # Package Files # | |
| *.war | |
| *.ear | |
| # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) | |
| hs_err_pid* | |
| ## Plugin-specific files: | |
| # mpeltonen/sbt-idea plugin | |
| .idea_modules/ | |
| # JIRA plugin | |
| atlassian-ide-plugin.xml | |
| # Mongo Explorer plugin | |
| .idea/mongoSettings.xml | |
| # Crashlytics plugin (for Android Studio and IntelliJ) | |
| com_crashlytics_export_strings.xml | |
| crashlytics.properties | |
| crashlytics-build.properties | |
| fabric.properties | |
| ### AndroidStudio Patch ### | |
| !/gradle/wrapper/gradle-wrapper.jar | |
| ### Firebase ### | |
| .idea | |
| **/node_modules/* | |
| **/.firebaserc | |
| ### Git ### | |
| *.orig | |
| ### Java ### | |
| # Compiled class file | |
| # Log file | |
| # BlueJ files | |
| *.ctxt | |
| # Mobile Tools for Java (J2ME) | |
| # Package Files # | |
| *.jar | |
| *.zip | |
| *.tar.gz | |
| *.rar | |
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | |
| ### Test ### | |
| ### Ignore all files that could be used to test your code and | |
| ### you wouldn't want to push | |
| # Reference https://en.wikipedia.org/wiki/Metasyntactic_variable | |
| # Most common | |
| *foo | |
| *bar | |
| *fubar | |
| *foobar | |
| *baz | |
| # Less common | |
| *qux | |
| *quux | |
| *bongo | |
| *bazola | |
| *ztesch | |
| # UK, Australia | |
| *wibble | |
| *wobble | |
| *wubble | |
| *flob | |
| *blep | |
| *blah | |
| *boop | |
| *beep | |
| # Japanese | |
| *hoge | |
| *piyo | |
| *fuga | |
| *hogera | |
| *hogehoge | |
| # Portugal, Spain | |
| *fulano | |
| *sicrano | |
| *beltrano | |
| *mengano | |
| *perengano | |
| *zutano | |
| # France, Italy, the Netherlands | |
| *toto | |
| *titi | |
| *tata | |
| *tutu | |
| *pipppo | |
| *pluto | |
| *paperino | |
| *aap | |
| *noot | |
| *mies | |
| # Other names that would make sense | |
| *tests | |
| *testsdir | |
| *testsfile | |
| *testsfiles | |
| *test | |
| *testdir | |
| *testfile | |
| *testfiles | |
| *testing | |
| *testingdir | |
| *testingfile | |
| *testingfiles | |
| *temp | |
| *tempdir | |
| *tempfile | |
| *tempfiles | |
| *tmp | |
| *tmpdir | |
| *tmpfile | |
| *tmpfiles | |
| *lol | |
| *.iml | |
| .gradle | |
| /local.properties | |
| /.idea/workspace.xml | |
| /.idea/libraries | |
| .DS_Store | |
| /build | |
| /captures | |
| .externalNativeBuild | |
| ### Gradle ### | |
| **/build/ | |
| # Ignore Gradle GUI config | |
| gradle-app.setting | |
| # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | |
| !gradle-wrapper.jar | |
| # Cache of project | |
| .gradletasknamecache | |
| # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | |
| # gradle/wrapper/gradle-wrapper.properties | |
| # End of https://www.gitignore.io/api/git,java,test,gradle,android,firebase,androidstudio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment