├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── App.kt
│ ├── test
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── kobakei
│ │ └── katsuo
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── data
├── api
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ └── strings.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── api
│ │ │ │ └── ApiClient.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── api
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── api
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── entity
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ └── strings.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── entity
│ │ │ │ ├── Articles.kt
│ │ │ │ ├── Ads.kt
│ │ │ │ ├── Author.kt
│ │ │ │ └── Article.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── entity
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── entity
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── database
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ └── strings.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── database
│ │ │ │ ├── ArticleDao.kt
│ │ │ │ └── AppDatabase.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── database
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── database
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
└── repository
│ ├── .gitignore
│ ├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── repository
│ │ │ ├── AdRepository.kt
│ │ │ └── ArticleRepository.kt
│ ├── androidTest
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── repository
│ │ │ └── ExampleInstrumentedTest.kt
│ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── kobakei
│ │ └── katsuo
│ │ └── repository
│ │ └── ArticleRepositoryTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── ui
├── author
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ └── strings.xml
│ │ │ │ └── layout
│ │ │ │ │ ├── author_activity.xml
│ │ │ │ │ ├── author_header.xml
│ │ │ │ │ └── author_item.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── author
│ │ │ │ ├── AuthorRouterImpl.kt
│ │ │ │ ├── AuthorViewModel.kt
│ │ │ │ ├── AuthorAdapter.kt
│ │ │ │ └── AuthorActivity.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── author
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── author
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── common
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── presentation
│ │ │ │ └── common
│ │ │ │ ├── ImageViewExt.kt
│ │ │ │ └── Extra.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── presentation
│ │ │ │ └── common
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── presentation
│ │ │ └── common
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── detail
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ └── strings.xml
│ │ │ │ ├── drawable
│ │ │ │ │ └── ic_share_black_24dp.xml
│ │ │ │ └── layout
│ │ │ │ │ └── detail_activity.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── detail
│ │ │ │ ├── DetailRouterImpl.kt
│ │ │ │ ├── DetailViewModel.kt
│ │ │ │ └── DetailActivity.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── detail
│ │ │ │ ├── ExampleUnitTest.kt
│ │ │ │ └── DetailViewModelTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── detail
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── router
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ └── values
│ │ │ │ │ └── strings.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── router
│ │ │ │ └── Router.kt
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── kobakei
│ │ │ │ └── katsuo
│ │ │ │ └── router
│ │ │ │ └── ExampleUnitTest.kt
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── router
│ │ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
└── timeline
│ ├── .gitignore
│ ├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── timeline_ad_item.xml
│ │ │ │ ├── timeline_article_item.xml
│ │ │ │ └── timeline_activity.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── timeline
│ │ │ ├── TimelineActivity.kt
│ │ │ ├── TimelineViewModel.kt
│ │ │ └── TimelineAdapter.kt
│ ├── test
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── kobakei
│ │ │ └── katsuo
│ │ │ └── timeline
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── kobakei
│ │ └── katsuo
│ │ └── timeline
│ │ └── ExampleInstrumentedTest.kt
│ ├── proguard-rules.pro
│ └── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── encodings.xml
├── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── vcs.xml
├── misc.xml
├── runConfigurations.xml
└── gradle.xml
├── .gitignore
├── settings.gradle
├── gradle.properties
├── .circleci
└── config.yml
├── README.md
├── gradlew.bat
├── versions.gradle
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/data/api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/data/entity/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ui/author/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ui/common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ui/detail/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ui/router/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ui/timeline/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/data/database/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/data/repository/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Katsuo
3 |
4 |
--------------------------------------------------------------------------------
/data/api/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Api
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/ui/author/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Author
3 |
4 |
--------------------------------------------------------------------------------
/ui/common/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Common
3 |
4 |
--------------------------------------------------------------------------------
/ui/detail/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Detail
3 |
4 |
--------------------------------------------------------------------------------
/ui/router/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Router
3 |
4 |
--------------------------------------------------------------------------------
/data/database/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Database
3 |
4 |
--------------------------------------------------------------------------------
/data/entity/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Entity
3 |
4 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Timeline
3 |
4 |
--------------------------------------------------------------------------------
/data/repository/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Repository
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kobakei/Katsuo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/data/api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/data/database/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/data/entity/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/ui/router/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/data/repository/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/ui/common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/data/entity/src/main/java/io/github/kobakei/katsuo/entity/Articles.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | @Serializable
6 | data class Articles(
7 | val articles: List
8 | )
--------------------------------------------------------------------------------
/ui/author/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ui/detail/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ui/common/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app',
2 | ':data:entity',
3 | ':data:api',
4 | ':data:database',
5 | ':data:repository',
6 | ':ui:common',
7 | ':ui:router',
8 | ':ui:timeline',
9 | ':ui:detail',
10 | ':ui:author'
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 21 02:01:10 JST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ui/common/src/main/java/io/github/kobakei/katsuo/presentation/common/ImageViewExt.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import android.widget.ImageView
4 | import androidx.databinding.BindingAdapter
5 | import com.bumptech.glide.Glide
6 |
7 | @BindingAdapter("imageUrl")
8 | fun ImageView.setImageUrl(url: String?) {
9 | Glide.with(this).load(url).into(this)
10 | }
--------------------------------------------------------------------------------
/data/entity/src/main/java/io/github/kobakei/katsuo/entity/Ads.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | @Serializable
6 | data class Ads(
7 | val timeline: Ad
8 | )
9 |
10 | @Serializable
11 | data class Ad(
12 | val id: Long,
13 | val description: String,
14 | val image: AdImage
15 | )
16 |
17 | @Serializable
18 | data class AdImage(
19 | val large: String
20 | )
--------------------------------------------------------------------------------
/data/entity/src/test/java/io/github/kobakei/katsuo/entity/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/data/repository/src/main/java/io/github/kobakei/katsuo/repository/AdRepository.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.repository
2 |
3 | import io.github.kobakei.katsuo.api.ApiClient
4 | import io.github.kobakei.katsuo.entity.Ad
5 |
6 | /**
7 | * 広告データのリポジトリ
8 | * このリポジトリは常にAPIクライアントからデータを取得する
9 | */
10 | class AdRepository(
11 | private val apiClient: ApiClient
12 | ) {
13 |
14 | suspend fun getTimelineAd(): Ad {
15 | return apiClient.getAdsAsync().timeline
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/ui/router/src/test/java/io/github/kobakei/katsuo/router/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.router
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/data/api/src/test/java/io/github/kobakei/katsuo/api/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.api
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, (2 + 2).toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/ui/author/src/test/java/io/github/kobakei/katsuo/author/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, (2 + 2).toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/ui/detail/src/test/java/io/github/kobakei/katsuo/detail/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, (2 + 2).toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/ui/timeline/src/test/java/io/github/kobakei/katsuo/timeline/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, (2 + 2).toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/data/database/src/test/java/io/github/kobakei/katsuo/database/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.database
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, (2 + 2).toLong())
16 | }
17 | }
--------------------------------------------------------------------------------
/ui/common/src/test/java/io/github/kobakei/katsuo/presentation/common/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.presentation.common
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see [Testing documentation](http://d.android.com/tools/testing)
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/ui/common/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ui/author/src/main/java/io/github/kobakei/katsuo/author/AuthorRouterImpl.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import io.github.kobakei.katsuo.entity.Author
6 | import io.github.kobakei.katsuo.router.AuthorRouter
7 |
8 | class AuthorRouterImpl : AuthorRouter {
9 | override fun navigateToAuthor(activity: Activity, author: Author) {
10 | val intent = AuthorActivity.createIntent(activity, author)
11 | activity.startActivity(intent)
12 | }
13 | }
--------------------------------------------------------------------------------
/ui/router/src/main/java/io/github/kobakei/katsuo/router/Router.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.router
2 |
3 | import android.app.Activity
4 | import io.github.kobakei.katsuo.entity.Article
5 | import io.github.kobakei.katsuo.entity.Author
6 |
7 | class Router(
8 | val detail: DetailRouter,
9 | val author: AuthorRouter
10 | )
11 |
12 | interface DetailRouter {
13 | fun navigateToDetail(activity: Activity, article: Article)
14 | }
15 |
16 | interface AuthorRouter {
17 | fun navigateToAuthor(activity: Activity, author: Author)
18 | }
--------------------------------------------------------------------------------
/ui/detail/src/main/java/io/github/kobakei/katsuo/detail/DetailRouterImpl.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import io.github.kobakei.katsuo.entity.Article
6 | import io.github.kobakei.katsuo.router.DetailRouter
7 |
8 | class DetailRouterImpl : DetailRouter {
9 |
10 | override fun navigateToDetail(activity: Activity, article: Article) {
11 | val intent = DetailActivity.createIntent(activity, article)
12 | activity.startActivity(intent)
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/test/java/io/github/kobakei/katsuo/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import org.junit.Assert.assertEquals
5 | import org.junit.Test
6 | import org.junit.runner.RunWith
7 |
8 | /**
9 | * Example local unit test, which will execute on the development machine (host).
10 | *
11 | * See [testing documentation](http://d.android.com/tools/testing).
12 | */
13 | @RunWith(AndroidJUnit4::class)
14 | class ExampleUnitTest {
15 | @Test
16 | fun addition_isCorrect() {
17 | assertEquals(4, 2 + 2)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/data/database/src/main/java/io/github/kobakei/katsuo/database/ArticleDao.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.database
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Insert
5 | import androidx.room.Query
6 | import io.github.kobakei.katsuo.entity.Article
7 |
8 | @Dao
9 | interface ArticleDao {
10 |
11 | @Query("SELECT * FROM article")
12 | suspend fun getAll(): List
13 |
14 | @Query("SELECT * FROM article WHERE author_id = :authorId")
15 | suspend fun getByAuthorId(authorId: Long): List
16 |
17 | @Insert
18 | suspend fun insertAll(vararg articles: Article)
19 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/data/database/src/main/java/io/github/kobakei/katsuo/database/AppDatabase.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.database
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 | import io.github.kobakei.katsuo.entity.Article
8 |
9 | @Database(entities = [
10 | Article::class
11 | ], version = 1, exportSchema = false)
12 | abstract class AppDatabase : RoomDatabase() {
13 |
14 | abstract fun articleDao(): ArticleDao
15 |
16 | }
17 |
18 | fun createDb(context: Context): AppDatabase =
19 | Room.databaseBuilder(context, AppDatabase::class.java, "database-name").build()
20 |
--------------------------------------------------------------------------------
/data/entity/src/main/java/io/github/kobakei/katsuo/entity/Author.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import android.os.Parcelable
4 | import androidx.room.ColumnInfo
5 | import androidx.room.Embedded
6 | import kotlinx.android.parcel.Parcelize
7 | import kotlinx.serialization.Serializable
8 |
9 | @Parcelize
10 | @Serializable
11 | data class Author(
12 | @ColumnInfo(name = "author_id") val id: Long,
13 | val name: String,
14 | @Embedded val image: AuthorImage?
15 | ): Parcelable
16 |
17 | @Parcelize
18 | @Serializable
19 | data class AuthorImage(
20 | @ColumnInfo(name = "author_image_thumbnail") val thumbnail: String,
21 | @ColumnInfo(name = "author_image_large") val large: String
22 | ): Parcelable
--------------------------------------------------------------------------------
/ui/common/src/main/java/io/github/kobakei/katsuo/presentation/common/Extra.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.presentation.common
2 |
3 | import android.app.Activity
4 | import kotlin.properties.ReadOnlyProperty
5 | import kotlin.reflect.KProperty
6 |
7 | class NonNullExtra : ReadOnlyProperty {
8 | @Suppress("UNCHECKED_CAST")
9 | override fun getValue(thisRef: Activity, property: KProperty<*>): T =
10 | requireNotNull(thisRef.intent.extras).get(property.name) as T
11 | }
12 |
13 | class NullableExtra : ReadOnlyProperty {
14 | @Suppress("UNCHECKED_CAST")
15 | override fun getValue(thisRef: Activity, property: KProperty<*>): T? =
16 | thisRef.intent.extras?.get(property.name) as? T
17 | }
--------------------------------------------------------------------------------
/data/entity/src/main/java/io/github/kobakei/katsuo/entity/Article.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import android.os.Parcelable
4 | import androidx.room.*
5 | import kotlinx.android.parcel.Parcelize
6 | import kotlinx.serialization.Serializable
7 |
8 | @Entity(indices = [Index("author_id")])
9 | @Parcelize
10 | @Serializable
11 | data class Article(
12 | @PrimaryKey val id: Long,
13 | val title: String,
14 | val body: String,
15 | @Embedded val image: ArticleImage,
16 | @Embedded val author: Author
17 | ): Parcelable
18 |
19 | @Parcelize
20 | @Serializable
21 | data class ArticleImage(
22 | @ColumnInfo(name = "article_image_thumbnail") val thumbnail: String,
23 | @ColumnInfo(name = "article_image_large") val large: String
24 | ): Parcelable
--------------------------------------------------------------------------------
/ui/detail/src/main/java/io/github/kobakei/katsuo/detail/DetailViewModel.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import android.view.View
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import io.github.kobakei.katsuo.entity.Article
7 | import io.github.kobakei.katsuo.entity.Author
8 |
9 | class DetailViewModel : ViewModel() {
10 |
11 | lateinit var article: Article
12 |
13 | val authorClick = MutableLiveData()
14 | val shareClick = MutableLiveData()
15 |
16 | fun onAuthorClick(@Suppress("UNUSED_PARAMETER") view: View) {
17 | authorClick.postValue(article.author)
18 | }
19 |
20 | fun onShareClick(@Suppress("UNUSED_PARAMETER") view: View) {
21 | shareClick.postValue(Unit)
22 | }
23 | }
--------------------------------------------------------------------------------
/ui/detail/src/main/res/drawable/ic_share_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/io/github/kobakei/katsuo/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("io.github.kobakei.katsuo", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/data/api/src/androidTest/java/io/github/kobakei/katsuo/api/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.api
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.api.test", appContext.getPackageName())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ui/router/src/androidTest/java/io/github/kobakei/katsuo/router/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.router
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 | import org.junit.Test
6 | import org.junit.runner.RunWith
7 |
8 | import org.junit.Assert.*
9 |
10 | /**
11 | * Instrumented test, which will execute on an Android device.
12 | *
13 | * @see [Testing documentation](http://d.android.com/tools/testing)
14 | */
15 | @RunWith(AndroidJUnit4::class)
16 | class ExampleInstrumentedTest {
17 | @Test
18 | fun useAppContext() {
19 | // Context of the app under test.
20 | val appContext = InstrumentationRegistry.getTargetContext()
21 |
22 | assertEquals("io.github.kobakei.katsuo.router.test", appContext.getPackageName())
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ui/author/src/androidTest/java/io/github/kobakei/katsuo/author/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.author.test", appContext.getPackageName())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ui/detail/src/androidTest/java/io/github/kobakei/katsuo/detail/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.detail.test", appContext.getPackageName())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/data/database/src/androidTest/java/io/github/kobakei/katsuo/database/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.database
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.database.test", appContext.packageName)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/data/api/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/data/entity/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/data/repository/src/androidTest/java/io/github/kobakei/katsuo/repository/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.repository
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 | import org.junit.Test
6 | import org.junit.runner.RunWith
7 |
8 | import org.junit.Assert.*
9 |
10 | /**
11 | * Instrumented test, which will execute on an Android device.
12 | *
13 | * @see [Testing documentation](http://d.android.com/tools/testing)
14 | */
15 | @RunWith(AndroidJUnit4::class)
16 | class ExampleInstrumentedTest {
17 | @Test
18 | fun useAppContext() {
19 | // Context of the app under test.
20 | val appContext = InstrumentationRegistry.getTargetContext()
21 |
22 | assertEquals("io.github.kobakei.katsuo.repository.test", appContext.getPackageName())
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ui/author/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/common/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/detail/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/router/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/timeline/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/timeline/src/androidTest/java/io/github/kobakei/katsuo/timeline/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.timeline.test", appContext.getPackageName())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/data/database/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/data/repository/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/ui/common/src/androidTest/java/io/github/kobakei/katsuo/presentation/common/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.presentation.common
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * @see [Testing documentation](http://d.android.com/tools/testing)
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 |
23 | assertEquals("io.github.kobakei.katsuo.presentation.common.test", appContext.getPackageName())
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/data/entity/src/androidTest/java/io/github/kobakei/katsuo/entity/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.entity
2 |
3 | import android.content.Context
4 | import android.support.test.InstrumentationRegistry
5 | import android.support.test.runner.AndroidJUnit4
6 |
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 |
10 | import org.junit.Assert.*
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see [Testing documentation](http://d.android.com/tools/testing)
16 | */
17 | @RunWith(AndroidJUnit4::class)
18 | class ExampleInstrumentedTest {
19 | @Test
20 | fun useAppContext() {
21 | // Context of the app under test.
22 | val appContext = InstrumentationRegistry.getTargetContext()
23 |
24 | assertEquals("io.github.kobakei.katsuo.entity.test", appContext.getPackageName())
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | android.useAndroidX=true
17 | android.enableJetifier=true
18 |
19 |
20 | # robolectric 4.0
21 | android.enableUnitTestBinaryResources=true
--------------------------------------------------------------------------------
/ui/author/src/main/java/io/github/kobakei/katsuo/author/AuthorViewModel.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import androidx.lifecycle.MutableLiveData
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import io.github.kobakei.katsuo.entity.Article
7 | import io.github.kobakei.katsuo.entity.Author
8 | import io.github.kobakei.katsuo.repository.ArticleRepository
9 | import kotlinx.coroutines.launch
10 |
11 | class AuthorViewModel(
12 | private val articleRepository: ArticleRepository
13 | ) : ViewModel() {
14 |
15 | val author = MutableLiveData()
16 | val articles = MutableLiveData>()
17 |
18 | val articleClick = MutableLiveData()
19 |
20 | fun loadArticles(author: Author) {
21 | this.author.value = author
22 | author.let {
23 | viewModelScope.launch {
24 | articles.value = articleRepository.getArticlesByAuthor(author)
25 | }
26 | }
27 | }
28 |
29 | fun onArticleClick(article: Article) {
30 | articleClick.postValue(article)
31 | }
32 | }
--------------------------------------------------------------------------------
/ui/router/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion build_versions.compile_sdk
8 |
9 | defaultConfig {
10 | minSdkVersion build_versions.min_sdk
11 | targetSdkVersion build_versions.target_sdk
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled true
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation project(':data:entity')
30 |
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 | implementation deps.kotlin.stdlib_jdk7
33 |
34 | testImplementation deps.test.junit
35 | testImplementation deps.test.arch_core_testing
36 |
37 | androidTestImplementation deps.test.runner
38 | androidTestImplementation deps.test.espresso_core
39 | }
40 |
--------------------------------------------------------------------------------
/data/repository/src/main/java/io/github/kobakei/katsuo/repository/ArticleRepository.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.repository
2 |
3 | import io.github.kobakei.katsuo.api.ApiClient
4 | import io.github.kobakei.katsuo.database.ArticleDao
5 | import io.github.kobakei.katsuo.entity.Article
6 | import io.github.kobakei.katsuo.entity.Author
7 |
8 | /**
9 | * 記事のリポジトリクラス
10 | * ローカルDBとAPIからデータを取得する。取得の優先度は、room => api。
11 | */
12 | class ArticleRepository(
13 | private val articleDao: ArticleDao,
14 | private val apiClient: ApiClient
15 | ) {
16 |
17 | /**
18 | * すべての記事を取得する
19 | */
20 | suspend fun getArticles(): List {
21 | val articles = articleDao.getAll()
22 | if (articles.isNotEmpty()) {
23 | return articles
24 | }
25 | val articles2 = apiClient.getArticlesAsync()
26 | articleDao.insertAll(*articles2.articles.toTypedArray())
27 | return articles2.articles
28 | }
29 |
30 | /**
31 | * 指定した著者のすべての記事を取得する
32 | */
33 | suspend fun getArticlesByAuthor(author: Author): List =
34 | articleDao.getByAuthorId(author.id)
35 | }
--------------------------------------------------------------------------------
/ui/author/src/main/res/layout/author_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/res/layout/timeline_ad_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/ui/common/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion build_versions.compile_sdk
8 |
9 | defaultConfig {
10 | minSdkVersion build_versions.min_sdk
11 | targetSdkVersion build_versions.target_sdk
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled true
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | dataBinding {
27 | enabled = true
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation deps.kotlin.stdlib_jdk7
34 |
35 | implementation deps.androidx.material
36 |
37 | implementation deps.glide.glide
38 | kapt deps.glide.compiler
39 |
40 | testImplementation deps.test.junit
41 | testImplementation deps.test.arch_core_testing
42 |
43 | androidTestImplementation deps.test.runner
44 | androidTestImplementation deps.test.espresso_core
45 | }
46 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | working_directory: ~/code
5 | docker:
6 | - image: circleci/android:api-28-alpha
7 | environment:
8 | JVM_OPTS: -Xmx3200m
9 | steps:
10 | - checkout
11 | - restore_cache:
12 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
13 | # - run:
14 | # name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
15 | # command: sudo chmod +x ./gradlew
16 | - run:
17 | name: Download Dependencies
18 | command: ./gradlew androidDependencies
19 | - save_cache:
20 | paths:
21 | - ~/.gradle
22 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
23 | - run:
24 | name: Run Tests
25 | command: ./gradlew lint test
26 | - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
27 | path: app/build/reports
28 | destination: reports
29 | - store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
30 | path: app/build/test-results
31 | # See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples
32 |
--------------------------------------------------------------------------------
/data/database/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion build_versions.compile_sdk
9 |
10 | defaultConfig {
11 | minSdkVersion build_versions.min_sdk
12 | targetSdkVersion build_versions.target_sdk
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation project(':data:entity')
28 |
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | implementation deps.kotlin.stdlib_jdk7
31 |
32 | // Room
33 | implementation deps.room.runtime
34 | implementation deps.room.ktx
35 | kapt deps.room.compiler
36 |
37 | testImplementation deps.test.junit
38 | testImplementation deps.test.arch_core_testing
39 |
40 | androidTestImplementation deps.test.runner
41 | androidTestImplementation deps.test.espresso_core
42 | }
43 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/data/api/src/main/java/io/github/kobakei/katsuo/api/ApiClient.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.api
2 |
3 | import com.jakewharton.retrofit2.converter.kotlinx.serialization.serializationConverterFactory
4 | import io.github.kobakei.katsuo.entity.Ads
5 | import io.github.kobakei.katsuo.entity.Articles
6 | import kotlinx.serialization.json.Json
7 | import okhttp3.MediaType
8 | import okhttp3.OkHttpClient
9 | import retrofit2.Retrofit
10 | import retrofit2.http.GET
11 |
12 | /**
13 | * Dummy json
14 | * https://gist.github.com/kobakei/a091214688e4c03e4e582019d16cc778
15 | */
16 | interface ApiClient {
17 | @GET("kobakei/a091214688e4c03e4e582019d16cc778/raw/b98a91dda49519564dc62bdc34c8c93734a24b82/articles.json")
18 | suspend fun getArticlesAsync(): Articles
19 |
20 | @GET("kobakei/a091214688e4c03e4e582019d16cc778/raw/b98a91dda49519564dc62bdc34c8c93734a24b82/ads.json")
21 | suspend fun getAdsAsync(): Ads
22 | }
23 |
24 | fun okHttpClient(): OkHttpClient {
25 | return OkHttpClient.Builder().build()
26 | }
27 |
28 | fun apiClient(): ApiClient {
29 | val retrofit = Retrofit.Builder()
30 | .addConverterFactory(serializationConverterFactory(MediaType.get("application/json"), Json))
31 | .client(okHttpClient())
32 | .baseUrl("https://gist.githubusercontent.com/")
33 | .build()
34 | return retrofit.create(ApiClient::class.java)
35 | }
--------------------------------------------------------------------------------
/data/entity/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 | apply plugin: 'kotlinx-serialization'
6 |
7 | android {
8 | compileSdkVersion build_versions.compile_sdk
9 |
10 | defaultConfig {
11 | minSdkVersion build_versions.min_sdk
12 | targetSdkVersion build_versions.target_sdk
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled true
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | // for Parcelize
29 | androidExtensions {
30 | experimental = true
31 | }
32 |
33 | dependencies {
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | implementation deps.kotlin.stdlib_jdk7
36 |
37 | // JSON
38 | implementation deps.kotlin.serialization_runtime
39 |
40 | // Room
41 | implementation deps.room.runtime
42 | kapt deps.room.compiler
43 |
44 | testImplementation deps.test.junit
45 | testImplementation deps.test.arch_core_testing
46 |
47 | androidTestImplementation deps.test.runner
48 | androidTestImplementation deps.test.espresso_core
49 | }
50 | repositories {
51 | mavenCentral()
52 | }
53 |
--------------------------------------------------------------------------------
/data/api/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion build_versions.compile_sdk
7 |
8 | defaultConfig {
9 | minSdkVersion build_versions.min_sdk
10 | targetSdkVersion build_versions.target_sdk
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation project(':data:entity')
33 |
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | implementation deps.kotlin.stdlib_jdk7
36 |
37 | implementation deps.okhttp
38 | implementation deps.retrofit.retrofit
39 | implementation deps.retrofit.serialization
40 |
41 | testImplementation deps.test.junit
42 | testImplementation deps.test.arch_core_testing
43 |
44 | androidTestImplementation deps.test.runner
45 | androidTestImplementation deps.test.espresso_core
46 | }
47 | repositories {
48 | mavenCentral()
49 | }
50 |
--------------------------------------------------------------------------------
/data/repository/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion build_versions.compile_sdk
7 |
8 | defaultConfig {
9 | minSdkVersion build_versions.min_sdk
10 | targetSdkVersion build_versions.target_sdk
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation project(':data:api')
29 | implementation project(':data:database')
30 | implementation project(':data:entity')
31 |
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation deps.kotlin.stdlib_jdk7
34 | implementation deps.kotlin.coroutines_core
35 | implementation deps.kotlin.coroutines_android
36 |
37 | // Room
38 | implementation deps.room.runtime
39 |
40 | testImplementation deps.test.junit
41 | testImplementation deps.test.mockk
42 | testImplementation deps.test.truth
43 | testImplementation deps.test.ext_truth
44 |
45 | androidTestImplementation deps.test.runner
46 | androidTestImplementation deps.test.espresso_core
47 | }
48 |
--------------------------------------------------------------------------------
/ui/detail/src/test/java/io/github/kobakei/katsuo/detail/DetailViewModelTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import android.view.View
4 | import androidx.arch.core.executor.testing.InstantTaskExecutorRule
5 | import com.google.common.truth.Truth
6 | import io.github.kobakei.katsuo.entity.Article
7 | import io.github.kobakei.katsuo.entity.ArticleImage
8 | import io.github.kobakei.katsuo.entity.Author
9 | import io.github.kobakei.katsuo.entity.AuthorImage
10 | import io.mockk.MockKAnnotations
11 | import io.mockk.impl.annotations.MockK
12 | import org.junit.Before
13 | import org.junit.Rule
14 | import org.junit.Test
15 |
16 | class DetailViewModelTest {
17 |
18 | @Rule
19 | @JvmField
20 | val instantTaskExecutorRule = InstantTaskExecutorRule()
21 |
22 | @MockK
23 | lateinit var view: View
24 |
25 | @Before
26 | fun setup() = MockKAnnotations.init(this)
27 |
28 | @Test
29 | fun onAuthorClick_isCorrect() {
30 | val author = Author(
31 | id = 123,
32 | name = "Hoge",
33 | image = AuthorImage(
34 | thumbnail = "",
35 | large = ""
36 | )
37 | )
38 | val viewModel = DetailViewModel().apply {
39 | article = Article(
40 | id = 1,
41 | title = "Title",
42 | body = "Body",
43 | image = ArticleImage(
44 | thumbnail = "",
45 | large = ""
46 | ),
47 | author = author
48 | )
49 | }
50 | viewModel.onAuthorClick(view)
51 | Truth.assertThat(viewModel.authorClick.value).isEqualTo(author)
52 | }
53 | }
--------------------------------------------------------------------------------
/ui/timeline/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion build_versions.compile_sdk
8 |
9 | defaultConfig {
10 | minSdkVersion build_versions.min_sdk
11 | targetSdkVersion build_versions.target_sdk
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled true
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | dataBinding {
27 | enabled = true
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation project(':data:entity')
33 | implementation project(':data:repository')
34 | implementation project(':ui:common')
35 | implementation project(':ui:router')
36 |
37 | implementation fileTree(dir: 'libs', include: ['*.jar'])
38 | implementation deps.kotlin.stdlib_jdk7
39 |
40 | // UI
41 | implementation deps.androidx.appcompat
42 | implementation deps.androidx.recyclerview
43 | implementation deps.androidx.constraint
44 |
45 | // Lifecycle
46 | implementation deps.androidx.lifecycle
47 | kapt deps.androidx.lifecycle_compiler
48 |
49 | // KTX
50 | implementation deps.androidx.core_ktx
51 | implementation deps.androidx.viewmodel_ktx
52 |
53 | implementation deps.koin_viewmodel
54 |
55 | implementation deps.timber
56 |
57 | testImplementation deps.test.junit
58 | testImplementation deps.test.arch_core_testing
59 |
60 | androidTestImplementation deps.test.runner
61 | androidTestImplementation deps.test.espresso_core
62 | }
63 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/java/io/github/kobakei/katsuo/timeline/TimelineActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import androidx.databinding.DataBindingUtil
6 | import androidx.lifecycle.Observer
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import io.github.kobakei.katsuo.router.DetailRouter
9 | import io.github.kobakei.katsuo.router.Router
10 | import io.github.kobakei.katsuo.timeline.databinding.TimelineActivityBinding
11 | import org.koin.android.ext.android.inject
12 | import org.koin.android.viewmodel.ext.android.viewModel
13 |
14 | class TimelineActivity : AppCompatActivity() {
15 |
16 | private lateinit var binding: TimelineActivityBinding
17 | private val timelineViewModel: TimelineViewModel by viewModel()
18 | private val router: Router by inject()
19 | private lateinit var adapter: TimelineAdapter
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 |
24 | binding = DataBindingUtil.setContentView(this, R.layout.timeline_activity)
25 | binding.lifecycleOwner = this
26 |
27 | binding.viewModel = timelineViewModel
28 | observeViewModel()
29 |
30 | adapter = TimelineAdapter(this, timelineViewModel)
31 | binding.recyclerView.adapter = adapter
32 | binding.recyclerView.layoutManager = LinearLayoutManager(this)
33 |
34 | timelineViewModel.loadData()
35 | }
36 |
37 | private fun observeViewModel() {
38 | timelineViewModel.timelineData.observe(this, Observer {
39 | adapter.notifyDataSetChanged()
40 | })
41 | timelineViewModel.articleClick.observe(this, Observer {
42 | router.detail.navigateToDetail(this, it)
43 | })
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ui/author/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-kapt'
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion build_versions.compile_sdk
9 |
10 | defaultConfig {
11 | minSdkVersion build_versions.min_sdk
12 | targetSdkVersion build_versions.target_sdk
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | dataBinding {
26 | enabled = true
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation project(':data:entity')
32 | implementation project(':data:repository')
33 | implementation project(':ui:common')
34 | implementation project(':ui:router')
35 |
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | implementation deps.kotlin.stdlib_jdk7
38 |
39 | // UI
40 | implementation deps.androidx.appcompat
41 | implementation deps.androidx.recyclerview
42 | implementation deps.androidx.constraint
43 |
44 | // Lifecycle
45 | implementation deps.androidx.lifecycle
46 | kapt deps.androidx.lifecycle_compiler
47 |
48 | // KTX
49 | implementation deps.androidx.core_ktx
50 | implementation deps.androidx.viewmodel_ktx
51 |
52 | implementation deps.koin_viewmodel
53 |
54 | implementation deps.timber
55 |
56 | testImplementation deps.test.junit
57 | testImplementation deps.test.arch_core_testing
58 |
59 | androidTestImplementation deps.test.runner
60 | androidTestImplementation deps.test.espresso_core
61 | }
62 |
--------------------------------------------------------------------------------
/ui/author/src/main/res/layout/author_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
28 |
29 |
42 |
43 |
--------------------------------------------------------------------------------
/data/repository/src/test/java/io/github/kobakei/katsuo/repository/ArticleRepositoryTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.repository
2 |
3 | import com.google.common.truth.Truth
4 | import io.github.kobakei.katsuo.api.ApiClient
5 | import io.github.kobakei.katsuo.database.ArticleDao
6 | import io.github.kobakei.katsuo.entity.Article
7 | import io.github.kobakei.katsuo.entity.Articles
8 | import io.github.kobakei.katsuo.entity.Author
9 | import io.mockk.coEvery
10 | import io.mockk.mockk
11 | import kotlinx.coroutines.runBlocking
12 | import org.junit.Test
13 |
14 | class ArticleRepositoryTest {
15 |
16 | private val articles = listOf(
17 | mockk(),
18 | mockk(),
19 | mockk()
20 | )
21 |
22 | @Test
23 | fun getArticles_isCorrectWithoutCache() {
24 | val dao = mockk()
25 | coEvery { dao.getAll() } returns listOf()
26 | coEvery { dao.insertAll(any(), any(), any()) } returns Unit
27 |
28 | val api = mockk()
29 | coEvery { api.getArticlesAsync() } returns Articles(
30 | articles = articles
31 | )
32 |
33 | val repo = ArticleRepository(dao, api)
34 | runBlocking {
35 | Truth.assertThat(repo.getArticles())
36 | .containsExactlyElementsIn(articles)
37 | }
38 | }
39 |
40 | @Test
41 | fun getArticlesByAuthor_isCorrect() {
42 | val author = Author(
43 | id = 1,
44 | name = "John",
45 | image = null
46 | )
47 | val dao = mockk()
48 | coEvery { dao.getByAuthorId(author.id) } returns articles
49 |
50 | val api = mockk()
51 |
52 | runBlocking {
53 | val repo = ArticleRepository(dao, api)
54 | Truth.assertThat(repo.getArticlesByAuthor(author))
55 | .containsExactlyElementsIn(articles)
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/ui/detail/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion build_versions.compile_sdk
8 |
9 | defaultConfig {
10 | minSdkVersion build_versions.min_sdk
11 | targetSdkVersion build_versions.target_sdk
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled true
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | dataBinding {
27 | enabled = true
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation project(':data:entity')
33 | implementation project(':ui:common')
34 | implementation project(':ui:router')
35 |
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | implementation deps.kotlin.stdlib_jdk7
38 |
39 | // UI
40 | implementation deps.androidx.appcompat
41 | implementation deps.androidx.recyclerview
42 | implementation deps.androidx.constraint
43 | implementation deps.androidx.material
44 |
45 | // Lifecycle
46 | implementation deps.androidx.lifecycle
47 | kapt deps.androidx.lifecycle_compiler
48 |
49 | // KTX
50 | implementation deps.androidx.core_ktx
51 | implementation deps.androidx.viewmodel_ktx
52 |
53 | implementation deps.koin_viewmodel
54 |
55 | implementation deps.timber
56 |
57 | testImplementation deps.test.junit
58 | testImplementation deps.test.arch_core_testing
59 | testImplementation deps.test.mockk
60 | testImplementation deps.test.truth
61 | testImplementation deps.test.ext_truth
62 |
63 | androidTestImplementation deps.test.runner
64 | androidTestImplementation deps.test.espresso_core
65 | }
66 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/res/layout/timeline_article_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
13 |
14 |
15 |
20 |
28 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/ui/author/src/main/res/layout/author_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
13 |
14 |
15 |
20 |
21 |
34 |
35 |
48 |
49 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-android-extensions'
5 | apply plugin: 'kotlin-kapt'
6 |
7 | android {
8 | compileSdkVersion build_versions.compile_sdk
9 | defaultConfig {
10 | applicationId "io.github.kobakei.katsuo"
11 | minSdkVersion build_versions.min_sdk
12 | targetSdkVersion build_versions.target_sdk
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 |
17 | // robolectric
18 | testOptions.unitTests.includeAndroidResources = true
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled true
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | dataBinding {
27 | enabled = true
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | }
34 |
35 | dependencies {
36 | // DIでモジュール間を結合するため、ほぼすべてのモジュールに依存する
37 | implementation project(':ui:timeline')
38 | implementation project(':ui:detail')
39 | implementation project(':ui:author')
40 | implementation project(':ui:router')
41 | implementation project(':data:repository')
42 | implementation project(':data:api')
43 | implementation project(':data:database')
44 | implementation project(':data:entity')
45 |
46 | implementation fileTree(include: ['*.jar'], dir: 'libs')
47 | implementation deps.kotlin.stdlib_jdk7
48 |
49 | implementation deps.androidx.appcompat
50 |
51 | implementation deps.koin_viewmodel
52 |
53 | implementation deps.timber
54 | implementation deps.stetho
55 |
56 | // Room
57 | implementation deps.room.runtime
58 |
59 | testImplementation deps.test.junit
60 | testImplementation deps.test.runner
61 | testImplementation deps.test.rules
62 | testImplementation deps.test.ext_junit_ktx
63 | testImplementation deps.test.arch_core_testing
64 | testImplementation deps.test.robolectric
65 |
66 | androidTestImplementation deps.test.runner
67 | androidTestImplementation deps.test.espresso_core
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/kobakei/katsuo/App.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo
2 |
3 | import android.app.Application
4 | import com.facebook.stetho.Stetho
5 | import io.github.kobakei.katsuo.api.apiClient
6 | import io.github.kobakei.katsuo.author.AuthorRouterImpl
7 | import io.github.kobakei.katsuo.author.AuthorViewModel
8 | import io.github.kobakei.katsuo.database.createDb
9 | import io.github.kobakei.katsuo.detail.DetailRouterImpl
10 | import io.github.kobakei.katsuo.detail.DetailViewModel
11 | import io.github.kobakei.katsuo.repository.AdRepository
12 | import io.github.kobakei.katsuo.repository.ArticleRepository
13 | import io.github.kobakei.katsuo.router.AuthorRouter
14 | import io.github.kobakei.katsuo.router.DetailRouter
15 | import io.github.kobakei.katsuo.router.Router
16 | import io.github.kobakei.katsuo.timeline.TimelineViewModel
17 | import org.koin.android.ext.koin.androidContext
18 | import org.koin.android.ext.koin.androidLogger
19 | import org.koin.android.viewmodel.dsl.viewModel
20 | import org.koin.core.context.startKoin
21 | import org.koin.dsl.module
22 | import timber.log.Timber
23 |
24 | class App : Application() {
25 |
26 | override fun onCreate() {
27 | super.onCreate()
28 |
29 | if (BuildConfig.DEBUG) {
30 | Timber.plant(Timber.DebugTree())
31 | Stetho.initializeWithDefaults(this)
32 | }
33 |
34 | startKoin {
35 | androidLogger()
36 | androidContext(this@App)
37 | modules(
38 | listOf(
39 | routerModule,
40 | viewModelModule,
41 | repoModule,
42 | dataModule
43 | )
44 | )
45 | }
46 | }
47 | }
48 |
49 | val dataModule = module {
50 | single { apiClient() }
51 | single { createDb(get()).articleDao() }
52 | }
53 |
54 | val repoModule = module {
55 | single { ArticleRepository(get(), get()) }
56 | single { AdRepository(get()) }
57 | }
58 |
59 | val routerModule = module {
60 | single { DetailRouterImpl() }
61 | single { AuthorRouterImpl() }
62 | single { Router(get(), get()) }
63 | }
64 |
65 | val viewModelModule = module {
66 | viewModel { TimelineViewModel(get(), get()) }
67 | viewModel { DetailViewModel() }
68 | viewModel { AuthorViewModel(get()) }
69 | }
--------------------------------------------------------------------------------
/ui/timeline/src/main/java/io/github/kobakei/katsuo/timeline/TimelineViewModel.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import android.view.View
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import io.github.kobakei.katsuo.entity.Ad
8 | import io.github.kobakei.katsuo.entity.Article
9 | import io.github.kobakei.katsuo.repository.AdRepository
10 | import io.github.kobakei.katsuo.repository.ArticleRepository
11 | import kotlinx.coroutines.*
12 | import timber.log.Timber
13 |
14 | data class TimelineData(
15 | val articles: List,
16 | val ad: Ad?
17 | )
18 |
19 | class TimelineViewModel(
20 | private val articleRepo: ArticleRepository,
21 | private val adRepo: AdRepository
22 | ) : ViewModel() {
23 |
24 | val timelineData = MutableLiveData()
25 |
26 | val progressVisibility = MutableLiveData().apply { postValue(View.VISIBLE) }
27 |
28 | val reloadVisibility = MutableLiveData().apply { postValue(View.GONE) }
29 |
30 | val articleClick = MutableLiveData()
31 |
32 | /**
33 | * 複数のデータを取得して表示するサンプル
34 | * ・並列実行: suspend blockをasyncで囲む
35 | * ・例外処理: supervisorScope.launchで囲む
36 | * ・エラーを無視: asyncの中をさらにrunCatchingで囲み、ResultをgetOrNullで変換
37 | */
38 | fun loadData() {
39 | viewModelScope.launch {
40 | supervisorScope {
41 | runCatching {
42 | val articlesAsync = async { articleRepo.getArticles() }
43 | val adAsync = async {
44 | runCatching { adRepo.getTimelineAd() }.getOrNull()
45 | }
46 | TimelineData(articlesAsync.await(), adAsync.await())
47 | }.fold(
48 | onSuccess = {
49 | timelineData.postValue(it)
50 | },
51 | onFailure = {
52 | reloadVisibility.postValue(View.VISIBLE)
53 | }
54 | )
55 | progressVisibility.postValue(View.GONE)
56 | }
57 | }
58 | }
59 |
60 | fun onItemClick(article: Article) {
61 | Timber.v("click: ${article.title}")
62 | articleClick.postValue(article)
63 | }
64 |
65 | fun onReloadClick() {
66 | progressVisibility.postValue(View.VISIBLE)
67 | reloadVisibility.postValue(View.GONE)
68 | loadData()
69 | }
70 | }
--------------------------------------------------------------------------------
/ui/detail/src/main/java/io/github/kobakei/katsuo/detail/DetailActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.detail
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import androidx.appcompat.app.AppCompatActivity
6 | import android.os.Bundle
7 | import android.view.MenuItem
8 | import android.widget.Toast
9 | import androidx.databinding.DataBindingUtil
10 | import androidx.lifecycle.Observer
11 | import io.github.kobakei.katsuo.detail.databinding.DetailActivityBinding
12 | import io.github.kobakei.katsuo.entity.Article
13 | import io.github.kobakei.katsuo.presentation.common.NonNullExtra
14 | import io.github.kobakei.katsuo.router.Router
15 | import org.koin.android.ext.android.inject
16 | import org.koin.android.viewmodel.ext.android.viewModel
17 |
18 | class DetailActivity : AppCompatActivity() {
19 |
20 | private lateinit var binding: DetailActivityBinding
21 | private val detailViewModel: DetailViewModel by viewModel()
22 | private val router: Router by inject()
23 |
24 | private val article: Article by NonNullExtra()
25 |
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 |
29 | binding = DataBindingUtil.setContentView(this, R.layout.detail_activity)
30 | binding.lifecycleOwner = this
31 | binding.viewModel = detailViewModel
32 |
33 | detailViewModel.article = article
34 |
35 | observeViewModel()
36 |
37 | supportActionBar?.apply {
38 | setDisplayShowHomeEnabled(true)
39 | }
40 | }
41 |
42 | override fun onOptionsItemSelected(item: MenuItem?): Boolean {
43 | return when (item?.itemId) {
44 | android.R.id.home -> {
45 | finish()
46 | true
47 | }
48 | else -> super.onOptionsItemSelected(item)
49 | }
50 | }
51 |
52 | private fun observeViewModel() {
53 | detailViewModel.authorClick.observe(this, Observer {
54 | router.author.navigateToAuthor(this, it)
55 | })
56 | detailViewModel.shareClick.observe(this, Observer {
57 | Toast.makeText(this, "Not implemented", Toast.LENGTH_SHORT).show()
58 | })
59 | }
60 |
61 | companion object {
62 | fun createIntent(activity: Activity, article: Article): Intent =
63 | Intent(activity, DetailActivity::class.java).apply {
64 | putExtra(DetailActivity::article.name, article)
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Katsuo
2 |
3 | [](https://circleci.com/gh/kobakei/Katsuo)
4 |
5 | This is a sample that adopted the latest trend in Android development.
6 |
7 | This app is supposed to be the official application of the news site. This app holds timeline screen, article screen, and author's screen.
8 |
9 | ## Architecture
10 |
11 | The architecture of this application mainly follows the following three items.
12 |
13 | - Multi modules
14 | - MVVM
15 | - Layered architecture
16 |
17 | This application does not adopt Flux or Redux. In applications where state management is not complicated, I think they are over-engineering.
18 |
19 | ### Modules
20 |
21 | - app
22 | - Module with Application class or DI related class
23 | - ui/timeline, ui/author, ui/detail
24 | - Module of each feature
25 | - ui/router
26 | - Module of router interfaces. The implementations of routers are in each feature module.
27 | - ui/common
28 | - Module of classes and extension functions commonly used by other UI modules
29 | - data/repository
30 | - Module of repository classes
31 | - data/api
32 | - Module of API client
33 | - data/database
34 | - Module of database
35 | - data/entity
36 | - Module of entity classes
37 |
38 | ## Libraries
39 |
40 | I am adopting libraries that are standard in Android development and widely used as much as possible.
41 | In addition, I try to use what Kotlin's language function provides as much as possible.
42 |
43 | - Kotlin
44 | - Coroutines
45 | - Serialization
46 | - Parcelize
47 | - Android Jetpack
48 | - Data binding
49 | - Lifecycle & ViewModel
50 | - LiveData
51 | - KTX
52 | - Room
53 | - Koin
54 | - OkHttp
55 | - Retrofit
56 | - KotlinX serialization converter
57 | - Glide
58 | - Timber
59 | - Stetho
60 | - Robolectric
61 | - MockK
62 | - Truth
63 |
64 | ## TODO
65 |
66 | Please check issues.
67 |
68 | ## License
69 |
70 | ```
71 | Copyright 2019-present Keisuke Kobayashi
72 |
73 | Licensed under the Apache License, Version 2.0 (the "License");
74 | you may not use this file except in compliance with the License.
75 | You may obtain a copy of the License at
76 |
77 | http://www.apache.org/licenses/LICENSE-2.0
78 |
79 | Unless required by applicable law or agreed to in writing, software
80 | distributed under the License is distributed on an "AS IS" BASIS,
81 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82 | See the License for the specific language governing permissions and
83 | limitations under the License.
84 | ```
85 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/ui/author/src/main/java/io/github/kobakei/katsuo/author/AuthorAdapter.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.databinding.ViewDataBinding
7 | import androidx.recyclerview.widget.RecyclerView
8 | import io.github.kobakei.katsuo.author.databinding.AuthorHeaderBinding
9 | import io.github.kobakei.katsuo.author.databinding.AuthorItemBinding
10 | import io.github.kobakei.katsuo.entity.Article
11 | import io.github.kobakei.katsuo.entity.Author
12 |
13 | class AuthorAdapter(context: Context, val viewModel: AuthorViewModel) : RecyclerView.Adapter() {
14 |
15 | private val inflater = LayoutInflater.from(context)
16 |
17 | var author: Author? = null
18 | var articles = mutableListOf()
19 |
20 | override fun getItemViewType(position: Int): Int {
21 | return if (position == 0) {
22 | TYPE_HEADER
23 | } else {
24 | TYPE_ITEM
25 | }
26 | }
27 |
28 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AuthorViewHolder {
29 | return when (viewType) {
30 | TYPE_HEADER -> {
31 | val binding = AuthorHeaderBinding.inflate(inflater, parent, false)
32 | AuthorHeaderViewHolder(binding)
33 | }
34 | TYPE_ITEM -> {
35 | val binding = AuthorItemBinding.inflate(inflater, parent, false)
36 | binding.viewModel = viewModel
37 | AuthorItemViewHolder(binding)
38 | }
39 | else -> throw IllegalArgumentException()
40 | }
41 | }
42 |
43 | override fun getItemCount(): Int = articles.size + 1
44 |
45 | override fun onBindViewHolder(holder: AuthorViewHolder, position: Int) {
46 | when (holder) {
47 | is AuthorHeaderViewHolder -> {
48 | holder.binding.author = author
49 | holder.binding.executePendingBindings()
50 | }
51 | is AuthorItemViewHolder -> {
52 | holder.binding.article = articles[position - 1]
53 | holder.binding.executePendingBindings()
54 | }
55 | }
56 | }
57 |
58 | companion object {
59 | private const val TYPE_HEADER = 1
60 | private const val TYPE_ITEM = 2
61 | }
62 | }
63 |
64 | sealed class AuthorViewHolder(binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root)
65 | class AuthorHeaderViewHolder(val binding: AuthorHeaderBinding) : AuthorViewHolder(binding)
66 | class AuthorItemViewHolder(val binding: AuthorItemBinding) : AuthorViewHolder(binding)
67 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/res/layout/timeline_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
31 |
32 |
46 |
47 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/ui/author/src/main/java/io/github/kobakei/katsuo/author/AuthorActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.author
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import androidx.appcompat.app.AppCompatActivity
6 | import android.os.Bundle
7 | import android.view.MenuItem
8 | import androidx.databinding.DataBindingUtil
9 | import androidx.lifecycle.Observer
10 | import androidx.recyclerview.widget.LinearLayoutManager
11 | import io.github.kobakei.katsuo.author.databinding.AuthorActivityBinding
12 | import io.github.kobakei.katsuo.entity.Author
13 | import io.github.kobakei.katsuo.presentation.common.NonNullExtra
14 | import io.github.kobakei.katsuo.router.Router
15 | import org.koin.android.ext.android.inject
16 | import org.koin.android.viewmodel.ext.android.viewModel
17 |
18 | class AuthorActivity : AppCompatActivity() {
19 |
20 | private lateinit var binding: AuthorActivityBinding
21 | private val authorViewModel: AuthorViewModel by viewModel()
22 | private lateinit var adapter: AuthorAdapter
23 | private val router: Router by inject()
24 |
25 | private val author: Author by NonNullExtra()
26 |
27 | override fun onCreate(savedInstanceState: Bundle?) {
28 | super.onCreate(savedInstanceState)
29 | binding = DataBindingUtil.setContentView(this, R.layout.author_activity)
30 | binding.lifecycleOwner = this
31 | binding.viewModel = authorViewModel
32 | observeViewModel()
33 |
34 | authorViewModel.loadArticles(author)
35 |
36 | adapter = AuthorAdapter(this, authorViewModel)
37 | binding.recyclerView.adapter = adapter
38 | binding.recyclerView.layoutManager = LinearLayoutManager(this)
39 |
40 | supportActionBar?.apply {
41 | setDisplayShowHomeEnabled(true)
42 | }
43 | }
44 |
45 | override fun onOptionsItemSelected(item: MenuItem?): Boolean {
46 | return when (item?.itemId) {
47 | android.R.id.home -> {
48 | finish()
49 | true
50 | }
51 | else -> super.onOptionsItemSelected(item)
52 | }
53 | }
54 |
55 | private fun observeViewModel() {
56 | authorViewModel.author.observe(this, Observer {
57 | adapter.author = it
58 | adapter.notifyDataSetChanged()
59 | })
60 | authorViewModel.articles.observe(this, Observer {
61 | adapter.articles.clear()
62 | adapter.articles.addAll(it)
63 | adapter.notifyDataSetChanged()
64 | })
65 | authorViewModel.articleClick.observe(this, Observer {
66 | router.detail.navigateToDetail(this, it)
67 | })
68 | }
69 |
70 | companion object {
71 | fun createIntent(activity: Activity, author: Author): Intent =
72 | Intent(activity, AuthorActivity::class.java).apply {
73 | putExtra(AuthorActivity::author.name, author)
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ui/timeline/src/main/java/io/github/kobakei/katsuo/timeline/TimelineAdapter.kt:
--------------------------------------------------------------------------------
1 | package io.github.kobakei.katsuo.timeline
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.databinding.ViewDataBinding
7 | import androidx.recyclerview.widget.RecyclerView
8 | import io.github.kobakei.katsuo.entity.Ad
9 | import io.github.kobakei.katsuo.entity.Article
10 | import io.github.kobakei.katsuo.timeline.databinding.TimelineAdItemBinding
11 | import io.github.kobakei.katsuo.timeline.databinding.TimelineArticleItemBinding
12 |
13 | sealed class TimelineViewHolder(binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root)
14 | class TimelineArticleViewHolder(val binding: TimelineArticleItemBinding): TimelineViewHolder(binding)
15 | class TimelineAdViewHolder(val binding: TimelineAdItemBinding): TimelineViewHolder(binding)
16 |
17 | /**
18 | * タイムライン画面のアダプター
19 | * この画面は、記事のリストがまず並び、一番下に広告が出ます。
20 | */
21 | class TimelineAdapter(
22 | context: Context,
23 | private val timelineViewModel: TimelineViewModel
24 | ) : RecyclerView.Adapter() {
25 |
26 | private val inflater = LayoutInflater.from(context)
27 |
28 | private val articles: List
29 | get() = timelineViewModel.timelineData.value?.articles ?: listOf()
30 |
31 | private val ad: Ad?
32 | get() = timelineViewModel.timelineData.value?.ad
33 |
34 | override fun getItemViewType(position: Int): Int {
35 | return if (position < articles.size) {
36 | TYPE_ARTICLE
37 | } else {
38 | TYPE_AD
39 | }
40 | }
41 |
42 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TimelineViewHolder {
43 | return when (viewType) {
44 | TYPE_ARTICLE -> {
45 | val binding = TimelineArticleItemBinding.inflate(inflater, parent, false)
46 | binding.viewModel = timelineViewModel
47 | TimelineArticleViewHolder(binding)
48 | }
49 | TYPE_AD -> {
50 | val binding = TimelineAdItemBinding.inflate(inflater, parent, false)
51 | TimelineAdViewHolder(binding)
52 | }
53 | else -> throw IllegalArgumentException()
54 | }
55 | }
56 |
57 | override fun getItemCount(): Int {
58 | var count = articles.size
59 | if (ad != null) {
60 | count++
61 | }
62 | return count
63 | }
64 |
65 | override fun onBindViewHolder(holder: TimelineViewHolder, position: Int) {
66 | when (holder) {
67 | is TimelineArticleViewHolder -> {
68 | val binding = holder.binding
69 | binding.item = articles[position]
70 | binding.executePendingBindings()
71 | }
72 | is TimelineAdViewHolder -> {
73 | val binding = holder.binding
74 | binding.ad = ad
75 | binding.executePendingBindings()
76 | }
77 | }
78 | }
79 |
80 | companion object {
81 | private const val TYPE_ARTICLE = 1
82 | private const val TYPE_AD = 2
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | xmlns:android
17 | ^$
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | xmlns:.*
27 | ^$
28 |
29 |
30 | BY_NAME
31 |
32 |
33 |
34 |
35 |
36 |
37 | .*:id
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 | http://schemas.android.com/apk/res/android
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | name
58 | ^$
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | style
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 | ^$
79 |
80 |
81 | BY_NAME
82 |
83 |
84 |
85 |
86 |
87 |
88 | .*
89 | http://schemas.android.com/apk/res/android
90 |
91 |
92 | ANDROID_ATTRIBUTE_ORDER
93 |
94 |
95 |
96 |
97 |
98 |
99 | .*
100 | .*
101 |
102 |
103 | BY_NAME
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/ui/detail/src/main/res/layout/detail_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
27 |
28 |
40 |
41 |
52 |
53 |
65 |
66 |
77 |
78 |
89 |
90 |
--------------------------------------------------------------------------------
/versions.gradle:
--------------------------------------------------------------------------------
1 | def build_versions = [:]
2 | build_versions.min_sdk = 21
3 | build_versions.compile_sdk = 28
4 | build_versions.target_sdk = 28
5 | ext.build_versions = build_versions
6 |
7 | def versions = [:]
8 |
9 | versions.android_gradle_plugin = '3.5.0'
10 |
11 | // kotlin
12 | versions.kotlin = '1.3.40'
13 | versions.kotlin_serialization = '0.11.1'
14 | versions.coroutines = '1.2.2'
15 |
16 | // jetpack
17 | // ref: https://developer.android.com/jetpack/androidx/versions
18 | versions.appcompat = '1.1.0'
19 | versions.recycler = '1.1.0-beta04'
20 | versions.material = "1.1.0-alpha10"
21 | versions.lifecycle = "2.1.0"
22 | versions.constraint = '1.1.3'
23 | versions.room_version = '2.1.0'
24 |
25 | // other libs
26 | versions.koin = '2.0.1'
27 | versions.okhttp = '3.14.2'
28 | versions.retrofit = '2.6.0'
29 | versions.retrofit_serialization = '0.4.0'
30 | versions.glide = '4.8.0'
31 | versions.timber = '4.7.1'
32 | versions.stetho = '1.5.0'
33 |
34 | // test
35 | versions.junit = '4.12'
36 | versions.test_core = '1.1.0'
37 | versions.test_runner = '1.1.0'
38 | versions.test_rules = '1.1.0'
39 | versions.espresso_core = '3.1.1'
40 | versions.robolectric = '4.2'
41 | versions.truth = "0.44"
42 | versions.ext_junit_ktx = "1.0.0"
43 | versions.ext_truth = "1.1.0"
44 | versions.mockk = "1.9.3"
45 |
46 | def deps = [:]
47 |
48 | // build script
49 | def plugins = [:]
50 | plugins.android_gradle_plugin = "com.android.tools.build:gradle:${versions.android_gradle_plugin}"
51 | plugins.kotlin_gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
52 | plugins.kotlin_serialization = "org.jetbrains.kotlin:kotlin-serialization:${versions.kotlin}"
53 | deps.plugins = plugins
54 |
55 | // kotlin
56 | def kotlin = [:]
57 | kotlin.stdlib_jdk7 = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
58 | kotlin.serialization_runtime = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${versions.kotlin_serialization}"
59 | kotlin.coroutines_core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}"
60 | kotlin.coroutines_android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}"
61 | deps.kotlin = kotlin
62 |
63 | def androidx = [:]
64 | androidx.material = "com.google.android.material:material:${versions.material}"
65 | androidx.appcompat = "androidx.appcompat:appcompat:${versions.appcompat}"
66 | androidx.recyclerview = "androidx.recyclerview:recyclerview:${versions.recycler}"
67 | androidx.constraint = "androidx.constraintlayout:constraintlayout:${versions.constraint}"
68 | androidx.lifecycle = "androidx.lifecycle:lifecycle-extensions:${versions.lifecycle}"
69 | androidx.lifecycle_compiler = "androidx.lifecycle:lifecycle-compiler:${versions.lifecycle}"
70 | androidx.core_ktx = 'androidx.core:core-ktx:1.1.0-alpha04'
71 | androidx.viewmodel_ktx = 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-alpha02'
72 | deps.androidx = androidx
73 |
74 | def room = [:]
75 | room.runtime = "androidx.room:room-runtime:${versions.room_version}"
76 | room.compiler = "androidx.room:room-compiler:${versions.room_version}"
77 | room.ktx = "androidx.room:room-ktx:${versions.room_version}"
78 | deps.room = room
79 |
80 | deps.koin_viewmodel = "org.koin:koin-android-viewmodel:${versions.koin}"
81 | deps.okhttp = "com.squareup.okhttp3:okhttp:${versions.okhttp}"
82 |
83 | def retrofit = [:]
84 | retrofit.retrofit = "com.squareup.retrofit2:retrofit:${versions.retrofit}"
85 | retrofit.serialization = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:${versions.retrofit_serialization}"
86 | deps.retrofit = retrofit
87 |
88 | def glide = [:]
89 | glide.glide = "com.github.bumptech.glide:glide:${versions.glide}"
90 | glide.compiler = "com.github.bumptech.glide:compiler:${versions.glide}"
91 | deps.glide = glide
92 |
93 | deps.timber = "com.jakewharton.timber:timber:${versions.timber}"
94 | deps.stetho = "com.facebook.stetho:stetho:${versions.stetho}"
95 |
96 | // test
97 | def test = [:]
98 | test.junit = "junit:junit:${versions.junit}"
99 | test.arch_core_testing = "androidx.arch.core:core-testing:${versions.lifecycle}"
100 | test.core_ktx = "androidx.test:core-ktx:${versions.test_core}"
101 | test.runner = "androidx.test:runner:${versions.test_runner}"
102 | test.rules = "androidx.test:rules:${versions.test_rules}"
103 |
104 | test.ext_junit_ktx = "androidx.test.ext:junit:${versions.ext_junit_ktx}"
105 | test.ext_truth = "androidx.test.ext:truth:${versions.ext_truth}"
106 | test.truth = "com.google.truth:truth:${versions.truth}"
107 |
108 | test.robolectric = "org.robolectric:robolectric:${versions.robolectric}"
109 |
110 | test.mockk = "io.mockk:mockk:${versions.mockk}"
111 | test.mockk_android = "io.mockk:mockk-android:${versions.mockk}"
112 |
113 | test.espresso_core = "androidx.test.espresso:espresso-core:${versions.espresso_core}"
114 |
115 | deps.test = test
116 |
117 |
118 | ext.deps = deps
119 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------