├── .gitignore
├── .idea
├── .gitignore
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── kotlinc.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── build
│ └── generated
│ │ ├── res
│ │ └── google-services
│ │ │ └── debug
│ │ │ └── values
│ │ │ └── values.xml
│ │ └── source
│ │ ├── buildConfig
│ │ └── debug
│ │ │ └── ro
│ │ │ └── alexmamo
│ │ │ └── optimizerealtimedatabase
│ │ │ └── BuildConfig.java
│ │ └── kapt
│ │ └── debug
│ │ ├── dagger
│ │ └── hilt
│ │ │ └── internal
│ │ │ └── aggregatedroot
│ │ │ └── codegen
│ │ │ └── _ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp.java
│ │ ├── hilt_aggregated_deps
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp_GeneratedInjector.java
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_di_AppModule.java
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_presentation_ProductsActivity_GeneratedInjector.java
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_BindsModule.java
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_KeyModule.java
│ │ ├── _ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_BindsModule.java
│ │ └── _ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_KeyModule.java
│ │ └── ro
│ │ └── alexmamo
│ │ └── optimizerealtimedatabase
│ │ ├── OptimizeRealtimeDatabaseApp_GeneratedInjector.java
│ │ ├── data
│ │ └── repository
│ │ │ └── ProductsRepositoryImpl_Factory.java
│ │ ├── di
│ │ ├── AppModule_ProvideFirebaseDatabaseReferenceFactory.java
│ │ ├── AppModule_ProvideProductsRepositoryFactory.java
│ │ └── AppModule_ProvideUseCasesFactory.java
│ │ └── presentation
│ │ ├── Hilt_ProductsActivity.java
│ │ ├── ProductsActivity_GeneratedInjector.java
│ │ ├── product
│ │ ├── ProductViewModel_Factory.java
│ │ ├── ProductViewModel_HiltModules.java
│ │ └── ProductViewModel_HiltModules_KeyModule_ProvideFactory.java
│ │ └── products
│ │ ├── ProductsViewModel_Factory.java
│ │ ├── ProductsViewModel_HiltModules.java
│ │ └── ProductsViewModel_HiltModules_KeyModule_ProvideFactory.java
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── ro
│ │ └── alexmamo
│ │ └── optimizerealtimedatabase
│ │ ├── OptimizeRealtimeDatabaseApp.kt
│ │ ├── components
│ │ └── ProgressBar.kt
│ │ ├── core
│ │ ├── Constants.kt
│ │ └── Utils.kt
│ │ ├── data
│ │ └── repository
│ │ │ └── ProductsRepositoryImpl.kt
│ │ ├── di
│ │ └── AppModule.kt
│ │ ├── domain
│ │ ├── model
│ │ │ ├── Product.kt
│ │ │ └── Response.kt
│ │ ├── repository
│ │ │ └── ProductsRepository.kt
│ │ └── use_case
│ │ │ ├── GetProduct.kt
│ │ │ ├── GetProducts.kt
│ │ │ └── UseCases.kt
│ │ ├── navigation
│ │ ├── NavGraph.kt
│ │ └── Screen.kt
│ │ └── presentation
│ │ ├── ProductsActivity.kt
│ │ ├── product
│ │ ├── ProductScreen.kt
│ │ ├── ProductViewModel.kt
│ │ └── components
│ │ │ ├── ProducTopBar.kt
│ │ │ └── ProductContent.kt
│ │ └── products
│ │ ├── ProductsScreen.kt
│ │ ├── ProductsViewModel.kt
│ │ └── components
│ │ ├── ProductCard.kt
│ │ ├── ProductsContent.kt
│ │ └── ProductsTopBar.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
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | xmlns:android
17 |
18 | ^$
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | xmlns:.*
28 |
29 | ^$
30 |
31 |
32 | BY_NAME
33 |
34 |
35 |
36 |
37 |
38 |
39 | .*:id
40 |
41 | http://schemas.android.com/apk/res/android
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | .*:name
51 |
52 | http://schemas.android.com/apk/res/android
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | name
62 |
63 | ^$
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | style
73 |
74 | ^$
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | .*
84 |
85 | ^$
86 |
87 |
88 | BY_NAME
89 |
90 |
91 |
92 |
93 |
94 |
95 | .*
96 |
97 | http://schemas.android.com/apk/res/android
98 |
99 |
100 | ANDROID_ATTRIBUTE_ORDER
101 |
102 |
103 |
104 |
105 |
106 |
107 | .*
108 |
109 | .*
110 |
111 |
112 | BY_NAME
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.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 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OptimizeRealtimeDatabase
2 | It's an app built with [Kotlin][1] that shows how to optimize [Firebase Realtime Database][2] calls using [Android Architecture Components][3] and the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.
3 |
4 | 
5 | 
6 |
7 | Below you can find the docs for each tehnology that is used in this app:
8 |
9 | ## Firebase Products:
10 | * [Firebase Realtime Database][2]
11 |
12 | ## Android Architecture Components:
13 | * [LiveData][4]
14 | * [ViewModel][5]
15 | * [Navigation][12]
16 |
17 | ## Dependency Injection:
18 | * [Hilt for Android][6]
19 |
20 | ## Asynchronous Programming:
21 | * [Kotlin Coroutines][7]
22 | * [Asynchronous Flow][8]
23 |
24 | ## Other Android Components:
25 | * [Jetpack Compose][9]
26 |
27 | ---
28 |
29 | This repo represents the code for following article writen on the Medium publication:
30 |
31 | * [How to optimize Firebase Realtime Database calls?][10]
32 |
33 | See it also on youtube:
34 |
35 | * https://youtu.be/1NON6azEJtU
36 |
37 | If you download or clone this repo, in order to make it work, you should follow the instructions given in the official documentation regarding on [how to add Firebase to your project][11].
38 |
39 | **License**
40 | ---
41 | The code in this project is licensed under the Apache License 2.0.
42 |
43 | Copyright 2018 Google LLC
44 |
45 | Licensed under the Apache License, Version 2.0 (the "License");
46 | you may not use this file except in compliance with the License.
47 | You may obtain a copy of the License at
48 |
49 | https://www.apache.org/licenses/LICENSE-2.0
50 |
51 | Unless required by applicable law or agreed to in writing, software
52 | distributed under the License is distributed on an "AS IS" BASIS,
53 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
54 | See the License for the specific language governing permissions and
55 | limitations under the License.
56 |
57 | **Disclaimer**
58 | ---
59 | * This is not an officially supported Google product.
60 |
61 | [1]: https://kotlinlang.org/
62 | [2]: https://firebase.google.com/docs/database
63 | [3]: https://developer.android.com/topic/libraries/architecture
64 | [4]: https://developer.android.com/topic/libraries/architecture/livedata
65 | [5]: https://developer.android.com/topic/libraries/architecture/viewmodel
66 | [6]: https://developer.android.com/training/dependency-injection/hilt-android
67 | [7]: https://kotlinlang.org/docs/coroutines-overview.html
68 | [8]: https://kotlinlang.org/docs/flow.html
69 | [9]: https://developer.android.com/jetpack/compose
70 | [10]: https://medium.com/firebase-tips-tricks/how-to-optimize-firebase-realtime-database-calls-to-improve-performance-cc63dad374d5
71 | [11]: https://firebase.google.com/docs/android/setup
72 | [12]: https://developer.android.com/guide/navigation
73 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/.gitignore
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "com.android.application"
3 | id "kotlin-android"
4 | id "kotlin-kapt"
5 | id "com.google.gms.google-services"
6 | id "dagger.hilt.android.plugin"
7 | }
8 |
9 | android {
10 | compileSdk 33
11 |
12 | defaultConfig {
13 | applicationId "ro.alexmamo.optimizerealtimedatabase"
14 | minSdk 21
15 | targetSdk 33
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_11
30 | targetCompatibility JavaVersion.VERSION_11
31 | }
32 | kotlinOptions {
33 | jvmTarget = JavaVersion.VERSION_11
34 | }
35 | buildFeatures {
36 | compose true
37 | }
38 | composeOptions {
39 | kotlinCompilerExtensionVersion compose_version
40 | }
41 | packagingOptions {
42 | resources {
43 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
44 | }
45 | }
46 | namespace 'ro.alexmamo.optimizerealtimedatabase'
47 | }
48 |
49 | dependencies {
50 | //ViewModel
51 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$viewmodel_version"
52 | //Navigation Compose
53 | implementation "androidx.navigation:navigation-compose:$navigation_compose_version"
54 | //Compose
55 | implementation "androidx.compose.material:material:$material_version"
56 | //Hilt
57 | implementation "com.google.dagger:hilt-android:$hilt_version"
58 | kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
59 | //Hilt Navigation Compose
60 | implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation_compose_version"
61 | //Firebase
62 | implementation platform("com.google.firebase:firebase-bom:$firebase_bom_version")
63 | implementation "com.google.firebase:firebase-database-ktx"
64 | //Play Services
65 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$play_services_version"
66 | }
--------------------------------------------------------------------------------
/app/build/generated/res/google-services/debug/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 345423207868-uh7tbcgsf3e7nrbe76bbjgf23g4l31lg.apps.googleusercontent.com
4 | https://firestore-9d53c.firebaseio.com
5 | 345423207868
6 | AIzaSyBrTgB6WU-R82mu2dTO1xQkwhx2osGHKNk
7 | 1:345423207868:android:3ff95f831441cb29b15fb9
8 | AIzaSyBrTgB6WU-R82mu2dTO1xQkwhx2osGHKNk
9 | firestore-9d53c.appspot.com
10 | firestore-9d53c
11 |
12 |
--------------------------------------------------------------------------------
/app/build/generated/source/buildConfig/debug/ro/alexmamo/optimizerealtimedatabase/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package ro.alexmamo.optimizerealtimedatabase;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String APPLICATION_ID = "ro.alexmamo.optimizerealtimedatabase";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final int VERSION_CODE = 1;
11 | public static final String VERSION_NAME = "1.0";
12 | }
13 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/dagger/hilt/internal/aggregatedroot/codegen/_ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp.java:
--------------------------------------------------------------------------------
1 | package dagger.hilt.internal.aggregatedroot.codegen;
2 |
3 | import dagger.hilt.android.HiltAndroidApp;
4 | import dagger.hilt.internal.aggregatedroot.AggregatedRoot;
5 | import javax.annotation.processing.Generated;
6 |
7 | /**
8 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
9 | */
10 | @AggregatedRoot(
11 | root = "ro.alexmamo.optimizerealtimedatabase.OptimizeRealtimeDatabaseApp",
12 | rootPackage = "ro.alexmamo.optimizerealtimedatabase",
13 | originatingRoot = "ro.alexmamo.optimizerealtimedatabase.OptimizeRealtimeDatabaseApp",
14 | originatingRootPackage = "ro.alexmamo.optimizerealtimedatabase",
15 | rootAnnotation = HiltAndroidApp.class,
16 | rootSimpleNames = "OptimizeRealtimeDatabaseApp",
17 | originatingRootSimpleNames = "OptimizeRealtimeDatabaseApp"
18 | )
19 | @Generated("dagger.hilt.processor.internal.root.AggregatedRootGenerator")
20 | public class _ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp {
21 | }
22 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp_GeneratedInjector.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.components.SingletonComponent",
11 | entryPoints = "ro.alexmamo.optimizerealtimedatabase.OptimizeRealtimeDatabaseApp_GeneratedInjector"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_OptimizeRealtimeDatabaseApp_GeneratedInjector {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_di_AppModule.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.components.SingletonComponent",
11 | modules = "ro.alexmamo.optimizerealtimedatabase.di.AppModule"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_di_AppModule {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_presentation_ProductsActivity_GeneratedInjector.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.android.components.ActivityComponent",
11 | entryPoints = "ro.alexmamo.optimizerealtimedatabase.presentation.ProductsActivity_GeneratedInjector"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_presentation_ProductsActivity_GeneratedInjector {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_BindsModule.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.android.components.ViewModelComponent",
11 | modules = "ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductViewModel_HiltModules.BindsModule"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_BindsModule {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_KeyModule.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.android.components.ActivityRetainedComponent",
11 | modules = "ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductViewModel_HiltModules.KeyModule"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_presentation_product_ProductViewModel_HiltModules_KeyModule {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_BindsModule.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.android.components.ViewModelComponent",
11 | modules = "ro.alexmamo.optimizerealtimedatabase.presentation.products.ProductsViewModel_HiltModules.BindsModule"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_BindsModule {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/hilt_aggregated_deps/_ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_KeyModule.java:
--------------------------------------------------------------------------------
1 | package hilt_aggregated_deps;
2 |
3 | import dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps;
4 | import javax.annotation.processing.Generated;
5 |
6 | /**
7 | * This class should only be referenced by generated code! This class aggregates information across multiple compilations.
8 | */
9 | @AggregatedDeps(
10 | components = "dagger.hilt.android.components.ActivityRetainedComponent",
11 | modules = "ro.alexmamo.optimizerealtimedatabase.presentation.products.ProductsViewModel_HiltModules.KeyModule"
12 | )
13 | @Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
14 | public class _ro_alexmamo_optimizerealtimedatabase_presentation_products_ProductsViewModel_HiltModules_KeyModule {
15 | }
16 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/OptimizeRealtimeDatabaseApp_GeneratedInjector.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase;
2 |
3 | import dagger.hilt.InstallIn;
4 | import dagger.hilt.codegen.OriginatingElement;
5 | import dagger.hilt.components.SingletonComponent;
6 | import dagger.hilt.internal.GeneratedEntryPoint;
7 | import javax.annotation.processing.Generated;
8 |
9 | @OriginatingElement(
10 | topLevelClass = OptimizeRealtimeDatabaseApp.class
11 | )
12 | @GeneratedEntryPoint
13 | @InstallIn(SingletonComponent.class)
14 | @Generated("dagger.hilt.android.processor.internal.androidentrypoint.InjectorEntryPointGenerator")
15 | public interface OptimizeRealtimeDatabaseApp_GeneratedInjector {
16 | void injectOptimizeRealtimeDatabaseApp(OptimizeRealtimeDatabaseApp optimizeRealtimeDatabaseApp);
17 | }
18 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/data/repository/ProductsRepositoryImpl_Factory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.data.repository;
2 |
3 | import com.google.firebase.database.DatabaseReference;
4 | import dagger.internal.DaggerGenerated;
5 | import dagger.internal.Factory;
6 | import dagger.internal.QualifierMetadata;
7 | import dagger.internal.ScopeMetadata;
8 | import javax.annotation.processing.Generated;
9 | import javax.inject.Provider;
10 |
11 | @ScopeMetadata("javax.inject.Singleton")
12 | @QualifierMetadata
13 | @DaggerGenerated
14 | @Generated(
15 | value = "dagger.internal.codegen.ComponentProcessor",
16 | comments = "https://dagger.dev"
17 | )
18 | @SuppressWarnings({
19 | "unchecked",
20 | "rawtypes"
21 | })
22 | public final class ProductsRepositoryImpl_Factory implements Factory {
23 | private final Provider dbProvider;
24 |
25 | public ProductsRepositoryImpl_Factory(Provider dbProvider) {
26 | this.dbProvider = dbProvider;
27 | }
28 |
29 | @Override
30 | public ProductsRepositoryImpl get() {
31 | return newInstance(dbProvider.get());
32 | }
33 |
34 | public static ProductsRepositoryImpl_Factory create(Provider dbProvider) {
35 | return new ProductsRepositoryImpl_Factory(dbProvider);
36 | }
37 |
38 | public static ProductsRepositoryImpl newInstance(DatabaseReference db) {
39 | return new ProductsRepositoryImpl(db);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/di/AppModule_ProvideFirebaseDatabaseReferenceFactory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.di;
2 |
3 | import com.google.firebase.database.DatabaseReference;
4 | import dagger.internal.DaggerGenerated;
5 | import dagger.internal.Factory;
6 | import dagger.internal.Preconditions;
7 | import dagger.internal.QualifierMetadata;
8 | import dagger.internal.ScopeMetadata;
9 | import javax.annotation.processing.Generated;
10 |
11 | @ScopeMetadata
12 | @QualifierMetadata
13 | @DaggerGenerated
14 | @Generated(
15 | value = "dagger.internal.codegen.ComponentProcessor",
16 | comments = "https://dagger.dev"
17 | )
18 | @SuppressWarnings({
19 | "unchecked",
20 | "rawtypes"
21 | })
22 | public final class AppModule_ProvideFirebaseDatabaseReferenceFactory implements Factory {
23 | private final AppModule module;
24 |
25 | public AppModule_ProvideFirebaseDatabaseReferenceFactory(AppModule module) {
26 | this.module = module;
27 | }
28 |
29 | @Override
30 | public DatabaseReference get() {
31 | return provideFirebaseDatabaseReference(module);
32 | }
33 |
34 | public static AppModule_ProvideFirebaseDatabaseReferenceFactory create(AppModule module) {
35 | return new AppModule_ProvideFirebaseDatabaseReferenceFactory(module);
36 | }
37 |
38 | public static DatabaseReference provideFirebaseDatabaseReference(AppModule instance) {
39 | return Preconditions.checkNotNullFromProvides(instance.provideFirebaseDatabaseReference());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/di/AppModule_ProvideProductsRepositoryFactory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.di;
2 |
3 | import com.google.firebase.database.DatabaseReference;
4 | import dagger.internal.DaggerGenerated;
5 | import dagger.internal.Factory;
6 | import dagger.internal.Preconditions;
7 | import dagger.internal.QualifierMetadata;
8 | import dagger.internal.ScopeMetadata;
9 | import javax.annotation.processing.Generated;
10 | import javax.inject.Provider;
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository;
12 |
13 | @ScopeMetadata
14 | @QualifierMetadata
15 | @DaggerGenerated
16 | @Generated(
17 | value = "dagger.internal.codegen.ComponentProcessor",
18 | comments = "https://dagger.dev"
19 | )
20 | @SuppressWarnings({
21 | "unchecked",
22 | "rawtypes"
23 | })
24 | public final class AppModule_ProvideProductsRepositoryFactory implements Factory {
25 | private final AppModule module;
26 |
27 | private final Provider dbProvider;
28 |
29 | public AppModule_ProvideProductsRepositoryFactory(AppModule module,
30 | Provider dbProvider) {
31 | this.module = module;
32 | this.dbProvider = dbProvider;
33 | }
34 |
35 | @Override
36 | public ProductsRepository get() {
37 | return provideProductsRepository(module, dbProvider.get());
38 | }
39 |
40 | public static AppModule_ProvideProductsRepositoryFactory create(AppModule module,
41 | Provider dbProvider) {
42 | return new AppModule_ProvideProductsRepositoryFactory(module, dbProvider);
43 | }
44 |
45 | public static ProductsRepository provideProductsRepository(AppModule instance,
46 | DatabaseReference db) {
47 | return Preconditions.checkNotNullFromProvides(instance.provideProductsRepository(db));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/di/AppModule_ProvideUseCasesFactory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.di;
2 |
3 | import dagger.internal.DaggerGenerated;
4 | import dagger.internal.Factory;
5 | import dagger.internal.Preconditions;
6 | import dagger.internal.QualifierMetadata;
7 | import dagger.internal.ScopeMetadata;
8 | import javax.annotation.processing.Generated;
9 | import javax.inject.Provider;
10 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository;
11 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases;
12 |
13 | @ScopeMetadata
14 | @QualifierMetadata
15 | @DaggerGenerated
16 | @Generated(
17 | value = "dagger.internal.codegen.ComponentProcessor",
18 | comments = "https://dagger.dev"
19 | )
20 | @SuppressWarnings({
21 | "unchecked",
22 | "rawtypes"
23 | })
24 | public final class AppModule_ProvideUseCasesFactory implements Factory {
25 | private final AppModule module;
26 |
27 | private final Provider repoProvider;
28 |
29 | public AppModule_ProvideUseCasesFactory(AppModule module,
30 | Provider repoProvider) {
31 | this.module = module;
32 | this.repoProvider = repoProvider;
33 | }
34 |
35 | @Override
36 | public UseCases get() {
37 | return provideUseCases(module, repoProvider.get());
38 | }
39 |
40 | public static AppModule_ProvideUseCasesFactory create(AppModule module,
41 | Provider repoProvider) {
42 | return new AppModule_ProvideUseCasesFactory(module, repoProvider);
43 | }
44 |
45 | public static UseCases provideUseCases(AppModule instance, ProductsRepository repo) {
46 | return Preconditions.checkNotNullFromProvides(instance.provideUseCases(repo));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/Hilt_ProductsActivity.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation;
2 |
3 | import android.content.Context;
4 | import androidx.activity.ComponentActivity;
5 | import androidx.activity.contextaware.OnContextAvailableListener;
6 | import androidx.lifecycle.ViewModelProvider;
7 | import dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories;
8 | import dagger.hilt.android.internal.managers.ActivityComponentManager;
9 | import dagger.hilt.internal.GeneratedComponentManagerHolder;
10 | import dagger.hilt.internal.UnsafeCasts;
11 | import java.lang.Object;
12 | import java.lang.Override;
13 | import javax.annotation.processing.Generated;
14 |
15 | /**
16 | * A generated base class to be extended by the @dagger.hilt.android.AndroidEntryPoint annotated class. If using the Gradle plugin, this is swapped as the base class via bytecode transformation.
17 | */
18 | @Generated("dagger.hilt.android.processor.internal.androidentrypoint.ActivityGenerator")
19 | public abstract class Hilt_ProductsActivity extends ComponentActivity implements GeneratedComponentManagerHolder {
20 | private volatile ActivityComponentManager componentManager;
21 |
22 | private final Object componentManagerLock = new Object();
23 |
24 | private boolean injected = false;
25 |
26 | Hilt_ProductsActivity() {
27 | super();
28 | _initHiltInternal();
29 | }
30 |
31 | Hilt_ProductsActivity(int contentLayoutId) {
32 | super(contentLayoutId);
33 | _initHiltInternal();
34 | }
35 |
36 | private void _initHiltInternal() {
37 | addOnContextAvailableListener(new OnContextAvailableListener() {
38 | @Override
39 | public void onContextAvailable(Context context) {
40 | inject();
41 | }
42 | });
43 | }
44 |
45 | @Override
46 | public final Object generatedComponent() {
47 | return this.componentManager().generatedComponent();
48 | }
49 |
50 | protected ActivityComponentManager createComponentManager() {
51 | return new ActivityComponentManager(this);
52 | }
53 |
54 | @Override
55 | public final ActivityComponentManager componentManager() {
56 | if (componentManager == null) {
57 | synchronized (componentManagerLock) {
58 | if (componentManager == null) {
59 | componentManager = createComponentManager();
60 | }
61 | }
62 | }
63 | return componentManager;
64 | }
65 |
66 | protected void inject() {
67 | if (!injected) {
68 | injected = true;
69 | ((ProductsActivity_GeneratedInjector) this.generatedComponent()).injectProductsActivity(UnsafeCasts.unsafeCast(this));
70 | }
71 | }
72 |
73 | @Override
74 | public ViewModelProvider.Factory getDefaultViewModelProviderFactory() {
75 | return DefaultViewModelFactories.getActivityFactory(this, super.getDefaultViewModelProviderFactory());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/ProductsActivity_GeneratedInjector.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation;
2 |
3 | import dagger.hilt.InstallIn;
4 | import dagger.hilt.android.components.ActivityComponent;
5 | import dagger.hilt.codegen.OriginatingElement;
6 | import dagger.hilt.internal.GeneratedEntryPoint;
7 | import javax.annotation.processing.Generated;
8 |
9 | @OriginatingElement(
10 | topLevelClass = ProductsActivity.class
11 | )
12 | @GeneratedEntryPoint
13 | @InstallIn(ActivityComponent.class)
14 | @Generated("dagger.hilt.android.processor.internal.androidentrypoint.InjectorEntryPointGenerator")
15 | public interface ProductsActivity_GeneratedInjector {
16 | void injectProductsActivity(ProductsActivity productsActivity);
17 | }
18 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/product/ProductViewModel_Factory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product;
2 |
3 | import dagger.internal.DaggerGenerated;
4 | import dagger.internal.Factory;
5 | import dagger.internal.QualifierMetadata;
6 | import dagger.internal.ScopeMetadata;
7 | import javax.annotation.processing.Generated;
8 | import javax.inject.Provider;
9 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases;
10 |
11 | @ScopeMetadata
12 | @QualifierMetadata
13 | @DaggerGenerated
14 | @Generated(
15 | value = "dagger.internal.codegen.ComponentProcessor",
16 | comments = "https://dagger.dev"
17 | )
18 | @SuppressWarnings({
19 | "unchecked",
20 | "rawtypes"
21 | })
22 | public final class ProductViewModel_Factory implements Factory {
23 | private final Provider useCasesProvider;
24 |
25 | public ProductViewModel_Factory(Provider useCasesProvider) {
26 | this.useCasesProvider = useCasesProvider;
27 | }
28 |
29 | @Override
30 | public ProductViewModel get() {
31 | return newInstance(useCasesProvider.get());
32 | }
33 |
34 | public static ProductViewModel_Factory create(Provider useCasesProvider) {
35 | return new ProductViewModel_Factory(useCasesProvider);
36 | }
37 |
38 | public static ProductViewModel newInstance(UseCases useCases) {
39 | return new ProductViewModel(useCases);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/product/ProductViewModel_HiltModules.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product;
2 |
3 | import androidx.lifecycle.ViewModel;
4 | import dagger.Binds;
5 | import dagger.Module;
6 | import dagger.Provides;
7 | import dagger.hilt.InstallIn;
8 | import dagger.hilt.android.components.ActivityRetainedComponent;
9 | import dagger.hilt.android.components.ViewModelComponent;
10 | import dagger.hilt.android.internal.lifecycle.HiltViewModelMap;
11 | import dagger.hilt.codegen.OriginatingElement;
12 | import dagger.multibindings.IntoMap;
13 | import dagger.multibindings.IntoSet;
14 | import dagger.multibindings.StringKey;
15 | import java.lang.String;
16 | import javax.annotation.processing.Generated;
17 |
18 | @Generated("dagger.hilt.android.processor.internal.viewmodel.ViewModelProcessor")
19 | @OriginatingElement(
20 | topLevelClass = ProductViewModel.class
21 | )
22 | public final class ProductViewModel_HiltModules {
23 | private ProductViewModel_HiltModules() {
24 | }
25 |
26 | @Module
27 | @InstallIn(ViewModelComponent.class)
28 | public abstract static class BindsModule {
29 | private BindsModule() {
30 | }
31 |
32 | @Binds
33 | @IntoMap
34 | @StringKey("ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductViewModel")
35 | @HiltViewModelMap
36 | public abstract ViewModel binds(ProductViewModel vm);
37 | }
38 |
39 | @Module
40 | @InstallIn(ActivityRetainedComponent.class)
41 | public static final class KeyModule {
42 | private KeyModule() {
43 | }
44 |
45 | @Provides
46 | @IntoSet
47 | @HiltViewModelMap.KeySet
48 | public static String provide() {
49 | return "ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductViewModel";
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/product/ProductViewModel_HiltModules_KeyModule_ProvideFactory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product;
2 |
3 | import dagger.internal.DaggerGenerated;
4 | import dagger.internal.Factory;
5 | import dagger.internal.Preconditions;
6 | import dagger.internal.QualifierMetadata;
7 | import dagger.internal.ScopeMetadata;
8 | import javax.annotation.processing.Generated;
9 |
10 | @ScopeMetadata
11 | @QualifierMetadata("dagger.hilt.android.internal.lifecycle.HiltViewModelMap.KeySet")
12 | @DaggerGenerated
13 | @Generated(
14 | value = "dagger.internal.codegen.ComponentProcessor",
15 | comments = "https://dagger.dev"
16 | )
17 | @SuppressWarnings({
18 | "unchecked",
19 | "rawtypes"
20 | })
21 | public final class ProductViewModel_HiltModules_KeyModule_ProvideFactory implements Factory {
22 | @Override
23 | public String get() {
24 | return provide();
25 | }
26 |
27 | public static ProductViewModel_HiltModules_KeyModule_ProvideFactory create() {
28 | return InstanceHolder.INSTANCE;
29 | }
30 |
31 | public static String provide() {
32 | return Preconditions.checkNotNullFromProvides(ProductViewModel_HiltModules.KeyModule.provide());
33 | }
34 |
35 | private static final class InstanceHolder {
36 | private static final ProductViewModel_HiltModules_KeyModule_ProvideFactory INSTANCE = new ProductViewModel_HiltModules_KeyModule_ProvideFactory();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/products/ProductsViewModel_Factory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products;
2 |
3 | import dagger.internal.DaggerGenerated;
4 | import dagger.internal.Factory;
5 | import dagger.internal.QualifierMetadata;
6 | import dagger.internal.ScopeMetadata;
7 | import javax.annotation.processing.Generated;
8 | import javax.inject.Provider;
9 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases;
10 |
11 | @ScopeMetadata
12 | @QualifierMetadata
13 | @DaggerGenerated
14 | @Generated(
15 | value = "dagger.internal.codegen.ComponentProcessor",
16 | comments = "https://dagger.dev"
17 | )
18 | @SuppressWarnings({
19 | "unchecked",
20 | "rawtypes"
21 | })
22 | public final class ProductsViewModel_Factory implements Factory {
23 | private final Provider useCasesProvider;
24 |
25 | public ProductsViewModel_Factory(Provider useCasesProvider) {
26 | this.useCasesProvider = useCasesProvider;
27 | }
28 |
29 | @Override
30 | public ProductsViewModel get() {
31 | return newInstance(useCasesProvider.get());
32 | }
33 |
34 | public static ProductsViewModel_Factory create(Provider useCasesProvider) {
35 | return new ProductsViewModel_Factory(useCasesProvider);
36 | }
37 |
38 | public static ProductsViewModel newInstance(UseCases useCases) {
39 | return new ProductsViewModel(useCases);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/products/ProductsViewModel_HiltModules.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products;
2 |
3 | import androidx.lifecycle.ViewModel;
4 | import dagger.Binds;
5 | import dagger.Module;
6 | import dagger.Provides;
7 | import dagger.hilt.InstallIn;
8 | import dagger.hilt.android.components.ActivityRetainedComponent;
9 | import dagger.hilt.android.components.ViewModelComponent;
10 | import dagger.hilt.android.internal.lifecycle.HiltViewModelMap;
11 | import dagger.hilt.codegen.OriginatingElement;
12 | import dagger.multibindings.IntoMap;
13 | import dagger.multibindings.IntoSet;
14 | import dagger.multibindings.StringKey;
15 | import java.lang.String;
16 | import javax.annotation.processing.Generated;
17 |
18 | @Generated("dagger.hilt.android.processor.internal.viewmodel.ViewModelProcessor")
19 | @OriginatingElement(
20 | topLevelClass = ProductsViewModel.class
21 | )
22 | public final class ProductsViewModel_HiltModules {
23 | private ProductsViewModel_HiltModules() {
24 | }
25 |
26 | @Module
27 | @InstallIn(ViewModelComponent.class)
28 | public abstract static class BindsModule {
29 | private BindsModule() {
30 | }
31 |
32 | @Binds
33 | @IntoMap
34 | @StringKey("ro.alexmamo.optimizerealtimedatabase.presentation.products.ProductsViewModel")
35 | @HiltViewModelMap
36 | public abstract ViewModel binds(ProductsViewModel vm);
37 | }
38 |
39 | @Module
40 | @InstallIn(ActivityRetainedComponent.class)
41 | public static final class KeyModule {
42 | private KeyModule() {
43 | }
44 |
45 | @Provides
46 | @IntoSet
47 | @HiltViewModelMap.KeySet
48 | public static String provide() {
49 | return "ro.alexmamo.optimizerealtimedatabase.presentation.products.ProductsViewModel";
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/build/generated/source/kapt/debug/ro/alexmamo/optimizerealtimedatabase/presentation/products/ProductsViewModel_HiltModules_KeyModule_ProvideFactory.java:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products;
2 |
3 | import dagger.internal.DaggerGenerated;
4 | import dagger.internal.Factory;
5 | import dagger.internal.Preconditions;
6 | import dagger.internal.QualifierMetadata;
7 | import dagger.internal.ScopeMetadata;
8 | import javax.annotation.processing.Generated;
9 |
10 | @ScopeMetadata
11 | @QualifierMetadata("dagger.hilt.android.internal.lifecycle.HiltViewModelMap.KeySet")
12 | @DaggerGenerated
13 | @Generated(
14 | value = "dagger.internal.codegen.ComponentProcessor",
15 | comments = "https://dagger.dev"
16 | )
17 | @SuppressWarnings({
18 | "unchecked",
19 | "rawtypes"
20 | })
21 | public final class ProductsViewModel_HiltModules_KeyModule_ProvideFactory implements Factory {
22 | @Override
23 | public String get() {
24 | return provide();
25 | }
26 |
27 | public static ProductsViewModel_HiltModules_KeyModule_ProvideFactory create() {
28 | return InstanceHolder.INSTANCE;
29 | }
30 |
31 | public static String provide() {
32 | return Preconditions.checkNotNullFromProvides(ProductsViewModel_HiltModules.KeyModule.provide());
33 | }
34 |
35 | private static final class InstanceHolder {
36 | private static final ProductsViewModel_HiltModules_KeyModule_ProvideFactory INSTANCE = new ProductsViewModel_HiltModules_KeyModule_ProvideFactory();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/OptimizeRealtimeDatabaseApp.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class OptimizeRealtimeDatabaseApp: Application()
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/components/ProgressBar.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.components
2 |
3 | import androidx.compose.foundation.layout.Box
4 | import androidx.compose.foundation.layout.fillMaxSize
5 | import androidx.compose.material.CircularProgressIndicator
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.Alignment
8 | import androidx.compose.ui.Modifier
9 |
10 | @Composable
11 | fun ProgressBar() {
12 | Box(
13 | modifier = Modifier.fillMaxSize(),
14 | contentAlignment = Alignment.Center
15 | ){
16 | CircularProgressIndicator()
17 | }
18 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/core/Constants.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.core
2 |
3 | object Constants {
4 | //App
5 | const val TAG = "AppTag"
6 |
7 | //Realtime Database
8 | const val PRODUCT_NAMES = "productNames"
9 | const val PRODUCTS = "products"
10 |
11 | //Product fields
12 | const val NAME = "name"
13 | const val IMAGE_URL = "imageUrl"
14 | const val DETAILS = "details"
15 | const val PRICE = "price"
16 | const val STOCK = "stock"
17 | const val HEIGHT = "height"
18 | const val WIDTH = "width"
19 | const val DEPTH = "depth"
20 | const val WEIGHT = "weight"
21 |
22 | //Arguments
23 | const val PRODUCT_KEY = "productKey"
24 | const val NO_VALUE = ""
25 |
26 | //Measurement units
27 | const val CM = "cm"
28 | const val KG = "Kg"
29 |
30 | //Screens
31 | const val PRODUCTS_SCREEN = "Product List"
32 | const val PRODUCT_SCREEN = "Product Details"
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/core/Utils.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.core
2 |
3 | import android.util.Log
4 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.TAG
5 |
6 | class Utils {
7 | companion object {
8 | fun print(e: Exception?) {
9 | Log.d(TAG, e?.message ?: e.toString())
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/data/repository/ProductsRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.data.repository
2 |
3 | import com.google.firebase.database.DataSnapshot
4 | import com.google.firebase.database.DatabaseReference
5 | import kotlinx.coroutines.tasks.await
6 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCTS
7 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCT_NAMES
8 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Product
9 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.Failure
10 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.Success
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductResponse
12 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository
13 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsResponse
14 | import javax.inject.Inject
15 | import javax.inject.Singleton
16 |
17 | @Singleton
18 | class ProductsRepositoryImpl @Inject constructor(
19 | private val db: DatabaseReference
20 | ): ProductsRepository {
21 | override suspend fun getProductsFromRealtimeDatabase(): ProductsResponse = try {
22 | val products = mutableListOf()
23 | db.child(PRODUCT_NAMES).get().await().children.forEach { snapshot ->
24 | val product = snapshot.toProduct()
25 | products.add(product)
26 | }
27 | Success(products)
28 | } catch (e: Exception) {
29 | Failure(e)
30 | }
31 |
32 | override suspend fun getProductFromRealtimeDatabase(productKey: String): ProductResponse = try {
33 | val productKeyRef = db.child(PRODUCTS).child(productKey)
34 | val product = productKeyRef.get().await().getValue(Product::class.java)
35 | Success(product)
36 | } catch (e: Exception) {
37 | Failure(e)
38 | }
39 | }
40 |
41 | fun DataSnapshot.toProduct() = Product(
42 | key = key,
43 | name = getValue(String::class.java)
44 | )
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.di
2 |
3 | import com.google.firebase.database.DatabaseReference
4 | import com.google.firebase.database.ktx.database
5 | import com.google.firebase.ktx.Firebase
6 | import dagger.Module
7 | import dagger.Provides
8 | import dagger.hilt.InstallIn
9 | import dagger.hilt.components.SingletonComponent
10 | import ro.alexmamo.optimizerealtimedatabase.data.repository.ProductsRepositoryImpl
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository
12 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.GetProduct
13 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.GetProducts
14 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases
15 |
16 | @Module
17 | @InstallIn(SingletonComponent::class)
18 | class AppModule {
19 | @Provides
20 | fun provideFirebaseDatabaseReference() = Firebase.database.reference
21 |
22 | @Provides
23 | fun provideProductsRepository(
24 | db: DatabaseReference
25 | ): ProductsRepository = ProductsRepositoryImpl(db)
26 |
27 | @Provides
28 | fun provideUseCases(
29 | repo: ProductsRepository
30 | ) = UseCases(
31 | getProducts = GetProducts(repo = repo),
32 | getProduct = GetProduct(repo = repo)
33 | )
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/model/Product.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.model
2 |
3 | data class Product (
4 | var key: String? = null,
5 | var name: String? = null,
6 | var imageUrl: String? = null,
7 | var details: String? = null,
8 | var price: Double? = null,
9 | var stock: Int? = null,
10 | var height: Double? = null,
11 | var width: Double? = null,
12 | var depth: Double? = null,
13 | var weight: Double? = null,
14 | )
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/model/Response.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.model
2 |
3 | sealed class Response {
4 | object Loading: Response()
5 |
6 | data class Success(
7 | val data: T?
8 | ): Response()
9 |
10 | data class Failure(
11 | val e: Exception?
12 | ): Response()
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/repository/ProductsRepository.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.repository
2 |
3 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Product
4 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response
5 |
6 | typealias Products = List
7 | typealias ProductsResponse = Response
8 | typealias ProductResponse = Response
9 |
10 | interface ProductsRepository {
11 | suspend fun getProductsFromRealtimeDatabase(): ProductsResponse
12 |
13 | suspend fun getProductFromRealtimeDatabase(productKey: String): ProductResponse
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/use_case/GetProduct.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.use_case
2 |
3 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository
4 |
5 | class GetProduct(
6 | private val repo: ProductsRepository
7 | ) {
8 | suspend operator fun invoke(
9 | productKey: String
10 | ) = repo.getProductFromRealtimeDatabase(productKey)
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/use_case/GetProducts.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.use_case
2 |
3 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsRepository
4 |
5 | class GetProducts(
6 | private val repo: ProductsRepository
7 | ) {
8 | suspend operator fun invoke() = repo.getProductsFromRealtimeDatabase()
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/domain/use_case/UseCases.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.domain.use_case
2 |
3 | data class UseCases(
4 | val getProducts: GetProducts,
5 | val getProduct: GetProduct
6 | )
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/navigation/NavGraph.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.navigation
2 |
3 | import androidx.compose.material.ExperimentalMaterialApi
4 | import androidx.compose.runtime.Composable
5 | import androidx.compose.runtime.mutableStateListOf
6 | import androidx.navigation.NavHostController
7 | import androidx.navigation.NavType.Companion.StringType
8 | import androidx.navigation.compose.NavHost
9 | import androidx.navigation.compose.composable
10 | import androidx.navigation.navArgument
11 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.NO_VALUE
12 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCT_KEY
13 | import ro.alexmamo.optimizerealtimedatabase.navigation.Screen.ProductScreen
14 | import ro.alexmamo.optimizerealtimedatabase.navigation.Screen.ProductsScreen
15 | import ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductScreen
16 | import ro.alexmamo.optimizerealtimedatabase.presentation.products.ProductsScreen
17 |
18 | @Composable
19 | @ExperimentalMaterialApi
20 | fun NavGraph (
21 | navController: NavHostController
22 | ) {
23 | NavHost(
24 | navController = navController,
25 | startDestination = ProductsScreen.route
26 | ) {
27 | composable(
28 | route = ProductsScreen.route
29 | ) {
30 | ProductsScreen(
31 | navigateToProductScreen = { productKey ->
32 | navController.navigate("${ProductScreen.route}/${productKey}")
33 | }
34 | )
35 | }
36 | composable(
37 | route = "${ProductScreen.route}/{$PRODUCT_KEY}",
38 | arguments = mutableStateListOf(
39 | navArgument(PRODUCT_KEY) {
40 | type = StringType
41 | }
42 | )
43 | ) { backStackEntry ->
44 | val productKey = backStackEntry.arguments?.getString(PRODUCT_KEY) ?: NO_VALUE
45 | ProductScreen(
46 | productKey = productKey,
47 | navigateBack = {
48 | navController.popBackStack()
49 | }
50 | )
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/navigation/Screen.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.navigation
2 |
3 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCT_SCREEN
4 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCTS_SCREEN
5 |
6 | sealed class Screen(val route: String) {
7 | object ProductsScreen: Screen(PRODUCTS_SCREEN)
8 | object ProductScreen: Screen(PRODUCT_SCREEN)
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/ProductsActivity.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.material.ExperimentalMaterialApi
7 | import androidx.navigation.compose.rememberNavController
8 | import dagger.hilt.android.AndroidEntryPoint
9 | import ro.alexmamo.optimizerealtimedatabase.navigation.NavGraph
10 |
11 | @AndroidEntryPoint
12 | @ExperimentalMaterialApi
13 | class ProductsActivity : ComponentActivity() {
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContent {
17 | NavGraph(
18 | navController = rememberNavController()
19 | )
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/product/ProductScreen.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product
2 |
3 | import androidx.compose.material.Scaffold
4 | import androidx.compose.runtime.Composable
5 | import ro.alexmamo.optimizerealtimedatabase.presentation.product.components.ProductContent
6 | import ro.alexmamo.optimizerealtimedatabase.presentation.product.components.ProductTopBar
7 |
8 | @Composable
9 | fun ProductScreen(
10 | productKey: String,
11 | navigateBack: () -> Unit
12 | ) {
13 | Scaffold(
14 | topBar = {
15 | ProductTopBar(
16 | navigateBack = navigateBack
17 | )
18 | },
19 | content = { padding ->
20 | ProductContent(
21 | padding = padding,
22 | productKey = productKey
23 | )
24 | }
25 | )
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/product/ProductViewModel.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product
2 |
3 | import androidx.compose.runtime.getValue
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.compose.runtime.setValue
6 | import androidx.lifecycle.ViewModel
7 | import androidx.lifecycle.viewModelScope
8 | import dagger.hilt.android.lifecycle.HiltViewModel
9 | import kotlinx.coroutines.launch
10 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.Loading
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductResponse
12 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases
13 | import javax.inject.Inject
14 |
15 | @HiltViewModel
16 | class ProductViewModel @Inject constructor(
17 | private val useCases: UseCases
18 | ): ViewModel() {
19 | var productResponse by mutableStateOf(Loading)
20 | private set
21 |
22 | fun getProduct(productKey: String) = viewModelScope.launch {
23 | productResponse = Loading
24 | productResponse = useCases.getProduct(productKey)
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/product/components/ProducTopBar.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product.components
2 |
3 | import androidx.compose.material.Icon
4 | import androidx.compose.material.IconButton
5 | import androidx.compose.material.Text
6 | import androidx.compose.material.TopAppBar
7 | import androidx.compose.material.icons.Icons
8 | import androidx.compose.material.icons.outlined.ArrowBack
9 | import androidx.compose.runtime.Composable
10 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCT_SCREEN
11 |
12 | @Composable
13 | fun ProductTopBar(
14 | navigateBack: () -> Unit
15 | ) {
16 | TopAppBar (
17 | title = {
18 | Text(
19 | text = PRODUCT_SCREEN
20 | )
21 | },
22 | navigationIcon = {
23 | IconButton(
24 | onClick = navigateBack
25 | ) {
26 | Icon(
27 | imageVector = Icons.Outlined.ArrowBack,
28 | contentDescription = null,
29 | )
30 | }
31 | }
32 | )
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/product/components/ProductContent.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.product.components
2 |
3 | import androidx.compose.foundation.layout.*
4 | import androidx.compose.material.Text
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.runtime.LaunchedEffect
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.unit.dp
9 | import androidx.compose.ui.unit.sp
10 | import androidx.hilt.navigation.compose.hiltViewModel
11 | import ro.alexmamo.optimizerealtimedatabase.components.ProgressBar
12 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.CM
13 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.DEPTH
14 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.DETAILS
15 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.HEIGHT
16 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.IMAGE_URL
17 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.KG
18 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.NAME
19 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRICE
20 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.STOCK
21 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.WEIGHT
22 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.WIDTH
23 | import ro.alexmamo.optimizerealtimedatabase.core.Utils.Companion.print
24 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.*
25 | import ro.alexmamo.optimizerealtimedatabase.presentation.product.ProductViewModel
26 |
27 | @Composable
28 | fun ProductContent(
29 | padding: PaddingValues,
30 | viewModel: ProductViewModel = hiltViewModel(),
31 | productKey: String,
32 | ) {
33 | LaunchedEffect(Unit) {
34 | viewModel.getProduct(productKey)
35 | }
36 |
37 | Box(
38 | modifier = Modifier.fillMaxSize().padding(padding)
39 | ) {
40 | when(val productResponse = viewModel.productResponse) {
41 | is Loading -> ProgressBar()
42 | is Success -> Column(
43 | modifier = Modifier.fillMaxSize().padding(
44 | top = 8.dp,
45 | start = 8.dp
46 | )
47 | ) {
48 | productResponse.data?.apply {
49 | name?.let {
50 | Text(
51 | text = "${NAME}: $name",
52 | fontSize = 24.sp
53 | )
54 | }
55 | imageUrl?.let {
56 | Text(
57 | text = "${IMAGE_URL}: $imageUrl",
58 | fontSize = 24.sp
59 | )
60 | }
61 | details?.let {
62 | Text(
63 | text = "${DETAILS}: $details",
64 | fontSize = 24.sp
65 | )
66 | }
67 | price?.let {
68 | Text(
69 | text = "${PRICE}: $$price",
70 | fontSize = 24.sp
71 | )
72 | }
73 | stock?.let {
74 | Text(
75 | text = "${STOCK}: $stock",
76 | fontSize = 24.sp
77 | )
78 | }
79 | height?.let {
80 | Text(
81 | text = "${HEIGHT}: $height $CM",
82 | fontSize = 24.sp
83 | )
84 | }
85 | width?.let {
86 | Text(
87 | text = "${WIDTH}: $width $CM",
88 | fontSize = 24.sp
89 | )
90 | }
91 | depth?.let {
92 | Text(
93 | text = "${DEPTH}: $depth $CM",
94 | fontSize = 24.sp
95 | )
96 | }
97 | weight?.let {
98 | Text(
99 | text = "${WEIGHT}: $weight $KG",
100 | fontSize = 24.sp
101 | )
102 | }
103 | }
104 | }
105 | is Failure -> print(productResponse.e)
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/products/ProductsScreen.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products
2 |
3 | import androidx.compose.material.ExperimentalMaterialApi
4 | import androidx.compose.material.Scaffold
5 | import androidx.compose.runtime.Composable
6 | import androidx.hilt.navigation.compose.hiltViewModel
7 | import ro.alexmamo.optimizerealtimedatabase.components.ProgressBar
8 | import ro.alexmamo.optimizerealtimedatabase.core.Utils.Companion.print
9 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.*
10 | import ro.alexmamo.optimizerealtimedatabase.presentation.products.components.ProductsTopBar
11 | import ro.alexmamo.optimizerealtimedatabase.presentation.products.components.ProductsContent
12 |
13 | @Composable
14 | @ExperimentalMaterialApi
15 | fun ProductsScreen(
16 | viewModel: ProductsViewModel = hiltViewModel(),
17 | navigateToProductScreen: (productKey: String) -> Unit
18 | ) {
19 | Scaffold(
20 | topBar = {
21 | ProductsTopBar()
22 | },
23 | content = { padding ->
24 | when(val productsResponse = viewModel.productsResponse) {
25 | is Loading -> ProgressBar()
26 | is Success -> ProductsContent(
27 | padding = padding,
28 | products = productsResponse.data,
29 | navigateToProductScreen = navigateToProductScreen
30 | )
31 | is Failure -> print(productsResponse.e)
32 | }
33 | }
34 | )
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/products/ProductsViewModel.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products
2 |
3 | import androidx.compose.runtime.getValue
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.compose.runtime.setValue
6 | import androidx.lifecycle.ViewModel
7 | import androidx.lifecycle.viewModelScope
8 | import dagger.hilt.android.lifecycle.HiltViewModel
9 | import kotlinx.coroutines.launch
10 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Response.Loading
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.ProductsResponse
12 | import ro.alexmamo.optimizerealtimedatabase.domain.use_case.UseCases
13 | import javax.inject.Inject
14 |
15 | @HiltViewModel
16 | class ProductsViewModel @Inject constructor(
17 | private val useCases: UseCases
18 | ): ViewModel() {
19 | var productsResponse by mutableStateOf(Loading)
20 | private set
21 |
22 | init {
23 | getProducts()
24 | }
25 |
26 | private fun getProducts() = viewModelScope.launch {
27 | productsResponse = Loading
28 | productsResponse = useCases.getProducts()
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/products/components/ProductCard.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products.components
2 |
3 | import androidx.compose.foundation.layout.Box
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.material.Card
7 | import androidx.compose.material.ExperimentalMaterialApi
8 | import androidx.compose.material.MaterialTheme
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.graphics.Color
13 | import androidx.compose.ui.unit.dp
14 | import androidx.compose.ui.unit.sp
15 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.NO_VALUE
16 | import ro.alexmamo.optimizerealtimedatabase.domain.model.Product
17 |
18 | @Composable
19 | @ExperimentalMaterialApi
20 | fun ProductCard(
21 | product: Product,
22 | onClick: () -> Unit
23 | ) {
24 | Card(
25 | shape = MaterialTheme.shapes.small,
26 | modifier = Modifier.fillMaxWidth()
27 | .padding(
28 | start = 8.dp,
29 | end = 8.dp,
30 | top = 4.dp,
31 | bottom = 4.dp
32 | ),
33 | elevation = 3.dp,
34 | onClick = onClick
35 | ) {
36 | Box(
37 | modifier = Modifier.fillMaxWidth()
38 | .padding(
39 | all = 12.dp
40 | )
41 | ) {
42 | val productName = product.name ?: NO_VALUE
43 | Text(
44 | text = productName,
45 | color = Color.DarkGray,
46 | fontSize = 25.sp
47 | )
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/products/components/ProductsContent.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products.components
2 |
3 | import androidx.compose.foundation.layout.PaddingValues
4 | import androidx.compose.foundation.layout.fillMaxSize
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.foundation.lazy.LazyColumn
7 | import androidx.compose.foundation.lazy.items
8 | import androidx.compose.material.ExperimentalMaterialApi
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Modifier
11 | import ro.alexmamo.optimizerealtimedatabase.domain.repository.Products
12 |
13 | @Composable
14 | @ExperimentalMaterialApi
15 | fun ProductsContent(
16 | padding: PaddingValues,
17 | products: Products?,
18 | navigateToProductScreen: (productKey: String) -> Unit
19 | ) {
20 | LazyColumn(
21 | modifier = Modifier.fillMaxSize().padding(padding)
22 | ) {
23 | products?.let {
24 | items(
25 | items = products
26 | ) { product ->
27 | ProductCard(
28 | product = product,
29 | onClick = {
30 | product.key?.let { productKey ->
31 | navigateToProductScreen(productKey)
32 | }
33 | }
34 | )
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/ro/alexmamo/optimizerealtimedatabase/presentation/products/components/ProductsTopBar.kt:
--------------------------------------------------------------------------------
1 | package ro.alexmamo.optimizerealtimedatabase.presentation.products.components
2 |
3 | import androidx.compose.material.Text
4 | import androidx.compose.material.TopAppBar
5 | import androidx.compose.runtime.Composable
6 | import ro.alexmamo.optimizerealtimedatabase.core.Constants.PRODUCTS_SCREEN
7 |
8 | @Composable
9 | fun ProductsTopBar() {
10 | TopAppBar (
11 | title = {
12 | Text(
13 | text = PRODUCTS_SCREEN
14 | )
15 | }
16 | )
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/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 |
--------------------------------------------------------------------------------
/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.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OptimizeRealtimeDatabase
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | gradle_version = '7.3.0'
4 | kotlin_version = '1.7.10'
5 | google_services_version = '4.3.14'
6 | viewmodel_version = '2.5.1'
7 | material_version = '1.3.0-rc01'
8 | navigation_compose_version = '2.5.2'
9 | compose_version = '1.3.0'
10 | hilt_version = '2.44'
11 | hilt_navigation_compose_version = '1.0.0'
12 | firebase_bom_version = '30.5.0'
13 | play_services_version = '1.6.4'
14 | }
15 | dependencies {
16 | classpath "com.google.gms:google-services:$google_services_version"
17 | classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
18 | }
19 | }
20 |
21 | plugins {
22 | id 'com.android.application' version "${gradle_version}" apply false
23 | id 'com.android.library' version "${gradle_version}" apply false
24 | id 'org.jetbrains.kotlin.android' version "${kotlin_version}" apply false
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexmamo/OptimizeRealtimeDatabase/56fb2236c7f55996b89bef4a0fa48a5ce17a2b2c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 06 14:43:16 EET 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "OptimizeRealtimeDatabase"
16 | include ':app'
--------------------------------------------------------------------------------