├── .codeclimate.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── build.gradle.kts
├── circle.yml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── livedata-combinetuple-kt
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── zhuinden
│ └── livedatacombinetuplekt
│ ├── LiveDataCombineTuple.kt
│ ├── LiveDataCombineTupleNonNull.kt
│ ├── LiveDataCombineTupleSkipNull.kt
│ └── LiveDataHelper.kt
└── settings.gradle.kts
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | ## other configuration excluded from example...
2 | exclude_patterns:
3 | - "simple-stack-example-**"
4 | - "simple-stack/src/test/"
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .idea
6 | /.idea/workspace.xml
7 | /.idea/libraries
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 | projectFilesBackup
13 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change log
2 |
3 | -LiveData-CombineTuple-KT 2.0.0 (2021-12-21)
4 | --------------------------------
5 |
6 | - BEHAVIOR CHANGE: `Objects.equals()` is applied before setting the value on the Mediator.
7 |
8 | Refer to https://github.com/android/architecture-components-samples/blob/ea59732402708c8e7bca3ecc24a7c9ca85736b55/GithubBrowserSample/app/src/main/java/com/android/example/github/repository/NetworkBoundResource.java#L60-L65
9 |
10 | - FIX: `onActive()` would call `setValue` which would trigger `observe()` as many times as there were LiveDatas.
11 |
12 | I think this was reported, but someone truly pointed out the cause not too long ago, unfortunately.
13 |
14 | -LiveData-CombineTuple-KT 1.3.0 (2021-11-03)
15 | --------------------------------
16 | - Add `combineTupleSkipNull`, which is probably what people always really wanted (has `null` until all values of all LiveData are not null).
17 |
18 | -LiveData-CombineTuple-KT 1.2.1 (2021-02-10)
19 | --------------------------------
20 |
21 | - Update Kotlin to 1.4.30.
22 |
23 | - Update tuples-kt to 1.1.0.
24 |
25 | -LiveData-CombineTuple-KT 1.2.0 (2020-12-19)
26 | --------------------------------
27 |
28 | - Update Kotlin to 1.4.21.
29 |
30 | - Update tuples-kt to 1.1.0.
31 |
32 | -LiveData-CombineTuple-KT 1.1.0 (2020-10-04)
33 | --------------------------------
34 |
35 | - Add `combineTupleNonNull`, which only allows LiveData with non-null values, but provides non-null decomposition.
36 |
37 | -LiveData-CombineTuple-KT 1.0.0 (2020-03-31)
38 | --------------------------------
39 |
40 | - Initial Release.
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LiveData-CombineTuple-KT
2 |
3 | LiveData-CombineTuple-KT contains helper functions for LiveData, to combine their latest emissions into typed tuples.
4 |
5 | Under the hood, it uses Tuples-KT to help provide combiners from 2 to 16 arity.
6 |
7 | ``` kotlin
8 | combineTuple(liveData1, liveData2, liveData3)
9 | .observe(lifecycleOwner) { (t1, t2, t3) ->
10 | // do something with combined livedata values
11 | }
12 | ```
13 |
14 | ## Why?
15 |
16 | It's useful when you want to combine multiple reactive streams together and get a combined object of the latest values, without defining an actual class with an actual name to do it.
17 |
18 | ## Using LiveData-CombineTuple-KT
19 |
20 | In order to use LiveData-CombineTuple-KT, you need to add `jitpack` to your project root `build.gradle.kts`
21 | (or `build.gradle`):
22 |
23 | ``` kotlin
24 | // build.gradle.kts
25 | allprojects {
26 | repositories {
27 | // ...
28 | maven { setUrl("https://jitpack.io") }
29 | }
30 | // ...
31 | }
32 | ```
33 |
34 | or
35 |
36 | ``` groovy
37 | // build.gradle
38 | allprojects {
39 | repositories {
40 | // ...
41 | maven { url "https://jitpack.io" }
42 | }
43 | // ...
44 | }
45 | ```
46 |
47 | In newer projects, you need to also update the `settings.gradle` file's `dependencyResolutionManagement` block:
48 |
49 | ```
50 | dependencyResolutionManagement {
51 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
52 | repositories {
53 | google()
54 | mavenCentral()
55 | maven { url 'https://jitpack.io' } // <--
56 | jcenter() // Warning: this repository is going to shut down soon
57 | }
58 | }
59 | ```
60 |
61 |
62 | and then, add the dependency to your module's `build.gradle.kts` (or `build.gradle`):
63 |
64 | ``` kotlin
65 | // build.gradle.kts
66 | implementation("com.github.Zhuinden:livedata-combinetuple-kt:2.0.0")
67 | ```
68 |
69 | or
70 |
71 | ``` groovy
72 | // build.gradle
73 | implementation 'com.github.Zhuinden:livedata-combinetuple-kt:2.0.0'
74 | ```
75 |
76 | ## License
77 |
78 | Copyright 2020 Gabor Varadi
79 |
80 | Licensed under the Apache License, Version 2.0 (the "License");
81 | you may not use this file except in compliance with the License.
82 | You may obtain a copy of the License at
83 |
84 | http://www.apache.org/licenses/LICENSE-2.0
85 |
86 | Unless required by applicable law or agreed to in writing, software
87 | distributed under the License is distributed on an "AS IS" BASIS,
88 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 | See the License for the specific language governing permissions and
90 | limitations under the License.
91 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | mavenCentral()
7 | maven { setUrl("https://clojars.org/repo/") }
8 | maven { setUrl("https://jitpack.io") }
9 | maven { setUrl("https://maven.google.com") }
10 | jcenter()
11 | }
12 | dependencies {
13 | classpath("com.android.tools.build:gradle:4.1.1")
14 | classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
15 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | mavenCentral()
25 | maven { setUrl("https://clojars.org/repo/") }
26 | maven { setUrl("https://jitpack.io") }
27 | maven { setUrl("https://oss.sonatype.org/content/repositories/snapshots/") }
28 | maven { setUrl("https://maven.google.com") }
29 | jcenter()
30 | }
31 | }
32 |
33 | task("clean") {
34 | delete(rootProject.buildDir)
35 | }
36 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | environment:
3 | ANDROID_HOME: /usr/local/android-sdk-linux
4 |
5 | dependencies:
6 | pre:
7 | - echo y | android update sdk --no-ui --all --filter "tools,platform-tools,android-25"
8 | - echo y | android update sdk --no-ui --all --filter "build-tools-25.0.2"
9 | - echo y | android update sdk --no-ui --all --filter "extra-android-support";
10 | - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository";
11 | - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services";
12 |
13 | test:
14 | override:
15 | - ./gradlew build check
16 |
17 | # copy lint report
18 | - mkdir $CIRCLE_TEST_REPORTS/Lint
19 | - mv simple-stack/build/outputs/lint-results-debug.xml $CIRCLE_TEST_REPORTS/lint
20 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 | kotlin.incremental=false
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
19 | android.enableJetifier=false
20 | android.useAndroidX=true
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zhuinden/livedata-combinetuple-kt/7be39a07132bb6ebef408ae76ab4cdca42f04cd6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 15 09:23:58 CEST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | kotlin("android")
4 | id("com.github.dcendents.android-maven")
5 | }
6 |
7 | android {
8 | compileSdkVersion(28)
9 |
10 | defaultConfig {
11 | minSdkVersion(9)
12 | targetSdkVersion(28)
13 | versionCode = 1
14 | versionName = "1.0.0"
15 | testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | getByName("release") {
20 | isMinifyEnabled = false
21 | proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
22 | }
23 | }
24 |
25 | lintOptions {
26 | isAbortOnError = false
27 | }
28 |
29 | compileOptions {
30 | this.sourceCompatibility(JavaVersion.VERSION_1_7)
31 | this.targetCompatibility(JavaVersion.VERSION_1_7)
32 | }
33 | }
34 |
35 | dependencies {
36 | //implementation(mapOf("dir" to "libs", "include" to listOf("*.jar")))
37 | api("com.github.Zhuinden:tuples-kt:1.1.1")
38 | api("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
39 |
40 | testImplementation("junit:junit:4.13.1")
41 | testImplementation("org.assertj:assertj-core:3.16.1")
42 | testImplementation("org.mockito:mockito-core:2.23.0")
43 | androidTestImplementation("junit:junit:4.13.1")
44 | }
45 |
46 | // build a jar with source files
47 | val sourcesJar by tasks.registering(Jar::class) {
48 | from(android.sourceSets["main"].java.srcDirs)
49 | archiveClassifier.set("sources")
50 | }
51 |
52 | val javadoc by tasks.registering(Javadoc::class) {
53 | isFailOnError = false
54 | source = android.sourceSets["main"].java.getSourceFiles()
55 | classpath += project.files(android.bootClasspath.joinToString(separator = File.pathSeparator))
56 | classpath += configurations.compile
57 | }
58 |
59 | // build a jar with javadoc
60 | val javadocJar by tasks.registering(Jar::class) {
61 | dependsOn(javadoc)
62 | archiveClassifier.set("javadoc")
63 | from(javadoc.get().destinationDir)
64 | }
65 |
66 | artifacts {
67 | archives(sourcesJar)
68 | archives(javadocJar)
69 | }
70 |
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Development\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/src/main/java/com/zhuinden/livedatacombinetuplekt/LiveDataCombineTuple.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gabor Varadi
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.zhuinden.livedatacombinetuplekt
17 |
18 | import androidx.lifecycle.LiveData
19 | import androidx.lifecycle.MediatorLiveData
20 | import com.zhuinden.tupleskt.*
21 |
22 | fun combineTuple(f1: LiveData, f2: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
23 | mediator.setValueIfNotEqual(Pair(f1.value, f2.value))
24 |
25 | mediator.addSource(f1) { t1: T1? ->
26 | val (_, t2) = mediator.value!!
27 | mediator.setValueIfNotEqual(Pair(t1, t2))
28 | }
29 |
30 | mediator.addSource(f2) { t2: T2? ->
31 | val (t1, _) = mediator.value!!
32 | mediator.setValueIfNotEqual(Pair(t1, t2))
33 | }
34 | }
35 |
36 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
37 | mediator.setValueIfNotEqual(Triple(f1.value, f2.value, f3.value))
38 |
39 | mediator.addSource(f1) { t1: T1? ->
40 | val (_, t2, t3) = mediator.value!!
41 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
42 | }
43 |
44 | mediator.addSource(f2) { t2: T2? ->
45 | val (t1, _, t3) = mediator.value!!
46 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
47 | }
48 |
49 | mediator.addSource(f3) { t3: T3? ->
50 | val (t1, t2, _) = mediator.value!!
51 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
52 | }
53 | }
54 |
55 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
56 | mediator.setValueIfNotEqual(Tuple4(f1.value, f2.value, f3.value, f4.value))
57 |
58 | mediator.addSource(f1) { t1: T1? ->
59 | val (_, t2, t3, t4) = mediator.value!!
60 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
61 | }
62 |
63 | mediator.addSource(f2) { t2: T2? ->
64 | val (t1, _, t3, t4) = mediator.value!!
65 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
66 | }
67 |
68 | mediator.addSource(f3) { t3: T3? ->
69 | val (t1, t2, _, t4) = mediator.value!!
70 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
71 | }
72 |
73 | mediator.addSource(f4) { t4: T4? ->
74 | val (t1, t2, t3, _) = mediator.value!!
75 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
76 | }
77 | }
78 |
79 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
80 | mediator.setValueIfNotEqual(Tuple5(f1.value, f2.value, f3.value, f4.value, f5.value))
81 |
82 | mediator.addSource(f1) { t1: T1? ->
83 | val (_, t2, t3, t4, t5) = mediator.value!!
84 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
85 | }
86 |
87 | mediator.addSource(f2) { t2: T2? ->
88 | val (t1, _, t3, t4, t5) = mediator.value!!
89 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
90 | }
91 |
92 | mediator.addSource(f3) { t3: T3? ->
93 | val (t1, t2, _, t4, t5) = mediator.value!!
94 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
95 | }
96 |
97 | mediator.addSource(f4) { t4: T4? ->
98 | val (t1, t2, t3, _, t5) = mediator.value!!
99 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
100 | }
101 |
102 | mediator.addSource(f5) { t5: T5? ->
103 | val (t1, t2, t3, t4, _) = mediator.value!!
104 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
105 | }
106 | }
107 |
108 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
109 | mediator.setValueIfNotEqual(Tuple6(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value))
110 |
111 | mediator.addSource(f1) { t1: T1? ->
112 | val (_, t2, t3, t4, t5, t6) = mediator.value!!
113 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
114 | }
115 |
116 | mediator.addSource(f2) { t2: T2? ->
117 | val (t1, _, t3, t4, t5, t6) = mediator.value!!
118 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
119 | }
120 |
121 | mediator.addSource(f3) { t3: T3? ->
122 | val (t1, t2, _, t4, t5, t6) = mediator.value!!
123 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
124 | }
125 |
126 | mediator.addSource(f4) { t4: T4? ->
127 | val (t1, t2, t3, _, t5, t6) = mediator.value!!
128 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
129 | }
130 |
131 | mediator.addSource(f5) { t5: T5? ->
132 | val (t1, t2, t3, t4, _, t6) = mediator.value!!
133 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
134 | }
135 |
136 | mediator.addSource(f6) { t6: T6? ->
137 | val (t1, t2, t3, t4, t5, _) = mediator.value!!
138 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
139 | }
140 | }
141 |
142 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
143 | mediator.setValueIfNotEqual(Tuple7(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value))
144 |
145 | mediator.addSource(f1) { t1: T1? ->
146 | val (_, t2, t3, t4, t5, t6, t7) = mediator.value!!
147 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
148 | }
149 |
150 | mediator.addSource(f2) { t2: T2? ->
151 | val (t1, _, t3, t4, t5, t6, t7) = mediator.value!!
152 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
153 | }
154 |
155 | mediator.addSource(f3) { t3: T3? ->
156 | val (t1, t2, _, t4, t5, t6, t7) = mediator.value!!
157 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
158 | }
159 |
160 | mediator.addSource(f4) { t4: T4? ->
161 | val (t1, t2, t3, _, t5, t6, t7) = mediator.value!!
162 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
163 | }
164 |
165 | mediator.addSource(f5) { t5: T5? ->
166 | val (t1, t2, t3, t4, _, t6, t7) = mediator.value!!
167 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
168 | }
169 |
170 | mediator.addSource(f6) { t6: T6? ->
171 | val (t1, t2, t3, t4, t5, _, t7) = mediator.value!!
172 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
173 | }
174 |
175 | mediator.addSource(f7) { t7: T7? ->
176 | val (t1, t2, t3, t4, t5, t6, _) = mediator.value!!
177 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
178 | }
179 | }
180 |
181 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
182 | mediator.setValueIfNotEqual(Tuple8(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value))
183 |
184 | mediator.addSource(f1) { t1: T1? ->
185 | val (_, t2, t3, t4, t5, t6, t7, t8) = mediator.value!!
186 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
187 | }
188 |
189 | mediator.addSource(f2) { t2: T2? ->
190 | val (t1, _, t3, t4, t5, t6, t7, t8) = mediator.value!!
191 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
192 | }
193 |
194 | mediator.addSource(f3) { t3: T3? ->
195 | val (t1, t2, _, t4, t5, t6, t7, t8) = mediator.value!!
196 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
197 | }
198 |
199 | mediator.addSource(f4) { t4: T4? ->
200 | val (t1, t2, t3, _, t5, t6, t7, t8) = mediator.value!!
201 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
202 | }
203 |
204 | mediator.addSource(f5) { t5: T5? ->
205 | val (t1, t2, t3, t4, _, t6, t7, t8) = mediator.value!!
206 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
207 | }
208 |
209 | mediator.addSource(f6) { t6: T6? ->
210 | val (t1, t2, t3, t4, t5, _, t7, t8) = mediator.value!!
211 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
212 | }
213 |
214 | mediator.addSource(f7) { t7: T7? ->
215 | val (t1, t2, t3, t4, t5, t6, _, t8) = mediator.value!!
216 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
217 | }
218 |
219 | mediator.addSource(f8) { t8: T8? ->
220 | val (t1, t2, t3, t4, t5, t6, t7, _) = mediator.value!!
221 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
222 | }
223 | }
224 |
225 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
226 | mediator.setValueIfNotEqual(Tuple9(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value))
227 |
228 | mediator.addSource(f1) { t1: T1? ->
229 | val (_, t2, t3, t4, t5, t6, t7, t8, t9) = mediator.value!!
230 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
231 | }
232 |
233 | mediator.addSource(f2) { t2: T2? ->
234 | val (t1, _, t3, t4, t5, t6, t7, t8, t9) = mediator.value!!
235 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
236 | }
237 |
238 | mediator.addSource(f3) { t3: T3? ->
239 | val (t1, t2, _, t4, t5, t6, t7, t8, t9) = mediator.value!!
240 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
241 | }
242 |
243 | mediator.addSource(f4) { t4: T4? ->
244 | val (t1, t2, t3, _, t5, t6, t7, t8, t9) = mediator.value!!
245 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
246 | }
247 |
248 | mediator.addSource(f5) { t5: T5? ->
249 | val (t1, t2, t3, t4, _, t6, t7, t8, t9) = mediator.value!!
250 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
251 | }
252 |
253 | mediator.addSource(f6) { t6: T6? ->
254 | val (t1, t2, t3, t4, t5, _, t7, t8, t9) = mediator.value!!
255 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
256 | }
257 |
258 | mediator.addSource(f7) { t7: T7? ->
259 | val (t1, t2, t3, t4, t5, t6, _, t8, t9) = mediator.value!!
260 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
261 | }
262 |
263 | mediator.addSource(f8) { t8: T8? ->
264 | val (t1, t2, t3, t4, t5, t6, t7, _, t9) = mediator.value!!
265 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
266 | }
267 |
268 | mediator.addSource(f9) { t9: T9? ->
269 | val (t1, t2, t3, t4, t5, t6, t7, t8, _) = mediator.value!!
270 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
271 | }
272 | }
273 |
274 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
275 | mediator.setValueIfNotEqual(Tuple10(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value))
276 |
277 | mediator.addSource(f1) { t1: T1? ->
278 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10) = mediator.value!!
279 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
280 | }
281 |
282 | mediator.addSource(f2) { t2: T2? ->
283 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10) = mediator.value!!
284 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
285 | }
286 |
287 | mediator.addSource(f3) { t3: T3? ->
288 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10) = mediator.value!!
289 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
290 | }
291 |
292 | mediator.addSource(f4) { t4: T4? ->
293 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10) = mediator.value!!
294 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
295 | }
296 |
297 | mediator.addSource(f5) { t5: T5? ->
298 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10) = mediator.value!!
299 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
300 | }
301 |
302 | mediator.addSource(f6) { t6: T6? ->
303 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10) = mediator.value!!
304 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
305 | }
306 |
307 | mediator.addSource(f7) { t7: T7? ->
308 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10) = mediator.value!!
309 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
310 | }
311 |
312 | mediator.addSource(f8) { t8: T8? ->
313 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10) = mediator.value!!
314 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
315 | }
316 |
317 | mediator.addSource(f9) { t9: T9? ->
318 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10) = mediator.value!!
319 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
320 | }
321 |
322 | mediator.addSource(f10) { t10: T10? ->
323 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _) = mediator.value!!
324 | mediator.setValueIfNotEqual(Tuple10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
325 | }
326 | }
327 |
328 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
329 | mediator.setValueIfNotEqual(Tuple11(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value))
330 |
331 | mediator.addSource(f1) { t1: T1? ->
332 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) = mediator.value!!
333 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
334 | }
335 |
336 | mediator.addSource(f2) { t2: T2? ->
337 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11) = mediator.value!!
338 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
339 | }
340 |
341 | mediator.addSource(f3) { t3: T3? ->
342 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11) = mediator.value!!
343 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
344 | }
345 |
346 | mediator.addSource(f4) { t4: T4? ->
347 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11) = mediator.value!!
348 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
349 | }
350 |
351 | mediator.addSource(f5) { t5: T5? ->
352 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11) = mediator.value!!
353 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
354 | }
355 |
356 | mediator.addSource(f6) { t6: T6? ->
357 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11) = mediator.value!!
358 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
359 | }
360 |
361 | mediator.addSource(f7) { t7: T7? ->
362 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11) = mediator.value!!
363 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
364 | }
365 |
366 | mediator.addSource(f8) { t8: T8? ->
367 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11) = mediator.value!!
368 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
369 | }
370 |
371 | mediator.addSource(f9) { t9: T9? ->
372 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11) = mediator.value!!
373 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
374 | }
375 |
376 | mediator.addSource(f10) { t10: T10? ->
377 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11) = mediator.value!!
378 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
379 | }
380 |
381 | mediator.addSource(f11) { t11: T11? ->
382 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _) = mediator.value!!
383 | mediator.setValueIfNotEqual(Tuple11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
384 | }
385 | }
386 |
387 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData, f12: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
388 | mediator.setValueIfNotEqual(Tuple12(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value, f12.value))
389 |
390 | mediator.addSource(f1) { t1: T1? ->
391 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) = mediator.value!!
392 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
393 | }
394 |
395 | mediator.addSource(f2) { t2: T2? ->
396 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) = mediator.value!!
397 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
398 | }
399 |
400 | mediator.addSource(f3) { t3: T3? ->
401 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11, t12) = mediator.value!!
402 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
403 | }
404 |
405 | mediator.addSource(f4) { t4: T4? ->
406 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11, t12) = mediator.value!!
407 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
408 | }
409 |
410 | mediator.addSource(f5) { t5: T5? ->
411 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11, t12) = mediator.value!!
412 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
413 | }
414 |
415 | mediator.addSource(f6) { t6: T6? ->
416 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11, t12) = mediator.value!!
417 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
418 | }
419 |
420 | mediator.addSource(f7) { t7: T7? ->
421 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11, t12) = mediator.value!!
422 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
423 | }
424 |
425 | mediator.addSource(f8) { t8: T8? ->
426 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11, t12) = mediator.value!!
427 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
428 | }
429 |
430 | mediator.addSource(f9) { t9: T9? ->
431 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11, t12) = mediator.value!!
432 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
433 | }
434 |
435 | mediator.addSource(f10) { t10: T10? ->
436 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11, t12) = mediator.value!!
437 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
438 | }
439 |
440 | mediator.addSource(f11) { t11: T11? ->
441 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _, t12) = mediator.value!!
442 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
443 | }
444 |
445 | mediator.addSource(f12) { t12: T12? ->
446 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, _) = mediator.value!!
447 | mediator.setValueIfNotEqual(Tuple12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
448 | }
449 | }
450 |
451 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData, f12: LiveData, f13: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
452 | mediator.setValueIfNotEqual(Tuple13(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value, f12.value, f13.value))
453 |
454 | mediator.addSource(f1) { t1: T1? ->
455 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
456 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
457 | }
458 |
459 | mediator.addSource(f2) { t2: T2? ->
460 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
461 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
462 | }
463 |
464 | mediator.addSource(f3) { t3: T3? ->
465 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
466 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
467 | }
468 |
469 | mediator.addSource(f4) { t4: T4? ->
470 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
471 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
472 | }
473 |
474 | mediator.addSource(f5) { t5: T5? ->
475 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
476 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
477 | }
478 |
479 | mediator.addSource(f6) { t6: T6? ->
480 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11, t12, t13) = mediator.value!!
481 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
482 | }
483 |
484 | mediator.addSource(f7) { t7: T7? ->
485 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11, t12, t13) = mediator.value!!
486 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
487 | }
488 |
489 | mediator.addSource(f8) { t8: T8? ->
490 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11, t12, t13) = mediator.value!!
491 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
492 | }
493 |
494 | mediator.addSource(f9) { t9: T9? ->
495 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11, t12, t13) = mediator.value!!
496 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
497 | }
498 |
499 | mediator.addSource(f10) { t10: T10? ->
500 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11, t12, t13) = mediator.value!!
501 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
502 | }
503 |
504 | mediator.addSource(f11) { t11: T11? ->
505 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _, t12, t13) = mediator.value!!
506 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
507 | }
508 |
509 | mediator.addSource(f12) { t12: T12? ->
510 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, _, t13) = mediator.value!!
511 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
512 | }
513 |
514 | mediator.addSource(f13) { t13: T13? ->
515 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, _) = mediator.value!!
516 | mediator.setValueIfNotEqual(Tuple13(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13))
517 | }
518 | }
519 |
520 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData, f12: LiveData, f13: LiveData, f14: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
521 | mediator.setValueIfNotEqual(Tuple14(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value, f12.value, f13.value, f14.value))
522 |
523 | mediator.addSource(f1) { t1: T1? ->
524 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
525 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
526 | }
527 |
528 | mediator.addSource(f2) { t2: T2? ->
529 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
530 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
531 | }
532 |
533 | mediator.addSource(f3) { t3: T3? ->
534 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
535 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
536 | }
537 |
538 | mediator.addSource(f4) { t4: T4? ->
539 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
540 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
541 | }
542 |
543 | mediator.addSource(f5) { t5: T5? ->
544 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
545 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
546 | }
547 |
548 | mediator.addSource(f6) { t6: T6? ->
549 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
550 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
551 | }
552 |
553 | mediator.addSource(f7) { t7: T7? ->
554 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11, t12, t13, t14) = mediator.value!!
555 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
556 | }
557 |
558 | mediator.addSource(f8) { t8: T8? ->
559 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11, t12, t13, t14) = mediator.value!!
560 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
561 | }
562 |
563 | mediator.addSource(f9) { t9: T9? ->
564 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11, t12, t13, t14) = mediator.value!!
565 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
566 | }
567 |
568 | mediator.addSource(f10) { t10: T10? ->
569 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11, t12, t13, t14) = mediator.value!!
570 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
571 | }
572 |
573 | mediator.addSource(f11) { t11: T11? ->
574 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _, t12, t13, t14) = mediator.value!!
575 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
576 | }
577 |
578 | mediator.addSource(f12) { t12: T12? ->
579 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, _, t13, t14) = mediator.value!!
580 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
581 | }
582 |
583 | mediator.addSource(f13) { t13: T13? ->
584 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, _, t14) = mediator.value!!
585 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
586 | }
587 |
588 | mediator.addSource(f14) { t14: T14? ->
589 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, _) = mediator.value!!
590 | mediator.setValueIfNotEqual(Tuple14(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14))
591 | }
592 | }
593 |
594 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData, f12: LiveData, f13: LiveData, f14: LiveData, f15: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
595 | mediator.setValueIfNotEqual(Tuple15(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value, f12.value, f13.value, f14.value, f15.value))
596 |
597 | mediator.addSource(f1) { t1: T1? ->
598 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
599 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
600 | }
601 |
602 | mediator.addSource(f2) { t2: T2? ->
603 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
604 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
605 | }
606 |
607 | mediator.addSource(f3) { t3: T3? ->
608 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
609 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
610 | }
611 |
612 | mediator.addSource(f4) { t4: T4? ->
613 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
614 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
615 | }
616 |
617 | mediator.addSource(f5) { t5: T5? ->
618 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
619 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
620 | }
621 |
622 | mediator.addSource(f6) { t6: T6? ->
623 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
624 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
625 | }
626 |
627 | mediator.addSource(f7) { t7: T7? ->
628 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
629 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
630 | }
631 |
632 | mediator.addSource(f8) { t8: T8? ->
633 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11, t12, t13, t14, t15) = mediator.value!!
634 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
635 | }
636 |
637 | mediator.addSource(f9) { t9: T9? ->
638 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11, t12, t13, t14, t15) = mediator.value!!
639 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
640 | }
641 |
642 | mediator.addSource(f10) { t10: T10? ->
643 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11, t12, t13, t14, t15) = mediator.value!!
644 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
645 | }
646 |
647 | mediator.addSource(f11) { t11: T11? ->
648 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _, t12, t13, t14, t15) = mediator.value!!
649 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
650 | }
651 |
652 | mediator.addSource(f12) { t12: T12? ->
653 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, _, t13, t14, t15) = mediator.value!!
654 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
655 | }
656 |
657 | mediator.addSource(f13) { t13: T13? ->
658 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, _, t14, t15) = mediator.value!!
659 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
660 | }
661 |
662 | mediator.addSource(f14) { t14: T14? ->
663 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, _, t15) = mediator.value!!
664 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
665 | }
666 |
667 | mediator.addSource(f15) { t15: T15? ->
668 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, _) = mediator.value!!
669 | mediator.setValueIfNotEqual(Tuple15(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15))
670 | }
671 | }
672 |
673 | fun combineTuple(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData, f10: LiveData, f11: LiveData, f12: LiveData, f13: LiveData, f14: LiveData, f15: LiveData, f16: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
674 | mediator.setValueIfNotEqual(Tuple16(f1.value, f2.value, f3.value, f4.value, f5.value, f6.value, f7.value, f8.value, f9.value, f10.value, f11.value, f12.value, f13.value, f14.value, f15.value, f16.value))
675 |
676 | mediator.addSource(f1) { t1: T1? ->
677 | val (_, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
678 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
679 | }
680 |
681 | mediator.addSource(f2) { t2: T2? ->
682 | val (t1, _, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
683 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
684 | }
685 |
686 | mediator.addSource(f3) { t3: T3? ->
687 | val (t1, t2, _, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
688 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
689 | }
690 |
691 | mediator.addSource(f4) { t4: T4? ->
692 | val (t1, t2, t3, _, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
693 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
694 | }
695 |
696 | mediator.addSource(f5) { t5: T5? ->
697 | val (t1, t2, t3, t4, _, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
698 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
699 | }
700 |
701 | mediator.addSource(f6) { t6: T6? ->
702 | val (t1, t2, t3, t4, t5, _, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
703 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
704 | }
705 |
706 | mediator.addSource(f7) { t7: T7? ->
707 | val (t1, t2, t3, t4, t5, t6, _, t8, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
708 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
709 | }
710 |
711 | mediator.addSource(f8) { t8: T8? ->
712 | val (t1, t2, t3, t4, t5, t6, t7, _, t9, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
713 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
714 | }
715 |
716 | mediator.addSource(f9) { t9: T9? ->
717 | val (t1, t2, t3, t4, t5, t6, t7, t8, _, t10, t11, t12, t13, t14, t15, t16) = mediator.value!!
718 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
719 | }
720 |
721 | mediator.addSource(f10) { t10: T10? ->
722 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, _, t11, t12, t13, t14, t15, t16) = mediator.value!!
723 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
724 | }
725 |
726 | mediator.addSource(f11) { t11: T11? ->
727 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _, t12, t13, t14, t15, t16) = mediator.value!!
728 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
729 | }
730 |
731 | mediator.addSource(f12) { t12: T12? ->
732 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, _, t13, t14, t15, t16) = mediator.value!!
733 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
734 | }
735 |
736 | mediator.addSource(f13) { t13: T13? ->
737 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, _, t14, t15, t16) = mediator.value!!
738 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
739 | }
740 |
741 | mediator.addSource(f14) { t14: T14? ->
742 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, _, t15, t16) = mediator.value!!
743 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
744 | }
745 |
746 | mediator.addSource(f15) { t15: T15? ->
747 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, _, t16) = mediator.value!!
748 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
749 | }
750 |
751 | mediator.addSource(f16) { t16: T16? ->
752 | val (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, _) = mediator.value!!
753 | mediator.setValueIfNotEqual(Tuple16(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16))
754 | }
755 | }
--------------------------------------------------------------------------------
/livedata-combinetuple-kt/src/main/java/com/zhuinden/livedatacombinetuplekt/LiveDataCombineTupleNonNull.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gabor Varadi
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.zhuinden.livedatacombinetuplekt
17 |
18 | import androidx.lifecycle.LiveData
19 | import androidx.lifecycle.MediatorLiveData
20 | import com.zhuinden.tupleskt.*
21 |
22 | fun combineTupleNonNull(f1: LiveData, f2: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
23 | mediator.setValueIfNotEqual(Pair(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }))
24 |
25 | mediator.addSource(f1) { t1: T1 ->
26 | val (_, t2) = mediator.value!!
27 | mediator.setValueIfNotEqual(Pair(t1, t2))
28 | }
29 |
30 | mediator.addSource(f2) { t2: T2 ->
31 | val (t1, _) = mediator.value!!
32 | mediator.setValueIfNotEqual(Pair(t1, t2))
33 | }
34 | }
35 |
36 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
37 | mediator.setValueIfNotEqual(Triple(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }))
38 |
39 | mediator.addSource(f1) { t1: T1 ->
40 | val (_, t2, t3) = mediator.value!!
41 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
42 | }
43 |
44 | mediator.addSource(f2) { t2: T2 ->
45 | val (t1, _, t3) = mediator.value!!
46 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
47 | }
48 |
49 | mediator.addSource(f3) { t3: T3 ->
50 | val (t1, t2, _) = mediator.value!!
51 | mediator.setValueIfNotEqual(Triple(t1, t2, t3))
52 | }
53 | }
54 |
55 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
56 | mediator.setValueIfNotEqual(Tuple4(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }))
57 |
58 | mediator.addSource(f1) { t1: T1 ->
59 | val (_, t2, t3, t4) = mediator.value!!
60 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
61 | }
62 |
63 | mediator.addSource(f2) { t2: T2 ->
64 | val (t1, _, t3, t4) = mediator.value!!
65 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
66 | }
67 |
68 | mediator.addSource(f3) { t3: T3 ->
69 | val (t1, t2, _, t4) = mediator.value!!
70 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
71 | }
72 |
73 | mediator.addSource(f4) { t4: T4 ->
74 | val (t1, t2, t3, _) = mediator.value!!
75 | mediator.setValueIfNotEqual(Tuple4(t1, t2, t3, t4))
76 | }
77 | }
78 |
79 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
80 | mediator.setValueIfNotEqual(Tuple5(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }, checkNotNull(f5.value) { "Value of f5 was null" }))
81 |
82 | mediator.addSource(f1) { t1: T1 ->
83 | val (_, t2, t3, t4, t5) = mediator.value!!
84 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
85 | }
86 |
87 | mediator.addSource(f2) { t2: T2 ->
88 | val (t1, _, t3, t4, t5) = mediator.value!!
89 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
90 | }
91 |
92 | mediator.addSource(f3) { t3: T3 ->
93 | val (t1, t2, _, t4, t5) = mediator.value!!
94 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
95 | }
96 |
97 | mediator.addSource(f4) { t4: T4 ->
98 | val (t1, t2, t3, _, t5) = mediator.value!!
99 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
100 | }
101 |
102 | mediator.addSource(f5) { t5: T5 ->
103 | val (t1, t2, t3, t4, _) = mediator.value!!
104 | mediator.setValueIfNotEqual(Tuple5(t1, t2, t3, t4, t5))
105 | }
106 | }
107 |
108 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
109 | mediator.setValueIfNotEqual(Tuple6(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }, checkNotNull(f5.value) { "Value of f5 was null" }, checkNotNull(f6.value) { "Value of f6 was null" }))
110 |
111 | mediator.addSource(f1) { t1: T1 ->
112 | val (_, t2, t3, t4, t5, t6) = mediator.value!!
113 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
114 | }
115 |
116 | mediator.addSource(f2) { t2: T2 ->
117 | val (t1, _, t3, t4, t5, t6) = mediator.value!!
118 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
119 | }
120 |
121 | mediator.addSource(f3) { t3: T3 ->
122 | val (t1, t2, _, t4, t5, t6) = mediator.value!!
123 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
124 | }
125 |
126 | mediator.addSource(f4) { t4: T4 ->
127 | val (t1, t2, t3, _, t5, t6) = mediator.value!!
128 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
129 | }
130 |
131 | mediator.addSource(f5) { t5: T5 ->
132 | val (t1, t2, t3, t4, _, t6) = mediator.value!!
133 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
134 | }
135 |
136 | mediator.addSource(f6) { t6: T6 ->
137 | val (t1, t2, t3, t4, t5, _) = mediator.value!!
138 | mediator.setValueIfNotEqual(Tuple6(t1, t2, t3, t4, t5, t6))
139 | }
140 | }
141 |
142 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
143 | mediator.setValueIfNotEqual(Tuple7(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }, checkNotNull(f5.value) { "Value of f5 was null" }, checkNotNull(f6.value) { "Value of f6 was null" }, checkNotNull(f7.value) { "Value of f7 was null" }))
144 |
145 | mediator.addSource(f1) { t1: T1 ->
146 | val (_, t2, t3, t4, t5, t6, t7) = mediator.value!!
147 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
148 | }
149 |
150 | mediator.addSource(f2) { t2: T2 ->
151 | val (t1, _, t3, t4, t5, t6, t7) = mediator.value!!
152 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
153 | }
154 |
155 | mediator.addSource(f3) { t3: T3 ->
156 | val (t1, t2, _, t4, t5, t6, t7) = mediator.value!!
157 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
158 | }
159 |
160 | mediator.addSource(f4) { t4: T4 ->
161 | val (t1, t2, t3, _, t5, t6, t7) = mediator.value!!
162 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
163 | }
164 |
165 | mediator.addSource(f5) { t5: T5 ->
166 | val (t1, t2, t3, t4, _, t6, t7) = mediator.value!!
167 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
168 | }
169 |
170 | mediator.addSource(f6) { t6: T6 ->
171 | val (t1, t2, t3, t4, t5, _, t7) = mediator.value!!
172 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
173 | }
174 |
175 | mediator.addSource(f7) { t7: T7 ->
176 | val (t1, t2, t3, t4, t5, t6, _) = mediator.value!!
177 | mediator.setValueIfNotEqual(Tuple7(t1, t2, t3, t4, t5, t6, t7))
178 | }
179 | }
180 |
181 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
182 | mediator.setValueIfNotEqual(Tuple8(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }, checkNotNull(f5.value) { "Value of f5 was null" }, checkNotNull(f6.value) { "Value of f6 was null" }, checkNotNull(f7.value) { "Value of f7 was null" }, checkNotNull(f8.value) { "Value of f8 was null" }))
183 |
184 | mediator.addSource(f1) { t1: T1 ->
185 | val (_, t2, t3, t4, t5, t6, t7, t8) = mediator.value!!
186 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
187 | }
188 |
189 | mediator.addSource(f2) { t2: T2 ->
190 | val (t1, _, t3, t4, t5, t6, t7, t8) = mediator.value!!
191 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
192 | }
193 |
194 | mediator.addSource(f3) { t3: T3 ->
195 | val (t1, t2, _, t4, t5, t6, t7, t8) = mediator.value!!
196 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
197 | }
198 |
199 | mediator.addSource(f4) { t4: T4 ->
200 | val (t1, t2, t3, _, t5, t6, t7, t8) = mediator.value!!
201 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
202 | }
203 |
204 | mediator.addSource(f5) { t5: T5 ->
205 | val (t1, t2, t3, t4, _, t6, t7, t8) = mediator.value!!
206 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
207 | }
208 |
209 | mediator.addSource(f6) { t6: T6 ->
210 | val (t1, t2, t3, t4, t5, _, t7, t8) = mediator.value!!
211 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
212 | }
213 |
214 | mediator.addSource(f7) { t7: T7 ->
215 | val (t1, t2, t3, t4, t5, t6, _, t8) = mediator.value!!
216 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
217 | }
218 |
219 | mediator.addSource(f8) { t8: T8 ->
220 | val (t1, t2, t3, t4, t5, t6, t7, _) = mediator.value!!
221 | mediator.setValueIfNotEqual(Tuple8(t1, t2, t3, t4, t5, t6, t7, t8))
222 | }
223 | }
224 |
225 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData, f7: LiveData, f8: LiveData, f9: LiveData): LiveData> = MediatorLiveData>().also { mediator ->
226 | mediator.setValueIfNotEqual(Tuple9(checkNotNull(f1.value) { "Value of f1 was null" }, checkNotNull(f2.value) { "Value of f2 was null" }, checkNotNull(f3.value) { "Value of f3 was null" }, checkNotNull(f4.value) { "Value of f4 was null" }, checkNotNull(f5.value) { "Value of f5 was null" }, checkNotNull(f6.value) { "Value of f6 was null" }, checkNotNull(f7.value) { "Value of f7 was null" }, checkNotNull(f8.value) { "Value of f8 was null" }, checkNotNull(f9.value) { "Value of f9 was null" }))
227 |
228 | mediator.addSource(f1) { t1: T1 ->
229 | val (_, t2, t3, t4, t5, t6, t7, t8, t9) = mediator.value!!
230 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
231 | }
232 |
233 | mediator.addSource(f2) { t2: T2 ->
234 | val (t1, _, t3, t4, t5, t6, t7, t8, t9) = mediator.value!!
235 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
236 | }
237 |
238 | mediator.addSource(f3) { t3: T3 ->
239 | val (t1, t2, _, t4, t5, t6, t7, t8, t9) = mediator.value!!
240 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
241 | }
242 |
243 | mediator.addSource(f4) { t4: T4 ->
244 | val (t1, t2, t3, _, t5, t6, t7, t8, t9) = mediator.value!!
245 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
246 | }
247 |
248 | mediator.addSource(f5) { t5: T5 ->
249 | val (t1, t2, t3, t4, _, t6, t7, t8, t9) = mediator.value!!
250 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
251 | }
252 |
253 | mediator.addSource(f6) { t6: T6 ->
254 | val (t1, t2, t3, t4, t5, _, t7, t8, t9) = mediator.value!!
255 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
256 | }
257 |
258 | mediator.addSource(f7) { t7: T7 ->
259 | val (t1, t2, t3, t4, t5, t6, _, t8, t9) = mediator.value!!
260 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
261 | }
262 |
263 | mediator.addSource(f8) { t8: T8 ->
264 | val (t1, t2, t3, t4, t5, t6, t7, _, t9) = mediator.value!!
265 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
266 | }
267 |
268 | mediator.addSource(f9) { t9: T9 ->
269 | val (t1, t2, t3, t4, t5, t6, t7, t8, _) = mediator.value!!
270 | mediator.setValueIfNotEqual(Tuple9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
271 | }
272 | }
273 |
274 | fun combineTupleNonNull(f1: LiveData, f2: LiveData, f3: LiveData, f4: LiveData, f5: LiveData, f6: LiveData