├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── custom.md
│ └── feature_request.md
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── xyz
│ │ └── sangcomz
│ │ └── stickytimeline
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── xyz
│ │ │ └── sangcomz
│ │ │ └── stickytimeline
│ │ │ ├── JavaExampleActivity.java
│ │ │ ├── MainActivity.kt
│ │ │ └── SingerAdapter.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_buzz.xml
│ │ ├── ic_finkl.xml
│ │ ├── ic_girlsgeneration.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_solo.xml
│ │ └── ic_wannaone.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── recycler_horizontal_row.xml
│ │ └── recycler_vertical_row.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── xyz
│ └── sangcomz
│ └── stickytimeline
│ └── ExampleUnitTest.kt
├── benchmark
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── github
│ └── sangcomz
│ └── benchmark
│ ├── StartupBenchmark.kt
│ └── StickyTimeLineLazyColumnScrollBenchmark.kt
├── build.gradle
├── data
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ └── io
│ └── github
│ └── sangcomz
│ └── stickytimeline
│ └── data
│ ├── Music.kt
│ ├── MusicRepo.kt
│ ├── Singer.kt
│ └── SingerRepo.kt
├── gradle.properties
├── gradle
├── release.compose.gradle
├── release.view.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pic
├── alleys_result.gif
├── compose.gif
├── sample_result.gif
└── stockroom_result.gif
├── privacy_policy.md
├── sample-compose
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── xyz
│ │ └── sangcomz
│ │ └── github
│ │ └── sample
│ │ └── compose
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── sangcomz
│ │ │ └── sample
│ │ │ └── compose
│ │ │ ├── MainActivity.kt
│ │ │ └── ui
│ │ │ └── theme
│ │ │ ├── Color.kt
│ │ │ ├── Theme.kt
│ │ │ └── Type.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── xyz
│ └── sangcomz
│ └── github
│ └── sample
│ └── compose
│ └── ExampleUnitTest.kt
├── settings.gradle
├── stickytimelineview-compose
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── xyz
│ │ └── sangcomz
│ │ └── github
│ │ └── stickytimelineview
│ │ └── compose
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── io
│ │ └── github
│ │ └── sangcomz
│ │ └── stickytimelineview
│ │ └── compose
│ │ ├── StickyTimeLineLazyColumn.kt
│ │ └── StickyTimeLineLazyRow.kt
│ └── test
│ └── java
│ └── xyz
│ └── sangcomz
│ └── github
│ └── stickytimelineview
│ └── compose
│ └── ExampleUnitTest.kt
└── stickytimelineview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── xyz
│ └── sangcomz
│ └── stickytimelineview
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── xyz
│ │ └── sangcomz
│ │ └── stickytimelineview
│ │ ├── TimeLineRecyclerView.kt
│ │ ├── callback
│ │ └── SectionCallback.kt
│ │ ├── decoration
│ │ ├── HorizontalSectionItemDecoration.kt
│ │ └── VerticalSectionItemDecoration.kt
│ │ ├── ext
│ │ ├── SizeExt.kt
│ │ └── ViewExt.kt
│ │ └── model
│ │ ├── RecyclerViewAttr.kt
│ │ └── SectionInfo.kt
└── res
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ └── strings.xml
└── test
└── java
└── xyz
└── sangcomz
└── stickytimelineview
└── ExampleUnitTest.java
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /release
11 | .idea/*
12 | /.vs
13 | .kotlin
14 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | I actively welcome your pull requests.
2 |
3 | 1. Fork the repo and create your branch from `develop`.
4 | 2. If you've added code that should be tested, add tests.
5 | 3. New pull request to `develop`.
6 |
--------------------------------------------------------------------------------
/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 2018 Seokwon Jeong
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 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | namespace "xyz.sangcomz.stickytimeline"
6 |
7 | compileSdk gradle.compileSdk
8 | defaultConfig {
9 | minSdk gradle.minSdk
10 | targetSdk gradle.targetSdk
11 | versionName gradle.versionName
12 | versionCode gradle.versionCode
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 |
16 | signingConfigs {
17 | if (project.rootProject.file('release/sign.properties').exists()) {
18 | Properties signProp = new Properties()
19 | signProp.load(project.rootProject.file('release/sign.properties').newDataInputStream())
20 | config {
21 | keyAlias signProp.get("alias") ? signProp.get("alias") : ""
22 | keyPassword signProp.get("alias_password") ? signProp.get("alias_password") : ""
23 | storeFile rootProject.file("release/key.jks")
24 | storePassword signProp.get("password") ? signProp.get("password") : ""
25 | }
26 | }
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | if (project.rootProject.file('release/sign.properties').exists()) {
34 | signingConfig signingConfigs.config
35 | }
36 | }
37 | debug {
38 |
39 | }
40 | }
41 |
42 | compileOptions {
43 | sourceCompatibility JavaVersion.VERSION_21
44 | targetCompatibility JavaVersion.VERSION_21
45 | }
46 |
47 | kotlinOptions {
48 | jvmTarget = '21'
49 | }
50 | }
51 |
52 | dependencies {
53 | implementation fileTree(include: ['*.jar'], dir: 'libs')
54 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
55 | implementation 'androidx.appcompat:appcompat:1.7.0'
56 | implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
57 | implementation "androidx.recyclerview:recyclerview:1.4.0"
58 | implementation 'androidx.cardview:cardview:1.0.0'
59 | implementation project(':stickytimelineview')
60 | implementation project(':data')
61 |
62 | testImplementation 'junit:junit:4.13.2'
63 | androidTestImplementation 'androidx.test:runner:1.5.2'
64 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
65 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/xyz/sangcomz/stickytimeline/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimeline
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("xyz.sangcomz.timeline", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/xyz/sangcomz/stickytimeline/JavaExampleActivity.java:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimeline;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.os.Bundle;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import androidx.appcompat.content.res.AppCompatResources;
8 | import androidx.recyclerview.widget.LinearLayoutManager;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.util.List;
14 |
15 | import io.github.sangcomz.stickytimeline.data.Singer;
16 | import io.github.sangcomz.stickytimeline.data.SingerRepo;
17 | import xyz.sangcomz.stickytimelineview.TimeLineRecyclerView;
18 | import xyz.sangcomz.stickytimelineview.callback.SectionCallback;
19 | import xyz.sangcomz.stickytimelineview.model.SectionInfo;
20 |
21 | public class JavaExampleActivity extends AppCompatActivity {
22 |
23 | private Drawable icFinkl, icBuzz, icWannaOne, icGirlsGeneration, icSolo;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 | initDrawable();
30 |
31 | TimeLineRecyclerView recyclerView = findViewById(R.id.vertical_recycler_view);
32 |
33 | recyclerView.setLayoutManager(new LinearLayoutManager(this,
34 | RecyclerView.VERTICAL,
35 | false));
36 |
37 | List singerList = getSingerList();
38 |
39 | recyclerView.addItemDecoration(getSectionCallback(singerList));
40 |
41 | recyclerView.setAdapter(new SingerAdapter(getLayoutInflater(), singerList, R.layout.recycler_vertical_row));
42 | }
43 |
44 | private SectionCallback getSectionCallback(final List singerList) {
45 | return new SectionCallback() {
46 |
47 | @Nullable
48 | @Override
49 | public SectionInfo getSectionHeader(int position) {
50 | Singer singer = singerList.get(position);
51 | Drawable dot;
52 | switch (singer.getGroup()) {
53 | case "FIN.K.L": {
54 | dot = icFinkl;
55 | break;
56 | }
57 | case "Girls' Generation": {
58 | dot = icGirlsGeneration;
59 | break;
60 | }
61 | case "Buzz": {
62 | dot = icBuzz;
63 | break;
64 | }
65 | case "Wanna One": {
66 | dot = icWannaOne;
67 | break;
68 | }
69 | default: {
70 | dot = icSolo;
71 | }
72 | }
73 | return new SectionInfo(singer.getDebuted(), singer.getGroup(), dot);
74 | }
75 |
76 | @Override
77 | public boolean isSection(int position) {
78 | return !singerList.get(position).getDebuted().equals(singerList.get(position - 1).getDebuted());
79 | }
80 | };
81 | }
82 |
83 | private List getSingerList() {
84 | return new SingerRepo().getSingerList();
85 | }
86 |
87 | private void initDrawable() {
88 | icFinkl = AppCompatResources.getDrawable(this, R.drawable.ic_finkl);
89 | icBuzz = AppCompatResources.getDrawable(this, R.drawable.ic_buzz);
90 | icWannaOne = AppCompatResources.getDrawable(this, R.drawable.ic_wannaone);
91 | icGirlsGeneration = AppCompatResources.getDrawable(this, R.drawable.ic_girlsgeneration);
92 | icSolo = AppCompatResources.getDrawable(this, R.drawable.ic_wannaone);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/sangcomz/stickytimeline/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimeline
2 |
3 | import android.graphics.drawable.Drawable
4 | import android.os.Bundle
5 | import androidx.appcompat.app.AppCompatActivity
6 | import androidx.appcompat.content.res.AppCompatResources
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import androidx.recyclerview.widget.RecyclerView
9 | import io.github.sangcomz.stickytimeline.data.Singer
10 | import io.github.sangcomz.stickytimeline.data.SingerRepo
11 | import xyz.sangcomz.stickytimelineview.TimeLineRecyclerView
12 | import xyz.sangcomz.stickytimelineview.callback.SectionCallback
13 | import xyz.sangcomz.stickytimelineview.model.SectionInfo
14 |
15 | class MainActivity : AppCompatActivity() {
16 |
17 | val icFinkl: Drawable? by lazy {
18 | AppCompatResources.getDrawable(this@MainActivity, R.drawable.ic_finkl)
19 | }
20 | val icBuzz: Drawable? by lazy {
21 | AppCompatResources.getDrawable(this@MainActivity, R.drawable.ic_buzz)
22 | }
23 | val icWannaOne: Drawable? by lazy {
24 | AppCompatResources.getDrawable(this@MainActivity, R.drawable.ic_wannaone)
25 | }
26 | val icGirlsGeneration: Drawable? by lazy {
27 | AppCompatResources.getDrawable(this@MainActivity, R.drawable.ic_girlsgeneration)
28 | }
29 | val icSolo: Drawable? by lazy {
30 | AppCompatResources.getDrawable(this@MainActivity, R.drawable.ic_solo)
31 | }
32 |
33 |
34 | override fun onCreate(savedInstanceState: Bundle?) {
35 | super.onCreate(savedInstanceState)
36 | setContentView(R.layout.activity_main)
37 | initVerticalRecyclerView()
38 | initHorizontalRecyclerView()
39 | }
40 |
41 | private fun initVerticalRecyclerView() {
42 | val singerList: List = getSingerList()
43 | findViewById(R.id.vertical_recycler_view).apply {
44 | adapter = SingerAdapter(
45 | layoutInflater,
46 | singerList,
47 | R.layout.recycler_vertical_row
48 | )
49 | layoutManager = LinearLayoutManager(
50 | this@MainActivity,
51 | RecyclerView.VERTICAL,
52 | false
53 | )
54 | addItemDecoration(getSectionCallback(singerList))
55 | }
56 | }
57 |
58 | private fun initHorizontalRecyclerView() {
59 | val singerList: List = getSingerList()
60 | findViewById(R.id.horizontal_recycler_view).apply {
61 | adapter = SingerAdapter(
62 | layoutInflater,
63 | singerList,
64 | R.layout.recycler_horizontal_row
65 | )
66 | layoutManager = LinearLayoutManager(
67 | this@MainActivity,
68 | RecyclerView.HORIZONTAL,
69 | false
70 | )
71 | addItemDecoration(getSectionCallback(singerList))
72 | }
73 |
74 | findViewById(R.id.horizontal_recycler_view2).apply {
75 | adapter = SingerAdapter(
76 | layoutInflater,
77 | singerList,
78 | R.layout.recycler_horizontal_row
79 | )
80 | layoutManager = LinearLayoutManager(
81 | this@MainActivity,
82 | RecyclerView.HORIZONTAL,
83 | false
84 | )
85 | addItemDecoration(getSectionCallbackWithDrawable(singerList))
86 | }
87 | }
88 |
89 | //Get data method
90 | private fun getSingerList() = SingerRepo().singerList
91 |
92 |
93 | //Get SectionCallback method
94 | private fun getSectionCallback(singerList: List): SectionCallback {
95 | return object : SectionCallback {
96 | //In your data, implement a method to determine if this is a section.
97 | override fun isSection(position: Int): Boolean =
98 | singerList[position].debuted != singerList[position - 1].debuted
99 |
100 | //Implement a method that returns a SectionHeader.
101 | override fun getSectionHeader(position: Int): SectionInfo? {
102 | val singer = singerList[position]
103 | return SectionInfo(singer.debuted, singer.group)
104 | }
105 |
106 | }
107 | }
108 |
109 | private fun getSectionCallbackWithDrawable(singerList: List): SectionCallback {
110 | return object : SectionCallback {
111 | //In your data, implement a method to determine if this is a section.
112 | override fun isSection(position: Int): Boolean =
113 | singerList[position].debuted != singerList[position - 1].debuted
114 |
115 | //Implement a method that returns a SectionHeader.
116 | override fun getSectionHeader(position: Int): SectionInfo? {
117 | val singer = singerList[position]
118 | val dot: Drawable? = when (singer.group) {
119 | "FIN.K.L" -> {
120 | icFinkl
121 | }
122 | "Girls' Generation" -> {
123 | icGirlsGeneration
124 | }
125 | "Buzz" -> {
126 | icBuzz
127 | }
128 | "Wanna One" -> {
129 | icWannaOne
130 | }
131 | else -> icSolo
132 | }
133 | return SectionInfo(singer.debuted, singer.group, dot)
134 | }
135 |
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/sangcomz/stickytimeline/SingerAdapter.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimeline
2 |
3 | import androidx.annotation.LayoutRes
4 | import androidx.recyclerview.widget.RecyclerView
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.TextView
9 | import io.github.sangcomz.stickytimeline.data.Singer
10 |
11 | /**
12 | * Created by paetztm on 2/6/2017.
13 | */
14 | class SingerAdapter(private val layoutInflater: LayoutInflater,
15 | private val singerList: List,
16 | @param:LayoutRes private val rowLayout: Int) : RecyclerView.Adapter() {
17 |
18 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
19 | val v = layoutInflater.inflate(rowLayout,
20 | parent,
21 | false)
22 | return ViewHolder(v)
23 | }
24 |
25 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
26 | val singer = singerList[position]
27 | holder.fullName.text = singer.name
28 | }
29 |
30 | override fun getItemCount(): Int = singerList.size
31 |
32 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
33 | val fullName: TextView = view.findViewById(R.id.full_name_tv) as TextView
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_buzz.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_finkl.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_girlsgeneration.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_solo.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_wannaone.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
26 |
27 |
43 |
44 |
50 |
51 |
57 |
58 |
75 |
76 |
96 |
97 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_horizontal_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_vertical_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StickyTimeLine
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/test/java/xyz/sangcomz/stickytimeline/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimeline
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 |
--------------------------------------------------------------------------------
/benchmark/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/benchmark/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.test'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | android {
7 | namespace 'io.github.sangcomz.benchmark'
8 | compileSdk 35
9 |
10 | defaultConfig {
11 | minSdk 23
12 | targetSdk 35
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | // This benchmark buildType is used for benchmarking, and should function like your
19 | // release build (for example, with minification on). It's signed with a debug key
20 | // for easy local/CI testing.
21 | benchmark {
22 | debuggable = true
23 | signingConfig = debug.signingConfig
24 | matchingFallbacks = ["release"]
25 | }
26 | }
27 |
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_21
30 | targetCompatibility JavaVersion.VERSION_21
31 | }
32 |
33 | kotlinOptions {
34 | jvmTarget = '21'
35 | }
36 |
37 | targetProjectPath = ":sample-compose"
38 | experimentalProperties["android.experimental.self-instrumenting"] = true
39 | }
40 |
41 | dependencies {
42 | implementation 'androidx.test.ext:junit:1.2.1'
43 | implementation 'androidx.test.espresso:espresso-core:3.6.1'
44 | implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
45 | implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.0-beta01'
46 | }
47 |
48 | androidComponents {
49 | beforeVariants(selector().all()) {
50 | enable = buildType == "benchmark"
51 | }
52 | }
--------------------------------------------------------------------------------
/benchmark/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/benchmark/src/main/java/io/github/sangcomz/benchmark/StartupBenchmark.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.benchmark
2 |
3 | import androidx.benchmark.macro.StartupMode
4 | import androidx.benchmark.macro.StartupTimingMetric
5 | import androidx.benchmark.macro.junit4.MacrobenchmarkRule
6 | import androidx.test.ext.junit.runners.AndroidJUnit4
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 |
11 | /**
12 | * This is an example startup benchmark.
13 | *
14 | * It navigates to the device's home screen, and launches the default activity.
15 | *
16 | * Before running this benchmark:
17 | * 1) switch your app's active build variant in the Studio (affects Studio runs only)
18 | * 2) add `` to your app's manifest, within the `` tag
19 | *
20 | * Run this benchmark from Studio to see startup measurements, and captured system traces
21 | * for investigating your app's performance.
22 | */
23 | @RunWith(AndroidJUnit4::class)
24 | class StartupBenchmark {
25 | @get:Rule
26 | val benchmarkRule = MacrobenchmarkRule()
27 |
28 | @Test
29 | fun startup() = benchmarkRule.measureRepeated(
30 | "io.github.sangcomz.sample.compose",
31 | metrics = listOf(StartupTimingMetric()),
32 | iterations = 5,
33 | startupMode = StartupMode.COLD
34 | ) {
35 | pressHome()
36 | startActivityAndWait()
37 | }
38 | }
--------------------------------------------------------------------------------
/benchmark/src/main/java/io/github/sangcomz/benchmark/StickyTimeLineLazyColumnScrollBenchmark.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.benchmark
2 |
3 | import androidx.benchmark.macro.FrameTimingMetric
4 | import androidx.benchmark.macro.StartupMode
5 | import androidx.benchmark.macro.junit4.MacrobenchmarkRule
6 | import androidx.test.ext.junit.runners.AndroidJUnit4
7 | import androidx.test.uiautomator.By
8 | import androidx.test.uiautomator.Direction
9 | import androidx.test.uiautomator.Until
10 | import org.junit.Rule
11 | import org.junit.Test
12 | import org.junit.runner.RunWith
13 |
14 | @RunWith(AndroidJUnit4::class)
15 | class StickyTimeLineBenchmark {
16 |
17 | @get:Rule
18 | val benchmarkRule = MacrobenchmarkRule()
19 |
20 | @Test
21 | fun scrollRow() = benchmarkRule.measureRepeated(
22 | packageName = "io.github.sangcomz.sample.compose",
23 | metrics = listOf(FrameTimingMetric()),
24 | iterations = 5,
25 | startupMode = StartupMode.WARM,
26 | setupBlock = {
27 | pressHome()
28 | startActivityAndWait()
29 | }
30 | ) {
31 |
32 | val condition = Until.hasObject(By.res("sticky_timeline_lazy_row"))
33 | device.wait(condition, 5_000)
34 |
35 | val timelineLazyRow = device.findObject(By.res("sticky_timeline_lazy_row"))
36 | ?: throw IllegalStateException("Cannot find object with resource ID 'sticky_timeline_lazy_row'")
37 | timelineLazyRow.setGestureMargin(device.displayWidth / 5)
38 |
39 | repeat(10) {
40 | timelineLazyRow.swipe(Direction.LEFT, 1f, 4000)
41 | device.waitForIdle()
42 | }
43 | }
44 |
45 | @Test
46 | fun scrollColumn() = benchmarkRule.measureRepeated(
47 | packageName = "io.github.sangcomz.sample.compose",
48 | metrics = listOf(FrameTimingMetric()),
49 | iterations = 5,
50 | startupMode = StartupMode.WARM,
51 | setupBlock = {
52 | pressHome()
53 | startActivityAndWait()
54 | }
55 | ) {
56 |
57 | val condition = Until.hasObject(By.res("sticky_timeline_lazy_column"))
58 | device.wait(condition, 5_000)
59 |
60 | val timelineLazyColumn = device.findObject(By.res("sticky_timeline_lazy_column"))
61 | ?: throw IllegalStateException("Cannot find object with resource ID 'sticky_timeline_lazy_column'")
62 | timelineLazyColumn.setGestureMargin(device.displayWidth / 5)
63 |
64 | repeat(15) {
65 | timelineLazyColumn.swipe(Direction.UP, 1f, 4000)
66 | device.waitForIdle()
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | ext {
6 | kotlin_version = '2.1.20'
7 | constraint_version = '2.2.1'
8 | }
9 |
10 | repositories {
11 | mavenCentral()
12 | google()
13 | maven {
14 | url "https://plugins.gradle.org/m2/"
15 | }
16 | }
17 | dependencies {
18 | classpath 'com.android.tools.build:gradle:8.8.2'
19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20 | classpath "io.github.sabujak-sabujak:gradle-github-release-plugin:0.0.2"
21 | // NOTE: Do not place your application dependencies here; they belong
22 | // in the individual module build.gradle files
23 | }
24 | }
25 |
26 | allprojects {
27 | repositories {
28 | mavenCentral()
29 | google()
30 | }
31 | }
32 |
33 | task clean(type: Delete) {
34 | delete rootProject.buildDir
35 | }
36 |
--------------------------------------------------------------------------------
/data/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/data/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'org.jetbrains.kotlin.jvm'
4 | }
5 |
6 | java {
7 | sourceCompatibility = JavaVersion.VERSION_21
8 | targetCompatibility = JavaVersion.VERSION_21
9 | }
--------------------------------------------------------------------------------
/data/src/main/java/io/github/sangcomz/stickytimeline/data/Music.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimeline.data
2 |
3 | data class Music(
4 | val title: String,
5 | val artist: String,
6 | val album: String,
7 | val year: String,
8 | val month: String,
9 | val genre: String,
10 | val duration: String
11 | )
--------------------------------------------------------------------------------
/data/src/main/java/io/github/sangcomz/stickytimeline/data/MusicRepo.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimeline.data
2 |
3 | class MusicRepo {
4 | val musicList: List
5 | get() {
6 | val musicList = ArrayList()
7 | // 2000
8 | musicList.add(Music("I Love You", "S.E.S.", "Love", "2000", "3", "Pop", "4:12"))
9 | musicList.add(Music("To My Boyfriend", "Fin.K.L", "Blue Rain", "2000", "5", "Pop", "3:55"))
10 | musicList.add(Music("Sad Promise", "Shinhwa", "Only One", "2000", "6", "Pop", "4:10"))
11 | musicList.add(Music("Invitation", "Uhm Jung Hwa", "005.1999.06", "2000", "2", "Dance", "3:50"))
12 | musicList.add(Music("Road", "g.o.d", "Chapter 3", "2000", "11", "Pop", "4:20"))
13 | musicList.add(Music("Couple", "Sechskies", "Special Album", "2000", "1", "Pop", "3:45"))
14 | musicList.add(Music("Poison", "Roo'ra", "Best & Last", "2000", "4", "Dance", "3:40"))
15 | musicList.add(Music("I Believe", "Shin Seung Hun", "I Believe", "2000", "7", "Ballad", "4:18"))
16 | musicList.add(Music("Like Yesterday", "J", "J-Blue", "2000", "8", "Ballad", "4:05"))
17 | musicList.add(Music("Love and Remembrance", "Kim Bum Soo", "A Promise", "2000", "9", "Ballad", "4:30"))
18 |
19 | // 2001
20 | musicList.add(Music("Because I'm A Girl", "KISS", "First Album", "2001", "8", "Ballad", "4:10"))
21 | musicList.add(Music("Road", "g.o.d", "Chapter 4", "2001", "11", "Pop", "3:55"))
22 | musicList.add(Music("I Want", "BoA", "ID; Peace B", "2001", "5", "Pop", "3:40"))
23 | musicList.add(Music("Last Promise", "Shinhwa", "Hey, Come On!", "2001", "6", "Pop", "4:00"))
24 | musicList.add(Music("Ahn", "Park Hyo Shin", "Second Story", "2001", "7", "Ballad", "4:20"))
25 | musicList.add(Music("Reminiscence", "Turbo", "Perfect Love", "2001", "3", "Dance", "3:55"))
26 | musicList.add(Music("I Miss You", "Kim Bum Soo", "Remember", "2001", "4", "Ballad", "4:15"))
27 | musicList.add(Music("To Heaven", "Jo Sung Mo", "Let Me Love", "2001", "12", "Ballad", "4:31"))
28 | musicList.add(Music("Sad Love", "Lee Hyun Woo", "Sad Love", "2001", "4", "Ballad", "4:18"))
29 | musicList.add(Music("Aloha", "Cool", "7th Album", "2001", "7", "Dance", "3:48"))
30 |
31 | // 2002
32 | musicList.add(Music("Atlantis Princess", "BoA", "Atlantis Princess", "2002", "5", "Pop", "3:47"))
33 | musicList.add(Music("One Candle", "g.o.d", "Chapter 4", "2002", "11", "Pop", "4:05"))
34 | musicList.add(Music("Never Ending Story", "Buzz", "Effect", "2002", "6", "Rock", "4:07"))
35 | musicList.add(Music("I Love You", "Position", "I Love You", "2002", "9", "Ballad", "4:22"))
36 | musicList.add(Music("Because of You", "J", "In Love", "2002", "8", "Ballad", "4:11"))
37 | musicList.add(Music("Reminiscence", "Turbo", "X", "2002", "2", "Dance", "3:50"))
38 | musicList.add(Music("Destiny", "H.O.T.", "Outside Castle", "2002", "1", "Dance", "3:30"))
39 | musicList.add(Music("Woman", "KISS", "KISS 1st", "2002", "3", "Pop", "3:45"))
40 | musicList.add(Music("Sadness", "Lee Soo Young", "Never Again", "2002", "4", "Ballad", "3:45"))
41 | musicList.add(Music("Candle Light", "g.o.d", "Chapter 4", "2002", "11", "Pop", "4:11"))
42 |
43 | // 2003
44 | musicList.add(Music("10 Minutes", "Lee Hyori", "Stylish", "2003", "8", "Dance", "3:26"))
45 | musicList.add(Music("Snow Flower", "Park Hyo Shin", "Second Story", "2003", "12", "Ballad", "4:40"))
46 | musicList.add(Music("I Miss You", "Kim Bum Soo", "The 4th Episode", "2003", "9", "Ballad", "4:05"))
47 | musicList.add(Music("Sad Promise", "Shinhwa", "Wedding", "2003", "7", "Pop", "4:10"))
48 | musicList.add(Music("My Friend", "Jo Kyu Chan", "8th Album", "2003", "11", "Ballad", "3:53"))
49 | musicList.add(Music("Lies", "Buzz", "Effect", "2003", "10", "Rock", "3:45"))
50 | musicList.add(Music("Sweet Dream", "Jang Nara", "Sweet Dream", "2003", "6", "Pop", "4:10"))
51 | musicList.add(Music("Like the First Time", "Lee Soo Young", "3rd Album", "2003", "4", "Ballad", "4:10"))
52 | musicList.add(Music("Come to Me", "Cool", "8th Album", "2003", "7", "Dance", "3:40"))
53 | musicList.add(Music("Password 486", "Younha", "1st Album", "2003", "10", "Rock", "3:45"))
54 |
55 | // 2004
56 | musicList.add(Music("My Name", "BoA", "My Name", "2004", "6", "Pop", "3:50"))
57 | musicList.add(Music("Lies", "Buzz", "Perfect", "2004", "6", "Rock", "3:45"))
58 | musicList.add(Music("Magic", "Brown Eyes", "Brown Eyes", "2004", "9", "R&B", "4:11"))
59 | musicList.add(Music("In My Heart", "g.o.d", "An Ordinary Day", "2004", "11", "Ballad", "3:59"))
60 | musicList.add(Music("Three Words", "Gummy", "For the Bloom", "2004", "10", "Ballad", "4:10"))
61 | musicList.add(Music("Reflection of Sound", "Lee Seung Chul", "Reflection of Sound", "2004", "8", "Rock", "4:07"))
62 | musicList.add(Music("Time Walking on Memory", "Nell", "Healing Process", "2004", "5", "Rock", "4:23"))
63 | musicList.add(Music("My Person", "SG Wannabe", "Sald Out", "2004", "4", "Ballad", "4:12"))
64 | musicList.add(Music("Secret", "Park Jung Hyun", "On & On", "2004", "10", "R&B", "4:15"))
65 | musicList.add(Music("Come to Me", "Cool", "9th Album", "2004", "7", "Dance", "3:51"))
66 |
67 | // 2005
68 | musicList.add(Music("Rising Sun", "TVXQ", "Rising Sun", "2005", "9", "Dance", "4:15"))
69 | musicList.add(Music("Love Letter", "BoA", "Girls on Top", "2005", "6", "Pop", "3:50"))
70 | musicList.add(Music("Because of You", "SG Wannabe", "Sald Out", "2005", "4", "Ballad", "4:12"))
71 | musicList.add(Music("Loveable", "Kim Jong Kook", "This is Me", "2005", "7", "Pop", "3:45"))
72 | musicList.add(Music("Casanova", "Lee Seung Gi", "The Dream of a Moth", "2005", "2", "Ballad", "4:10"))
73 | musicList.add(Music("Crazy", "Son Dam Bi", "Crazy", "2005", "11", "Dance", "3:30"))
74 | musicList.add(Music("I", "Taeyeon", "I", "2005", "10", "Pop", "3:55"))
75 | musicList.add(Music("Love is a Gift", "M.C the Max", "The Rusted Love", "2005", "3", "Ballad", "4:20"))
76 | musicList.add(Music("Flower", "Kim Gun Mo", "He-story", "2005", "5", "Pop", "3:40"))
77 | musicList.add(Music("Only You", "Fly to the Sky", "Transition", "2005", "3", "R&B", "4:05"))
78 |
79 | // 2006
80 | musicList.add(Music("U", "Super Junior", "U", "2006", "6", "Dance", "3:45"))
81 | musicList.add(Music("Love Like This", "SS501", "S.T 01 Now", "2006", "11", "Pop", "3:50"))
82 | musicList.add(Music("Haru Haru", "BIGBANG", "Always", "2006", "8", "Hip-Hop", "4:16"))
83 | musicList.add(Music("Toc Toc Toc", "Lee Hyori", "Dark Angel", "2006", "2", "Dance", "3:30"))
84 | musicList.add(Music("Love Story", "Rain", "Rain's World", "2006", "10", "Pop", "4:00"))
85 | musicList.add(Music("Don't Don", "Super Junior", "Don't Don", "2006", "9", "Dance", "4:10"))
86 | musicList.add(Music("Lalala", "SG Wannabe", "The 3rd Masterpiece", "2006", "5", "Ballad", "4:12"))
87 | musicList.add(Music("Smile Again", "Se7en", "Se7olution", "2006", "11", "Pop", "3:55"))
88 | musicList.add(Music("Love and War", "Davichi", "Amaranth", "2006", "3", "Ballad", "4:18"))
89 | musicList.add(Music("I Love You", "Younha", "A Perfect Day to Say I Love You", "2006", "7", "Pop", "3:40"))
90 |
91 | // 2023
92 | musicList.add(Music("Super Shy", "NewJeans", "Get Up", "2023", "7", "Dance", "2:34"))
93 | musicList.add(Music("Seven", "Jungkook", "Seven", "2023", "7", "Pop", "3:00"))
94 | musicList.add(Music("Love Lee", "AKMU", "Love Lee", "2023", "8", "Pop", "2:55"))
95 | musicList.add(Music("ETA", "NewJeans", "Get Up", "2023", "7", "Dance", "2:53"))
96 | musicList.add(Music("EASY", "LE SSERAFIM", "EASY", "2023", "2", "Dance", "2:43"))
97 | musicList.add(Music("Drama", "aespa", "Drama", "2023", "11", "Dance", "3:30"))
98 | musicList.add(Music("I AM", "IVE", "I've IVE", "2023", "4", "Dance", "3:12"))
99 | musicList.add(Music("Spicy", "aespa", "MY WORLD", "2023", "5", "Dance", "3:28"))
100 | musicList.add(Music("Kitsch", "IVE", "I've IVE", "2023", "3", "Dance", "2:49"))
101 | musicList.add(Music("Hype Boy", "NewJeans", "New Jeans", "2023", "1", "Dance", "2:57"))
102 |
103 | // 2024
104 | musicList.add(Music("Love Wins All", "IU", "Love Wins All", "2024", "1", "Ballad", "3:52"))
105 | musicList.add(Music("Supernova", "aespa", "Supernova", "2024", "5", "Dance", "3:14"))
106 | musicList.add(Music("Magnetic", "ILLIT", "Super Real Me", "2024", "3", "Dance", "2:45"))
107 | musicList.add(Music("Fate", "IVE", "I've IVE", "2024", "4", "Dance", "3:15"))
108 | musicList.add(Music("SHEESH", "BABYMONSTER", "BABYMONS7ER", "2024", "4", "Hip-Hop", "3:30"))
109 | musicList.add(Music("Siren", "RIIZE", "RIIZING", "2024", "1", "Pop", "3:18"))
110 | musicList.add(Music("Girls Never Die", "TWICE", "With YOU-th", "2024", "2", "Dance", "3:14"))
111 | musicList.add(Music("Tough Cookie", "ZICO", "Gallery", "2024", "3", "Hip-Hop", "3:12"))
112 | musicList.add(Music("Perfect Night", "LE SSERAFIM", "Perfect Night", "2024", "10", "Pop", "2:51"))
113 | musicList.add(Music("How Sweet", "NewJeans", "How Sweet", "2024", "5", "Dance", "2:41"))
114 |
115 | return musicList
116 | }
117 | }
--------------------------------------------------------------------------------
/data/src/main/java/io/github/sangcomz/stickytimeline/data/Singer.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimeline.data
2 |
3 | /**
4 | * Created by seokwon.jeong on 20/11/2017.
5 | */
6 | data class Singer(val group: String,
7 | val debuted: String,
8 | val name: String)
--------------------------------------------------------------------------------
/data/src/main/java/io/github/sangcomz/stickytimeline/data/SingerRepo.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimeline.data
2 |
3 | import java.util.*
4 |
5 | /**
6 | * Created by paetztm on 2/6/2017.
7 | */
8 |
9 | class SingerRepo {
10 | //solo
11 | val singerList: List
12 | get() {
13 | val singerList = ArrayList()
14 | singerList.add(
15 | Singer(
16 | "Solo",
17 | "1995.04",
18 | "Lim ChangJung"
19 | )
20 | )
21 |
22 | singerList.add(
23 | Singer(
24 | "FIN.K.L",
25 | "1998.05",
26 | "Lee Jin"
27 | )
28 | )
29 | singerList.add(
30 | Singer(
31 | "FIN.K.L",
32 | "1998.05",
33 | "Sung YuRi"
34 | )
35 | )
36 | singerList.add(
37 | Singer(
38 | "FIN.K.L",
39 | "1998.05",
40 | "Oak JooHyun"
41 | )
42 | )
43 | singerList.add(
44 | Singer(
45 | "FIN.K.L",
46 | "1998.05",
47 | "Lee HyoRi"
48 | )
49 | )
50 |
51 | singerList.add(
52 | Singer(
53 | "Solo",
54 | "1999.04",
55 | "Kim BumSoo"
56 | )
57 | )
58 |
59 | singerList.add(
60 | Singer(
61 | "Solo",
62 | "1999.11",
63 | "Park HyoShin"
64 | )
65 | )
66 | singerList.add(
67 | Singer(
68 | "Solo",
69 | "1999.11",
70 | "Lee SooYoung"
71 | )
72 | )
73 | singerList.add(
74 | Singer(
75 | "Solo",
76 | "2000.11",
77 | "Sung SiKyung"
78 | )
79 | )
80 |
81 | singerList.add(
82 | Singer(
83 | "Buzz",
84 | "2003.10",
85 | "Kim Yeah"
86 | )
87 | )
88 | singerList.add(
89 | Singer(
90 | "Buzz",
91 | "2003.10",
92 | "Yun WooHyun"
93 | )
94 | )
95 | singerList.add(
96 | Singer(
97 | "Buzz",
98 | "2003.10",
99 | "Sin JunKi"
100 | )
101 | )
102 | singerList.add(
103 | Singer(
104 | "Buzz",
105 | "2003.10",
106 | "Min KyungHoon"
107 | )
108 | )
109 |
110 | singerList.add(
111 | Singer(
112 | "Solo",
113 | "2006.06",
114 | "Yunha"
115 | )
116 | )
117 |
118 | singerList.add(
119 | Singer(
120 | "Girls' Generation",
121 | "2007.08",
122 | "TaeYeon"
123 | )
124 | )
125 | singerList.add(
126 | Singer(
127 | "Girls' Generation",
128 | "2007.08",
129 | "Sunny"
130 | )
131 | )
132 | singerList.add(
133 | Singer(
134 | "Girls' Generation",
135 | "2007.08",
136 | "Tiffany"
137 | )
138 | )
139 | singerList.add(
140 | Singer(
141 | "Girls' Generation",
142 | "2007.08",
143 | "HyoYeon"
144 | )
145 | )
146 | singerList.add(
147 | Singer(
148 | "Girls' Generation",
149 | "2007.08",
150 | "YuRi"
151 | )
152 | )
153 | singerList.add(
154 | Singer(
155 | "Girls' Generation",
156 | "2007.08",
157 | "SooYoung"
158 | )
159 | )
160 | singerList.add(
161 | Singer(
162 | "Girls' Generation",
163 | "2007.08",
164 | "YoonA"
165 | )
166 | )
167 | singerList.add(
168 | Singer(
169 | "Girls' Generation",
170 | "2007.08",
171 | "SeoHyun"
172 | )
173 | )
174 |
175 | singerList.add(
176 | Singer(
177 | "Wanna One",
178 | "2017.08",
179 | "Kang Daniel"
180 | )
181 | )
182 | singerList.add(
183 | Singer(
184 | "Wanna One",
185 | "2017.08",
186 | "Lai Kuan Lin"
187 | )
188 | )
189 | singerList.add(
190 | Singer(
191 | "Wanna One",
192 | "2017.08",
193 | "Ong SeongWu"
194 | )
195 | )
196 | singerList.add(
197 | Singer(
198 | "Wanna One",
199 | "2017.08",
200 | "Ha SungWoon"
201 | )
202 | )
203 | singerList.add(
204 | Singer(
205 | "Wanna One",
206 | "2017.08",
207 | "Yoon JiSung"
208 | )
209 | )
210 | singerList.add(
211 | Singer(
212 | "Wanna One",
213 | "2017.08",
214 | "Park WooJin"
215 | )
216 | )
217 | singerList.add(
218 | Singer(
219 | "Wanna One",
220 | "2017.08",
221 | "Lee DaeHwi"
222 | )
223 | )
224 | singerList.add(
225 | Singer(
226 | "Wanna One",
227 | "2017.08",
228 | "Kim JaeHwan"
229 | )
230 | )
231 | singerList.add(
232 | Singer(
233 | "Wanna One",
234 | "2017.08",
235 | "Bae JinYoung"
236 | )
237 | )
238 | singerList.add(
239 | Singer(
240 | "Wanna One",
241 | "2017.08",
242 | "Hwang MinHyun"
243 | )
244 | )
245 | singerList.add(
246 | Singer(
247 | "Wanna One",
248 | "2017.08",
249 | "Park JiHoon"
250 | )
251 | )
252 |
253 | singerList.add(
254 | Singer(
255 | "Solo",
256 | "2017.11",
257 | "Woo WonJae"
258 | )
259 | )
260 |
261 | return singerList
262 | }
263 | }
264 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.nonFinalResIds=false
13 | android.nonTransitiveRClass=false
14 | android.useAndroidX=true
15 | org.gradle.jvmargs=-Xmx1536m
16 |
17 | # When configured, Gradle will run in incubating parallel mode.
18 | # This option should only be used with decoupled projects. More details, visit
19 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
20 | # org.gradle.parallel=true
21 |
--------------------------------------------------------------------------------
/gradle/release.compose.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "maven-publish"
2 | apply plugin: "signing"
3 | apply plugin: "io.github.sabujak-sabujak"
4 |
5 | if (project.rootProject.file('local.properties').isFile()) {
6 | Properties props = new Properties()
7 | props.load(new FileInputStream(rootProject.file("local.properties")))
8 | project.ext {
9 | setProperty("ossrhUsername", props["ossrhUsername"] ?: ' ')
10 | setProperty("ossrhPassword", props["ossrhPassword"] ?: ' ')
11 | setProperty("signingKeyId", props["signing.keyId"] ?: ' ')
12 | setProperty("signingPassword", props["signing.password"] ?: ' ')
13 | setProperty("signingKey", props["signing.key"] ?: ' ')
14 | setProperty("githubAccessTokens", props["github_access_tokens"] ?: ' ')
15 | }
16 | } else {
17 | project.ext {
18 | setProperty("ossrhUsername", ' ')
19 | setProperty("ossrhPassword", ' ')
20 | setProperty("signingKeyId", ' ')
21 | setProperty("signingPassword", ' ')
22 | setProperty("signingKey", ' ')
23 | setProperty("githubAccessTokens", ' ')
24 | }
25 | }
26 |
27 | group = "io.github.sangcomz"
28 | version = gradle.composeVersionName
29 | archivesBaseName = "stickytimeline-compose"
30 |
31 | def siteUrl = 'https://github.com/sangcomz/StickyTimeLine' // Homepage URL of the library
32 | def gitUrl = 'https://github.com/sangcomz/StickyTimeLine.git' // Git repository URL
33 |
34 | afterEvaluate {
35 | task sourceJar(type: Jar) {
36 | from android.sourceSets.main.java.srcDirs
37 | archiveClassifier.set("sources")
38 | }
39 |
40 | task javadoc(type: Javadoc) {
41 | source = android.sourceSets.main.java.srcDirs
42 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
43 | }
44 |
45 | task javadocJar(type: Jar, dependsOn: javadoc) {
46 | archiveClassifier.set("javadoc")
47 | from javadoc.destinationDir
48 | }
49 |
50 | // https://docs.gradle.org/current/userguide/publishing_maven.html
51 | publishing {
52 | publications {
53 | // Creates a Maven publication called "release".
54 | release(MavenPublication) {
55 | tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("sourceJar") }
56 | groupId group
57 | artifactId archivesBaseName
58 | version version
59 |
60 | if (project.plugins.findPlugin("com.android.library")) {
61 | from components.release
62 | } else {
63 | from components.java
64 | }
65 | artifact javadocJar
66 |
67 | pom {
68 | name = archivesBaseName
69 | description = 'StickyTimeLine is timeline view for android compose.'
70 | url = siteUrl
71 | licenses {
72 | license {
73 | name = 'The Apache License, Version 2.0'
74 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
75 | }
76 | }
77 | developers {
78 | developer {
79 | id = 'sangcomz'
80 | name = 'Seokwon Jeong'
81 | email = 'dev.seokwon2@gmail.com'
82 | }
83 | }
84 | scm {
85 | url = gitUrl
86 | }
87 | }
88 | }
89 | }
90 |
91 | repositories {
92 | maven {
93 | if (version.endsWith("-SNAPSHOT")) {
94 | url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
95 | } else {
96 | url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
97 | }
98 | credentials {
99 | username ossrhUsername
100 | password ossrhPassword
101 | }
102 | }
103 | }
104 | }
105 |
106 | signing {
107 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
108 | sign publishing.publications.release
109 | }
110 |
111 | javadoc {
112 | if (JavaVersion.current().isJava9Compatible()) {
113 | options.addBooleanOption('html5', true)
114 | }
115 | }
116 | }
117 |
118 | githubRelease {
119 | owner = 'sangcomz'
120 | repo = 'StickyTimeLine'
121 | token = githubAccessTokens
122 | tagName = version
123 | targetCommitish = 'master'
124 | body = """## Release Note
125 | * [Improvement] lib version update
126 | """
127 | name = version
128 | }
--------------------------------------------------------------------------------
/gradle/release.view.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "maven-publish"
2 | apply plugin: "signing"
3 | apply plugin: "io.github.sabujak-sabujak"
4 |
5 | if (project.rootProject.file('local.properties').isFile()) {
6 | Properties props = new Properties()
7 | props.load(new FileInputStream(rootProject.file("local.properties")))
8 | project.ext {
9 | setProperty("ossrhUsername", props["ossrhUsername"] ?: ' ')
10 | setProperty("ossrhPassword", props["ossrhPassword"] ?: ' ')
11 | setProperty("signingKeyId", props["signing.keyId"] ?: ' ')
12 | setProperty("signingPassword", props["signing.password"] ?: ' ')
13 | setProperty("signingKey", props["signing.key"] ?: ' ')
14 | setProperty("githubAccessTokens", props["github_access_tokens"] ?: ' ')
15 | }
16 | } else {
17 | project.ext {
18 | setProperty("ossrhUsername", ' ')
19 | setProperty("ossrhPassword", ' ')
20 | setProperty("signingKeyId", ' ')
21 | setProperty("signingPassword", ' ')
22 | setProperty("signingKey", ' ')
23 | setProperty("githubAccessTokens", ' ')
24 | }
25 | }
26 |
27 | group = "io.github.sangcomz"
28 | version = gradle.versionName
29 | archivesBaseName = "StickyTimeLine"
30 |
31 | def siteUrl = 'https://github.com/sangcomz/StickyTimeLine' // Homepage URL of the library
32 | def gitUrl = 'https://github.com/sangcomz/StickyTimeLine.git' // Git repository URL
33 |
34 | afterEvaluate {
35 | task sourceJar(type: Jar) {
36 | from android.sourceSets.main.java.srcDirs
37 | archiveClassifier.set("sources")
38 | }
39 |
40 | task javadoc(type: Javadoc) {
41 | source = android.sourceSets.main.java.srcDirs
42 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
43 | }
44 |
45 | task javadocJar(type: Jar, dependsOn: javadoc) {
46 | archiveClassifier.set("javadoc")
47 | from javadoc.destinationDir
48 | }
49 |
50 | // https://docs.gradle.org/current/userguide/publishing_maven.html
51 | publishing {
52 | publications {
53 | // Creates a Maven publication called "release".
54 | release(MavenPublication) {
55 | tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("sourceJar") }
56 | groupId group
57 | artifactId archivesBaseName
58 | version version
59 |
60 | if (project.plugins.findPlugin("com.android.library")) {
61 | from components.release
62 | } else {
63 | from components.java
64 | }
65 | artifact javadocJar
66 |
67 | pom {
68 | name = archivesBaseName
69 | description = 'StickyTimeLine is timeline view for android.'
70 | url = siteUrl
71 | licenses {
72 | license {
73 | name = 'The Apache License, Version 2.0'
74 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
75 | }
76 | }
77 | developers {
78 | developer {
79 | id = 'sangcomz'
80 | name = 'Seokwon Jeong'
81 | email = 'dev.seokwon2@gmail.com'
82 | }
83 | }
84 | scm {
85 | url = gitUrl
86 | }
87 | }
88 | }
89 | }
90 |
91 | repositories {
92 | maven {
93 | if (version.endsWith("-SNAPSHOT")) {
94 | url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
95 | } else {
96 | url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
97 | }
98 | credentials {
99 | username ossrhUsername
100 | password ossrhPassword
101 | }
102 | }
103 | }
104 | }
105 |
106 | signing {
107 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
108 | sign publishing.publications.release
109 | }
110 |
111 | javadoc {
112 | if (JavaVersion.current().isJava9Compatible()) {
113 | options.addBooleanOption('html5', true)
114 | }
115 | }
116 | }
117 |
118 | githubRelease {
119 | owner = 'sangcomz'
120 | repo = 'StickyTimeLine'
121 | token = githubAccessTokens
122 | tagName = version
123 | targetCommitish = 'master'
124 | body = """## Release Note
125 | * [Improvement] lib version update
126 | """
127 | name = version
128 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 16 21:54:52 KST 2020
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-8.10.2-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/pic/alleys_result.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/pic/alleys_result.gif
--------------------------------------------------------------------------------
/pic/compose.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/pic/compose.gif
--------------------------------------------------------------------------------
/pic/sample_result.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/pic/sample_result.gif
--------------------------------------------------------------------------------
/pic/stockroom_result.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/pic/stockroom_result.gif
--------------------------------------------------------------------------------
/privacy_policy.md:
--------------------------------------------------------------------------------
1 | ## Privacy Policy
2 |
3 | sangcomz built the StickyTimeLine app as an Open Source app. This SERVICE is provided by sangcomz at no cost and is intended for use as is.
4 |
5 | This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
6 |
7 | If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
8 |
9 | The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at StickyTimeLine unless otherwise defined in this Privacy Policy.
10 |
11 | **Information Collection and Use**
12 |
13 | For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retained on your device and is not collected by me in any way.
14 |
15 | The app does use third party services that may collect information used to identify you.
16 |
17 | Link to privacy policy of third party service providers used by the app
18 |
19 | * [AdMob](https://support.google.com/admob/answer/6128543?hl=en)
20 |
21 | **Log Data**
22 |
23 | I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics.
24 |
25 | **Cookies**
26 |
27 | Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
28 |
29 | This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.
30 |
31 | **Service Providers**
32 |
33 | I may employ third-party companies and individuals due to the following reasons:
34 |
35 | * To facilitate our Service;
36 | * To provide the Service on our behalf;
37 | * To perform Service-related services; or
38 | * To assist us in analyzing how our Service is used.
39 |
40 | I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
41 |
42 | **Security**
43 |
44 | I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security.
45 |
46 | **Links to Other Sites**
47 |
48 | This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.
49 |
50 | **Children’s Privacy**
51 |
52 | These Services do not address anyone under the age of 13\. I do not knowingly collect personally identifiable information from children under 13\. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions.
53 |
54 | **Changes to This Privacy Policy**
55 |
56 | I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page.
57 |
58 | **Contact Us**
59 |
60 | If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me.
61 |
62 | This privacy policy page was created at [privacypolicytemplate.net](https://privacypolicytemplate.net) and modified/generated by [App Privacy Policy Generator](https://app-privacy-policy-generator.firebaseapp.com/)
--------------------------------------------------------------------------------
/sample-compose/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/sample-compose/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id("org.jetbrains.kotlin.plugin.compose") version "2.1.20"
5 | }
6 |
7 | android {
8 | namespace 'io.github.sangcomz.sample.compose'
9 | compileSdk 35
10 |
11 | defaultConfig {
12 | applicationId "io.github.sangcomz.sample.compose"
13 | minSdk 21
14 | targetSdk 35
15 | versionCode 1
16 | versionName "1.0"
17 |
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | vectorDrawables {
20 | useSupportLibrary true
21 | }
22 | }
23 |
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28 | }
29 | benchmark {
30 | initWith release
31 | signingConfig signingConfigs.debug
32 | matchingFallbacks = ['release']
33 | debuggable false
34 | }
35 | }
36 |
37 | compileOptions {
38 | sourceCompatibility JavaVersion.VERSION_21
39 | targetCompatibility JavaVersion.VERSION_21
40 | }
41 |
42 | kotlinOptions {
43 | jvmTarget = '21'
44 | }
45 |
46 | buildFeatures {
47 | compose true
48 | }
49 | composeOptions {
50 | kotlinCompilerExtensionVersion '1.5.11'
51 | }
52 | packaging {
53 | resources {
54 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
55 | }
56 | }
57 | }
58 |
59 | dependencies {
60 |
61 | implementation 'androidx.core:core-ktx:1.16.0'
62 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.9.0'
63 | implementation 'androidx.activity:activity-compose:1.10.1'
64 | implementation platform('androidx.compose:compose-bom:2025.05.01')
65 | implementation 'androidx.compose.ui:ui'
66 | implementation 'androidx.compose.ui:ui-graphics'
67 | implementation 'androidx.compose.ui:ui-tooling-preview'
68 | implementation 'androidx.compose.material3:material3'
69 | implementation project(':stickytimelineview-compose')
70 | implementation project(':data')
71 |
72 | testImplementation 'junit:junit:4.13.2'
73 | androidTestImplementation 'androidx.test.ext:junit:1.2.1'
74 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
75 | androidTestImplementation platform('androidx.compose:compose-bom:2025.05.01')
76 | androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
77 | debugImplementation 'androidx.compose.ui:ui-tooling'
78 | debugImplementation 'androidx.compose.ui:ui-test-manifest'
79 | }
--------------------------------------------------------------------------------
/sample-compose/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
--------------------------------------------------------------------------------
/sample-compose/src/androidTest/java/xyz/sangcomz/github/sample/compose/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.github.sample.compose
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("xyz.sangcomz.github.sample.compose", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/sample-compose/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/sample-compose/src/main/java/io/github/sangcomz/sample/compose/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.sample.compose
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.background
7 | import androidx.compose.foundation.layout.Box
8 | import androidx.compose.foundation.layout.Column
9 | import androidx.compose.foundation.layout.Row
10 | import androidx.compose.foundation.layout.Spacer
11 | import androidx.compose.foundation.layout.fillMaxSize
12 | import androidx.compose.foundation.layout.fillMaxWidth
13 | import androidx.compose.foundation.layout.height
14 | import androidx.compose.foundation.layout.padding
15 | import androidx.compose.foundation.layout.safeContentPadding
16 | import androidx.compose.foundation.layout.size
17 | import androidx.compose.foundation.layout.width
18 | import androidx.compose.foundation.layout.wrapContentHeight
19 | import androidx.compose.foundation.layout.wrapContentSize
20 | import androidx.compose.foundation.layout.wrapContentWidth
21 | import androidx.compose.material3.Card
22 | import androidx.compose.material3.CardDefaults
23 | import androidx.compose.material3.MaterialTheme
24 | import androidx.compose.material3.Surface
25 | import androidx.compose.material3.Text
26 | import androidx.compose.runtime.Composable
27 | import androidx.compose.ui.Alignment
28 | import androidx.compose.ui.Modifier
29 | import androidx.compose.ui.graphics.Color
30 | import androidx.compose.ui.platform.testTag
31 | import androidx.compose.ui.semantics.semantics
32 | import androidx.compose.ui.semantics.testTagsAsResourceId
33 | import androidx.compose.ui.text.TextStyle
34 | import androidx.compose.ui.text.font.FontWeight
35 | import androidx.compose.ui.text.style.TextAlign
36 | import androidx.compose.ui.tooling.preview.Preview
37 | import androidx.compose.ui.unit.dp
38 | import androidx.compose.ui.unit.sp
39 | import io.github.sangcomz.stickytimelineview.compose.StickyTimeLineLazyRow
40 | import io.github.sangcomz.sample.compose.ui.theme.StickyTimeLineTheme
41 | import io.github.sangcomz.stickytimeline.data.Music
42 | import io.github.sangcomz.stickytimeline.data.MusicRepo
43 | import io.github.sangcomz.stickytimelineview.compose.StickyTimeLineLazyColumn
44 |
45 | class MainActivity : ComponentActivity() {
46 | override fun onCreate(savedInstanceState: Bundle?) {
47 | super.onCreate(savedInstanceState)
48 | setContent {
49 | StickyTimeLineTheme {
50 | Surface(
51 | modifier = Modifier
52 | .fillMaxSize()
53 | .safeContentPadding().semantics {
54 | testTagsAsResourceId = true
55 | },
56 | ) {
57 | val musicList = MusicRepo().musicList
58 | val sortedMusicList = musicList.sortedWith(
59 | compareBy(
60 | { it.year.toIntOrNull() ?: 0 },
61 | { it.month.toIntOrNull() ?: 0 }
62 | )
63 | )
64 |
65 | Column(
66 | Modifier.background(Color.White)
67 | ) {
68 | Box(
69 | modifier = Modifier
70 | .fillMaxWidth()
71 | .height(56.dp)
72 | .background(Color(0xff00118F)),
73 | contentAlignment = Alignment.Center
74 | ) {
75 | Text(
76 | text = "StickyTimeLineLazyColumn",
77 | style = MaterialTheme.typography.titleLarge.copy(
78 | color = Color.White
79 | ),
80 | textAlign = TextAlign.Center
81 | )
82 | }
83 |
84 | StickyTimeLineLazyColumn(
85 | modifier = Modifier
86 | .weight(.5f)
87 | .testTag("sticky_timeline_lazy_column"),
88 | items = sortedMusicList,
89 | makeHeaderItem = { key, _ ->
90 | key
91 | },
92 | groupBy = { it.year },
93 | sectionHeader = { year ->
94 | SectionHeaderForLazyColumn(year = year)
95 | },
96 | itemContent = { music ->
97 | MusicCardForLazyColumn(music = music)
98 | },
99 | timeLineDot = {
100 | Dot()
101 | }
102 | )
103 |
104 | Box(
105 | modifier = Modifier
106 | .fillMaxWidth()
107 | .height(56.dp)
108 | .background(Color(0xff003E8F)),
109 | contentAlignment = Alignment.Center
110 | ) {
111 | Text(
112 | text = "StickyTimeLineLazyRow",
113 | style = MaterialTheme.typography.titleLarge.copy(
114 | color = Color.White
115 | ),
116 | textAlign = TextAlign.Center
117 | )
118 | }
119 |
120 | StickyTimeLineLazyRow(
121 | modifier = Modifier
122 | .fillMaxWidth()
123 | .weight(.5f).testTag("sticky_timeline_lazy_row"),
124 | items = sortedMusicList,
125 | lineColor = Color(0xff003E8F),
126 | lineWidth = 2.dp,
127 | groupBy = { it.year },
128 | makeHeaderItem = { key, _ ->
129 | key
130 | },
131 | headerContent = { year ->
132 | SectionHeaderForLazyRow(year = year)
133 | },
134 | itemContent = { music ->
135 | MusicCardForLazyRow(music = music)
136 | },
137 | dotContent = { _ ->
138 | DotForLazyRow()
139 | },
140 | )
141 | }
142 |
143 | }
144 | }
145 | }
146 | }
147 | }
148 |
149 | @Composable
150 | fun SectionHeaderForLazyColumn(
151 | year: String
152 | ) {
153 | Row(
154 | verticalAlignment = Alignment.CenterVertically,
155 | modifier = Modifier
156 | .background(Color.White)
157 | .padding(8.dp)
158 | .wrapContentHeight()
159 | .fillMaxWidth()
160 | ) {
161 | Column {
162 | Text(
163 | text = year,
164 | style = TextStyle(
165 | fontSize = 18.sp,
166 | fontWeight = FontWeight.Bold,
167 | color = Color(0xFF414FCA)
168 | )
169 | )
170 | Text(
171 | text = "Popular Songs",
172 | style = TextStyle(
173 | fontSize = 14.sp,
174 | color = Color(0xFFD16767)
175 | )
176 | )
177 | }
178 | }
179 | }
180 |
181 | @Composable
182 | fun SectionHeaderForLazyRow(
183 | year: String
184 | ) {
185 | Row(
186 | verticalAlignment = Alignment.CenterVertically,
187 | modifier = Modifier
188 | .wrapContentSize()
189 | .padding(horizontal = 8.dp)
190 | ) {
191 | Column {
192 | Text(
193 | text = year,
194 | style = TextStyle(
195 | fontSize = 18.sp,
196 | fontWeight = FontWeight.Bold,
197 | color = Color(0xFF414FCA)
198 | )
199 | )
200 | Text(
201 | text = "Popular Songs",
202 | style = TextStyle(
203 | fontSize = 14.sp,
204 | color = Color(0xFFD16767)
205 | )
206 | )
207 | }
208 | }
209 | }
210 |
211 | @Composable
212 | fun MusicCardForLazyRow(music: Music) {
213 | Card(
214 | modifier = Modifier.wrapContentWidth(),
215 | shape = MaterialTheme.shapes.medium,
216 | elevation = CardDefaults.cardElevation(4.dp)
217 | ) {
218 | Column(modifier = Modifier.padding(16.dp)) {
219 | Text(music.title, style = MaterialTheme.typography.titleMedium)
220 | Text(music.artist, style = MaterialTheme.typography.bodyMedium)
221 | Text(music.album, style = MaterialTheme.typography.bodySmall)
222 | Spacer(modifier = Modifier.height(4.dp))
223 | Text(
224 | text = "${music.year} ${music.month} · ${music.genre}",
225 | style = MaterialTheme.typography.bodySmall
226 | )
227 | Text(music.duration, style = MaterialTheme.typography.bodySmall)
228 | }
229 | }
230 | }
231 |
232 | @Composable
233 | fun MusicCardForLazyColumn(music: Music) {
234 | Card(
235 | modifier = Modifier.fillMaxWidth(),
236 | shape = MaterialTheme.shapes.medium,
237 | elevation = CardDefaults.cardElevation(4.dp)
238 | ) {
239 | Column(modifier = Modifier.padding(16.dp)) {
240 | Text(music.title, style = MaterialTheme.typography.titleMedium)
241 | Text(music.artist, style = MaterialTheme.typography.bodyMedium)
242 | Text(music.album, style = MaterialTheme.typography.bodySmall)
243 | Spacer(modifier = Modifier.height(4.dp))
244 | Text(
245 | text = "${music.year} ${music.month} · ${music.genre}",
246 | style = MaterialTheme.typography.bodySmall
247 | )
248 | Text(music.duration, style = MaterialTheme.typography.bodySmall)
249 | }
250 | }
251 | }
252 |
253 | @Composable
254 | fun Dot() {
255 | Box(
256 | modifier = Modifier
257 | .width(48.dp)
258 | .wrapContentHeight(),
259 | contentAlignment = Alignment.Center
260 | ) {
261 | Box(
262 | modifier = Modifier
263 | .size(32.dp)
264 | .background(
265 | Color.Gray.copy(alpha = 0.2f),
266 | shape = androidx.compose.foundation.shape.CircleShape
267 | )
268 | )
269 |
270 | Box(
271 | modifier = Modifier
272 | .size(24.dp)
273 | .background(Color.Gray, shape = androidx.compose.foundation.shape.CircleShape)
274 | )
275 | }
276 | }
277 |
278 | @Composable
279 | fun DotForLazyRow() {
280 | Box(
281 | modifier = Modifier
282 | .padding(horizontal = 8.dp)
283 | .width(24.dp),
284 | contentAlignment = Alignment.Center
285 | ) {
286 | Box(
287 | modifier = Modifier
288 | .size(24.dp)
289 | .background(
290 | Color.Gray.copy(alpha = 0.2f),
291 | shape = androidx.compose.foundation.shape.CircleShape
292 | )
293 | )
294 |
295 | Box(
296 | modifier = Modifier
297 | .size(12.dp)
298 | .background(Color.Gray, shape = androidx.compose.foundation.shape.CircleShape)
299 | )
300 | }
301 | }
302 |
303 | @Preview(showBackground = true)
304 | @Composable
305 | fun GreetingPreview() {
306 | StickyTimeLineTheme {
307 |
308 | }
309 | }
--------------------------------------------------------------------------------
/sample-compose/src/main/java/io/github/sangcomz/sample/compose/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.sample.compose.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/sample-compose/src/main/java/io/github/sangcomz/sample/compose/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.sample.compose.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun StickyTimeLineTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
--------------------------------------------------------------------------------
/sample-compose/src/main/java/io/github/sangcomz/sample/compose/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.sample.compose.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/sample-compose/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/sample-compose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample-compose/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | sample-compose
3 |
--------------------------------------------------------------------------------
/sample-compose/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample-compose/src/test/java/xyz/sangcomz/github/sample/compose/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.github.sample.compose
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 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':stickytimelineview'
2 |
3 | gradle.ext.set('versionCode', 11)
4 | gradle.ext.set('versionName', '1.1.0')
5 |
6 | gradle.ext.set('composeVersionCode', 1)
7 | gradle.ext.set('composeVersionName', '0.1.0')
8 |
9 | gradle.ext.set('minSdk', 21)
10 | gradle.ext.set('targetSdk', 35)
11 | gradle.ext.set('compileSdk', 35)
12 | include ':stickytimelineview-compose'
13 | include ':sample-compose'
14 | include ':data'
15 | include ':benchmark'
16 |
--------------------------------------------------------------------------------
/stickytimelineview-compose/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/stickytimelineview-compose/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'org.jetbrains.kotlin.android'
4 | id("org.jetbrains.kotlin.plugin.compose") version "2.1.20"
5 | }
6 |
7 | android {
8 | namespace 'io.github.sangcomz.stickytimelineview.compose'
9 | compileSdk gradle.compileSdk
10 |
11 | defaultConfig {
12 | minSdk gradle.minSdk
13 | targetSdk gradle.targetSdk
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles "consumer-rules.pro"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | kotlinOptions {
29 | jvmTarget = '1.8'
30 | }
31 | buildFeatures {
32 | compose true
33 | }
34 | composeOptions {
35 | kotlinCompilerExtensionVersion '1.5.11'
36 | }
37 | }
38 |
39 | apply from: '../gradle/release.compose.gradle'
40 |
41 | dependencies {
42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
43 | implementation 'androidx.appcompat:appcompat:1.7.0'
44 |
45 | //compose activity
46 | implementation 'androidx.activity:activity-compose:1.10.1'
47 | implementation 'androidx.compose.ui:ui:1.8.2'
48 | implementation 'androidx.compose.ui:ui-graphics:1.8.2'
49 | implementation 'androidx.compose.ui:ui-tooling:1.8.2'
50 | implementation 'androidx.compose.material3:material3:1.3.2'
51 | implementation 'androidx.compose.material:material:1.8.2'
52 | implementation platform('androidx.compose:compose-bom:2025.05.01')
53 |
54 | testImplementation 'junit:junit:4.13.2'
55 | androidTestImplementation 'androidx.test:runner:1.6.2'
56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
57 | }
58 |
59 | tasks.withType(Javadoc).all {
60 | enabled = false
61 | }
--------------------------------------------------------------------------------
/stickytimelineview-compose/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sangcomz/StickyTimeLine/f8070f51364be01fc1f9d0778869aca11c7033f0/stickytimelineview-compose/consumer-rules.pro
--------------------------------------------------------------------------------
/stickytimelineview-compose/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
--------------------------------------------------------------------------------
/stickytimelineview-compose/src/androidTest/java/xyz/sangcomz/github/stickytimelineview/compose/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.github.stickytimelineview.compose
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("xyz.sangcomz.github.stickytimelineview.compose.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/stickytimelineview-compose/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/stickytimelineview-compose/src/main/java/io/github/sangcomz/stickytimelineview/compose/StickyTimeLineLazyColumn.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimelineview.compose
2 |
3 | import androidx.compose.foundation.Canvas
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.Arrangement
6 | import androidx.compose.foundation.layout.Box
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.Spacer
9 | import androidx.compose.foundation.layout.fillMaxHeight
10 | import androidx.compose.foundation.layout.fillMaxSize
11 | import androidx.compose.foundation.layout.fillMaxWidth
12 | import androidx.compose.foundation.layout.offset
13 | import androidx.compose.foundation.layout.width
14 | import androidx.compose.foundation.layout.wrapContentHeight
15 | import androidx.compose.foundation.lazy.LazyColumn
16 | import androidx.compose.foundation.lazy.itemsIndexed
17 | import androidx.compose.foundation.lazy.rememberLazyListState
18 | import androidx.compose.runtime.Composable
19 | import androidx.compose.runtime.MutableIntState
20 | import androidx.compose.runtime.derivedStateOf
21 | import androidx.compose.runtime.getValue
22 | import androidx.compose.runtime.key
23 | import androidx.compose.runtime.mutableIntStateOf
24 | import androidx.compose.runtime.remember
25 | import androidx.compose.runtime.setValue
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.draw.clipToBounds
29 | import androidx.compose.ui.geometry.Offset
30 | import androidx.compose.ui.graphics.Color
31 | import androidx.compose.ui.layout.SubcomposeLayout
32 | import androidx.compose.ui.layout.onGloballyPositioned
33 | import androidx.compose.ui.platform.LocalDensity
34 | import androidx.compose.ui.unit.Dp
35 | import androidx.compose.ui.unit.IntOffset
36 | import androidx.compose.ui.unit.dp
37 | import androidx.compose.ui.unit.max
38 | import kotlin.math.roundToInt
39 |
40 | @Composable
41 | fun StickyTimeLineLazyColumn(
42 | modifier: Modifier = Modifier,
43 | items: List,
44 | groupBy: (T) -> String,
45 | makeHeaderItem: (key: String, items: List) -> G,
46 | generateItemKey: ((T) -> Any) = { it.hashCode() },
47 | contentBackgroundColor: Color = Color.White,
48 | lineColor: Color = Color.Blue,
49 | lineWidth: Dp = 2.dp,
50 | verticalSpaceBy: Dp = 12.dp,
51 | timeLineHorizontalPadding: Dp = 0.dp,
52 | timeLineDot: @Composable () -> Unit,
53 | sectionHeader: @Composable (headerItem: G) -> Unit,
54 | itemContent: @Composable (item: T) -> Unit,
55 | ) {
56 | val density = LocalDensity.current
57 | val listState = rememberLazyListState()
58 | var stickyHeaderHeight by remember { mutableIntStateOf(0) }
59 | val dotWidthPx = remember { mutableIntStateOf(0) }
60 |
61 | val groupedMap = remember(items, groupBy) {
62 | val map = linkedMapOf>()
63 | for (item in items) {
64 | val key = groupBy(item)
65 | val list = map.getOrPut(key) { mutableListOf() }
66 | list.add(item)
67 | }
68 | map
69 | }
70 |
71 | val headerItemMap = remember(groupedMap, makeHeaderItem) {
72 | groupedMap.mapValues { (key, value) -> makeHeaderItem(key, value) }
73 | }
74 |
75 | val headerIndexList = remember(groupedMap) {
76 | val list = mutableListOf>()
77 | var index = 0
78 | groupedMap.forEach { (key, items) ->
79 | list.add(key to index)
80 | index += 1 + items.size
81 | }
82 | list
83 | }
84 |
85 | val timeLineTotalWidth by remember {
86 | derivedStateOf {
87 | with(density) {
88 | timeLineHorizontalPadding * 2 + max(dotWidthPx.intValue.toDp(), lineWidth)
89 | }
90 | }
91 | }
92 |
93 | Box(
94 | modifier = modifier
95 | .fillMaxSize()
96 | .background(contentBackgroundColor)
97 | .clipToBounds()
98 | ) {
99 | Canvas(
100 | modifier = Modifier
101 | .fillMaxHeight()
102 | .width(timeLineTotalWidth)
103 | .align(Alignment.TopStart)
104 | ) {
105 | val centerX = size.width / 2
106 | drawLine(
107 | color = lineColor,
108 | start = Offset(centerX, 0f),
109 | end = Offset(centerX, size.height),
110 | strokeWidth = lineWidth.toPx()
111 | )
112 | }
113 |
114 | LazyColumn(
115 | state = listState,
116 | modifier = Modifier.fillMaxSize(),
117 | verticalArrangement = Arrangement.spacedBy(verticalSpaceBy)
118 | ) {
119 | groupedMap.forEach { (key, items) ->
120 | val headerItem = headerItemMap[key]!!
121 | item {
122 | HeaderItem(
123 | headerItem = headerItem,
124 | dotWidthPx = dotWidthPx,
125 | timeLineDot = timeLineDot,
126 | sectionHeader = sectionHeader,
127 | contentBackgroundColor = contentBackgroundColor,
128 | lineColor = lineColor,
129 | lineWidth = lineWidth
130 | )
131 | }
132 | itemsIndexed(items) { _, item ->
133 | key(generateItemKey(item)) {
134 | Row(
135 | modifier = Modifier
136 | .fillMaxWidth()
137 | .wrapContentHeight(),
138 | verticalAlignment = Alignment.Top
139 | ) {
140 | Spacer(Modifier.width(timeLineTotalWidth))
141 | itemContent(item)
142 | }
143 | }
144 | }
145 | }
146 | }
147 |
148 | val currentStickyHeaderKey = remember {
149 | derivedStateOf {
150 | headerIndexList
151 | .takeWhile { it.second <= listState.firstVisibleItemIndex }
152 | .lastOrNull()?.first ?: headerIndexList.firstOrNull()?.first
153 | }
154 | }
155 |
156 | currentStickyHeaderKey.value?.let { key ->
157 | val nextHeaderIndex = headerIndexList.indexOfFirst { it.first == key } + 1
158 | val nextHeaderOffset = listState.layoutInfo.visibleItemsInfo
159 | .firstOrNull { it.index == headerIndexList.getOrNull(nextHeaderIndex)?.second }
160 | ?.offset ?: 0
161 |
162 | val yOffset = if (nextHeaderOffset in 1 until stickyHeaderHeight) {
163 | nextHeaderOffset - stickyHeaderHeight
164 | } else {
165 | 0
166 | }
167 |
168 | val headerItem = headerItemMap[key]!!
169 |
170 | Box(
171 | modifier = Modifier
172 | .fillMaxWidth()
173 | .offset { IntOffset(0, yOffset) }
174 | .onGloballyPositioned { coordinates ->
175 | stickyHeaderHeight = coordinates.size.height
176 | }
177 | ) {
178 | HeaderItem(
179 | headerItem = headerItem,
180 | dotWidthPx = dotWidthPx,
181 | timeLineDot = timeLineDot,
182 | sectionHeader = sectionHeader,
183 | contentBackgroundColor = contentBackgroundColor,
184 | lineColor = lineColor,
185 | lineWidth = lineWidth
186 | )
187 | }
188 | }
189 | }
190 | }
191 |
192 | @Composable
193 | private fun HeaderItem(
194 | headerItem: G,
195 | dotWidthPx: MutableIntState,
196 | timeLineDot: @Composable () -> Unit,
197 | sectionHeader: @Composable (G) -> Unit,
198 | contentBackgroundColor: Color,
199 | lineColor: Color,
200 | lineWidth: Dp,
201 | modifier: Modifier = Modifier,
202 | ) {
203 | val density = LocalDensity.current
204 | val horizontalPadding = 8.dp
205 | val horizontalPaddingPx = with(density) { horizontalPadding.roundToPx() }
206 | val lineWidthPx = with(density) { lineWidth.toPx().roundToInt() }
207 |
208 | SubcomposeLayout(
209 | modifier = modifier.background(contentBackgroundColor)
210 | ) { constraints ->
211 |
212 | val dotPlaceable = subcompose("dot", timeLineDot).first().measure(constraints)
213 |
214 | val timeLineWidthPx = maxOf(dotPlaceable.width, lineWidthPx) + horizontalPaddingPx * 2
215 |
216 | val linePlaceable = subcompose("line") {
217 | Box(
218 | modifier = Modifier
219 | .width(with(density) { timeLineWidthPx.toDp() })
220 | .fillMaxHeight()
221 | ) {
222 | Canvas(modifier = Modifier.fillMaxSize()) {
223 | val centerX = size.width / 2
224 | drawLine(
225 | color = lineColor,
226 | start = Offset(centerX, 0f),
227 | end = Offset(centerX, size.height),
228 | strokeWidth = lineWidth.toPx()
229 | )
230 | }
231 | }
232 | }.first().measure(constraints)
233 |
234 | val headerPlaceable = subcompose("header") {
235 | Row(
236 | verticalAlignment = Alignment.CenterVertically,
237 | modifier = Modifier
238 | .fillMaxWidth()
239 | .wrapContentHeight()
240 | ) {
241 | Spacer(Modifier.width(with(density) { timeLineWidthPx.toDp() }))
242 | sectionHeader(headerItem)
243 | }
244 | }.first().measure(constraints)
245 |
246 | val height = maxOf(dotPlaceable.height, headerPlaceable.height)
247 |
248 | dotWidthPx.intValue = timeLineWidthPx
249 |
250 | layout(constraints.maxWidth, height) {
251 | linePlaceable.placeRelative(0, 0)
252 | val dotX = (timeLineWidthPx - dotPlaceable.width) / 2
253 | val dotY = (height - dotPlaceable.height) / 2
254 | dotPlaceable.placeRelative(dotX, dotY)
255 | headerPlaceable.placeRelative(0, 0)
256 | }
257 | }
258 | }
--------------------------------------------------------------------------------
/stickytimelineview-compose/src/main/java/io/github/sangcomz/stickytimelineview/compose/StickyTimeLineLazyRow.kt:
--------------------------------------------------------------------------------
1 | package io.github.sangcomz.stickytimelineview.compose
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.Column
7 | import androidx.compose.foundation.layout.PaddingValues
8 | import androidx.compose.foundation.layout.fillMaxWidth
9 | import androidx.compose.foundation.layout.height
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.foundation.lazy.LazyListState
12 | import androidx.compose.foundation.lazy.LazyRow
13 | import androidx.compose.foundation.lazy.items
14 | import androidx.compose.foundation.lazy.rememberLazyListState
15 | import androidx.compose.foundation.shape.CircleShape
16 | import androidx.compose.runtime.Composable
17 | import androidx.compose.runtime.key
18 | import androidx.compose.runtime.remember
19 | import androidx.compose.ui.Modifier
20 | import androidx.compose.ui.graphics.Color
21 | import androidx.compose.ui.layout.SubcomposeLayout
22 | import androidx.compose.ui.platform.testTag
23 | import androidx.compose.ui.unit.Dp
24 | import androidx.compose.ui.unit.dp
25 | import kotlin.math.max
26 |
27 | @Composable
28 | fun StickyTimeLineLazyRow(
29 | modifier: Modifier = Modifier,
30 | items: List,
31 | groupBy: (T) -> String,
32 | makeHeaderItem: (key: String, items: List) -> G,
33 | generateItemKey: ((T) -> Any) = { it.hashCode() },
34 | headerContent: @Composable (headerItem: G) -> Unit,
35 | itemContent: @Composable (item: T) -> Unit,
36 | dotContent: @Composable (group: String) -> Unit = {
37 | Box(
38 | modifier = Modifier
39 | .size(8.dp)
40 | .background(Color.Blue, CircleShape)
41 | )
42 | },
43 | lineColor: Color = Color.Blue,
44 | lineWidth: Dp = 2.dp,
45 | horizontalSpaceBy: Dp = 12.dp,
46 | contentPaddingValues: PaddingValues = PaddingValues(horizontal = 8.dp),
47 | ) {
48 | val state = rememberLazyListState()
49 |
50 | val groupedMap = remember(items, groupBy) {
51 | val map = linkedMapOf>()
52 | for (item in items) {
53 | val key = groupBy(item)
54 | val list = map.getOrPut(key) { mutableListOf() }
55 | list.add(item)
56 | }
57 | map
58 | }
59 |
60 | val headerItemMap = remember(groupedMap, makeHeaderItem) {
61 | groupedMap.mapValues { (key, value) -> makeHeaderItem(key, value) }
62 | }
63 |
64 | Box(
65 | modifier = modifier.fillMaxWidth()
66 | ) {
67 | Column {
68 | HeaderWithTimeLine(
69 | state = state,
70 | groupedMap = groupedMap,
71 | headerItemMap = headerItemMap,
72 | headerContent = headerContent,
73 | dotContent = dotContent,
74 | lineColor = lineColor,
75 | lineWidth = lineWidth
76 | )
77 | LazyRow(
78 | state = state,
79 | modifier = Modifier.fillMaxWidth(),
80 | contentPadding = contentPaddingValues,
81 | horizontalArrangement = Arrangement.spacedBy(horizontalSpaceBy)
82 | ) {
83 | items(items) { item ->
84 | key(generateItemKey(item)) {
85 | itemContent(item)
86 | }
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
93 | @Composable
94 | fun HeaderWithTimeLine(
95 | state: LazyListState,
96 | groupedMap: Map>,
97 | headerItemMap: Map,
98 | headerContent: @Composable (headerItem: G) -> Unit,
99 | dotContent: @Composable (group: String) -> Unit,
100 | lineColor: Color,
101 | lineWidth: Dp
102 | ) {
103 | SubcomposeLayout { constraints ->
104 | val visibleItems = state.layoutInfo.visibleItemsInfo
105 | val verticalPadding = 8.dp.toPx()
106 |
107 | if (visibleItems.isEmpty()) return@SubcomposeLayout layout(0, 0) {}
108 |
109 | val visibleGroups = visibleItems
110 | .mapNotNull { itemInfo ->
111 | val idx = itemInfo.index
112 | groupedMap.entries.firstOrNull { entry ->
113 | idx >= 0 && groupedMap.values.takeWhile { it !== entry.value }.sumOf { it.size } <= idx
114 | && idx < groupedMap.values.takeWhile { it !== entry.value }.sumOf { it.size } + entry.value.size
115 | }?.key
116 | }
117 | .distinct()
118 |
119 | if (visibleGroups.isEmpty()) return@SubcomposeLayout layout(0, 0) {}
120 |
121 | val firstGroup = visibleGroups.first()
122 | val nextGroup = visibleGroups.getOrNull(1)
123 |
124 | val headers = visibleGroups.map { groupId ->
125 | val header = subcompose("StickyHeader-$groupId") {
126 | headerContent(headerItemMap[groupId]!!)
127 | }.map { it.measure(constraints) }
128 |
129 | val firstItem = visibleItems.firstOrNull {
130 | val idx = it.index
131 | val items = groupedMap[groupId] ?: emptyList()
132 | val groupStart = groupedMap.values.takeWhile { it !== items }.sumOf { it.size }
133 | idx in groupStart until (groupStart + items.size)
134 | }
135 | val offsetX = firstItem?.offset ?: 0
136 |
137 | groupId to (header to offsetX)
138 | }
139 |
140 | val dots = visibleGroups.map { groupId ->
141 | val dot = subcompose("StickyDot-$groupId") {
142 | dotContent(groupId)
143 | }.map { it.measure(constraints) }
144 |
145 | val firstItem = visibleItems.firstOrNull {
146 | val idx = it.index
147 | val items = groupedMap[groupId] ?: emptyList()
148 | val groupStart = groupedMap.values.takeWhile { it !== items }.sumOf { it.size }
149 | idx in groupStart until (groupStart + items.size)
150 | }
151 | val offsetX = firstItem?.offset ?: 0
152 |
153 | groupId to (dot to offsetX)
154 | }
155 |
156 | val linePlaceables = subcompose("Line") {
157 | Box(
158 | Modifier
159 | .fillMaxWidth()
160 | .height(lineWidth)
161 | .background(lineColor)
162 | )
163 | }.map { it.measure(constraints) }
164 |
165 | val firstHeader = headers.firstOrNull { it.first == firstGroup }
166 | val firstHeaderHeight = firstHeader
167 | ?.second
168 | ?.let { (placeables, _) ->
169 | placeables.maxOfOrNull { it.height } ?: 0
170 | } ?: 0
171 |
172 | val firstHeaderWidth = firstHeader?.second?.first?.maxOfOrNull { it.width } ?: 0
173 | val pushOffset = nextGroup?.let { next ->
174 | val nextItem = visibleItems.firstOrNull {
175 | val idx = it.index
176 | val items = groupedMap[next] ?: emptyList()
177 | val groupStart = groupedMap.values.takeWhile { it !== items }.sumOf { it.size }
178 | idx in groupStart until (groupStart + items.size)
179 | }
180 |
181 | nextItem?.let {
182 | val distanceToNext = it.offset - firstHeaderWidth
183 | if (distanceToNext < 0) distanceToNext else 0
184 | } ?: 0
185 | } ?: 0
186 |
187 | val firstDotHeight = dots.firstOrNull { it.first == firstGroup }
188 | ?.second
189 | ?.let { (placeables, _) ->
190 | placeables.maxOfOrNull { it.height } ?: 0
191 | } ?: 0
192 |
193 | val lineAndDotYValuePair = if (lineWidth.roundToPx() > firstDotHeight) {
194 | firstHeaderHeight + verticalPadding.toInt() to firstHeaderHeight + verticalPadding.toInt() + (lineWidth / 2).roundToPx() - (firstDotHeight / 2)
195 | } else {
196 | firstHeaderHeight + verticalPadding.toInt() - (lineWidth / 2).roundToPx() + (firstDotHeight / 2) to firstHeaderHeight + verticalPadding.toInt()
197 | }
198 |
199 | layout(
200 | constraints.maxWidth,
201 | firstHeaderHeight + max(
202 | lineWidth.roundToPx(),
203 | firstDotHeight
204 | ) + (verticalPadding * 2).toInt()
205 | ) {
206 | linePlaceables.forEach {
207 | it.placeRelative(
208 | x = 0,
209 | y = lineAndDotYValuePair.first
210 | )
211 | }
212 |
213 | headers.forEach { (groupId, pair) ->
214 | val (placeables, itemOffset) = pair
215 | val x = if (groupId == firstGroup) pushOffset else max(itemOffset, 0)
216 | placeables.forEach {
217 | it.placeRelative(
218 | x = x,
219 | y = 0
220 | )
221 | }
222 | }
223 |
224 | dots.forEach { (groupId, pair) ->
225 | val (placeables, itemOffset) = pair
226 | val x = if (groupId == firstGroup) pushOffset else max(itemOffset, 0)
227 | placeables.forEach {
228 | it.placeRelative(
229 | x = x,
230 | y = lineAndDotYValuePair.second
231 | )
232 | }
233 | }
234 | }
235 | }
236 | }
--------------------------------------------------------------------------------
/stickytimelineview-compose/src/test/java/xyz/sangcomz/github/stickytimelineview/compose/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.github.stickytimelineview.compose
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 | }
--------------------------------------------------------------------------------
/stickytimelineview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/stickytimelineview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | repositories {
5 | mavenCentral()
6 | }
7 |
8 | android {
9 | compileSdk gradle.compileSdk
10 | defaultConfig {
11 | minSdk gradle.minSdk
12 | targetSdk gradle.targetSdk
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | namespace 'xyz.sangcomz.stickytimelineview'
23 |
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_21
26 | targetCompatibility JavaVersion.VERSION_21
27 | }
28 |
29 | kotlinOptions {
30 | jvmTarget = '21'
31 | }
32 | }
33 |
34 | apply from: '../gradle/release.view.gradle'
35 |
36 | dependencies {
37 | implementation fileTree(include: ['*.jar'], dir: 'libs')
38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39 | implementation 'androidx.appcompat:appcompat:1.7.0'
40 | implementation 'androidx.recyclerview:recyclerview:1.4.0'
41 | implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
42 |
43 | testImplementation 'junit:junit:4.13.2'
44 | androidTestImplementation 'androidx.test:runner:1.6.2'
45 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
46 | }
47 |
48 | tasks.withType(Javadoc).all {
49 | enabled = false
50 | }
--------------------------------------------------------------------------------
/stickytimelineview/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 |
--------------------------------------------------------------------------------
/stickytimelineview/src/androidTest/java/xyz/sangcomz/stickytimelineview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("xyz.sangcomz.timelineview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/TimeLineRecyclerView.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import androidx.core.content.ContextCompat
6 | import androidx.recyclerview.widget.RecyclerView
7 | import xyz.sangcomz.stickytimelineview.callback.SectionCallback
8 | import xyz.sangcomz.stickytimelineview.decoration.HorizontalSectionItemDecoration
9 | import xyz.sangcomz.stickytimelineview.decoration.VerticalSectionItemDecoration
10 | import xyz.sangcomz.stickytimelineview.ext.shouldUseLayoutRtl
11 | import xyz.sangcomz.stickytimelineview.model.RecyclerViewAttr
12 |
13 |
14 | /*
15 | * Copyright 2018 SeokWon Jeong.
16 | *
17 | * Licensed under the Apache License, Version 2.0 (the "License");
18 | * you may not use this file except in compliance with the License.
19 | * You may obtain a copy of the License at
20 | *
21 | * http://www.apache.org/licenses/LICENSE-2.0
22 | *
23 | * Unless required by applicable law or agreed to in writing, software
24 | * distributed under the License is distributed on an "AS IS" BASIS,
25 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 | * See the License for the specific language governing permissions and
27 | * limitations under the License.
28 | */
29 |
30 | class TimeLineRecyclerView(context: Context, attrs: AttributeSet?) : RecyclerView(context, attrs) {
31 |
32 | private var recyclerViewAttr: RecyclerViewAttr? = null
33 |
34 | companion object {
35 | private const val MODE_VERTICAL = 0x00
36 | private const val MODE_HORIZONTAL = 0x01
37 |
38 | const val MODE_FULL = 0x00
39 | const val MODE_TO_TIME_LINE = 0x01
40 | const val MODE_TO_DOT = 0x02
41 | }
42 |
43 | init {
44 | attrs?.let {
45 | val a = context.theme?.obtainStyledAttributes(
46 | attrs,
47 | R.styleable.TimeLineRecyclerView,
48 | 0, 0
49 | )
50 |
51 | a?.let {
52 | recyclerViewAttr =
53 | RecyclerViewAttr(
54 | it.getColor(
55 | R.styleable.TimeLineRecyclerView_sectionBackgroundColor,
56 | ContextCompat.getColor(context, R.color.colorDefaultBackground)
57 | ),
58 | it.getColor(
59 | R.styleable.TimeLineRecyclerView_sectionTitleTextColor,
60 | ContextCompat.getColor(context, R.color.colorDefaultTitle)
61 | ),
62 | it.getColor(
63 | R.styleable.TimeLineRecyclerView_sectionSubTitleTextColor,
64 | ContextCompat.getColor(context, R.color.colorDefaultSubTitle)
65 | ),
66 | it.getColor(
67 | R.styleable.TimeLineRecyclerView_timeLineColor,
68 | ContextCompat.getColor(context, R.color.colorDefaultTitle)
69 | ),
70 | it.getColor(
71 | R.styleable.TimeLineRecyclerView_timeLineDotColor,
72 | ContextCompat.getColor(context, R.color.colorDefaultTitle)
73 | ),
74 | it.getColor(
75 | R.styleable.TimeLineRecyclerView_timeLineDotStrokeColor,
76 | ContextCompat.getColor(context, R.color.colorDefaultStroke)
77 | ),
78 | it.getDimension(
79 | R.styleable.TimeLineRecyclerView_sectionTitleTextSize,
80 | context.resources.getDimension(R.dimen.title_text_size)
81 | ),
82 | it.getDimension(
83 | R.styleable.TimeLineRecyclerView_sectionSubTitleTextSize,
84 | context.resources.getDimension(R.dimen.sub_title_text_size)
85 | ),
86 | it.getDimension(
87 | R.styleable.TimeLineRecyclerView_timeLineWidth,
88 | context.resources.getDimension(R.dimen.line_width)
89 | ),
90 | it.getBoolean(R.styleable.TimeLineRecyclerView_isSticky, true),
91 | it.getDrawable(R.styleable.TimeLineRecyclerView_customDotDrawable),
92 | it.getInt(R.styleable.TimeLineRecyclerView_timeLineMode, MODE_VERTICAL),
93 | it.getInt(
94 | R.styleable.TimeLineRecyclerView_sectionBackgroundColorMode,
95 | MODE_FULL
96 | ), it.getDimension(
97 | R.styleable.TimeLineRecyclerView_timeLineDotRadius,
98 | context.resources.getDimension(R.dimen.dot_radius)
99 | ),
100 | it.getDimension(
101 | R.styleable.TimeLineRecyclerView_timeLineDotStrokeSize,
102 | context.resources.getDimension(R.dimen.dot_stroke_width)
103 | )
104 |
105 | )
106 | }
107 |
108 | a?.recycle()
109 | }
110 | }
111 |
112 | /**
113 | * Add VerticalSectionItemDecoration for Sticky TimeLineView
114 | *
115 | * @param callback SectionCallback
116 | * if you'd like to know more mode , look at res/values/attrs.xml
117 | */
118 | fun addItemDecoration(callback: SectionCallback) {
119 | recyclerViewAttr?.let {
120 | val decoration: ItemDecoration =
121 | when (it.timeLineMode) {
122 | MODE_VERTICAL -> {
123 | VerticalSectionItemDecoration(
124 | context,
125 | callback,
126 | it
127 | )
128 | }
129 | MODE_HORIZONTAL -> {
130 | HorizontalSectionItemDecoration(
131 | context,
132 | callback,
133 | it
134 | )
135 | }
136 | else -> {
137 | VerticalSectionItemDecoration(
138 | context,
139 | callback,
140 | it
141 | )
142 | }
143 | }
144 |
145 | this.addItemDecoration(decoration)
146 | }
147 | }
148 | }
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/callback/SectionCallback.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.callback
2 |
3 | import xyz.sangcomz.stickytimelineview.model.SectionInfo
4 |
5 | interface SectionCallback {
6 | /**
7 | * To check if section is
8 | */
9 | fun isSection(position: Int): Boolean
10 |
11 | /**
12 | * Functions that return a section header in a section
13 | */
14 | fun getSectionHeader(position: Int): SectionInfo?
15 | }
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/decoration/VerticalSectionItemDecoration.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.decoration
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Paint
6 | import android.graphics.Rect
7 | import android.graphics.Typeface
8 | import android.graphics.drawable.Drawable
9 | import android.graphics.drawable.GradientDrawable
10 | import android.view.View
11 | import androidx.recyclerview.widget.RecyclerView
12 | import xyz.sangcomz.stickytimelineview.callback.SectionCallback
13 | import xyz.sangcomz.stickytimelineview.ext.DP
14 | import xyz.sangcomz.stickytimelineview.ext.shouldUseLayoutRtl
15 | import xyz.sangcomz.stickytimelineview.model.RecyclerViewAttr
16 | import xyz.sangcomz.stickytimelineview.model.SectionInfo
17 | import kotlin.math.roundToInt
18 |
19 | /**
20 | * Copyright 2017 Timothy Paetz
21 | * Copyright 2017 SeokWon Jeong
22 | * thanks to @tim.paetz
23 | * I was inspired by his code. And I used some of his code in the library.
24 | * https://github.com/paetztm/recycler_view_headers
25 | */
26 | class VerticalSectionItemDecoration(
27 | context: Context,
28 | private val sectionCallback: SectionCallback,
29 | private val recyclerViewAttr: RecyclerViewAttr
30 | ) : RecyclerView.ItemDecoration() {
31 |
32 | private val headerSectionBackgroundPaint = Paint().apply {
33 | isAntiAlias = true
34 | color = recyclerViewAttr.sectionBackgroundColor
35 | }
36 |
37 | private val linePaint = Paint().apply {
38 | isAntiAlias = true
39 | color = recyclerViewAttr.sectionLineColor
40 | strokeWidth = recyclerViewAttr.sectionLineWidth
41 | }
42 |
43 | private val headerTitlePaint = Paint().apply {
44 | isAntiAlias = true
45 | textSize = recyclerViewAttr.sectionTitleTextSize
46 | color = recyclerViewAttr.sectionTitleTextColor
47 | typeface = Typeface.create(FONT_FAMILY, Typeface.BOLD)
48 | }
49 |
50 | private val headerSubTitlePaint = Paint().apply {
51 | isAntiAlias = true
52 | textSize = recyclerViewAttr.sectionSubTitleTextSize
53 | color = recyclerViewAttr.sectionSubTitleTextColor
54 | typeface = Typeface.create(FONT_FAMILY, Typeface.NORMAL)
55 | }
56 |
57 | private var defaultOffset: Int = 8.DP(context).toInt()
58 | private var sectionHeight: Int = 64.DP(context).toInt()
59 | private var dotRadius: Int =
60 | (recyclerViewAttr.sectionDotSize + recyclerViewAttr.sectionDotStrokeSize).roundToInt()
61 | private var headerOffset = defaultOffset * 8
62 |
63 |
64 | /**
65 | * Get the offset for each Item.
66 | * There is a difference in top offset between sections and not sections.
67 | */
68 | override fun getItemOffsets(
69 | outRect: Rect,
70 | view: View,
71 | parent: RecyclerView,
72 | state: RecyclerView.State
73 | ) {
74 | super.getItemOffsets(
75 | outRect,
76 | view,
77 | parent,
78 | state
79 | )
80 |
81 | val pos = parent.getChildAdapterPosition(view)
82 |
83 | if (getIsSection(pos)) {
84 | outRect.top = headerOffset
85 | } else {
86 | outRect.top = defaultOffset / 2
87 | }
88 |
89 | val isLayoutRtl = parent.shouldUseLayoutRtl()
90 |
91 | val leftMargin = if (isLayoutRtl) defaultOffset * 2 else defaultOffset * 6
92 | val rightMargin = if (isLayoutRtl) defaultOffset * 6 else defaultOffset * 2
93 |
94 | outRect.bottom = defaultOffset / 2
95 | outRect.left = leftMargin
96 | outRect.right = rightMargin
97 |
98 | }
99 |
100 | /**
101 | * Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
102 | * Any content drawn by this method will be drawn after the item views are drawn
103 | * and will thus appear over the views.
104 | *
105 | * @param c Canvas to draw into
106 | * @param parent RecyclerView this ItemDecoration is drawing into
107 | * @param state The current state of RecyclerView.
108 | */
109 | override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
110 | super.onDrawOver(
111 | c,
112 | parent,
113 | state
114 | )
115 | var previousHeader = SectionInfo("")
116 | drawAllLine(c, parent)
117 |
118 | val childInContact = getChildInContact(parent, headerOffset * 2)
119 |
120 | childInContact?.let {
121 | val contractPosition = parent.getChildAdapterPosition(childInContact)
122 | if (getIsSection(contractPosition) && recyclerViewAttr.isSticky) {
123 | val topChild = parent.getChildAt(0) ?: return
124 | val topChildPosition = parent.getChildAdapterPosition(topChild)
125 | sectionCallback.getSectionHeader(topChildPosition)?.let { sectionInfo ->
126 | previousHeader = sectionInfo
127 | val offset =
128 | if (topChildPosition == 0
129 | && childInContact.top - (headerOffset * 2) == (-1 * headerOffset)
130 | ) 0f
131 | else
132 | (childInContact.top - (headerOffset * 2)).toFloat()
133 |
134 | drawHeader(c, parent, it, sectionInfo, offset)
135 | }
136 | }
137 | }
138 |
139 | for (i in 0 until parent.childCount) {
140 | val child = parent.getChildAt(i)
141 | val position = parent.getChildAdapterPosition(child)
142 | sectionCallback.getSectionHeader(position)?.let { sectionInfo ->
143 | if (previousHeader.title != sectionInfo.title) {
144 | drawHeader(c, parent, child, sectionInfo)
145 | previousHeader = sectionInfo
146 | }
147 | }
148 | }
149 | }
150 |
151 | /**
152 | * Draw a line in the timeline.
153 | */
154 | private fun drawAllLine(c: Canvas, parent: RecyclerView) {
155 | val offset = getLineOffset(parent)
156 |
157 | c.drawLines(
158 | floatArrayOf(
159 | offset,
160 | 0f,
161 | offset,
162 | parent.height.toFloat()
163 | ), linePaint
164 | )
165 | }
166 |
167 | /**
168 | * Draw a line in the timeline.
169 | */
170 | private fun drawLine(c: Canvas, parent: RecyclerView) {
171 | val offset = getLineOffset(parent)
172 |
173 | c.drawLines(
174 | floatArrayOf(
175 | offset,
176 | 0f,
177 | offset,
178 | sectionHeight.toFloat()
179 | ), linePaint
180 | )
181 | }
182 |
183 | private fun getChildInContact(parent: RecyclerView, contactPoint: Int): View? =
184 | (0 until parent.childCount)
185 | .map {
186 | parent.getChildAt(it)
187 | }
188 | .firstOrNull {
189 | it.top in contactPoint / 2..contactPoint
190 | }
191 |
192 | /**
193 | * Returns the oval dotDrawable of the timeline.
194 | */
195 | private fun getOvalDrawable(): Drawable {
196 | val strokeWidth = recyclerViewAttr.sectionDotStrokeSize.toInt()
197 | val strokeColor = recyclerViewAttr.sectionDotStrokeColor
198 | val fillColor = recyclerViewAttr.sectionDotColor
199 |
200 | val gd = GradientDrawable()
201 | gd.shape = GradientDrawable.OVAL
202 | gd.setColor(fillColor)
203 | gd.cornerRadius = dotRadius * 2.toFloat()
204 | gd.setStroke(strokeWidth, strokeColor)
205 |
206 | return gd
207 | }
208 |
209 | /**
210 | * Draw a header
211 | */
212 | private fun drawHeader(
213 | canvas: Canvas,
214 | parent: RecyclerView,
215 | child: View,
216 | sectionInfo: SectionInfo,
217 | offset: Float = 0f
218 | ) {
219 | canvas.save()
220 | if (recyclerViewAttr.isSticky) {
221 | if (offset != 0f) {
222 | canvas.translate(0f, offset)
223 | } else {
224 | canvas.translate(0f, 0.coerceAtLeast(child.top - sectionHeight).toFloat())
225 | }
226 | } else {
227 | canvas.translate(0f, (child.top - sectionHeight).toFloat())
228 | }
229 |
230 | drawBackground(canvas, parent)
231 | drawLine(canvas, parent)
232 | drawDotDrawable(canvas, parent, sectionInfo)
233 | drawHeaderTitle(canvas, parent, sectionInfo)
234 | drawHeaderSubTitle(canvas, parent, sectionInfo)
235 | canvas.restore()
236 | }
237 |
238 | private fun drawBackground(canvas: Canvas, parent: RecyclerView) {
239 | val rect = Rect(0, 0, parent.width, sectionHeight)
240 | canvas.drawRect(rect, headerSectionBackgroundPaint)
241 | }
242 |
243 | private fun drawDotDrawable(canvas: Canvas, parent: RecyclerView, sectionInfo: SectionInfo) {
244 | val dotDrawable =
245 | sectionInfo.dotDrawable ?: recyclerViewAttr.customDotDrawable ?: getOvalDrawable()
246 | canvas.save()
247 | canvas.translate(
248 | getDotTranslateX(parent, dotRadius),
249 | (sectionHeight / 2).toFloat() - dotRadius
250 | )
251 | dotDrawable.setBounds(0, 0, dotRadius * 2, dotRadius * 2)
252 | dotDrawable.draw(canvas)
253 | canvas.restore()
254 | }
255 |
256 | private fun drawHeaderTitle(canvas: Canvas, parent: RecyclerView, sectionInfo: SectionInfo) {
257 | canvas.drawText(
258 | sectionInfo.title,
259 | getTitleTranslateX(parent, sectionInfo.title),
260 | (sectionHeight / 2) + (recyclerViewAttr.sectionTitleTextSize / 4),
261 | headerTitlePaint
262 | )
263 | }
264 |
265 | private fun drawHeaderSubTitle(canvas: Canvas, parent: RecyclerView, sectionInfo: SectionInfo) {
266 | val subTitle = sectionInfo.subTitle ?: return
267 |
268 | canvas.drawText(
269 | subTitle,
270 | getSubTitleTranslateX(parent, sectionInfo.subTitle),
271 | (sectionHeight / 2) + (recyclerViewAttr.sectionTitleTextSize) + (recyclerViewAttr.sectionSubTitleTextSize / 4),
272 | headerSubTitlePaint
273 | )
274 | }
275 |
276 | /**
277 | * To check if section is
278 | */
279 | private fun getIsSection(position: Int): Boolean = when (position) {
280 | 0 -> {
281 | true
282 | }
283 | -1 -> {
284 | false
285 | }
286 | else -> {
287 | sectionCallback.isSection(position)
288 | }
289 |
290 | }
291 |
292 | private fun getLineOffset(parent: View): Float {
293 | return if (parent.shouldUseLayoutRtl()) {
294 | parent.width - defaultOffset * 3f
295 | } else {
296 | defaultOffset * 3f
297 | }
298 | }
299 |
300 | private fun getDotTranslateX(parent: View, radius: Int): Float {
301 | return if (parent.shouldUseLayoutRtl()) {
302 | parent.width - ((defaultOffset * 3f) + radius)
303 | } else {
304 | (defaultOffset * 3f) - radius
305 | }
306 | }
307 |
308 | private fun getTitleTranslateX(parent: View, title: String): Float {
309 | return if (parent.shouldUseLayoutRtl()) {
310 | parent.width - (defaultOffset * 6).toFloat() - headerTitlePaint.measureText(title)
311 | } else {
312 | (defaultOffset * 6).toFloat()
313 | }
314 | }
315 |
316 | private fun getSubTitleTranslateX(parent: View, subtitle: String): Float {
317 | return if (parent.shouldUseLayoutRtl()) {
318 | parent.width - (defaultOffset * 6).toFloat() - headerSubTitlePaint.measureText(subtitle)
319 | } else {
320 | (defaultOffset * 6).toFloat()
321 | }
322 | }
323 |
324 | companion object {
325 | private const val FONT_FAMILY = "sans-serif-light"
326 | }
327 | }
328 |
329 |
330 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/ext/SizeExt.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.ext
2 |
3 | import android.content.Context
4 |
5 | /**
6 | * Created by seokwon.jeong on 16/11/2017.
7 | */
8 | fun Int.DP(context: Context): Float = (this * context.resources.displayMetrics.density)
9 |
10 | fun Float.DP(context: Context): Float = (this * context.resources.displayMetrics.density)
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/ext/ViewExt.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.ext
2 |
3 | import android.view.View
4 |
5 | fun View.shouldUseLayoutRtl(): Boolean {
6 | return if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
7 | View.LAYOUT_DIRECTION_RTL == this.layoutDirection
8 | } else {
9 | false
10 | }
11 | }
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/model/RecyclerViewAttr.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.model
2 |
3 | import android.graphics.drawable.Drawable
4 |
5 | /**
6 | * Created by seokwon.jeong on 17/11/2017.
7 | */
8 | data class RecyclerViewAttr(
9 | val sectionBackgroundColor: Int,
10 | val sectionTitleTextColor: Int,
11 | val sectionSubTitleTextColor: Int,
12 | val sectionLineColor: Int,
13 | val sectionDotColor: Int,
14 | val sectionDotStrokeColor: Int,
15 | val sectionTitleTextSize: Float,
16 | val sectionSubTitleTextSize: Float,
17 | val sectionLineWidth: Float,
18 | val isSticky: Boolean,
19 | val customDotDrawable: Drawable?,
20 | val timeLineMode: Int,
21 | val sectionBackgroundColorMode: Int,
22 | val sectionDotSize: Float,
23 | val sectionDotStrokeSize: Float
24 | )
--------------------------------------------------------------------------------
/stickytimelineview/src/main/java/xyz/sangcomz/stickytimelineview/model/SectionInfo.kt:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview.model
2 |
3 | import android.graphics.drawable.Drawable
4 |
5 | /**
6 | * Created by seokwon.jeong on 16/11/2017.
7 | */
8 | data class SectionInfo(
9 | val title: String,
10 | val subTitle: String? = null,
11 | val dotDrawable: Drawable? = null
12 | )
--------------------------------------------------------------------------------
/stickytimelineview/src/main/res/values/attrs.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 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F9F9F9
4 | #414fca
5 | #d16767
6 | #51ae45
7 | #51ae45
8 | #F9F9F9
9 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 64dp
4 | 12dp
5 | 12dp
6 | 8dp
7 | 20dp
8 |
9 | 14sp
10 | 12sp
11 | 4dp
12 | 8dp
13 | 4dp
14 |
15 |
--------------------------------------------------------------------------------
/stickytimelineview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TimeLineView
3 |
4 |
--------------------------------------------------------------------------------
/stickytimelineview/src/test/java/xyz/sangcomz/stickytimelineview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package xyz.sangcomz.stickytimelineview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------