├── jubako-sample
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── 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
│ │ ├── layout
│ │ │ ├── grid_cell.xml
│ │ │ ├── simple_carousel.xml
│ │ │ ├── grid_fill_progress.xml
│ │ │ ├── carousel_item_movie.xml
│ │ │ ├── simple_carousel_item_text.xml
│ │ │ ├── simple_item_text.xml
│ │ │ ├── simple_carousel_with_heading.xml
│ │ │ ├── carousel_movies.xml
│ │ │ ├── activity_grid_fill.xml
│ │ │ ├── activity_jubako_recycler.xml
│ │ │ ├── activity_home.xml
│ │ │ └── item_movie_hero.xml
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── drawable
│ │ │ ├── movie_hero_nav_gradient.xml
│ │ │ ├── ic_add.xml
│ │ │ ├── ic_play_arrow.xml
│ │ │ ├── ic_info.xml
│ │ │ ├── movie_hero_gradient.xml
│ │ │ ├── ic_jubako_icon.xml
│ │ │ └── ic_launcher_background.xml
│ │ └── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── assets
│ │ ├── 1
│ │ │ ├── 4d-Man-03-movie-poster.webp
│ │ │ ├── 3-stooges-1941-movie-poster.webp
│ │ │ ├── 5-Element-Kung-Fu-01-movie-poster.webp
│ │ │ ├── 5-Fingers-Of-Death-01-movie-poster.webp
│ │ │ ├── 5-Fingers-Of-Death-02-movie-poster.webp
│ │ │ └── 3stooges-movie-maniacs-1935-movie-poster.webp
│ │ ├── 2
│ │ │ ├── 13-Ghosts-01-movie-poster.webp
│ │ │ ├── Ace-High-01-0-movie-poster.webp
│ │ │ ├── 13-rue-madeleine-1946-movie-poster.webp
│ │ │ ├── 18-Weapons-Of-Kung-Fu-01-movie-poster.webp
│ │ │ ├── 20-Million-Miles-To-Earth-01-movie-poster.webp
│ │ │ └── abbott-and-costello-meet-frankenstein-1948-movie-poster.webp
│ │ └── 3
│ │ │ ├── 5-Man-Army-01-movie-poster.webp
│ │ │ ├── 7-Man-Army-01-movie-poster.webp
│ │ │ ├── 10-To-Midnight-01-movie-poster.webp
│ │ │ ├── 7th-Commandment-01-movie-poster.webp
│ │ │ ├── 7-Faces-Of-Dr-Lao-01-movie-poster.webp
│ │ │ └── 13-Frightened-Girls-01-movie-poster.webp
│ │ ├── java
│ │ └── com
│ │ │ └── sample
│ │ │ └── jubako
│ │ │ ├── HelloJubakoActivity.kt
│ │ │ ├── InfiniteHelloJubakoActivity.kt
│ │ │ ├── SelfUpdatingItemsActivity.kt
│ │ │ ├── HomeActivity.kt
│ │ │ ├── RowUpdatesActivity.kt
│ │ │ ├── SimpleCarouselsActivity.kt
│ │ │ ├── LoadAsyncActivity.kt
│ │ │ ├── MoviesActivity.kt
│ │ │ ├── EnterpriseHelloJubakoActivity.kt
│ │ │ └── GridFillActivity.kt
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── jubako
├── .gitignore
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── default_progress.xml
│ │ └── java
│ │ │ ├── com
│ │ │ └── justeat
│ │ │ │ └── jubako
│ │ │ │ ├── JubakoViewSpec.kt
│ │ │ │ ├── data
│ │ │ │ ├── EmptyLiveData.kt
│ │ │ │ ├── InstantLiveData.kt
│ │ │ │ ├── PaginatedDataState.kt
│ │ │ │ └── PaginatedLiveData.kt
│ │ │ │ ├── JubakoAssembler.kt
│ │ │ │ ├── ContentDescriptionProvider.kt
│ │ │ │ ├── extensions
│ │ │ │ ├── JubakoLoadExtensions.kt
│ │ │ │ └── JubakoAssembleExtensions.kt
│ │ │ │ ├── SimpleJubakoAssembler.kt
│ │ │ │ ├── ContentDescriptionCollection.kt
│ │ │ │ ├── ContentDescription.kt
│ │ │ │ └── Jubako.kt
│ │ │ └── samples
│ │ │ └── Samples.kt
│ ├── androidTest
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── justeat
│ │ │ │ └── jubako
│ │ │ │ ├── platform
│ │ │ │ ├── TestViewHolder.kt
│ │ │ │ ├── TestViewHolderFactory.kt
│ │ │ │ ├── TestConditionalContentAssembler.kt
│ │ │ │ ├── TestContentDescriptionProvider.kt
│ │ │ │ ├── TestJubakoActivity.kt
│ │ │ │ ├── TestContentAssembler.kt
│ │ │ │ └── RobustnessTestJubakoActivity.kt
│ │ │ │ ├── util
│ │ │ │ ├── IntentLauncher.java
│ │ │ │ └── RecyclerViewExt.java
│ │ │ │ ├── JubakoTests.kt
│ │ │ │ ├── JubakoRobustnessTests.kt
│ │ │ │ ├── steps
│ │ │ │ └── JubakoSteps.kt
│ │ │ │ └── screen
│ │ │ │ └── JubakoScreen.kt
│ │ └── res
│ │ │ └── layout
│ │ │ ├── item_simple.xml
│ │ │ ├── activity_test_jubako.xml
│ │ │ └── activity_test_robustness_jubakoi.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── justeat
│ │ └── jubako
│ │ ├── SimpleJubakoAssemblerTest.kt
│ │ ├── ContentDescriptionCollectionTest.kt
│ │ ├── ContentDescriptionTest.kt
│ │ ├── data
│ │ └── PaginatedLiveDataTest.kt
│ │ ├── PaginatedContentLoadingStrategyTest.kt
│ │ └── JubakoTest.kt
├── proguard-rules.pro
└── build.gradle
├── jubako-recyclerviews
├── .gitignore
├── consumer-rules.pro
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── justeat
│ │ │ └── jubako
│ │ │ └── recyclerviews
│ │ │ ├── JubakoExtensions.kt
│ │ │ ├── util
│ │ │ ├── IJubakoScreenFiller.kt
│ │ │ └── JubakoScreenFiller.kt
│ │ │ ├── addHolder.kt
│ │ │ ├── adapters
│ │ │ ├── ProgressView.kt
│ │ │ ├── ContentAdapterContentDescriptionCollectionListener.kt
│ │ │ ├── DefaultProgressViewHolder.kt
│ │ │ ├── StaticDataAdapter.kt
│ │ │ ├── PaginatedDataAdapter.kt
│ │ │ ├── JubakoRecyclerViewHolder.kt
│ │ │ └── JubakoAdapter.kt
│ │ │ ├── ContentLoadingStrategy.kt
│ │ │ ├── widgets
│ │ │ ├── JubakoCarouselRecyclerView.kt
│ │ │ └── JubakoRecyclerView.kt
│ │ │ ├── JubakoRecyclerViewExtensions.kt
│ │ │ ├── JubakoViewHolder.kt
│ │ │ └── JubakoViewContent.kt
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── justeat
│ │ │ └── jubako
│ │ │ └── recyclerviews
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── justeat
│ │ └── jubako
│ │ └── recyclerviews
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gfx
├── jubako_logo.png
├── jubako_movies.png
├── jubako_logo.afdesign
└── jubako_icon.svg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── LICENSE
├── gradle.properties
├── gradlew.bat
└── gradlew
/jubako-sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jubako/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | .idea
3 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jubako/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':jubako-sample', ':jubako', ':jubako-recyclerviews'
2 |
--------------------------------------------------------------------------------
/gfx/jubako_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/gfx/jubako_logo.png
--------------------------------------------------------------------------------
/gfx/jubako_movies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/gfx/jubako_movies.png
--------------------------------------------------------------------------------
/gfx/jubako_logo.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/gfx/jubako_logo.afdesign
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/jubako/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Jubako
3 |
4 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/JubakoViewSpec.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | interface JubakoViewSpec
4 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Jubako RecyclerViews
3 |
4 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/4d-Man-03-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/4d-Man-03-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/3-stooges-1941-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/3-stooges-1941-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/13-Ghosts-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/13-Ghosts-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/Ace-High-01-0-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/Ace-High-01-0-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/5-Man-Army-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/5-Man-Army-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/7-Man-Army-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/7-Man-Army-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/10-To-Midnight-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/10-To-Midnight-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/7th-Commandment-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/7th-Commandment-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/5-Element-Kung-Fu-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/5-Element-Kung-Fu-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/5-Fingers-Of-Death-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/5-Fingers-Of-Death-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/5-Fingers-Of-Death-02-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/5-Fingers-Of-Death-02-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/13-rue-madeleine-1946-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/13-rue-madeleine-1946-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/7-Faces-Of-Dr-Lao-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/7-Faces-Of-Dr-Lao-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/data/EmptyLiveData.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.data
2 |
3 | import androidx.lifecycle.LiveData
4 |
5 | class EmptyLiveData : LiveData()
6 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/18-Weapons-Of-Kung-Fu-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/18-Weapons-Of-Kung-Fu-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/3/13-Frightened-Girls-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/3/13-Frightened-Girls-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/1/3stooges-movie-maniacs-1935-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/1/3stooges-movie-maniacs-1935-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/20-Million-Miles-To-Earth-01-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/20-Million-Miles-To-Earth-01-movie-poster.webp
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/grid_cell.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/assets/2/abbott-and-costello-meet-frankenstein-1948-movie-poster.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justeat/jubako/HEAD/jubako-sample/src/main/assets/2/abbott-and-costello-meet-frankenstein-1948-movie-poster.webp
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/JubakoAssembler.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | interface JubakoAssembler {
4 | suspend fun assemble(): List>
5 | fun hasMore(): Boolean = false
6 | }
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/JubakoExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
2 |
3 | fun pageSize(pageSize: Int) = com.justeat.jubako.recyclerviews.adapters.PaginatedContentLoadingStrategy(pageSize)
4 |
--------------------------------------------------------------------------------
/jubako-sample/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 | .idea
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jun 23 00:09:16 BST 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.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/data/InstantLiveData.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.data
2 |
3 | import androidx.lifecycle.LiveData
4 |
5 | class InstantLiveData(private val data: DATA) : LiveData() {
6 | override fun onActive() {
7 | postValue(data)
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/drawable/movie_hero_nav_gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/simple_carousel.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/drawable/ic_play_arrow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/drawable/ic_info.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/drawable/movie_hero_gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
10 |
--------------------------------------------------------------------------------
/jubako/src/main/java/samples/Samples.kt:
--------------------------------------------------------------------------------
1 | import com.justeat.jubako.data.PaginatedLiveData
2 | import kotlinx.coroutines.delay
3 |
4 | internal object Samples {
5 | internal fun samplePaginatedLiveData() {
6 | PaginatedLiveData {
7 | hasMore = { loaded.size < 100 }
8 | nextPage = {
9 | delay(100)
10 | listOf("Hello")
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/jubako/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/util/IJubakoScreenFiller.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.util
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | interface IJubakoScreenFiller {
6 | fun attach(recyclerView: RecyclerView)
7 |
8 | companion object {
9 | val NOOP = object: IJubakoScreenFiller {
10 | override fun attach(recyclerView: RecyclerView) {}
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/test/java/com/justeat/jubako/recyclerviews/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
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 | }
18 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/addHolder.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
2 |
3 | import com.justeat.jubako.ContentDescription
4 | import com.justeat.jubako.descriptionProvider
5 | import com.justeat.jubako.extensions.JubakoMutableList
6 | import com.justeat.jubako.extensions.add
7 |
8 | fun JubakoMutableList.addHolder(delegate: () -> JubakoViewHolder) {
9 | add(descriptionProvider {
10 | ContentDescription(
11 | viewSpec = viewHolderFactory { delegate.invoke() })
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/ContentDescriptionProvider.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | /**
4 | * Produces an instances of [ContentDescription]
5 | */
6 | interface ContentDescriptionProvider {
7 | fun createDescription(): ContentDescription
8 | }
9 |
10 | /**
11 | * Simple way to construct a [ContentDescriptionProvider]
12 | */
13 | fun descriptionProvider(delegate: () -> ContentDescription): ContentDescriptionProvider {
14 | return object : ContentDescriptionProvider {
15 | override fun createDescription() = delegate()
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/data/PaginatedDataState.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.data
2 |
3 | data class PaginatedDataState(
4 | var loaded: List,
5 | var page: List,
6 | var loading: Boolean = false,
7 | var error: Throwable? = null,
8 | var accepted: Boolean = false
9 | ) {
10 | fun accept(): Boolean {
11 | if (!accepted) {
12 | accepted = true
13 | return true
14 | }
15 | return false
16 | }
17 | }
18 |
19 | fun PaginatedDataState<*>?.ready(): Boolean {
20 | return this != null && !loading && error == null
21 | }
22 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/platform/TestViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.platform
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import com.justeat.jubako.recyclerviews.JubakoViewHolder
6 | import com.justeat.jubako.test.R
7 |
8 | class TestViewHolder(view: View) : com.justeat.jubako.recyclerviews.JubakoViewHolder(view) {
9 | override fun bind(data: String?) {
10 | itemView.findViewById(R.id.itemText).apply {
11 | text = data
12 | setOnClickListener {
13 | reload()
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2019 JUST EAT Holding Limited
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/grid_fill_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/carousel_item_movie.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/platform/TestViewHolderFactory.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.platform
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import com.justeat.jubako.recyclerviews.adapters.JubakoAdapter
6 | import com.justeat.jubako.recyclerviews.JubakoViewHolder
7 | import com.justeat.jubako.test.R
8 |
9 | class TestViewHolderFactory : com.justeat.jubako.recyclerviews.adapters.JubakoAdapter.HolderFactory {
10 | override fun createViewHolder(parent: ViewGroup): com.justeat.jubako.recyclerviews.JubakoViewHolder {
11 | val view = LayoutInflater.from(parent.context).inflate(R.layout.item_simple, parent, false)
12 | return TestViewHolder(view)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/simple_carousel_item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/adapters/ProgressView.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.adapters
2 |
3 | /**
4 | * When providing a custom progress [RecyclerView.ViewHolder] they
5 | * must implement this interface so Jubako can communicate state to your view holder
6 | */
7 | interface ProgressView {
8 | /**
9 | * WHen called you should show a progress indicator
10 | */
11 | fun onProgress()
12 |
13 | /**
14 | * When called you should show an error button or similar
15 | */
16 | fun onError(error: Throwable)
17 |
18 | /**
19 | * Gives you a callback that you can invoke with `retry.invoke()` when you
20 | * want to try loading again
21 | */
22 | fun setRetryCallback(retry: () -> Unit)
23 | }
24 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/simple_item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/jubako/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 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/res/layout/item_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
--------------------------------------------------------------------------------
/jubako/src/main/res/layout/default_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/jubako-sample/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 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/extensions/JubakoLoadExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.extensions
2 |
3 | import com.justeat.jubako.ContentDescriptionProvider
4 | import com.justeat.jubako.Jubako
5 | import com.justeat.jubako.SimpleJubakoAssembler
6 |
7 | /**
8 | * Simply load with the given descriptions then just call [add], [addView], [addHolder], etc
9 | * to specify how and what you wish to display conveniently or manually construct and add [ContentDescriptionProvider]'s
10 | */
11 | fun Jubako.load(descriptionProviders: ListReceiver) {
12 | load(SimpleJubakoAssembler(descriptionProviders.apply { invoke(mutableListOf()) }))
13 | }
14 | /**
15 | * Same as [load] but happens on the IO dispatcher (use with caution!)
16 | */
17 | fun Jubako.loadAsync(descriptionProviders: ListReceiver) {
18 | load(descriptionProviders.assemble())
19 | }
20 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/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 |
--------------------------------------------------------------------------------
/jubako/src/test/java/com/justeat/jubako/SimpleJubakoAssemblerTest.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | import com.justeat.jubako.extensions.add
4 | import kotlinx.coroutines.runBlocking
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.mockito.Mockito.mock
8 |
9 | class SimpleJubakoAssemblerTest {
10 | @Test
11 | @Throws(Exception::class)
12 | fun assemble_returns_list_from_constructor_delegate() {
13 | // act
14 | val assembler = SimpleJubakoAssembler {
15 | add(mock(ContentDescriptionProvider::class.java))
16 | add(mock(ContentDescriptionProvider::class.java))
17 | add(mock(ContentDescriptionProvider::class.java))
18 | }
19 |
20 | // assert
21 | runBlocking {
22 | assertEquals(3, assembler.assemble().size)
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Jubako Examples
3 | Hello
4 | Simple Carousels
5 | Load Async
6 | Row Updates
7 | Self Updating Items
8 | Enterprise Hello
9 | Try Again
10 | Something went wrong!
11 | Movies
12 | Infinite Hello
13 | Grid Fill
14 |
15 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/androidTest/java/com/justeat/jubako/recyclerviews/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.justeat.jubako.recyclerviews.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/ContentLoadingStrategy.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
2 |
3 | import androidx.lifecycle.LifecycleOwner
4 | import com.justeat.jubako.ContentDescription
5 | import com.justeat.jubako.ContentDescriptionCollection
6 | import com.justeat.jubako.Jubako
7 | import com.justeat.jubako.data.PaginatedDataState
8 |
9 | interface ContentLoadingStrategy {
10 | /**
11 | * @param onLoaded A callback invoked when the strategy has loaded, clients should return true if they wish to load more
12 | */
13 | fun load(
14 | lifecycleOwner: LifecycleOwner,
15 | data: Jubako.Data,
16 | callback: (state: PaginatedDataState>, hasMore: Boolean) -> Unit
17 | )
18 |
19 | fun reload(lifecycleOwner: LifecycleOwner, position: Int, descriptions: ContentDescriptionCollection)
20 | fun reset()
21 | }
22 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/platform/TestConditionalContentAssembler.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.platform
2 |
3 | import com.justeat.jubako.ContentDescriptionProvider
4 | import com.justeat.jubako.SimpleJubakoAssembler
5 |
6 | class TestConditionalContentAssembler(
7 | private val showDo: Boolean = true,
8 | private val showRe: Boolean = true,
9 | private val showMi: Boolean = true
10 | ) : SimpleJubakoAssembler() {
11 | override fun onAssemble(list: MutableList>) = with(list) {
12 | if (showDo) add(
13 | TestContentDescriptionProvider(
14 | data = "Do"
15 | )
16 | )
17 | if (showRe) add(
18 | TestContentDescriptionProvider(
19 | data = "Re"
20 | )
21 | )
22 | if (showMi) add(
23 | TestContentDescriptionProvider(
24 | data = "Mi"
25 | )
26 | )
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/util/IntentLauncher.java:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.util;
2 |
3 | import android.app.Instrumentation;
4 | import android.content.Intent;
5 | import android.util.Log;
6 | import androidx.test.InstrumentationRegistry;
7 |
8 | public class IntentLauncher {
9 |
10 | private static final String TAG = IntentLauncher.class.getSimpleName();
11 |
12 |
13 | public static void launchActivityFromIntent(Intent intent) {
14 | Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
15 | Log.d(TAG, String.format("Launching from intent %s", intent.toString()));
16 |
17 | startActivityWithIntent(instrumentation, intent);
18 | }
19 |
20 | private static void startActivityWithIntent(Instrumentation instrumentation, Intent intent) {
21 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
22 | instrumentation.startActivitySync(intent);
23 | instrumentation.waitForIdleSync();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/JubakoTests.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | import com.justeat.jubako.steps.JubakoSteps.amLookingAtTestJubakoActivity
4 | import com.justeat.jubako.steps.JubakoSteps.shouldSeeRayTextChangesToPeekaBoo
5 | import com.justeat.jubako.steps.JubakoSteps.tapTheRowWithRayText
6 | import com.justeat.jubako.steps.JubakoSteps.tapTheShowPeekaBooButton
7 | import org.junit.Test
8 |
9 | internal class JubakoTests {
10 |
11 | @Test
12 | fun rowUpdatesWhenClicked() {
13 | // Given I
14 | amLookingAtTestJubakoActivity()
15 |
16 | // When I
17 | tapTheRowWithRayText()
18 |
19 | // Then I
20 | shouldSeeRayTextChangesToPeekaBoo()
21 | }
22 |
23 | @Test
24 | fun rowUpdatesWhenOutsideButtonIsClicked() {
25 | // Given I
26 | amLookingAtTestJubakoActivity()
27 |
28 | // When I
29 | tapTheShowPeekaBooButton()
30 |
31 | // Then I
32 | shouldSeeRayTextChangesToPeekaBoo()
33 | }
34 | }
--------------------------------------------------------------------------------
/jubako/src/androidTest/res/layout/activity_test_jubako.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
24 |
25 |
--------------------------------------------------------------------------------
/jubako/src/main/java/com/justeat/jubako/SimpleJubakoAssembler.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | /**
4 | * Construct a list of [ContentDescriptionProvider] by simply providing a delegate or override
5 | * the [onAssemble] method to add descriptions to the given list
6 | */
7 | open class SimpleJubakoAssembler(private val delegate: (MutableList>.() -> Unit)? = null) :
8 | JubakoAssembler {
9 | override suspend fun assemble(): List> {
10 | return mutableListOf>().apply {
11 | delegate?.invoke(this)
12 | onAssemble(this)
13 | }
14 | }
15 |
16 | /**
17 | * Just add [ContentDescriptionProvider]s to the given list, easy
18 | */
19 | open suspend fun onAssemble(list: MutableList>) {}
20 |
21 | open fun MutableList>.add(provider: ContentDescriptionProvider<*>) {
22 | add(provider as ContentDescriptionProvider)
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/adapters/ContentAdapterContentDescriptionCollectionListener.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.adapters
2 |
3 | import com.justeat.jubako.ContentDescriptionCollection
4 | import com.justeat.jubako.Jubako
5 |
6 | class ContentAdapterContentDescriptionCollectionListener(
7 | private val contentAdapter: JubakoAdapter
8 | ) : ContentDescriptionCollection.Listener {
9 | var logger = Jubako.logger
10 | override fun notifyItemChanged(index: Int, payload: Any?) {
11 | logger.log(TAG, "Notify Item Changed", "index: $index")
12 | contentAdapter.notifyItemChanged(index, payload)
13 | }
14 |
15 | override fun notifyItemRangeRemoved(positionStart: Int, itemCount: Int) {
16 | logger.log(
17 | TAG,
18 | "Notify Item Range Removed",
19 | "positionStart: $positionStart, itemCount: $itemCount"
20 | )
21 | contentAdapter.notifyItemRangeRemoved(positionStart, itemCount)
22 | }
23 | }
24 |
25 | private val TAG = JubakoAdapter::class.java.simpleName
26 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/platform/TestContentDescriptionProvider.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.platform
2 |
3 | import androidx.lifecycle.LiveData
4 | import com.justeat.jubako.ContentDescription
5 | import com.justeat.jubako.ContentDescriptionProvider
6 | import java.util.*
7 |
8 | class TestContentDescriptionProvider(
9 | val data: String,
10 | val id: String = UUID.randomUUID().toString()
11 | ) : ContentDescriptionProvider {
12 | override fun createDescription(): ContentDescription {
13 | return ContentDescription(
14 | id = id,
15 | viewSpec = TestViewHolderFactory(),
16 | data = object : LiveData() {
17 | override fun onActive() {
18 | postValue(data)
19 | }
20 | },
21 | onReload = {
22 | data = object : LiveData() {
23 | override fun onActive() {
24 | postValue("Peek-a-Boo!")
25 | }
26 | }
27 | })
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/simple_carousel_with_heading.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
25 |
26 |
--------------------------------------------------------------------------------
/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 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/java/com/sample/jubako/HelloJubakoActivity.kt:
--------------------------------------------------------------------------------
1 | package com.sample.jubako
2 |
3 | import android.os.Bundle
4 | import android.util.TypedValue
5 | import android.widget.TextView
6 | import androidx.appcompat.app.AppCompatActivity
7 | import com.justeat.jubako.Jubako
8 | import com.justeat.jubako.extensions.load
9 | import com.justeat.jubako.recyclerviews.addView
10 | import com.justeat.jubako.recyclerviews.withJubako
11 | import kotlinx.android.synthetic.main.activity_jubako_recycler.recyclerView
12 |
13 | class HelloJubakoActivity : AppCompatActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_jubako_recycler)
17 |
18 | Jubako.logger.enabled = true
19 |
20 | recyclerView.withJubako(this).load {
21 | for (i in 0..100) {
22 | addView { textView("Hello Jubako!") }
23 | addView { textView("こんにちはジュバコ") }
24 | }
25 | }
26 | }
27 |
28 | private fun textView(text: String): TextView {
29 | return TextView(this).apply {
30 | setText(text)
31 | setTextSize(TypedValue.COMPLEX_UNIT_DIP, 48f)
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/jubako-sample/src/main/res/layout/carousel_movies.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/adapters/DefaultProgressViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.adapters
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.justeat.jubako.R
8 |
9 | class DefaultProgressViewHolder(
10 | inflater: LayoutInflater,
11 | parent: ViewGroup,
12 | layoutId: Int = R.layout.default_progress
13 | ) :
14 | RecyclerView.ViewHolder(inflater.inflate(layoutId, parent, false)), ProgressView {
15 | override fun setRetryCallback(retry: () -> Unit) {
16 | itemView.findViewById(R.id.button_retry).setOnClickListener {
17 | retry.invoke()
18 | }
19 | }
20 |
21 | override fun onProgress() {
22 | itemView.findViewById(R.id.progress).visibility =
23 | View.VISIBLE
24 | itemView.findViewById(R.id.button_retry).visibility =
25 | View.GONE
26 | }
27 |
28 | override fun onError(error: Throwable) {
29 | itemView.findViewById(R.id.progress).visibility = View.GONE
30 | itemView.findViewById(R.id.button_retry).visibility =
31 | View.VISIBLE
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/JubakoRobustnessTests.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | import com.justeat.jubako.screen.JubakoScreen.clickDoButton
4 | import com.justeat.jubako.screen.JubakoScreen.clickMiButton
5 | import com.justeat.jubako.screen.JubakoScreen.clickReButton
6 | import com.justeat.jubako.screen.JubakoScreen.clickShowAllButton
7 | import com.justeat.jubako.steps.JubakoSteps.amLookingAtRobustnessTestJubakoActivity
8 | import org.junit.Ignore
9 | import org.junit.Test
10 | import kotlin.random.Random
11 | import kotlin.random.nextInt
12 |
13 | /**
14 | * Run to test robustness, uncomment [Ignore] to use
15 | */
16 | //@Ignore
17 | internal class JubakoRobustnessTests {
18 | @Test
19 | fun thrashContentAssemblerReloading() {
20 | // Given I
21 | amLookingAtRobustnessTestJubakoActivity()
22 |
23 | // And I
24 | val buttons = listOf(
25 | { clickDoButton() },
26 | { clickReButton() },
27 | { clickMiButton() },
28 | { clickShowAllButton() }
29 | )
30 |
31 | val random = Random(System.currentTimeMillis())
32 |
33 | for (x in 0..1000) {
34 | buttons[random.nextInt(0 until buttons.size)]()
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/jubako-sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 28
7 | defaultConfig {
8 | applicationId "com.sample.jubako"
9 | minSdkVersion 21
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
25 | implementation "androidx.appcompat:appcompat:$androidx_version"
26 | implementation "androidx.core:core-ktx:$androidx_version"
27 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
28 |
29 | implementation 'com.squareup.picasso:picasso:2.71828'
30 |
31 | implementation project(path: ':jubako')
32 | implementation project(path: ':jubako-recyclerviews')
33 |
34 | testImplementation 'junit:junit:4.12'
35 |
36 | androidTestImplementation 'androidx.test:runner:1.2.0'
37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38 | }
39 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/adapters/StaticDataAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.adapters
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.justeat.jubako.Jubako
7 | import com.justeat.jubako.recyclerviews.CreateViewHolderDelegate
8 |
9 | @Suppress("UNCHECKED_CAST")
10 | class StaticDataAdapter(
11 | private val data: DATA,
12 | var logger: Jubako.Logger,
13 | var itemViewHolder: CreateViewHolderDelegate,
14 | var itemBinder: (holder: ITEM_HOLDER, data: ITEM_DATA?) -> Unit = { _, _ -> },
15 | var itemData: (data: DATA, position: Int) -> ITEM_DATA,
16 | var itemCount: (data: DATA) -> Int
17 | ) : RecyclerView.Adapter() {
18 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
19 | logger.log(TAG, "Create View Holder", "")
20 | return itemViewHolder(LayoutInflater.from(parent.context), parent, viewType)
21 | }
22 |
23 | override fun getItemCount(): Int = itemCount(data)
24 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) =
25 | itemBinder(holder as ITEM_HOLDER, itemData(data, position))
26 | }
27 |
28 | private val TAG = StaticDataAdapter::class.java.simpleName
29 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/widgets/JubakoCarouselRecyclerView.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews.widgets
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.view.MotionEvent
6 | import androidx.recyclerview.widget.LinearLayoutManager
7 | import androidx.recyclerview.widget.RecyclerView
8 |
9 | class JubakoCarouselRecyclerView @JvmOverloads constructor(
10 | context: Context,
11 | attrs: AttributeSet? = null,
12 | defStyleAttr: Int = 0
13 | ) : JubakoRecyclerView(context, attrs, defStyleAttr) {
14 |
15 | init {
16 | layoutManager = LinearLayoutManager(context, HORIZONTAL, false)
17 |
18 | addOnItemTouchListener(object : OnItemTouchListener {
19 | override fun onTouchEvent(recyclerView: RecyclerView, event: MotionEvent) {}
20 | override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean {
21 | if (event.action == MotionEvent.ACTION_DOWN && recyclerView.scrollState == SCROLL_STATE_SETTLING) {
22 | recyclerView.stopScroll()
23 | }
24 | return false
25 | }
26 |
27 | override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
28 | })
29 | }
30 |
31 | override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
32 | }
33 |
--------------------------------------------------------------------------------
/jubako/src/test/java/com/justeat/jubako/ContentDescriptionCollectionTest.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako
2 |
3 | import android.view.ViewGroup
4 | import org.junit.Assert.assertEquals
5 | import org.junit.Test
6 |
7 | class ContentDescriptionCollectionTest {
8 | @Test
9 | @Throws(Exception::class)
10 | fun addAllPersistsEntries() {
11 | val collection = ContentDescriptionCollection()
12 |
13 | val descriptions = mutableListOf>()
14 | descriptions.add(ContentDescription(object : com.justeat.jubako.recyclerviews.adapters.JubakoAdapter.HolderFactory {
15 | override fun createViewHolder(parent: ViewGroup): com.justeat.jubako.recyclerviews.JubakoViewHolder = null!!
16 | }))
17 | descriptions.add(ContentDescription(object : com.justeat.jubako.recyclerviews.adapters.JubakoAdapter.HolderFactory {
18 | override fun createViewHolder(parent: ViewGroup): com.justeat.jubako.recyclerviews.JubakoViewHolder = null!!
19 | }))
20 | descriptions.add(ContentDescription(object : com.justeat.jubako.recyclerviews.adapters.JubakoAdapter.HolderFactory {
21 | override fun createViewHolder(parent: ViewGroup): com.justeat.jubako.recyclerviews.JubakoViewHolder = null!!
22 | }))
23 |
24 | collection.addAll(descriptions)
25 |
26 | assertEquals(3, collection.size())
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'com.github.dcendents.android-maven'
5 |
6 | group = 'com.github.justeat'
7 | version = "0.61"
8 |
9 | android {
10 | compileSdkVersion 29
11 | buildToolsVersion "29.0.2"
12 |
13 |
14 | defaultConfig {
15 | minSdkVersion 15
16 | targetSdkVersion 29
17 | versionCode 1
18 | versionName "1.0"
19 |
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21 | consumerProguardFiles 'consumer-rules.pro'
22 | }
23 |
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 |
31 | }
32 |
33 | dependencies {
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
36 | implementation "androidx.appcompat:appcompat:$androidx_version"
37 | implementation "androidx.core:core-ktx:$androidx_version"
38 |
39 | implementation project(path: ':jubako')
40 |
41 | api "androidx.recyclerview:recyclerview:$androidx_version"
42 |
43 | testImplementation 'junit:junit:4.12'
44 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
45 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
46 | }
47 |
--------------------------------------------------------------------------------
/jubako-recyclerviews/src/main/java/com/justeat/jubako/recyclerviews/JubakoRecyclerViewExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.recyclerviews
2 |
3 | import androidx.fragment.app.FragmentActivity
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.justeat.jubako.Jubako
6 | import com.justeat.jubako.recyclerviews.adapters.JubakoAdapter
7 | import com.justeat.jubako.recyclerviews.adapters.PaginatedContentLoadingStrategy
8 | import com.justeat.jubako.recyclerviews.widgets.JubakoRecyclerView
9 |
10 | fun RecyclerView.withJubako(
11 | activity: FragmentActivity,
12 | loadingStrategy: ContentLoadingStrategy = PaginatedContentLoadingStrategy(10),
13 | onAssembled: (data: Jubako.Data) -> Unit = {},
14 | onAssembling: () -> Unit = {},
15 | onAssembleError: () -> Unit = {},
16 | onInitialFill: () -> Unit = {},
17 | onViewHolderEvent: (com.justeat.jubako.recyclerviews.JubakoViewHolder.Event) -> Unit = {}
18 | ): Jubako {
19 | assert(this is JubakoRecyclerView)
20 |
21 | return Jubako.observe(activity) { state ->
22 | when (state) {
23 | is Jubako.State.Assembled -> {
24 | onAssembled(state.data)
25 | adapter = JubakoAdapter(activity, state.data, loadingStrategy).apply {
26 | this.onInitialFill = onInitialFill
27 | this.onViewHolderEvent = onViewHolderEvent
28 | }
29 | }
30 | is Jubako.State.Assembling -> onAssembling()
31 | is Jubako.State.AssembleError -> onAssembleError()
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/jubako/src/androidTest/java/com/justeat/jubako/platform/TestJubakoActivity.kt:
--------------------------------------------------------------------------------
1 | package com.justeat.jubako.platform
2 |
3 | import android.os.Bundle
4 | import android.widget.Button
5 | import androidx.appcompat.app.AppCompatActivity
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.justeat.jubako.Jubako
8 | import com.justeat.jubako.recyclerviews.adapters.JubakoAdapter
9 | import com.justeat.jubako.test.R
10 |
11 | class TestJubakoActivity : AppCompatActivity() {
12 |
13 | override fun onCreate(savedInstanceState: Bundle?) {
14 | super.onCreate(savedInstanceState)
15 |
16 | setContentView(R.layout.activity_test_jubako)
17 |
18 | Jubako.logger.enabled = true
19 | Jubako.observe(this) { state ->
20 | when (state) {
21 | is Jubako.State.Assembled -> {
22 | bindAdapter(state.data)
23 | }
24 | }
25 | }.load(TestContentAssembler())
26 | }
27 |
28 | private fun bindAdapter(data: Jubako.Data) {
29 | val contentAdapter = com.justeat.jubako.recyclerviews.adapters.JubakoAdapter(
30 | lifecycleOwner = this,
31 | data = data
32 | )
33 |
34 | findViewById(R.id.recyclerView).apply {
35 | layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this@TestJubakoActivity)
36 | adapter = contentAdapter
37 | }
38 |
39 | findViewById