diff --git a/ActionEveryMinute/README.md b/ActionEveryMinute/README.md index c0e046da..92a8b2a0 100644 --- a/ActionEveryMinute/README.md +++ b/ActionEveryMinute/README.md @@ -1,36 +1,4 @@ -## Action Every Minute +# Action Every Minute -Aplikasi Android sederhana - Penambahan angka tiap menit. - -| ![Gambar 1](./documentation/SS01_ActionEveryMinute.jpg) | ![Gambar 2](./documentation/SS02_ActionEveryMinute.jpg) | ![Gambar 3](./documentation/SS03_ActionEveryMinute.jpg) | -|:-------------------------------------------------------:|:-------------------------------------------------------:|:-------------------------------------------------------:| -| Gambar 1:
Begin Action | Gambar 2:
Start Action | Gambar 3:
Action until 5 Times | - -## Environment -- **Android Gradle**: 8.5.0 -- **Plugins Version**: 8.7 -- **Gradle Version**: 8.0 -- **Java JDK**: 17 -- **Kotlin Version**: 1.9.0 -- **Min SDK**: 21 -- **Target SDK**: 34 - -## Contributors -Thanks all contributors for build this repository - -``` -Copyright [2021] [The Dictionary of Android Projects] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -``` +--- VERSION --- +- 1.0.0 : Create APK Project \ No newline at end of file diff --git a/ActionEveryMinute/app/build.gradle b/ActionEveryMinute/app/build.gradle index 371d328c..8a0aa8a6 100644 --- a/ActionEveryMinute/app/build.gradle +++ b/ActionEveryMinute/app/build.gradle @@ -1,17 +1,18 @@ plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) } android { - compileSdk 32 + namespace 'com.algokelvin.actioneveryminute' + compileSdk 35 defaultConfig { - applicationId "algokelvin.app.actioneveryminute" - minSdk 21 - targetSdk 32 + applicationId "com.algokelvin.actioneveryminute" + minSdk 24 + targetSdk 35 versionCode 1 - versionName "1.0" + versionName "1.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -23,11 +24,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } buildFeatures { viewBinding = true @@ -35,11 +36,12 @@ android { } dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.6.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation libs.androidx.core.ktx + implementation libs.androidx.appcompat + implementation libs.material + implementation libs.androidx.activity + implementation libs.androidx.constraintlayout + testImplementation libs.junit + androidTestImplementation libs.androidx.junit + androidTestImplementation libs.androidx.espresso.core } \ No newline at end of file diff --git a/ActionEveryMinute/app/src/androidTest/java/algokelvin/app/actioneveryminute/ExampleInstrumentedTest.kt b/ActionEveryMinute/app/src/androidTest/java/algokelvin/app/actioneveryminute/ExampleInstrumentedTest.kt deleted file mode 100644 index 5e8f5e00..00000000 --- a/ActionEveryMinute/app/src/androidTest/java/algokelvin/app/actioneveryminute/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package algokelvin.app.actioneveryminute - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("algokelvin.app.actioneveryminute", appContext.packageName) - } -} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/androidTest/java/com/algokelvin/actioneveryminute/ExampleInstrumentedTest.kt b/ActionEveryMinute/app/src/androidTest/java/com/algokelvin/actioneveryminute/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..4b677c1d --- /dev/null +++ b/ActionEveryMinute/app/src/androidTest/java/com/algokelvin/actioneveryminute/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.algokelvin.actioneveryminute + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.algokelvin.actioneveryminute", appContext.packageName) + } +} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/AndroidManifest.xml b/ActionEveryMinute/app/src/main/AndroidManifest.xml index 00bf3655..c8c7db43 100644 --- a/ActionEveryMinute/app/src/main/AndroidManifest.xml +++ b/ActionEveryMinute/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> + diff --git a/ActionEveryMinute/app/src/main/ic_launcher-playstore.png b/ActionEveryMinute/app/src/main/ic_launcher-playstore.png new file mode 100644 index 00000000..afeecb3b Binary files /dev/null and b/ActionEveryMinute/app/src/main/ic_launcher-playstore.png differ diff --git a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/MainActivity.kt b/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/MainActivity.kt deleted file mode 100644 index 0f7961c0..00000000 --- a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/MainActivity.kt +++ /dev/null @@ -1,29 +0,0 @@ -package algokelvin.app.actioneveryminute - -import algokelvin.app.actioneveryminute.databinding.ActivityMainBinding -import java.util.* - -class MainActivity : BindingActivity(), UiThreadInterface { - private var times = 1 - - override fun contentView() { - binding = ActivityMainBinding.inflate(layoutInflater) - setContentView(binding.root) - } - - override fun mainUI() { - val timer = Timer() - timer.scheduleAtFixedRate(object : TimerTask() { - override fun run() { - runOnUiThread { - uiThread() - } - } - }, 5000, 5000) - } - - override fun uiThread() { - binding.txtRun.text = ("${times++} Times") - } - -} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/UiThreadInterface.kt b/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/UiThreadInterface.kt deleted file mode 100644 index 334d0a8a..00000000 --- a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/UiThreadInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package algokelvin.app.actioneveryminute - -interface UiThreadInterface { - fun uiThread() -} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/BindingActivity.java b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/BindingActivity.java similarity index 91% rename from ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/BindingActivity.java rename to ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/BindingActivity.java index 08ed14d3..b284fa75 100644 --- a/ActionEveryMinute/app/src/main/java/algokelvin/app/actioneveryminute/BindingActivity.java +++ b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/BindingActivity.java @@ -1,4 +1,4 @@ -package algokelvin.app.actioneveryminute; +package com.algokelvin.actioneveryminute; import android.os.Bundle; diff --git a/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/MainActivity.kt b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/MainActivity.kt new file mode 100644 index 00000000..99961cfc --- /dev/null +++ b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/MainActivity.kt @@ -0,0 +1,29 @@ +package com.algokelvin.actioneveryminute + +import com.algokelvin.actioneveryminute.databinding.ActivityMainBinding +import java.util.* + +class MainActivity : BindingActivity(), UiThreadInterface { + private var times = 1 + + override fun contentView() { + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) + } + + override fun mainUI() { + val timer = Timer() + timer.scheduleAtFixedRate(object : TimerTask() { + override fun run() { + runOnUiThread { + uiThread() + } + } + }, 5000, 5000) + } + + override fun uiThread() { + binding.txtRun.text = ("${times++} Times") + } + +} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/UiThreadInterface.kt b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/UiThreadInterface.kt new file mode 100644 index 00000000..8f8aa099 --- /dev/null +++ b/ActionEveryMinute/app/src/main/java/com/algokelvin/actioneveryminute/UiThreadInterface.kt @@ -0,0 +1,5 @@ +package com.algokelvin.actioneveryminute + +interface UiThreadInterface { + fun uiThread() +} \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/res/drawable/ic_launcher_background.xml b/ActionEveryMinute/app/src/main/res/drawable/ic_launcher_background.xml index 07d5da9c..ca3826a4 100644 --- a/ActionEveryMinute/app/src/main/res/drawable/ic_launcher_background.xml +++ b/ActionEveryMinute/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,74 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + xmlns:android="http://schemas.android.com/apk/res/android"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ActionEveryMinute/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ActionEveryMinute/app/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from ActionEveryMinute/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to ActionEveryMinute/app/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cfe..c4a603d4 100644 --- a/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index eca70cfe..c4a603d4 100644 --- a/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/ActionEveryMinute/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher.webp index c209e78e..1f4c0d01 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..7b289835 Binary files /dev/null and b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp index b2dfe3d1..1a6ccc46 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/ActionEveryMinute/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher.webp index 4f0f1d64..559e666e 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..cd0a7975 Binary files /dev/null and b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp index 62b611da..617fd9ea 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/ActionEveryMinute/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher.webp index 948a3070..5efb6422 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..bcae5e61 Binary files /dev/null and b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp index 1b9a6956..0cb98685 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp index 28d4b77f..ee8d549c 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..f8f8d033 Binary files /dev/null and b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp index 9287f508..ef80d15c 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp index aa7d6427..b4e0005b 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..fed1a6c4 Binary files /dev/null and b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp index 9126ae37..31b5df0a 100644 Binary files a/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/ActionEveryMinute/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/ActionEveryMinute/app/src/main/res/values-night/themes.xml b/ActionEveryMinute/app/src/main/res/values-night/themes.xml index 7619ee46..ba94d439 100644 --- a/ActionEveryMinute/app/src/main/res/values-night/themes.xml +++ b/ActionEveryMinute/app/src/main/res/values-night/themes.xml @@ -1,16 +1,7 @@ - \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/res/values/colors.xml b/ActionEveryMinute/app/src/main/res/values/colors.xml index f8c6127d..c8524cd9 100644 --- a/ActionEveryMinute/app/src/main/res/values/colors.xml +++ b/ActionEveryMinute/app/src/main/res/values/colors.xml @@ -1,10 +1,5 @@ - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 #FF000000 #FFFFFFFF \ No newline at end of file diff --git a/ActionEveryMinute/app/src/main/res/values/themes.xml b/ActionEveryMinute/app/src/main/res/values/themes.xml index d4f39948..ddac1942 100644 --- a/ActionEveryMinute/app/src/main/res/values/themes.xml +++ b/ActionEveryMinute/app/src/main/res/values/themes.xml @@ -1,16 +1,9 @@ - + + + \ No newline at end of file diff --git a/ImageText/app/src/main/res/values/colors.xml b/Animation/app/src/main/res/values/colors.xml similarity index 100% rename from ImageText/app/src/main/res/values/colors.xml rename to Animation/app/src/main/res/values/colors.xml diff --git a/Animation/app/src/main/res/values/strings.xml b/Animation/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..3200b201 --- /dev/null +++ b/Animation/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + Animation + Hello Translation Part01 + Translation + Translation01 + Translation02 + \ No newline at end of file diff --git a/Animation/app/src/main/res/values/themes.xml b/Animation/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..af5291c6 --- /dev/null +++ b/Animation/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + + - \ No newline at end of file diff --git a/AnimationApp/app/src/main/res/values/strings.xml b/AnimationApp/app/src/main/res/values/strings.xml deleted file mode 100644 index ca90650b..00000000 --- a/AnimationApp/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - AnimationAndroid - Hello Translation Part01 - Translation - Translation01 - Translation02 - \ No newline at end of file diff --git a/AnimationApp/app/src/main/res/values/themes.xml b/AnimationApp/app/src/main/res/values/themes.xml deleted file mode 100644 index 44354e03..00000000 --- a/AnimationApp/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/AnimationApp/build.gradle b/AnimationApp/build.gradle deleted file mode 100644 index 024b1f11..00000000 --- a/AnimationApp/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext { - agp_version = '8.5.0' - } - ext.kotlin_version = "1.3.72" - repositories { - google() - jcenter() - } - dependencies { - classpath "com.android.tools.build:gradle:$agp_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/AnimationApp/documentation/SS_Animation_01.gif b/AnimationApp/documentation/SS_Animation_01.gif deleted file mode 100644 index de9f741e..00000000 Binary files a/AnimationApp/documentation/SS_Animation_01.gif and /dev/null differ diff --git a/AnimationApp/gradle.properties b/AnimationApp/gradle.properties deleted file mode 100644 index 98bed167..00000000 --- a/AnimationApp/gradle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file diff --git a/AnimationApp/gradle/wrapper/gradle-wrapper.properties b/AnimationApp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index fbd24241..00000000 --- a/AnimationApp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Feb 23 12:28:57 WIB 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/AnimationApp/settings.gradle b/AnimationApp/settings.gradle deleted file mode 100644 index a19055f5..00000000 --- a/AnimationApp/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -include ':app' -rootProject.name = "AnimationAndroid" -include ':animator-featuring' \ No newline at end of file diff --git a/BirthdayCardCompose/README.md b/BirthdayCardCompose/README.md deleted file mode 100644 index 4932ecce..00000000 --- a/BirthdayCardCompose/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Birthday Card Compose - -| ![Gambar 1](./documentation/SS_Animation_01.gif) | -|:------------------------------------------------:| -| Gambar 1:
Card Birthday | - -## Implementation -- Jetpack Compose Android - -## Environment -- **Android Gradle**: 8.5.0 -- **Plugins Version**: 8.7 -- **Gradle Version**: 8.0 -- **Java JDK**: 17 -- **Kotlin Version**: 1.9.0 -- **Min SDK**: 21 -- **Target SDK**: 34 - -## Contributors -Thanks all contributors for build this repository - -``` -Copyright [2021] [The Dictionary of Android Projects] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -``` diff --git a/BirthdayCardCompose/app/build.gradle b/BirthdayCardCompose/app/build.gradle deleted file mode 100644 index 7c5d6eea..00000000 --- a/BirthdayCardCompose/app/build.gradle +++ /dev/null @@ -1,62 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdk 32 - - defaultConfig { - applicationId "kelvinht.app.birthdaycard" - minSdk 21 - targetSdk 32 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion compose_version - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - - implementation 'androidx.core:core-ktx:1.7.0' - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" -} \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/androidTest/java/kelvinht/app/birthdaycard/ExampleInstrumentedTest.kt b/BirthdayCardCompose/app/src/androidTest/java/kelvinht/app/birthdaycard/ExampleInstrumentedTest.kt deleted file mode 100644 index b46bab22..00000000 --- a/BirthdayCardCompose/app/src/androidTest/java/kelvinht/app/birthdaycard/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package kelvinht.app.birthdaycard - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("kelvinht.app.birthdaycard", appContext.packageName) - } -} \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/AndroidManifest.xml b/BirthdayCardCompose/app/src/main/AndroidManifest.xml deleted file mode 100644 index e8420fed..00000000 --- a/BirthdayCardCompose/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/MainActivity.kt b/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/MainActivity.kt deleted file mode 100644 index 4c828b5d..00000000 --- a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/MainActivity.kt +++ /dev/null @@ -1,74 +0,0 @@ -package kelvinht.app.birthdaycard - -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import kelvinht.app.birthdaycard.ui.theme.BirthdayCardTheme - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - DefaultPreview() - } - } -} - -@Composable -fun BirthdayGreeting(name: String, from: String) { - Box { - val image = painterResource(R.drawable.androidparty) - Image( - painter = image, - contentDescription = null, - modifier = Modifier - .fillMaxHeight() - .fillMaxWidth(), - contentScale = ContentScale.Crop - ) - Column() { - Text( - text = "Happy Birthday $name", - fontSize = 24.sp, - textAlign = TextAlign.Center, - modifier = Modifier - .fillMaxWidth() - .padding(16.dp) - ) - Text( - text = "from: $from", - fontSize = 20.sp, - textAlign = TextAlign.End, - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight() - .wrapContentHeight(Alignment.Bottom) - .padding(16.dp) - ) - } - } -} - -@Preview(showBackground = true, showSystemUi = true) -@Composable -fun DefaultPreview() { - BirthdayCardTheme { - Surface(color = MaterialTheme.colors.background) { - BirthdayGreeting("Kelvin Tandrio", "AlgoKelvin") - } - } -} \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Color.kt b/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Color.kt deleted file mode 100644 index 8b5cd3c8..00000000 --- a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Color.kt +++ /dev/null @@ -1,8 +0,0 @@ -package kelvinht.app.birthdaycard.ui.theme - -import androidx.compose.ui.graphics.Color - -val Purple200 = Color(0xFFBB86FC) -val Purple500 = Color(0xFF6200EE) -val Purple700 = Color(0xFF3700B3) -val Teal200 = Color(0xFF03DAC5) \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Shape.kt b/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Shape.kt deleted file mode 100644 index 72702f4b..00000000 --- a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Shape.kt +++ /dev/null @@ -1,11 +0,0 @@ -package kelvinht.app.birthdaycard.ui.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes -import androidx.compose.ui.unit.dp - -val Shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) -) \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Theme.kt b/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Theme.kt deleted file mode 100644 index 4e29347e..00000000 --- a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Theme.kt +++ /dev/null @@ -1,44 +0,0 @@ -package kelvinht.app.birthdaycard.ui.theme - -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors -import androidx.compose.runtime.Composable - -private val DarkColorPalette = darkColors( - primary = Purple200, - primaryVariant = Purple700, - secondary = Teal200 -) - -private val LightColorPalette = lightColors( - primary = Purple500, - primaryVariant = Purple700, - secondary = Teal200 - - /* Other default colors to override - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black, - */ -) - -@Composable -fun BirthdayCardTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { - val colors = if (darkTheme) { - DarkColorPalette - } else { - LightColorPalette - } - - MaterialTheme( - colors = colors, - typography = Typography, - shapes = Shapes, - content = content - ) -} \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Type.kt b/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Type.kt deleted file mode 100644 index ee65c33a..00000000 --- a/BirthdayCardCompose/app/src/main/java/kelvinht/app/birthdaycard/ui/theme/Type.kt +++ /dev/null @@ -1,28 +0,0 @@ -package kelvinht.app.birthdaycard.ui.theme - -import androidx.compose.material.Typography -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.sp - -// Set of Material typography styles to start with -val Typography = Typography( - body1 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp - ) - /* Other default text styles to override - button = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp - ), - caption = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp - ) - */ -) \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/res/drawable-nodpi/androidparty.png b/BirthdayCardCompose/app/src/main/res/drawable-nodpi/androidparty.png deleted file mode 100644 index 87124d65..00000000 Binary files a/BirthdayCardCompose/app/src/main/res/drawable-nodpi/androidparty.png and /dev/null differ diff --git a/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe..00000000 --- a/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe..00000000 --- a/BirthdayCardCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/res/values/strings.xml b/BirthdayCardCompose/app/src/main/res/values/strings.xml deleted file mode 100644 index 6b663783..00000000 --- a/BirthdayCardCompose/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - BirthdayCard - \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/main/res/values/themes.xml b/BirthdayCardCompose/app/src/main/res/values/themes.xml deleted file mode 100644 index 5d6c2dd8..00000000 --- a/BirthdayCardCompose/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BirthdayCardCompose/app/src/test/java/kelvinht/app/birthdaycard/ExampleUnitTest.kt b/BirthdayCardCompose/app/src/test/java/kelvinht/app/birthdaycard/ExampleUnitTest.kt deleted file mode 100644 index 0d2cdf04..00000000 --- a/BirthdayCardCompose/app/src/test/java/kelvinht/app/birthdaycard/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package kelvinht.app.birthdaycard - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/BirthdayCardCompose/build.gradle b/BirthdayCardCompose/build.gradle deleted file mode 100644 index b2f37c82..00000000 --- a/BirthdayCardCompose/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -buildscript { - ext { - compose_version = '1.1.0-beta01' - agp_version = '8.5.0' - } -}// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '8.5.0' apply false - id 'com.android.library' version '7.2.2' apply false - id 'org.jetbrains.kotlin.android' version '1.5.31' apply false -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/BirthdayCardCompose/gradle.properties b/BirthdayCardCompose/gradle.properties deleted file mode 100644 index cd0519bb..00000000 --- a/BirthdayCardCompose/gradle.properties +++ /dev/null @@ -1,23 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file diff --git a/BirthdayCardCompose/gradle/wrapper/gradle-wrapper.properties b/BirthdayCardCompose/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 133523e4..00000000 --- a/BirthdayCardCompose/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon Mar 10 13:40:38 WIB 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/BirthdayCardCompose/settings.gradle b/BirthdayCardCompose/settings.gradle deleted file mode 100644 index b18acd6e..00000000 --- a/BirthdayCardCompose/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - google() - mavenCentral() - } -} -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} -rootProject.name = "BirthdayCard" -include ':app' diff --git a/CalculatorCompose/app/build.gradle b/CalculatorCompose/app/build.gradle deleted file mode 100644 index 490d9a82..00000000 --- a/CalculatorCompose/app/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.jetbrains.kotlin.android) -} - -android { - namespace 'com.algokelvin.calculator' - compileSdk 34 - - defaultConfig { - applicationId "com.algokelvin.calculator" - minSdk 24 - targetSdk 34 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion '1.5.1' - } - packaging { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - - implementation libs.androidx.core.ktx - implementation libs.androidx.lifecycle.runtime.ktx - implementation libs.androidx.activity.compose - implementation platform(libs.androidx.compose.bom) - implementation libs.androidx.ui - implementation libs.androidx.ui.graphics - implementation libs.androidx.ui.tooling.preview - implementation libs.androidx.material3 - testImplementation libs.junit - androidTestImplementation libs.androidx.junit - androidTestImplementation libs.androidx.espresso.core - androidTestImplementation platform(libs.androidx.compose.bom) - androidTestImplementation libs.androidx.ui.test.junit4 - debugImplementation libs.androidx.ui.tooling - debugImplementation libs.androidx.ui.test.manifest -} \ No newline at end of file diff --git a/CalculatorCompose/app/src/androidTest/java/com/algokelvin/calculator/ExampleInstrumentedTest.kt b/CalculatorCompose/app/src/androidTest/java/com/algokelvin/calculator/ExampleInstrumentedTest.kt deleted file mode 100644 index 239568f4..00000000 --- a/CalculatorCompose/app/src/androidTest/java/com/algokelvin/calculator/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.algokelvin.calculator - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.algokelvin.calculator", appContext.packageName) - } -} \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/AndroidManifest.xml b/CalculatorCompose/app/src/main/AndroidManifest.xml deleted file mode 100644 index 8d7bca4a..00000000 --- a/CalculatorCompose/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/MainActivity.kt b/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/MainActivity.kt deleted file mode 100644 index c31b723a..00000000 --- a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/MainActivity.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.algokelvin.calculator - -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import com.algokelvin.calculator.ui.theme.CalculatorTheme - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - enableEdgeToEdge() - setContent { - CalculatorTheme { - Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> - Greeting( - name = "Android", - modifier = Modifier.padding(innerPadding) - ) - } - } - } - } -} - -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} - -@Preview(showBackground = true) -@Composable -fun GreetingPreview() { - CalculatorTheme { - Greeting("Android") - } -} \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Color.kt b/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Color.kt deleted file mode 100644 index 8b9f6512..00000000 --- a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Color.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.calculator.ui.theme - -import androidx.compose.ui.graphics.Color - -val Purple80 = Color(0xFFD0BCFF) -val PurpleGrey80 = Color(0xFFCCC2DC) -val Pink80 = Color(0xFFEFB8C8) - -val Purple40 = Color(0xFF6650a4) -val PurpleGrey40 = Color(0xFF625b71) -val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Theme.kt b/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Theme.kt deleted file mode 100644 index 9005478d..00000000 --- a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Theme.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.algokelvin.calculator.ui.theme - -import android.app.Activity -import android.os.Build -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.darkColorScheme -import androidx.compose.material3.dynamicDarkColorScheme -import androidx.compose.material3.dynamicLightColorScheme -import androidx.compose.material3.lightColorScheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext - -private val DarkColorScheme = darkColorScheme( - primary = Purple80, - secondary = PurpleGrey80, - tertiary = Pink80 -) - -private val LightColorScheme = lightColorScheme( - primary = Purple40, - secondary = PurpleGrey40, - tertiary = Pink40 - - /* Other default colors to override - background = Color(0xFFFFFBFE), - surface = Color(0xFFFFFBFE), - onPrimary = Color.White, - onSecondary = Color.White, - onTertiary = Color.White, - onBackground = Color(0xFF1C1B1F), - onSurface = Color(0xFF1C1B1F), - */ -) - -@Composable -fun CalculatorTheme( - darkTheme: Boolean = isSystemInDarkTheme(), - // Dynamic color is available on Android 12+ - dynamicColor: Boolean = true, - content: @Composable () -> Unit -) { - val colorScheme = when { - dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { - val context = LocalContext.current - if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) - } - - darkTheme -> DarkColorScheme - else -> LightColorScheme - } - - MaterialTheme( - colorScheme = colorScheme, - typography = Typography, - content = content - ) -} \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Type.kt b/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Type.kt deleted file mode 100644 index 9748ca99..00000000 --- a/CalculatorCompose/app/src/main/java/com/algokelvin/calculator/ui/theme/Type.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.algokelvin.calculator.ui.theme - -import androidx.compose.material3.Typography -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.sp - -// Set of Material typography styles to start with -val Typography = Typography( - bodyLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - lineHeight = 24.sp, - letterSpacing = 0.5.sp - ) - /* Other default text styles to override - titleLarge = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 22.sp, - lineHeight = 28.sp, - letterSpacing = 0.sp - ), - labelSmall = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Medium, - fontSize = 11.sp, - lineHeight = 16.sp, - letterSpacing = 0.5.sp - ) - */ -) \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/res/values/strings.xml b/CalculatorCompose/app/src/main/res/values/strings.xml deleted file mode 100644 index 665ca8de..00000000 --- a/CalculatorCompose/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Calculator - \ No newline at end of file diff --git a/CalculatorCompose/app/src/main/res/values/themes.xml b/CalculatorCompose/app/src/main/res/values/themes.xml deleted file mode 100644 index f2446788..00000000 --- a/CalculatorCompose/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CameraRotation/app/src/main/res/values/colors.xml b/CameraRotation/app/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127d..00000000 --- a/CameraRotation/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/CameraRotation/app/src/main/res/values/strings.xml b/CameraRotation/app/src/main/res/values/strings.xml deleted file mode 100644 index f548a5a5..00000000 --- a/CameraRotation/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - CameraRotation - \ No newline at end of file diff --git a/CameraRotation/app/src/main/res/values/themes.xml b/CameraRotation/app/src/main/res/values/themes.xml deleted file mode 100644 index 7189886f..00000000 --- a/CameraRotation/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/CameraRotation/build.gradle b/CameraRotation/build.gradle deleted file mode 100644 index 055c2bd2..00000000 --- a/CameraRotation/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext { - agp_version = '8.5.0' - } - repositories { - google() - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:$agp_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - jcenter() // Warning: this repository is going to shut down soon - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/CameraRotation/gradle/wrapper/gradle-wrapper.jar b/CameraRotation/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd..00000000 Binary files a/CameraRotation/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/CameraRotation/gradle/wrapper/gradle-wrapper.properties b/CameraRotation/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 58df879b..00000000 --- a/CameraRotation/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sat Feb 22 21:57:43 WIB 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/CameraRotation/gradlew b/CameraRotation/gradlew deleted file mode 100644 index cccdd3d5..00000000 --- a/CameraRotation/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/CameraRotation/gradlew.bat b/CameraRotation/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/CameraRotation/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/CameraRotation/settings.gradle b/CameraRotation/settings.gradle deleted file mode 100644 index 58a57d18..00000000 --- a/CameraRotation/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "CameraRotation" -include ':app' diff --git a/CleanArchitectureMVVM/app/build.gradle b/CleanArchitectureMVVM/app/build.gradle deleted file mode 100644 index 60fa895c..00000000 --- a/CleanArchitectureMVVM/app/build.gradle +++ /dev/null @@ -1,57 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-kapt' - id 'kotlin-parcelize' -} - -android { - compileSdkVersion 31 - buildToolsVersion "30.0.3" - - defaultConfig { - applicationId "com.algokelvin.app" - minSdkVersion 21 - targetSdkVersion 31 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - buildFeatures { - viewBinding true - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.1' - - // Lifecycle - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0" - - // Room - implementation "androidx.room:room-ktx:2.3.0" - kapt "androidx.room:room-compiler:2.3.0" - - // Coroutines - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1' -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/AndroidManifest.xml b/CleanArchitectureMVVM/app/src/main/AndroidManifest.xml deleted file mode 100644 index 5df23274..00000000 --- a/CleanArchitectureMVVM/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/BaseActivity.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/BaseActivity.kt deleted file mode 100644 index bff763dd..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/BaseActivity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.app.base - -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity - -open class BaseActivity: AppCompatActivity() { - protected fun toast(message: String, isLong: Boolean = false) { - Toast.makeText(this, message, - if (isLong) - Toast.LENGTH_LONG - else - Toast.LENGTH_SHORT - ).show() - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/UseCase.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/UseCase.kt deleted file mode 100644 index 8beeb1a0..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/base/UseCase.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.algokelvin.app.base - -import com.algokelvin.app.model.Resource -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.flowOn - -abstract class UseCase(private val dispatcher: CoroutineDispatcher) { - - operator fun invoke(param: P): Flow> { - return execute(param).catch { - emit(Resource.error(it.message ?: "")) - }.flowOn(dispatcher) - } - - @Throws(RuntimeException::class) - abstract fun execute(param: P): Flow> - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/NetworkBoundResource.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/NetworkBoundResource.kt deleted file mode 100644 index 7b5273c2..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/NetworkBoundResource.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.algokelvin.app.data - -import kotlinx.coroutines.flow.* - -/* -* This is the strategy util to make a data request -* supported offline-mode using Flow. -* */ -class NetworkBoundResource( - val query: () -> Flow, // first, getting the data from local db - val fetch: suspend () -> T, // then, fetch the data from network - val saveFetchResult: (T) -> Unit, // after getting the data from network, save it into local db - val onFetchFailed: (Throwable) -> Unit = {}, // handling fetch failed if any - val isShouldFetch: (T) -> Boolean = { _ -> true } // is it need to fetch to network or not (default: true) -) { - - fun asFlow(): Flow> = flow { - val flow = query() - .onStart { emit(Resource.loading(null)) } - .flatMapConcat { data -> - if (isShouldFetch(data)) { - emit(Resource.loading(data)) - - try { - saveFetchResult(fetch()) - query().map { Resource.success(it) } - } catch (throwable: Throwable) { - onFetchFailed(throwable) - query().map { - Resource.error(throwable.message?: "", null) - } - } - } else { - query().map { Resource.success(it) } - } - } - - emitAll(flow) - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/Resource.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/Resource.kt deleted file mode 100644 index f9a9c3b3..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/Resource.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.algokelvin.app.data - -data class Resource (val status: Status, val data: T?, val message: String?) { - enum class Status { - SUCCESS, - ERROR, - LOADING - } - - companion object { - fun success(data: T):Resource { - return Resource(Status.SUCCESS, data, null) - } - fun error(message: String, data: T? = null):Resource { - return Resource(Status.ERROR, data, message) - } - fun loading(data: T? = null):Resource { - return Resource(Status.LOADING, data, null) - } - } -} diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDao.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDao.kt deleted file mode 100644 index a941b537..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDao.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.algokelvin.app.data.datasource.local - -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import com.algokelvin.app.data.entity.Product -import kotlinx.coroutines.flow.Flow - -@Dao -interface ProductDao { - @Query("SELECT * FROM product") - fun products(): Flow> - - @JvmSuppressWildcards - @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insertAll(products: List) - - @Insert - fun insert(product: Product) - - @Query("SELECT * FROM product WHERE id=:id") - fun productBy(id: Int): Flow -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDatabase.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDatabase.kt deleted file mode 100644 index 1e3cba6e..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/local/ProductDatabase.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.algokelvin.app.data.datasource.local - -import android.content.Context -import androidx.room.Database -import androidx.room.Room -import androidx.room.RoomDatabase -import com.algokelvin.app.data.entity.Product - -@Database(entities = [Product::class], version = 1) -abstract class ProductDatabase : RoomDatabase() { - abstract fun productDao(): ProductDao - - companion object { - private const val DB_NAME = "product_data" - @Volatile private var INSTANCE: ProductDatabase? = null - - fun instance(context: Context): ProductDatabase { - return INSTANCE?: synchronized(this) { - Room.databaseBuilder( - context.applicationContext, - ProductDatabase::class.java, - DB_NAME - ).fallbackToDestructiveMigration() - .build() - .also { INSTANCE = it } - } - } - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/ProductServices.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/ProductServices.kt deleted file mode 100644 index ecc2ffc7..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/ProductServices.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.app.data.datasource.remote - -import com.algokelvin.app.data.entity.Product - -interface ProductServices { - fun products(): List - fun productById(id: Int): Product -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/RemoteProductFactory.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/RemoteProductFactory.kt deleted file mode 100644 index d40bfc1e..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/datasource/remote/RemoteProductFactory.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.algokelvin.app.data.datasource.remote - -import com.algokelvin.app.data.entity.Product - -class RemoteProductFactory: ProductServices { - private val products = listOf( - Product(id = 1, name = "iPhone", price = 1000), - Product(id = 2, name = "Android", price = 2000), - Product(id = 3, name = "Huawei", price = 3000), - Product(id = 4, name = "Xiaomi", price = 4000), - Product(id = 5, name = "Samsung", price = 5000), - ) - - override fun products(): List { - return products - } - - override fun productById(id: Int): Product { - return products.first { it.id == id } - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/entity/Product.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/entity/Product.kt deleted file mode 100644 index 77e70790..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/entity/Product.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.algokelvin.app.data.entity - -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey - -@Entity(tableName = "product") -data class Product( - @PrimaryKey(autoGenerate = true) - @ColumnInfo(name="id") - val id: Int = 0, - - @ColumnInfo(name="name") - val name: String = "", - - @ColumnInfo(name="price") - val price: Int = 0 -) \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/mapper/Mapper.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/mapper/Mapper.kt deleted file mode 100644 index 42699118..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/mapper/Mapper.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.algokelvin.app.data.mapper - -import com.algokelvin.app.data.entity.Product -import com.algokelvin.app.ui.uimodel.ProductUIModel -import com.algokelvin.app.ui.uimodel.ProductsUIModel - -fun Product?.mapToUiModel() = ProductUIModel( - id = this?.id?: 0, - name = this?.name?: "", - price = this?.price?: 0 -) - -fun List?.mapToUiModel() = ProductsUIModel( - data = this?.map { - it.mapToUiModel() - }?: listOf() -) \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepository.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepository.kt deleted file mode 100644 index b90bccd0..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepository.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.app.data.repository - -import com.algokelvin.app.data.Resource -import com.algokelvin.app.data.entity.Product -import kotlinx.coroutines.flow.Flow - -interface ProductRepository { - fun products(): Flow>> - fun productById(id: Int): Flow -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepositoryImpl.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepositoryImpl.kt deleted file mode 100644 index 03d94a8d..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/data/repository/ProductRepositoryImpl.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.algokelvin.app.data.repository - -import com.algokelvin.app.data.NetworkBoundResource -import com.algokelvin.app.data.Resource -import com.algokelvin.app.data.datasource.local.ProductDao -import com.algokelvin.app.data.datasource.remote.ProductServices -import com.algokelvin.app.data.entity.Product -import kotlinx.coroutines.flow.Flow - -class ProductRepositoryImpl(private val localSource: ProductDao, private val remoteSource: ProductServices): ProductRepository { - - override fun products(): Flow>> { - return NetworkBoundResource( - query = { localSource.products() }, - fetch = { remoteSource.products() }, - saveFetchResult = { localSource.insertAll(it) } - ).asFlow() - } - - override fun productById(id: Int): Flow { - return localSource.productBy(id) - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/di/DependencyFactory.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/di/DependencyFactory.kt deleted file mode 100644 index ff1644ad..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/di/DependencyFactory.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.algokelvin.app.di - -import android.content.Context -import com.algokelvin.app.domain.GetProductByIdUseCase -import com.algokelvin.app.domain.GetProductsUseCase -import com.algokelvin.app.model.datasource.local.ProductDatabase -import com.algokelvin.app.model.datasource.remote.RemoteProductFactory -import com.algokelvin.app.model.repository.ProductRepository -import com.algokelvin.app.model.repository.ProductRepositoryImpl -import com.algokelvin.app.ui.main.MainViewModel -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Dispatchers - -object DependencyFactory { - - fun buildMainViewModel(context: Context): MainViewModel { - val repository = provideProductRepository(context) - val dispatcherIo = Dispatchers.IO - - val provideProductsUseCase = provideProductsUseCase(repository, dispatcherIo) - val provideGetProductByIdUseCase = provideGetProductByIdUseCase(repository, dispatcherIo) - return provideMainViewModel(provideProductsUseCase, provideGetProductByIdUseCase) - } - - private fun provideMainViewModel( - getProductsUseCase: GetProductsUseCase, - getProductByIdUseCase: GetProductByIdUseCase - ) = MainViewModel(getProductByIdUseCase, getProductsUseCase) - - private fun provideProductsUseCase( - repository: ProductRepository, - dispatcher: CoroutineDispatcher - ) = GetProductsUseCase(repository, dispatcher) - - private fun provideGetProductByIdUseCase( - repository: ProductRepository, - dispatcher: CoroutineDispatcher - ) = GetProductByIdUseCase(repository, dispatcher) - - private fun provideProductRepository(context: Context): ProductRepository { - return ProductRepositoryImpl( - localSource = ProductDatabase.instance(context).productDao(), - remoteSource = RemoteProductFactory() - ) - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductByIdUseCase.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductByIdUseCase.kt deleted file mode 100644 index 49360110..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductByIdUseCase.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.algokelvin.app.domain - -import com.algokelvin.app.base.UseCase -import com.algokelvin.app.model.Resource -import com.algokelvin.app.model.mapper.mapToUiModel -import com.algokelvin.app.model.repository.ProductRepository -import com.algokelvin.app.model.uimodel.ProductUIModel -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -class GetProductByIdUseCase( - private val repository: ProductRepository, - dispatcher: CoroutineDispatcher -): UseCase(dispatcher) { - - override fun execute(param: Int): Flow> { - return repository.productBy(param).map { - Resource.success(it.mapToUiModel()) - } - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductsUseCase.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductsUseCase.kt deleted file mode 100644 index 0b321b7d..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/domain/GetProductsUseCase.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.algokelvin.app.domain - -import com.algokelvin.app.base.UseCase -import com.algokelvin.app.model.Resource -import com.algokelvin.app.model.mapper.mapToUiModel -import com.algokelvin.app.model.repository.ProductRepository -import com.algokelvin.app.model.uimodel.ProductsUIModel -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -class GetProductsUseCase ( - private val repository: ProductRepository, - dispatcher: CoroutineDispatcher -) : UseCase(dispatcher) { - - override fun execute(param: Unit): Flow> { - return repository.products().map { - when(it.status) { - Resource.Status.SUCCESS -> Resource.success(it.data.mapToUiModel()) - else -> Resource.error(it.message ?: "") - } - } - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/NetworkBoundResource.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/NetworkBoundResource.kt deleted file mode 100644 index 281c1a5b..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/NetworkBoundResource.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.algokelvin.app.model - -import kotlinx.coroutines.flow.* - -/* -* This is the strategy util to make a data request -* supported offline-mode using Flow. -* */ -class NetworkBoundResource( - val query: () -> Flow, // first, getting the data from local db - val fetch: suspend () -> T, // then, fetch the data from network - val saveFetchResult: (T) -> Unit, // after getting the data from network, save it into local db - val onFetchFailed: (Throwable) -> Unit = {}, // handling fetch failed if any - val isShouldFetch: (T) -> Boolean = { _ -> true } // is it need to fetch to network or not (default: true) -) { - - fun asFlow(): Flow> = flow { - val flow = query() - .onStart { emit(Resource.loading(null)) } - .flatMapConcat { data -> - if (isShouldFetch(data)) { - emit(Resource.loading(data)) - - try { - saveFetchResult(fetch()) - query().map { - Resource.success(it) - } - } catch (throwable: Throwable) { - onFetchFailed(throwable) - query().map { - Resource.error(throwable.message?: "", null) - } - } - } else { - query().map { - Resource.success(it) - } - } - } - - emitAll(flow) - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/Resource.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/Resource.kt deleted file mode 100644 index 3c659e14..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/Resource.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.algokelvin.app.model - -data class Resource(val status: Status, val data: T?, val message: String?) { - - enum class Status { SUCCESS, ERROR, LOADING } - - companion object { - fun success(data: T): Resource { - return Resource(Status.SUCCESS, data, null) - } - - fun error(message: String, data: T? = null): Resource { - return Resource(Status.ERROR, data, message) - } - - fun loading(data: T? = null): Resource { - return Resource(Status.LOADING, data, null) - } - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDao.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDao.kt deleted file mode 100644 index dfc22797..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDao.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.algokelvin.app.model.datasource.local - -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import com.algokelvin.app.model.entity.Product -import kotlinx.coroutines.flow.Flow - -@Dao -interface ProductDao { - @Query("SELECT * FROM product") - fun products(): Flow> - - @JvmSuppressWildcards - @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insertAll(products: List) - - @Insert - fun insert(product: Product) - - @Query("SELECT * FROM product WHERE id=:id") - fun productBy(id: Int): Flow -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDatabase.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDatabase.kt deleted file mode 100644 index ae5c4c64..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/local/ProductDatabase.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.algokelvin.app.model.datasource.local - -import android.content.Context -import androidx.room.Database -import androidx.room.Room -import androidx.room.RoomDatabase -import com.algokelvin.app.model.entity.Product - -@Database(entities = [Product::class], version = 1) -abstract class ProductDatabase: RoomDatabase() { - abstract fun productDao(): ProductDao - - companion object { - private const val DB_NAME = "product_data" - @Volatile private var INSTANCE: ProductDatabase? = null - - fun instance(context: Context): ProductDatabase { - return INSTANCE?: synchronized(this) { - Room.databaseBuilder( - context.applicationContext, - ProductDatabase::class.java, - DB_NAME - ).fallbackToDestructiveMigration() - .build() - .also { INSTANCE = it } - } - } - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/ProductServices.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/ProductServices.kt deleted file mode 100644 index 128bac2a..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/ProductServices.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.app.model.datasource.remote - -import com.algokelvin.app.model.entity.Product - -interface ProductServices { - fun products(): List - fun productBy(id: Int): Product -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/RemoteProductFactory.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/RemoteProductFactory.kt deleted file mode 100644 index 8b5cfd4a..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/datasource/remote/RemoteProductFactory.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.algokelvin.app.model.datasource.remote - -import com.algokelvin.app.model.entity.Product - -class RemoteProductFactory: ProductServices { - - private val products = listOf( - Product(id = 1, name = "iPhone", price = 1000), - Product(id = 2, name = "Android", price = 2000), - Product(id = 3, name = "Huawei", price = 3000), - Product(id = 4, name = "Xiaomi", price = 4000), - Product(id = 5, name = "Samsung", price = 5000), - ) - - override fun products(): List { - return products - } - - override fun productBy(id: Int): Product { - return products.first { it.id == id } - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/entity/Product.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/entity/Product.kt deleted file mode 100644 index 7c8e1915..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/entity/Product.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.algokelvin.app.model.entity - -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey - -@Entity(tableName = "product") -data class Product ( - @PrimaryKey(autoGenerate = true) - @ColumnInfo(name = "id") - val id: Int = 0, - - @ColumnInfo(name = "name") - val name: String = "", - - @ColumnInfo(name = "price") - val price: Int = 0 -) \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/mapper/Mapper.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/mapper/Mapper.kt deleted file mode 100644 index d6f98b2c..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/mapper/Mapper.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.algokelvin.app.model.mapper - -import com.algokelvin.app.model.entity.Product -import com.algokelvin.app.model.uimodel.ProductUIModel -import com.algokelvin.app.model.uimodel.ProductsUIModel - -fun List?.mapToUiModel() = ProductsUIModel( - data = this?.map { - it.mapToUiModel() - }?: listOf() -) - -fun Product?.mapToUiModel() = ProductUIModel( - id = this?.id?: 0, - name = this?.name?: "", - price = this?.price?: 0 -) \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepository.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepository.kt deleted file mode 100644 index 3f0fe42d..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepository.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.app.model.repository - -import com.algokelvin.app.model.Resource -import com.algokelvin.app.model.entity.Product -import kotlinx.coroutines.flow.Flow - -interface ProductRepository { - fun products(): Flow>> - fun productBy(id: Int): Flow -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepositoryImpl.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepositoryImpl.kt deleted file mode 100644 index 20053a06..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/repository/ProductRepositoryImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.algokelvin.app.model.repository - -import com.algokelvin.app.model.NetworkBoundResource -import com.algokelvin.app.model.Resource -import com.algokelvin.app.model.datasource.local.ProductDao -import com.algokelvin.app.model.datasource.remote.ProductServices -import com.algokelvin.app.model.entity.Product -import kotlinx.coroutines.flow.Flow - -class ProductRepositoryImpl( - private val localSource: ProductDao, - private val remoteSource: ProductServices -): ProductRepository { - - override fun products(): Flow>> { - return NetworkBoundResource( - query = { localSource.products() }, - fetch = { remoteSource.products() }, - saveFetchResult = { localSource.insertAll(it) } - ).asFlow() - } - - override fun productBy(id: Int): Flow { - return localSource.productBy(id) - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductUIModel.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductUIModel.kt deleted file mode 100644 index 3c1ce12c..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductUIModel.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.app.model.uimodel - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class ProductUIModel( - var id: Int = 0, - var name: String = "", - var price: Int = 0 -) : Parcelable \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductsUIModel.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductsUIModel.kt deleted file mode 100644 index 68596e5e..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/model/uimodel/ProductsUIModel.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.app.model.uimodel - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class ProductsUIModel(var data: List = emptyList()) : Parcelable \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/adapter/ProductAdapter.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/adapter/ProductAdapter.kt deleted file mode 100644 index 8a1cbf09..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/adapter/ProductAdapter.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.algokelvin.app.ui.adapter - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.algokelvin.app.databinding.ItemProductBinding -import com.algokelvin.app.model.uimodel.ProductUIModel -import com.algokelvin.app.model.uimodel.ProductsUIModel - -class ProductAdapter( - private val items: MutableList = mutableListOf(), - private val onItemClicked: (ProductUIModel) -> Unit -): RecyclerView.Adapter() { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductViewHolder { - return ProductViewHolder.create(parent, onItemClicked) - } - - override fun onBindViewHolder(holder: ProductViewHolder, position: Int) { - holder.bind(items[position]) - } - - override fun getItemCount() = items.size - - fun addAll(products: ProductsUIModel) { - items.clear() - items.addAll(products.data) - notifyDataSetChanged() - } - - class ProductViewHolder constructor( - private val binding: ItemProductBinding, - private val onItemClicked: (ProductUIModel) -> Unit - ): RecyclerView.ViewHolder(binding.root) { - - fun bind(model: ProductUIModel) { - binding.txtName.text = model.name - - itemView.setOnClickListener { - onItemClicked(model) - } - } - - companion object { - fun create( - container: ViewGroup, - onItemClicked: (ProductUIModel) -> Unit - ): ProductViewHolder { - val inflate = LayoutInflater.from(container.context) - return ProductViewHolder( - ItemProductBinding.inflate( - inflate, - container, - false - ), - onItemClicked - ) - } - } - - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/detail/ProductDetailBottomSheet.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/detail/ProductDetailBottomSheet.kt deleted file mode 100644 index e9d0c3f6..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/detail/ProductDetailBottomSheet.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.algokelvin.app.ui.detail - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.FragmentManager -import com.algokelvin.app.databinding.DialogProductDetailBinding -import com.algokelvin.app.model.uimodel.ProductUIModel -import com.google.android.material.bottomsheet.BottomSheetDialogFragment - -class ProductDetailBottomSheet : BottomSheetDialogFragment() { - private var _binding: DialogProductDetailBinding? = null - private val binding: DialogProductDetailBinding get() = _binding!! - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - _binding = DialogProductDetailBinding.inflate(inflater, container, false) - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initView() - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - } - - private fun initView() { - arguments?.let { - val data = it.getParcelable(KEY_PRODUCT_DETAIL)?: return - - binding.txtName.text = data.name - binding.txtPrice.text = priceIdr(data.price) - } - } - - private fun priceIdr(price: Int): String { - return "Rp.$price,-" - } - - companion object { - private val TAG = ProductDetailBottomSheet::class.java.name - - private const val KEY_PRODUCT_DETAIL = "product_detail" - - fun show(fm: FragmentManager, product: ProductUIModel) { - val sheet = ProductDetailBottomSheet() - sheet.arguments = Bundle().apply { - putParcelable(KEY_PRODUCT_DETAIL, product) - } - sheet.show(fm, TAG) - } - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainActivity.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainActivity.kt deleted file mode 100644 index c8f0c91e..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainActivity.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.algokelvin.app.ui.main - -import android.os.Bundle -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.app.base.BaseActivity -import com.algokelvin.app.databinding.ActivityMainBinding -import com.algokelvin.app.model.Resource -import com.algokelvin.app.model.uimodel.ProductUIModel -import com.algokelvin.app.ui.adapter.ProductAdapter -import com.algokelvin.app.ui.detail.ProductDetailBottomSheet - -class MainActivity : BaseActivity() { - private lateinit var binding: ActivityMainBinding - - private val productAdapter by lazy { ProductAdapter(onItemClicked = ::onItemProductClicked) } - private val mainViewModelFactory by lazy { MainViewModelFactory(applicationContext) } - private val mainViewModel by lazy { - ViewModelProvider(this, mainViewModelFactory)[MainViewModel::class.java] - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) - setContentView(binding.root) - - initView() - getAllProducts() - getDetailProductById() - } - - private fun initView() { - binding.listProduct.adapter = productAdapter - } - - private fun getAllProducts() { - mainViewModel.products.observe(this, { - when(it.status) { - Resource.Status.SUCCESS -> productAdapter.addAll(it.data!!) - Resource.Status.LOADING -> toast("Getting the list of product") - Resource.Status.ERROR -> {} - } - }) - } - - private fun getDetailProductById() { - mainViewModel.productById.observe(this, { - when(it.status) { - Resource.Status.SUCCESS -> it.data?.let { product -> showProductDetailSheet(product) } - Resource.Status.LOADING -> toast("Getting the product detail info") - Resource.Status.ERROR -> {} - } - }) - } - - private fun showProductDetailSheet(product: ProductUIModel) { - ProductDetailBottomSheet.show(fm = supportFragmentManager, product = product) - } - - private fun onItemProductClicked(product: ProductUIModel) { - mainViewModel.productId(product.id) - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModel.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModel.kt deleted file mode 100644 index cda97e4d..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModel.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.algokelvin.app.ui.main - -import androidx.lifecycle.* -import com.algokelvin.app.domain.* - -class MainViewModel( - private val getProductById: GetProductByIdUseCase, - getProducts: GetProductsUseCase -): ViewModel() { - - private val _productId = MutableLiveData() - val products = getProducts(Unit).asLiveData() - val productById = _productId.switchMap { id -> - getProductById(id).asLiveData() - } - - fun productId(id: Int) { - _productId.value = id - } - -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModelFactory.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModelFactory.kt deleted file mode 100644 index 613fc0b3..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/main/MainViewModelFactory.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.algokelvin.app.ui.main - -import android.content.Context -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.app.di.DependencyFactory -import java.lang.IllegalArgumentException - -class MainViewModelFactory(private val context: Context): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return if (modelClass.isAssignableFrom(MainViewModel::class.java)) { - DependencyFactory.buildMainViewModel(context) as T - } else { - throw IllegalArgumentException("ViewModel not found") - } - } -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductUIModel.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductUIModel.kt deleted file mode 100644 index 8acb5fd6..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductUIModel.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.app.ui.uimodel - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class ProductUIModel( - var id: Int = 0, - var name: String = "", - var price: Int = 0 -) : Parcelable \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductsUIModel.kt b/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductsUIModel.kt deleted file mode 100644 index 0a7833d6..00000000 --- a/CleanArchitectureMVVM/app/src/main/java/com/algokelvin/app/ui/uimodel/ProductsUIModel.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.algokelvin.app.ui.uimodel - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class ProductsUIModel( - var data: List = emptyList() -) : Parcelable \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/drawable/ic_launcher_background.xml b/CleanArchitectureMVVM/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CleanArchitectureMVVM/app/src/main/res/layout/activity_main.xml b/CleanArchitectureMVVM/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 8249276f..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/layout/dialog_product_detail.xml b/CleanArchitectureMVVM/app/src/main/res/layout/dialog_product_detail.xml deleted file mode 100644 index a75d798a..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/layout/dialog_product_detail.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/layout/item_product.xml b/CleanArchitectureMVVM/app/src/main/res/layout/item_product.xml deleted file mode 100644 index 6fe794f7..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/layout/item_product.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a571e600..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 61da551c..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c41dd285..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index db5080a7..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 6dba46da..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index da31a871..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 15ac6817..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index b216f2d3..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index f25a4197..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index e96783cc..00000000 Binary files a/CleanArchitectureMVVM/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/CleanArchitectureMVVM/app/src/main/res/values-night/themes.xml b/CleanArchitectureMVVM/app/src/main/res/values-night/themes.xml deleted file mode 100644 index a6c0e208..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/values/colors.xml b/CleanArchitectureMVVM/app/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127d..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/values/strings.xml b/CleanArchitectureMVVM/app/src/main/res/values/strings.xml deleted file mode 100644 index c378d60e..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - MVVM_CleanArch_App - \ No newline at end of file diff --git a/CleanArchitectureMVVM/app/src/main/res/values/themes.xml b/CleanArchitectureMVVM/app/src/main/res/values/themes.xml deleted file mode 100644 index 38fe1bdf..00000000 --- a/CleanArchitectureMVVM/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/CleanArchitectureMVVM/build.gradle b/CleanArchitectureMVVM/build.gradle deleted file mode 100644 index 602817e6..00000000 --- a/CleanArchitectureMVVM/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext { - kotlin_version = "1.4.32" - roomVersion = "2.3.0" - } - repositories { - google() - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:4.2.0" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - //jcenter() // Warning: this repository is going to shut down soon - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/CleanArchitectureMVVM/gradle.properties b/CleanArchitectureMVVM/gradle.properties deleted file mode 100644 index 25217527..00000000 --- a/CleanArchitectureMVVM/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file diff --git a/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.jar b/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd..00000000 Binary files a/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.properties b/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 7a15355f..00000000 --- a/CleanArchitectureMVVM/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon Oct 18 20:24:53 WIB 2021 -distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip -distributionPath=wrapper/dists -zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME diff --git a/CleanArchitectureMVVM/gradlew b/CleanArchitectureMVVM/gradlew deleted file mode 100644 index cccdd3d5..00000000 --- a/CleanArchitectureMVVM/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/CleanArchitectureMVVM/gradlew.bat b/CleanArchitectureMVVM/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/CleanArchitectureMVVM/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/CleanArchitectureMVVM/settings.gradle b/CleanArchitectureMVVM/settings.gradle deleted file mode 100644 index 9ad6d48c..00000000 --- a/CleanArchitectureMVVM/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "MVVM_CleanArch_App" -include ':app' diff --git a/BirthdayCardCompose/.gitignore b/ComposeTextImage/.gitignore similarity index 100% rename from BirthdayCardCompose/.gitignore rename to ComposeTextImage/.gitignore diff --git a/ComposeTextImage/README.md b/ComposeTextImage/README.md new file mode 100644 index 00000000..3fa6505f --- /dev/null +++ b/ComposeTextImage/README.md @@ -0,0 +1,4 @@ +# Compose Text Image + +--- VERSION --- +- 1.0.0 : Create APK Project \ No newline at end of file diff --git a/AnimationApp/app/.gitignore b/ComposeTextImage/app/.gitignore similarity index 100% rename from AnimationApp/app/.gitignore rename to ComposeTextImage/app/.gitignore diff --git a/ComposeTextImage/app/build.gradle b/ComposeTextImage/app/build.gradle new file mode 100644 index 00000000..2b2f7505 --- /dev/null +++ b/ComposeTextImage/app/build.gradle @@ -0,0 +1,66 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrains.kotlin.android) +} + +android { + namespace 'com.algokelvin.imagetext' + compileSdk 35 + + defaultConfig { + applicationId "com.algokelvin.imagetext" + minSdk 24 + targetSdk 35 + versionCode 1 + versionName "1.0.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary true + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + compose true + viewBinding true + } + composeOptions { + kotlinCompilerExtensionVersion '1.5.1' + } + packaging { + resources { + excludes += '/META-INF/{AL2.0,LGPL2.1}' + } + } +} + +dependencies { + implementation libs.androidx.core.ktx + implementation libs.androidx.lifecycle.runtime.ktx + implementation libs.androidx.activity.compose + implementation platform(libs.androidx.compose.bom) + implementation libs.androidx.ui + implementation libs.androidx.ui.graphics + implementation libs.androidx.ui.tooling.preview + implementation libs.androidx.material3 + testImplementation libs.junit + androidTestImplementation libs.androidx.junit + androidTestImplementation libs.androidx.espresso.core + androidTestImplementation platform(libs.androidx.compose.bom) + androidTestImplementation libs.androidx.ui.test.junit4 + debugImplementation libs.androidx.ui.tooling + debugImplementation libs.androidx.ui.test.manifest +} \ No newline at end of file diff --git a/AnimationApp/app/proguard-rules.pro b/ComposeTextImage/app/proguard-rules.pro similarity index 100% rename from AnimationApp/app/proguard-rules.pro rename to ComposeTextImage/app/proguard-rules.pro diff --git a/ImageText/app/src/androidTest/java/com/algokelvin/imagetext/ExampleInstrumentedTest.kt b/ComposeTextImage/app/src/androidTest/java/com/algokelvin/imagetext/ExampleInstrumentedTest.kt similarity index 100% rename from ImageText/app/src/androidTest/java/com/algokelvin/imagetext/ExampleInstrumentedTest.kt rename to ComposeTextImage/app/src/androidTest/java/com/algokelvin/imagetext/ExampleInstrumentedTest.kt diff --git a/ImageTextCompose/app/src/main/AndroidManifest.xml b/ComposeTextImage/app/src/main/AndroidManifest.xml similarity index 100% rename from ImageTextCompose/app/src/main/AndroidManifest.xml rename to ComposeTextImage/app/src/main/AndroidManifest.xml diff --git a/ComposeTextImage/app/src/main/ic_launcher-playstore.png b/ComposeTextImage/app/src/main/ic_launcher-playstore.png new file mode 100644 index 00000000..afeecb3b Binary files /dev/null and b/ComposeTextImage/app/src/main/ic_launcher-playstore.png differ diff --git a/ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/MainActivity.kt b/ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/MainActivity.kt similarity index 100% rename from ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/MainActivity.kt rename to ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/MainActivity.kt diff --git a/ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Color.kt b/ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Color.kt similarity index 100% rename from ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Color.kt rename to ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Color.kt diff --git a/ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Theme.kt b/ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Theme.kt similarity index 100% rename from ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Theme.kt rename to ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Theme.kt diff --git a/ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Type.kt b/ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Type.kt similarity index 100% rename from ImageTextCompose/app/src/main/java/com/algokelvin/imagetext/ui/theme/Type.kt rename to ComposeTextImage/app/src/main/java/com/algokelvin/imagetext/ui/theme/Type.kt diff --git a/ImageTextCompose/app/src/main/res/drawable/ic_compose.png b/ComposeTextImage/app/src/main/res/drawable/ic_compose.png similarity index 100% rename from ImageTextCompose/app/src/main/res/drawable/ic_compose.png rename to ComposeTextImage/app/src/main/res/drawable/ic_compose.png diff --git a/ComposeTextImage/app/src/main/res/drawable/ic_launcher_background.xml b/ComposeTextImage/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..ca3826a4 --- /dev/null +++ b/ComposeTextImage/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BirthdayCardCompose/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ComposeTextImage/app/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from BirthdayCardCompose/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to ComposeTextImage/app/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/ImageTextCompose/app/src/main/res/layout/activity_main.xml b/ComposeTextImage/app/src/main/res/layout/activity_main.xml similarity index 100% rename from ImageTextCompose/app/src/main/res/layout/activity_main.xml rename to ComposeTextImage/app/src/main/res/layout/activity_main.xml diff --git a/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..c4a603d4 --- /dev/null +++ b/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..c4a603d4 --- /dev/null +++ b/ComposeTextImage/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000..1f4c0d01 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..7b289835 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000..1a6ccc46 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000..559e666e Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..cd0a7975 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000..617fd9ea Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000..5efb6422 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..bcae5e61 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..0cb98685 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000..ee8d549c Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..f8f8d033 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..ef80d15c Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000..b4e0005b Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..fed1a6c4 Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..31b5df0a Binary files /dev/null and b/ComposeTextImage/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/AnimationApp/app/src/main/res/values/colors.xml b/ComposeTextImage/app/src/main/res/values/colors.xml similarity index 100% rename from AnimationApp/app/src/main/res/values/colors.xml rename to ComposeTextImage/app/src/main/res/values/colors.xml diff --git a/ImageTextCompose/app/src/main/res/values/strings.xml b/ComposeTextImage/app/src/main/res/values/strings.xml similarity index 100% rename from ImageTextCompose/app/src/main/res/values/strings.xml rename to ComposeTextImage/app/src/main/res/values/strings.xml diff --git a/ImageTextCompose/app/src/main/res/values/themes.xml b/ComposeTextImage/app/src/main/res/values/themes.xml similarity index 100% rename from ImageTextCompose/app/src/main/res/values/themes.xml rename to ComposeTextImage/app/src/main/res/values/themes.xml diff --git a/BirthdayCardCompose/app/src/main/res/xml/backup_rules.xml b/ComposeTextImage/app/src/main/res/xml/backup_rules.xml similarity index 100% rename from BirthdayCardCompose/app/src/main/res/xml/backup_rules.xml rename to ComposeTextImage/app/src/main/res/xml/backup_rules.xml diff --git a/CalculatorCompose/app/src/main/res/xml/data_extraction_rules.xml b/ComposeTextImage/app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from CalculatorCompose/app/src/main/res/xml/data_extraction_rules.xml rename to ComposeTextImage/app/src/main/res/xml/data_extraction_rules.xml diff --git a/ImageText/app/src/test/java/com/algokelvin/imagetext/ExampleUnitTest.kt b/ComposeTextImage/app/src/test/java/com/algokelvin/imagetext/ExampleUnitTest.kt similarity index 100% rename from ImageText/app/src/test/java/com/algokelvin/imagetext/ExampleUnitTest.kt rename to ComposeTextImage/app/src/test/java/com/algokelvin/imagetext/ExampleUnitTest.kt diff --git a/CalculatorCompose/build.gradle b/ComposeTextImage/build.gradle similarity index 100% rename from CalculatorCompose/build.gradle rename to ComposeTextImage/build.gradle diff --git a/ECommerce/gradle.properties b/ComposeTextImage/gradle.properties similarity index 100% rename from ECommerce/gradle.properties rename to ComposeTextImage/gradle.properties diff --git a/ComposeTextImage/gradle/libs.versions.toml b/ComposeTextImage/gradle/libs.versions.toml new file mode 100644 index 00000000..c0e28329 --- /dev/null +++ b/ComposeTextImage/gradle/libs.versions.toml @@ -0,0 +1,31 @@ +[versions] +agp = "8.10.1" +kotlin = "1.9.0" +coreKtx = "1.15.0" +junit = "4.13.2" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +lifecycleRuntimeKtx = "2.8.7" +activityCompose = "1.10.1" +composeBom = "2024.04.01" + +[libraries] +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } +androidx-material3 = { group = "androidx.compose.material3", name = "material3" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + diff --git a/CalculatorCompose/gradle/wrapper/gradle-wrapper.jar b/ComposeTextImage/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from CalculatorCompose/gradle/wrapper/gradle-wrapper.jar rename to ComposeTextImage/gradle/wrapper/gradle-wrapper.jar diff --git a/ComposeTextImage/gradle/wrapper/gradle-wrapper.properties b/ComposeTextImage/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..eed34ba2 --- /dev/null +++ b/ComposeTextImage/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Mar 11 15:45:16 WIB 2025 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/CalculatorCompose/gradlew b/ComposeTextImage/gradlew similarity index 100% rename from CalculatorCompose/gradlew rename to ComposeTextImage/gradlew diff --git a/CalculatorCompose/gradlew.bat b/ComposeTextImage/gradlew.bat similarity index 100% rename from CalculatorCompose/gradlew.bat rename to ComposeTextImage/gradlew.bat diff --git a/ImageText/settings.gradle b/ComposeTextImage/settings.gradle similarity index 100% rename from ImageText/settings.gradle rename to ComposeTextImage/settings.gradle diff --git a/ConnectHealthApp/.idea/workspace.xml b/ConnectHealthApp/.idea/workspace.xml new file mode 100644 index 00000000..8f263305 --- /dev/null +++ b/ConnectHealthApp/.idea/workspace.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + 1757152979077 + + + + \ No newline at end of file diff --git a/CountNumberCompose/README.md b/CountNumberCompose/README.md deleted file mode 100644 index 5c182ee5..00000000 --- a/CountNumberCompose/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Count Number Compose - -| ![Gambar 1](./documentation/SS_CountNumberCompose_01.jpg) | ![Gambar 2](./documentation/SS_CountNumberCompose_02.jpg) | ![Gambar 3](./documentation/SS_CountNumberCompose_03.jpg) | -|:---------------------------------------------------------:|:---------------------------------------------------------:|:---------------------------------------------------------:| -| Gambar 1: Page Count 1 | Gambar 2: Page Count 2 | Gambar 3: Page Count 3 | - -## Implementation -- Jetpack Compose - -## Environment -- **Android Gradle**: 8.5.0 -- **Plugins Version**: 8.7 -- **Gradle Version**: 8.0 -- **Java JDK**: 17 -- **Kotlin Version**: 1.9.0 -- **Min SDK**: 21 -- **Target SDK**: 34 - -## Contributors -Thanks all contributors for build this repository - -``` -Copyright [2021] [The Dictionary of Android Projects] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -``` diff --git a/CountNumberCompose/app/build.gradle b/CountNumberCompose/app/build.gradle deleted file mode 100644 index 6fa91d26..00000000 --- a/CountNumberCompose/app/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - namespace 'algokelvin.app.countnumbercompose' - compileSdk 32 - - defaultConfig { - applicationId "algokelvin.app.countnumbercompose" - minSdk 21 - targetSdk 32 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion '1.1.1' - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' - implementation "androidx.compose.ui:ui:$compose_ui_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" - implementation 'androidx.compose.material:material:1.1.1' - - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version" -} \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/AndroidManifest.xml b/CountNumberCompose/app/src/main/AndroidManifest.xml deleted file mode 100644 index 51343a3b..00000000 --- a/CountNumberCompose/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/MainActivity.kt b/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/MainActivity.kt deleted file mode 100644 index fe434510..00000000 --- a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/MainActivity.kt +++ /dev/null @@ -1,120 +0,0 @@ -package algokelvin.app.countnumbercompose - -import android.content.Context -import android.os.Bundle -import android.widget.Toast -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.* -import androidx.compose.runtime.* -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import algokelvin.app.countnumbercompose.ui.theme.EffectsDemo1Theme -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch - -class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - EffectsDemo1Theme { - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colors.background - ) { - MainScreen() - } - } - } - } -} - -@Preview -@Composable -fun MainScreen( - modifier: Modifier = Modifier, - context: Context = LocalContext.current -) { - var round by remember { mutableStateOf(1) } - var total by remember { mutableStateOf(0.0) } - var input by remember { mutableStateOf("") } - - val scaffoldState: ScaffoldState = rememberScaffoldState() - val coroutineScope: CoroutineScope = rememberCoroutineScope() - - Scaffold(scaffoldState = scaffoldState) { - // LaunchedEffect - LaunchedEffect(key1 = round) { - Toast.makeText(context, context.getString(R.string.start_your_app), Toast.LENGTH_LONG).show() // Using Toast - scaffoldState.snackbarHostState.showSnackbar( // Using scaffoldState - message = context.getString(R.string.enjoy_this), - duration = SnackbarDuration.Short - ) - } - - Column( - modifier = Modifier - .fillMaxSize() - .padding(40.dp), - verticalArrangement = Arrangement.spacedBy(8.dp) - ) { - Text( - text = context.getString(R.string.total_count, total.toString()), - fontWeight = FontWeight.Bold, - fontSize = 30.sp, - color = Color.DarkGray - ) - OutlinedTextField( - placeholder = { Text(context.getString(R.string.enter_value)) }, - value = input, - onValueChange = { - input = it - }, - textStyle = TextStyle( - color = Color.LightGray, - fontSize = 30.sp, - fontWeight = FontWeight.Bold - ), - label = { - Text( - text = context.getString(R.string.new_count), - fontSize = 30.sp - )}, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) - ) - - Button( - onClick = { - total += input.toDouble() - coroutineScope.launch { - scaffoldState.snackbarHostState.showSnackbar( - message = context.getString(R.string.count_updated), - duration = SnackbarDuration.Short - ) - } - if (total > 300) { - total = 0.0 - input = "" - round++ - } - } - ) { - Text( - text = context.getString(R.string.count), - fontSize = 30.sp, - fontWeight = FontWeight.Bold - ) - } - } - } -} - diff --git a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Color.kt b/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Color.kt deleted file mode 100644 index 1dc14b6e..00000000 --- a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Color.kt +++ /dev/null @@ -1,8 +0,0 @@ -package algokelvin.app.countnumbercompose.ui.theme - -import androidx.compose.ui.graphics.Color - -val Purple200 = Color(0xFFBB86FC) -val Purple500 = Color(0xFF6200EE) -val Purple700 = Color(0xFF3700B3) -val Teal200 = Color(0xFF03DAC5) \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Shape.kt b/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Shape.kt deleted file mode 100644 index ea2d6aa6..00000000 --- a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Shape.kt +++ /dev/null @@ -1,11 +0,0 @@ -package algokelvin.app.countnumbercompose.ui.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes -import androidx.compose.ui.unit.dp - -val Shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) -) \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Theme.kt b/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Theme.kt deleted file mode 100644 index 906e596d..00000000 --- a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Theme.kt +++ /dev/null @@ -1,44 +0,0 @@ -package algokelvin.app.countnumbercompose.ui.theme - -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors -import androidx.compose.runtime.Composable - -private val DarkColorPalette = darkColors( - primary = Purple200, - primaryVariant = Purple700, - secondary = Teal200 -) - -private val LightColorPalette = lightColors( - primary = Purple500, - primaryVariant = Purple700, - secondary = Teal200 - - /* Other default colors to override - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black, - */ -) - -@Composable -fun EffectsDemo1Theme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { - val colors = if (darkTheme) { - DarkColorPalette - } else { - LightColorPalette - } - - MaterialTheme( - colors = colors, - typography = Typography, - shapes = Shapes, - content = content - ) -} \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Type.kt b/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Type.kt deleted file mode 100644 index d9d69452..00000000 --- a/CountNumberCompose/app/src/main/java/algokelvin/app/countnumbercompose/ui/theme/Type.kt +++ /dev/null @@ -1,28 +0,0 @@ -package algokelvin.app.countnumbercompose.ui.theme - -import androidx.compose.material.Typography -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.sp - -// Set of Material typography styles to start with -val Typography = Typography( - body1 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp - ) - /* Other default text styles to override - button = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp - ), - caption = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp - ) - */ -) \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/res/drawable/ic_launcher_background.xml b/CountNumberCompose/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/CountNumberCompose/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe..00000000 --- a/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe..00000000 --- a/CountNumberCompose/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/res/values/colors.xml b/CountNumberCompose/app/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127d..00000000 --- a/CountNumberCompose/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/res/values/strings.xml b/CountNumberCompose/app/src/main/res/values/strings.xml deleted file mode 100644 index f3283997..00000000 --- a/CountNumberCompose/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,10 +0,0 @@ - - EffectsDemo1 - Start Your App - Enjoy This - Enter value here - New count - Count Updated - Count - Total is %s - \ No newline at end of file diff --git a/CountNumberCompose/app/src/main/res/values/themes.xml b/CountNumberCompose/app/src/main/res/values/themes.xml deleted file mode 100644 index 78e632f3..00000000 --- a/CountNumberCompose/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CountNumberCompose/build.gradle b/CountNumberCompose/build.gradle deleted file mode 100644 index 551dfef3..00000000 --- a/CountNumberCompose/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -buildscript { - ext { - compose_ui_version = '1.1.1' - agp_version = '8.5.0' - } -}// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '8.5.0' apply false - id 'com.android.library' version '7.3.1' apply false - id 'org.jetbrains.kotlin.android' version '1.6.10' apply false -} \ No newline at end of file diff --git a/CountNumberCompose/documentation/SS_CountNumberCompose_01.jpg b/CountNumberCompose/documentation/SS_CountNumberCompose_01.jpg deleted file mode 100644 index b94e12d2..00000000 Binary files a/CountNumberCompose/documentation/SS_CountNumberCompose_01.jpg and /dev/null differ diff --git a/CountNumberCompose/documentation/SS_CountNumberCompose_02.jpg b/CountNumberCompose/documentation/SS_CountNumberCompose_02.jpg deleted file mode 100644 index 6107d77b..00000000 Binary files a/CountNumberCompose/documentation/SS_CountNumberCompose_02.jpg and /dev/null differ diff --git a/CountNumberCompose/documentation/SS_CountNumberCompose_03.jpg b/CountNumberCompose/documentation/SS_CountNumberCompose_03.jpg deleted file mode 100644 index 43d95772..00000000 Binary files a/CountNumberCompose/documentation/SS_CountNumberCompose_03.jpg and /dev/null differ diff --git a/CountNumberCompose/gradle.properties b/CountNumberCompose/gradle.properties deleted file mode 100644 index 3c5031eb..00000000 --- a/CountNumberCompose/gradle.properties +++ /dev/null @@ -1,23 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file diff --git a/CountNumberCompose/gradle/wrapper/gradle-wrapper.properties b/CountNumberCompose/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3c2d0b41..00000000 --- a/CountNumberCompose/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Feb 23 14:21:04 WIB 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/CountNumberCompose/settings.gradle b/CountNumberCompose/settings.gradle deleted file mode 100644 index a613e19b..00000000 --- a/CountNumberCompose/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - google() - mavenCentral() - } -} -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} -rootProject.name = "EffectsDemo1" -include ':app' diff --git a/DesignUIToast/README.md b/DesignUIToast/README.md deleted file mode 100644 index 920cff84..00000000 --- a/DesignUIToast/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Design UI Toast - -| ![Gambar 1](./documentation/SS_DesignUIToast.gif) | -|:-------------------------------------------------:| -| Gambar 1: Page Count 1 | - -## Implementation -- Kotlin Android Extensions - -## Environment -- **Android Gradle**: 8.5.0 -- **Plugins Version**: 8.7 -- **Gradle Version**: 8.0 -- **Java JDK**: 17 -- **Kotlin Version**: 1.9.0 -- **Min SDK**: 21 -- **Target SDK**: 34 - -## Contributors -Thanks all contributors for build this repository - -``` -Copyright [2021] [The Dictionary of Android Projects] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -``` diff --git a/DesignUIToast/app/build.gradle b/DesignUIToast/app/build.gradle deleted file mode 100644 index 30348039..00000000 --- a/DesignUIToast/app/build.gradle +++ /dev/null @@ -1,42 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-android-extensions' -} - -android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" - - defaultConfig { - applicationId "com.algokelvin.toastui" - minSdkVersion 16 - targetSdkVersion 30 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' -} \ No newline at end of file diff --git a/DesignUIToast/app/src/main/AndroidManifest.xml b/DesignUIToast/app/src/main/AndroidManifest.xml deleted file mode 100644 index 9cccf7c9..00000000 --- a/DesignUIToast/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/java/com/algokelvin/toastui/MainActivity.kt b/DesignUIToast/app/src/main/java/com/algokelvin/toastui/MainActivity.kt deleted file mode 100644 index 5070cc68..00000000 --- a/DesignUIToast/app/src/main/java/com/algokelvin/toastui/MainActivity.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.algokelvin.toastui - -import android.os.Bundle -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.google.android.material.snackbar.Snackbar -import kotlinx.android.synthetic.main.activity_main.* - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - btnToast.setOnClickListener { showWithToast() } - btnSnackBar.setOnClickListener { showWithSnackBar() } - } - - private fun showWithToast() { - Toast.makeText(this, "Show with Toast", Toast.LENGTH_LONG).show() - } - - private fun showWithSnackBar() { - Snackbar.make(coordinatorLayout, "Show with SnackBar", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - } - -} \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/drawable/ic_launcher_background.xml b/DesignUIToast/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/DesignUIToast/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe..00000000 --- a/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe..00000000 --- a/DesignUIToast/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher.png b/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a571e600..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 61da551c..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher.png b/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c41dd285..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index db5080a7..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 6dba46da..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index da31a871..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 15ac6817..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index b216f2d3..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index f25a4197..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index e96783cc..00000000 Binary files a/DesignUIToast/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/DesignUIToast/app/src/main/res/values-night/themes.xml b/DesignUIToast/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 477872c2..00000000 --- a/DesignUIToast/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/values/colors.xml b/DesignUIToast/app/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127d..00000000 --- a/DesignUIToast/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/values/strings.xml b/DesignUIToast/app/src/main/res/values/strings.xml deleted file mode 100644 index 29b728bc..00000000 --- a/DesignUIToast/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - ToastUI - Toast - SnackBar - \ No newline at end of file diff --git a/DesignUIToast/app/src/main/res/values/themes.xml b/DesignUIToast/app/src/main/res/values/themes.xml deleted file mode 100644 index e30aad5d..00000000 --- a/DesignUIToast/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/DesignUIToast/build.gradle b/DesignUIToast/build.gradle deleted file mode 100644 index 024b1f11..00000000 --- a/DesignUIToast/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext { - agp_version = '8.5.0' - } - ext.kotlin_version = "1.3.72" - repositories { - google() - jcenter() - } - dependencies { - classpath "com.android.tools.build:gradle:$agp_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/DesignUIToast/documentation/SS_DesignUIToast.gif b/DesignUIToast/documentation/SS_DesignUIToast.gif deleted file mode 100644 index 3e9c12d2..00000000 Binary files a/DesignUIToast/documentation/SS_DesignUIToast.gif and /dev/null differ diff --git a/DesignUIToast/gradle.properties b/DesignUIToast/gradle.properties deleted file mode 100644 index 98bed167..00000000 --- a/DesignUIToast/gradle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file diff --git a/DesignUIToast/gradle/wrapper/gradle-wrapper.jar b/DesignUIToast/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd..00000000 Binary files a/DesignUIToast/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/DesignUIToast/gradle/wrapper/gradle-wrapper.properties b/DesignUIToast/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 283ca013..00000000 --- a/DesignUIToast/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Feb 23 16:22:43 WIB 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/DesignUIToast/gradlew b/DesignUIToast/gradlew deleted file mode 100644 index cccdd3d5..00000000 --- a/DesignUIToast/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/DesignUIToast/gradlew.bat b/DesignUIToast/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/DesignUIToast/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/DesignUIToast/settings.gradle b/DesignUIToast/settings.gradle deleted file mode 100644 index 466d2651..00000000 --- a/DesignUIToast/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include ':app' -rootProject.name = "ToastUI" \ No newline at end of file diff --git a/ECommerce/app/build.gradle.kts b/ECommerce/app/build.gradle.kts deleted file mode 100644 index 348c88fd..00000000 --- a/ECommerce/app/build.gradle.kts +++ /dev/null @@ -1,90 +0,0 @@ -plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.jetbrains.kotlin.android) - id ("kotlin-kapt") - id ("kotlin-parcelize") -} - -android { - namespace = "com.algokelvin.shoppingyuk" - compileSdk = 34 - - defaultConfig { - applicationId = "com.algokelvin.shoppingyuk" - minSdk = 30 - targetSdk = 34 - versionCode = 1 - versionName = "1.0" - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - - buildConfigField("String", "BASE_URL", "\"https://fakestoreapi.com/\"") - } - - buildTypes { - release { - isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - } - buildFeatures { - dataBinding = true - buildConfig = true - } -} - -dependencies { - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.appcompat) - implementation(libs.material) - implementation(libs.androidx.activity) - implementation(libs.androidx.constraintlayout) - - val lifecycle_version = "2.8.6" - val room_version = "2.6.1" - - // ViewModel - implementation(libs.androidx.lifecycle.viewmodel.ktx) - // LiveData - implementation(libs.androidx.lifecycle.livedata.ktx) - // Saved state module for ViewModel - implementation(libs.androidx.lifecycle.viewmodel.savedstate) - // Annotation processor - kapt(libs.androidx.lifecycle.compiler) - - implementation(libs.androidx.room.runtime) - implementation(libs.androidx.room.ktx) - - // To use Kotlin annotation processing tool (kapt) - kapt(libs.androidx.room.compiler) - - implementation(libs.kotlinx.coroutines.core) - implementation(libs.kotlinx.coroutines.android) - - implementation(libs.dagger) - kapt(libs.dagger.compiler) - - implementation(libs.retrofit) - implementation(libs.converter.gson) - implementation(libs.logging.interceptor) - - implementation(libs.glide) - - implementation(libs.kotlinx.coroutines.android) - - implementation(libs.androidx.security.crypto) - - testImplementation(libs.junit) - androidTestImplementation(libs.androidx.junit) - androidTestImplementation(libs.androidx.espresso.core) -} \ No newline at end of file diff --git a/ECommerce/app/src/androidTest/java/com/algokelvin/shoppingyuk/ExampleInstrumentedTest.kt b/ECommerce/app/src/androidTest/java/com/algokelvin/shoppingyuk/ExampleInstrumentedTest.kt deleted file mode 100644 index 6e69658d..00000000 --- a/ECommerce/app/src/androidTest/java/com/algokelvin/shoppingyuk/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.algokelvin.shoppingyuk - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.algokelvin.movieapp", appContext.packageName) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/AndroidManifest.xml b/ECommerce/app/src/main/AndroidManifest.xml deleted file mode 100644 index 4d383b36..00000000 --- a/ECommerce/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ECommerce/app/src/main/ic_shopping_yuk-playstore.png b/ECommerce/app/src/main/ic_shopping_yuk-playstore.png deleted file mode 100644 index 413b0480..00000000 Binary files a/ECommerce/app/src/main/ic_shopping_yuk-playstore.png and /dev/null differ diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ProductApiService.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ProductApiService.kt deleted file mode 100644 index a761a66c..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ProductApiService.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.algokelvin.shoppingyuk.data.api - -import com.algokelvin.shoppingyuk.data.model.cart.Cart -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.data.model.user.User -import retrofit2.Response -import retrofit2.http.Body -import retrofit2.http.GET -import retrofit2.http.POST -import retrofit2.http.Path - -interface ProductApiService { - @GET("products") - suspend fun getProductsList(): Response> - - @GET("products/{id}") - suspend fun getProductDetailList(@Path("id") id: String): Response - - @GET("carts/user/{id}") - suspend fun getCartByIdUser(@Path("id") id: String): Response> - - @POST("auth/login") - suspend fun login(@Body login: Login): Response - - @GET("users") - suspend fun getAllUsers(): Response> -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ResponseResults.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ResponseResults.kt deleted file mode 100644 index 8e7cef51..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/api/ResponseResults.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.algokelvin.shoppingyuk.data.api - -data class ResponseResults(val data: T?, val errorMessage: String? = null) diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/CartDao.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/CartDao.kt deleted file mode 100644 index 12088dc1..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/CartDao.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.algokelvin.shoppingyuk.data.db - -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import com.algokelvin.shoppingyuk.data.model.cart.CartDB - -@Dao -interface CartDao { - @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun addProductInCart(cartDB: CartDB) - - @Query("SELECT * FROM cart_data WHERE cart_user_id = :userId") - suspend fun getCart(userId: Int): List - - @Query("UPDATE cart_data SET cart_count = :count WHERE cart_user_id = :userId AND cart_product_id = :productId") - suspend fun updateCountProductInCart(userId: Int, productId: Int, count: Int) - - @Query("DELETE FROM cart_data WHERE cart_user_id = :userId AND cart_product_id = :productId") - suspend fun deleteProductInCart(userId: Int, productId: Int) - - @Query("DELETE FROM cart_data WHERE cart_user_id = :userId") - suspend fun deleteProductForCheckout(userId: Int) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDB.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDB.kt deleted file mode 100644 index bf5846cb..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDB.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.algokelvin.shoppingyuk.data.db - -import androidx.room.Database -import androidx.room.RoomDatabase -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.model.user.User - -@Database( - entities = [Product::class, User::class, CartDB::class], - version = 4, - exportSchema = false -) -abstract class ProductDB: RoomDatabase() { - abstract fun productDao(): ProductDao - abstract fun userDao(): UserDao - abstract fun cartDao(): CartDao -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDao.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDao.kt deleted file mode 100644 index 2e3a82c0..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/ProductDao.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.algokelvin.shoppingyuk.data.db - -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import com.algokelvin.shoppingyuk.data.model.product.Product - -@Dao -interface ProductDao { - @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun saveProducts(products: List) - - @Query("DELETE FROM products_data") - suspend fun deleteAllProducts() - - @Query("SELECT * FROM products_data") - suspend fun getAllProducts(): List - - @Query("SELECT * FROM products_data WHERE id = :id") - suspend fun getProductById(id: Int): Product -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/UserDao.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/UserDao.kt deleted file mode 100644 index 1c2e6be5..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/db/UserDao.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.algokelvin.shoppingyuk.data.db - -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query -import com.algokelvin.shoppingyuk.data.model.user.User - -@Dao -interface UserDao { - @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun saveUser(user: User) - - @Query("SELECT * FROM users_data WHERE id = :id") - suspend fun getUser(id: Int): User -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/Cart.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/Cart.kt deleted file mode 100644 index bff6bf6b..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/Cart.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.cart - -import com.google.gson.annotations.SerializedName - -data class ProductCart( - @SerializedName("productId") - val productId: Int, - - @SerializedName("quantity") - val quantity: Int, -) - -data class Cart( - @SerializedName("id") - val id: Int, - - @SerializedName("userId") - val userId: Int, - - @SerializedName("products") - val products: ArrayList, -) diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/CartDB.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/CartDB.kt deleted file mode 100644 index c8731a6c..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/cart/CartDB.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.cart - -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.PrimaryKey - -@Entity(tableName = "cart_data") -data class CartDB ( - @PrimaryKey(autoGenerate = true) - val id: Int = 0, - - @ColumnInfo("cart_user_id") - val userId: Int, - - @ColumnInfo("cart_product_id") - val productId: Int, - - @ColumnInfo(name = "cart_product_title") - val productTitle: String?, - - @ColumnInfo(name = "cart_product_price") - val productPrice: Double?, - - @ColumnInfo(name = "cart_product_image") - val productImage: String?, - - @ColumnInfo("cart_count") - val count: Int -) \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Product.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Product.kt deleted file mode 100644 index e2cbd9b2..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Product.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.product - -import androidx.room.ColumnInfo -import androidx.room.Embedded -import androidx.room.Entity -import androidx.room.PrimaryKey -import com.google.gson.annotations.SerializedName - -@Entity(tableName = "products_data") -data class Product ( - @PrimaryKey - @SerializedName("id") - val id: Int, - - @ColumnInfo(name = "product_title") - @SerializedName("title") - val title: String?, - - @ColumnInfo(name = "product_price") - @SerializedName("price") - val price: Double?, - - @ColumnInfo(name = "product_description") - @SerializedName("description") - val description: String?, - - @ColumnInfo(name = "product_category") - @SerializedName("category") - val category: String?, - - @ColumnInfo(name = "product_image") - @SerializedName("image") - val image: String?, - - @SerializedName("rating") - @Embedded(prefix = "product_") - val rating: Rating? -) \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Rating.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Rating.kt deleted file mode 100644 index 4177c4ff..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/product/Rating.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.product - -import androidx.room.ColumnInfo -import com.google.gson.annotations.SerializedName - -data class Rating( - @SerializedName("rate") - @ColumnInfo("rate") - val rate: Double?, - - @SerializedName("count") - @ColumnInfo("count") - val count: Int?, -) diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Login.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Login.kt deleted file mode 100644 index 626d0d9b..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Login.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.user - -data class Login( - val username: String, - val password: String -) \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Token.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Token.kt deleted file mode 100644 index a15b4af3..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/Token.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.user - -data class Token(val token: String) \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/User.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/User.kt deleted file mode 100644 index 512f09c5..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/model/user/User.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.algokelvin.shoppingyuk.data.model.user - -import android.os.Parcelable -import androidx.room.ColumnInfo -import androidx.room.Embedded -import androidx.room.Entity -import androidx.room.PrimaryKey -import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize - -@Parcelize -data class NamePerson( - @SerializedName("firstname") - @ColumnInfo("firstname") - val firstName: String, - - @SerializedName("lastname") - @ColumnInfo("lastname") - val lastName: String, -): Parcelable - -@Entity(tableName = "users_data") -@Parcelize -data class User( - @SerializedName("id") - @PrimaryKey - val id: Int, - - @SerializedName("email") - @ColumnInfo("user_email") - val email: String, - - @SerializedName("username") - @ColumnInfo("user_username") - val username: String, - - @SerializedName("password") - @ColumnInfo("user_password") - val password: String, - - @SerializedName("name") - @Embedded(prefix = "user_") - val name: NamePerson, - - @SerializedName("phone") - @ColumnInfo("user_phone") - val phone: String, -): Parcelable \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/CartRepositoryImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/CartRepositoryImpl.kt deleted file mode 100644 index 02a368c9..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/CartRepositoryImpl.kt +++ /dev/null @@ -1,72 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.cart - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartLocalDataSource -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class CartRepositoryImpl( - private val localCart: CartLocalDataSource, -): CartRepository { - override suspend fun addProductInCart(cartDB: CartDB): String = addProductInCartDB(cartDB) - - override suspend fun getCartByUserId(userId: Int): ResponseResults> = getCartInDB(userId) - - override suspend fun updateCountProductInCart( - userId: Int, - productId: Int, - count: Int - ): String = updateCountProduct(userId, productId, count) - - override suspend fun deleteProductInCart( - userId: Int, - productId: Int - ): String = deleteProduct(userId, productId) - - override suspend fun deleteProductForCheckout(userId: Int): String = deleteForCheckout(userId) - - private suspend fun addProductInCartDB(cartDB: CartDB): String { - try { - localCart.addProductInCart(cartDB) - return "Success Add to Cart" - } catch (e: Exception) { - return "Failed Add to Cart - ${e.message}" - } - } - - private suspend fun getCartInDB(userId: Int): ResponseResults> { - try { - val listCart = localCart.getCart(userId) - return ResponseResults(listCart, null) - } catch (e: Exception) { - return ResponseResults(null, "Failed to Show Cart - ${e.message}") - } - } - - private suspend fun updateCountProduct(userId: Int, productId: Int, count: Int): String { - try { - localCart.updateCountProductInCart(userId, productId, count) - return "Success Update Count Product" - } catch (e: Exception) { - return "Failed Update Count Product" - } - } - - private suspend fun deleteProduct(userId: Int, productId: Int): String { - try { - localCart.deleteProductInCart(userId, productId) - return "Success Delete Product In Cart" - } catch (e: Exception) { - return "Failed Delete Product In Cart" - } - } - - private suspend fun deleteForCheckout(userId: Int): String { - try { - localCart.deleteAllForCheckout(userId) - return "Success Confirm Your Shopping" - } catch (e: Exception) { - return "Failed Confirm Your Shopping" - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartLocalDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartLocalDataSource.kt deleted file mode 100644 index e52ff426..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartLocalDataSource.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.cart.datasource - -import com.algokelvin.shoppingyuk.data.model.cart.CartDB - -interface CartLocalDataSource { - suspend fun getCart(userId: Int): List - suspend fun addProductInCart(cartDB: CartDB) - suspend fun updateCountProductInCart(userId: Int, productId: Int, count: Int) - suspend fun deleteProductInCart(userId: Int, productId: Int) - suspend fun deleteAllForCheckout(userId: Int) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartRemoteDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartRemoteDataSource.kt deleted file mode 100644 index 20603ab3..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasource/CartRemoteDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.cart.datasource - -import com.algokelvin.shoppingyuk.data.model.cart.Cart -import retrofit2.Response - -interface CartRemoteDataSource { - suspend fun getCartByUserid(id: String): Response> -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartLocalDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartLocalDataSourceImpl.kt deleted file mode 100644 index 28556560..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartLocalDataSourceImpl.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.cart.datasourceImpl - -import com.algokelvin.shoppingyuk.data.db.CartDao -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartLocalDataSource -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch - -class CartLocalDataSourceImpl( - private val cartDao: CartDao, -): CartLocalDataSource { - - override suspend fun getCart(userId: Int): List = cartDao.getCart(userId) - - override suspend fun addProductInCart(cartDB: CartDB) { - CoroutineScope(Dispatchers.IO).launch { - cartDao.addProductInCart(cartDB) - } - } - - override suspend fun updateCountProductInCart(userId: Int, productId: Int, count: Int) { - CoroutineScope(Dispatchers.IO).launch { - cartDao.updateCountProductInCart(userId, productId, count) - } - } - - override suspend fun deleteProductInCart(userId: Int, productId: Int) { - CoroutineScope(Dispatchers.IO).launch { - cartDao.deleteProductInCart(userId, productId) - } - } - - override suspend fun deleteAllForCheckout(userId: Int) { - CoroutineScope(Dispatchers.IO).launch { - cartDao.deleteProductForCheckout(userId) - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartRemoteDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartRemoteDataSourceImpl.kt deleted file mode 100644 index 13f2cae0..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/cart/datasourceImpl/CartRemoteDataSourceImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.cart.datasourceImpl - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.model.cart.Cart -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartRemoteDataSource -import retrofit2.Response - -class CartRemoteDataSourceImpl( - private val service: ProductApiService, -): CartRemoteDataSource { - override suspend fun getCartByUserid(id: String): Response> = service.getCartByIdUser(id) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/LoginRepositoryImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/LoginRepositoryImpl.kt deleted file mode 100644 index 2579bfab..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/LoginRepositoryImpl.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.login - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginRemoteDataSource -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository - -class LoginRepositoryImpl( - private val remote: LoginRemoteDataSource, - private val local: LoginLocalDataSource, -): LoginRepository { - override suspend fun login(login: Login): ResponseResults = loginProcess(login) - - override suspend fun getUser(login: Login): ResponseResults = getProfileUser(login) - - override suspend fun getUserFromDB(id: Int): User = getProfileFromDB(id) - - private suspend fun loginProcess(login: Login): ResponseResults { - val token: Token? - - try { - val response = remote.login(login) - if (response.isSuccessful) { - val body = response.body() - if (body != null) { - token = body - return ResponseResults(token) - } else { - return ResponseResults(null, "Value Body is NULL") - } - } else { - val errorMessage = response.errorBody()?.string() ?: "Unknown Error" - return ResponseResults(null, errorMessage) - } - } catch (e: Exception) { - return ResponseResults(null, e.message) - } - } - - private suspend fun getProfileUser(login: Login): ResponseResults { - val user: User? - - try { - val response = remote.getAllUser() - if (response.isSuccessful) { - val body = response.body() - if (body != null) { - user = body.find { it.username == login.username && it.password == login.password } - user?.let { saveProfile(it) } - return ResponseResults(user) - } else { - return ResponseResults(null, "Value Body is NULL") - } - } else { - val errorMessage = response.errorBody()?.string() ?: "Unknown Error" - return ResponseResults(null, errorMessage) - } - } catch (e: Exception) { - return ResponseResults(null, e.message) - } - } - - private suspend fun saveProfile(user: User) { - try { - local.saveUserToDB(user) - } catch (e: Exception) { - //Log.i("ALGOKELVIN_DEBUG", e.message.toString()) - } - } - - private suspend fun getProfileFromDB(id: Int): User { - lateinit var user: User - - try { - user = local.getUserFromDB(id) - } catch (e: Exception) { - //Log.i("ALGOKELVIN_DEBUG", e.message.toString()) - } - - return user - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginLocalDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginLocalDataSource.kt deleted file mode 100644 index 45aea5a4..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginLocalDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.login.datasource - -import com.algokelvin.shoppingyuk.data.model.user.User - -interface LoginLocalDataSource { - suspend fun saveUserToDB(user: User) - suspend fun getUserFromDB(id: Int): User -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginRemoteDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginRemoteDataSource.kt deleted file mode 100644 index 8c330294..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasource/LoginRemoteDataSource.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.login.datasource - -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.data.model.user.User -import retrofit2.Response - -interface LoginRemoteDataSource { - suspend fun login(login: Login): Response - suspend fun getAllUser(): Response> -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginLocalDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginLocalDataSourceImpl.kt deleted file mode 100644 index c7bb4958..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginLocalDataSourceImpl.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.login.datasourceImpl - -import com.algokelvin.shoppingyuk.data.db.UserDao -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginLocalDataSource -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch - -class LoginLocalDataSourceImpl(private val userDao: UserDao): LoginLocalDataSource { - override suspend fun saveUserToDB(user: User) { - CoroutineScope(Dispatchers.IO).launch { - userDao.saveUser(user) - } - } - - override suspend fun getUserFromDB(id: Int): User = userDao.getUser(id) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginRemoteDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginRemoteDataSourceImpl.kt deleted file mode 100644 index 5176a295..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/login/datasourceImpl/LoginRemoteDataSourceImpl.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.login.datasourceImpl - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginRemoteDataSource -import retrofit2.Response - -class LoginRemoteDataSourceImpl( - private val productApiService: ProductApiService -): LoginRemoteDataSource { - override suspend fun login(login: Login): Response = productApiService.login(login) - override suspend fun getAllUser(): Response> = productApiService.getAllUsers() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/ProductRepositoryImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/ProductRepositoryImpl.kt deleted file mode 100644 index 11f0c228..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/ProductRepositoryImpl.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductCacheDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductRemoteDataSource -import com.algokelvin.shoppingyuk.domain.repository.ProductRepository - -class ProductRepositoryImpl( - private val remote: ProductRemoteDataSource, - private val local: ProductLocalDataSource, - private val cache: ProductCacheDataSource, -): ProductRepository { - - override suspend fun getProducts(): List = getProductsFromCache() - - override suspend fun updateProducts(): List { - val newListOfProducts = getProductsFromAPI() - local.clearAll() - local.saveProductsToDB(newListOfProducts) - cache.saveProductsToCache(newListOfProducts) - return newListOfProducts - } - - private suspend fun getProductsFromAPI(): List { - lateinit var productList: ArrayList - - try { - val response = remote.getProducts() - val body = response.body() - if (body != null) { - productList = body - } - } catch (e: Exception) { - //Log.i("ALGOKELVIN", e.message.toString()) - } - - return productList - } - - private suspend fun getProductsFromDB(): List { - lateinit var productList: List - - try { - productList = local.getProductsFromDB() - } catch (e: Exception) { - //Log.i("ALGOKELVIN", e.message.toString()) - } - - if (productList.isNotEmpty()) { - return productList - } else { - productList = getProductsFromAPI() - local.saveProductsToDB(productList) - } - - return productList - } - - private suspend fun getProductsFromCache(): List { - lateinit var productList: List - - try { - productList = cache.getProductsFromCache() - } catch (e: Exception) { - //Log.i("ALGOKELVIN", e.message.toString()) - } - - if (productList.isNotEmpty()) { - return productList - } else { - productList = getProductsFromDB() - cache.saveProductsToCache(productList) - } - - return productList - } - - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductCacheDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductCacheDataSource.kt deleted file mode 100644 index e9087215..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductCacheDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasource - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface ProductCacheDataSource { - suspend fun getProductsFromCache(): List - suspend fun saveProductsToCache(products: List) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductLocalDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductLocalDataSource.kt deleted file mode 100644 index 6064c2d7..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductLocalDataSource.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasource - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface ProductLocalDataSource { - suspend fun getProductsFromDB(): List - suspend fun getProductByIdFromDB(id: Int): Product - suspend fun saveProductsToDB(products: List) - suspend fun clearAll() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductRemoteDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductRemoteDataSource.kt deleted file mode 100644 index 0afc8a4f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasource/ProductRemoteDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasource - -import com.algokelvin.shoppingyuk.data.model.product.Product -import retrofit2.Response - -interface ProductRemoteDataSource { - suspend fun getProducts(): Response> -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductCacheDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductCacheDataSourceImpl.kt deleted file mode 100644 index 86d88c5a..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductCacheDataSourceImpl.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductCacheDataSource - -class ProductCacheDataSourceImpl: ProductCacheDataSource { - private var productList = ArrayList() - - override suspend fun getProductsFromCache(): List { - return productList - } - - override suspend fun saveProductsToCache(products: List) { - productList.clear() - productList = ArrayList(products) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductLocalDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductLocalDataSourceImpl.kt deleted file mode 100644 index cb2f0c94..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductLocalDataSourceImpl.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl - -import com.algokelvin.shoppingyuk.data.db.ProductDao -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductLocalDataSource -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch - -class ProductLocalDataSourceImpl(private val productDao: ProductDao): ProductLocalDataSource { - override suspend fun getProductsFromDB(): List = productDao.getAllProducts() - override suspend fun getProductByIdFromDB(id: Int): Product = productDao.getProductById(id) - - override suspend fun saveProductsToDB(products: List) { - CoroutineScope(Dispatchers.IO).launch { - productDao.saveProducts(products) - } - } - - override suspend fun clearAll() { - CoroutineScope(Dispatchers.IO).launch { - productDao.deleteAllProducts() - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductRemoteDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductRemoteDataSourceImpl.kt deleted file mode 100644 index 037b7853..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/product/datasourceImpl/ProductRemoteDataSourceImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductRemoteDataSource -import retrofit2.Response - -class ProductRemoteDataSourceImpl( - private val service: ProductApiService, -): ProductRemoteDataSource { - override suspend fun getProducts(): Response> = service.getProductsList() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/ProductCategoryRepositoryImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/ProductCategoryRepositoryImpl.kt deleted file mode 100644 index 87162f26..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/ProductCategoryRepositoryImpl.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productCategory - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.productCategory.datasource.ProductCategoryRemoteDataSource -import com.algokelvin.shoppingyuk.domain.repository.ProductCategoryRepository - -class ProductCategoryRepositoryImpl( - private val remote: ProductCategoryRemoteDataSource -): ProductCategoryRepository { - - override suspend fun getProductsSortByCategory(): List = getProductsFromAPI() - - private suspend fun getProductsFromAPI(): List { - lateinit var productList: ArrayList - - try { - val response = remote.getProductsSortByCategory() - val body = response.body() - if (body != null) { - productList = body - } - } catch (e: Exception) { - //Log.i("ALGOKELVIN", e.message.toString()) - } - - return productList.sortedBy { it.category } - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasource/ProductCategoryRemoteDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasource/ProductCategoryRemoteDataSource.kt deleted file mode 100644 index d5a40ed9..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasource/ProductCategoryRemoteDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productCategory.datasource - -import com.algokelvin.shoppingyuk.data.model.product.Product -import retrofit2.Response - -interface ProductCategoryRemoteDataSource { - suspend fun getProductsSortByCategory(): Response> -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasourceImpl/ProductCategoryRemoteDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasourceImpl/ProductCategoryRemoteDataSourceImpl.kt deleted file mode 100644 index 2085444d..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productCategory/datasourceImpl/ProductCategoryRemoteDataSourceImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productCategory.datasourceImpl - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.productCategory.datasource.ProductCategoryRemoteDataSource -import retrofit2.Response - -class ProductCategoryRemoteDataSourceImpl( - private val service: ProductApiService, -): ProductCategoryRemoteDataSource { - override suspend fun getProductsSortByCategory(): Response> = service.getProductsList() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/ProductDetailRepositoryImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/ProductDetailRepositoryImpl.kt deleted file mode 100644 index 5c63056e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/ProductDetailRepositoryImpl.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productDetail - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.productDetail.datasource.ProductDetailRemoteDataSource -import com.algokelvin.shoppingyuk.domain.repository.ProductDetailRepository - -class ProductDetailRepositoryImpl( - private val remote: ProductDetailRemoteDataSource, -): ProductDetailRepository { - - override suspend fun getProductDetail(id: String): Product = getProductDetailFromAPI(id) - - private suspend fun getProductDetailFromAPI(id: String): Product { - lateinit var product: Product - - try { - val response = remote.getProductDetail(id) - val body = response.body() - if (body != null) { - product = body - } - } catch (e: Exception) { - //Log.i("ALGOKELVIN", e.message.toString()) - } - - return product - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasource/ProductDetailRemoteDataSource.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasource/ProductDetailRemoteDataSource.kt deleted file mode 100644 index 00127749..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasource/ProductDetailRemoteDataSource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productDetail.datasource - -import com.algokelvin.shoppingyuk.data.model.product.Product -import retrofit2.Response - -interface ProductDetailRemoteDataSource { - suspend fun getProductDetail(id: String): Response -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasourceImpl/ProductDetailRemoteDataSourceImpl.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasourceImpl/ProductDetailRemoteDataSourceImpl.kt deleted file mode 100644 index 43799baa..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/data/repository/productDetail/datasourceImpl/ProductDetailRemoteDataSourceImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.data.repository.productDetail.datasourceImpl - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.data.repository.productDetail.datasource.ProductDetailRemoteDataSource -import retrofit2.Response - -class ProductDetailRemoteDataSourceImpl( - private val service: ProductApiService -): ProductDetailRemoteDataSource { - override suspend fun getProductDetail(id: String): Response = service.getProductDetailList(id) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/CartRepository.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/CartRepository.kt deleted file mode 100644 index f588238f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/CartRepository.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.repository - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.cart.CartDB - -interface CartRepository { - suspend fun addProductInCart(cartDB: CartDB): String - suspend fun getCartByUserId(userId: Int): ResponseResults> - suspend fun updateCountProductInCart(userId: Int, productId: Int, count: Int): String - suspend fun deleteProductInCart(userId: Int, productId: Int): String - suspend fun deleteProductForCheckout(userId: Int): String -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/LoginRepository.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/LoginRepository.kt deleted file mode 100644 index 123fb9ce..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/LoginRepository.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.repository - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.data.model.user.User - -interface LoginRepository { - suspend fun login(login: Login): ResponseResults - suspend fun getUser(login: Login): ResponseResults - suspend fun getUserFromDB(id: Int): User -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductCategoryRepository.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductCategoryRepository.kt deleted file mode 100644 index d93c2340..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductCategoryRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.repository - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface ProductCategoryRepository { - suspend fun getProductsSortByCategory(): List -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductDetailRepository.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductDetailRepository.kt deleted file mode 100644 index f66a0fd2..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductDetailRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.repository - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface ProductDetailRepository { - suspend fun getProductDetail(id: String): Product? -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductRepository.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductRepository.kt deleted file mode 100644 index 2b7ac113..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/repository/ProductRepository.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.repository - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface ProductRepository { - suspend fun getProducts(): List? - suspend fun updateProducts(): List? -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/AddProductToCartUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/AddProductToCartUseCase.kt deleted file mode 100644 index 7fe9ecdb..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/AddProductToCartUseCase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class AddProductToCartUseCase(private val cartRepository: CartRepository) { - suspend fun execute(cartDB: CartDB): String = cartRepository.addProductInCart(cartDB) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/CheckoutUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/CheckoutUseCase.kt deleted file mode 100644 index bfa0e9fe..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/CheckoutUseCase.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class CheckoutUseCase(private val cartRepository: CartRepository) { - suspend fun execute(userId: Int): String = cartRepository.deleteProductForCheckout(userId) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/DeleteProductInCartUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/DeleteProductInCartUseCase.kt deleted file mode 100644 index d204340a..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/DeleteProductInCartUseCase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class DeleteProductInCartUseCase(private val cartRepository: CartRepository) { - suspend fun execute( - userId: Int, - productInt: Int, - ): String = cartRepository.deleteProductInCart(userId, productInt) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetCartByUserIdUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetCartByUserIdUseCase.kt deleted file mode 100644 index 76dd0b69..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetCartByUserIdUseCase.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class GetCartByUserIdUseCase(private val cartRepository: CartRepository) { - suspend fun execute(userId: Int): ResponseResults> = cartRepository.getCartByUserId(userId) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductDetailUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductDetailUseCase.kt deleted file mode 100644 index c4757b28..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductDetailUseCase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.domain.repository.ProductDetailRepository - -class GetProductDetailUseCase(private val productDetailRepository: ProductDetailRepository) { - suspend fun execute(id: String): Product? = productDetailRepository.getProductDetail(id) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsCategoryUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsCategoryUseCase.kt deleted file mode 100644 index 2699bd3c..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsCategoryUseCase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.domain.repository.ProductCategoryRepository - -class GetProductsCategoryUseCase(private val productCategoryRepository: ProductCategoryRepository) { - suspend fun execute(): List = productCategoryRepository.getProductsSortByCategory() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsUseCase.kt deleted file mode 100644 index 4b48ab28..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProductsUseCase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.domain.repository.ProductRepository - -class GetProductsUseCase(private val productRepository: ProductRepository) { - suspend fun execute(): List? = productRepository.getProducts() -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileFromDBUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileFromDBUseCase.kt deleted file mode 100644 index 0c4f1865..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileFromDBUseCase.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository - -class GetProfileFromDBUseCase(private val loginRepository: LoginRepository) { - suspend fun execute(id: Int): User = loginRepository.getUserFromDB(id) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileUseCase.kt deleted file mode 100644 index 887f48ae..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/GetProfileUseCase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository - -class GetProfileUseCase(private val loginRepository: LoginRepository) { - suspend fun execute(login: Login): ResponseResults = loginRepository.getUser(login) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/LoginUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/LoginUseCase.kt deleted file mode 100644 index af9a734a..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/LoginUseCase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.data.api.ResponseResults -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.data.model.user.Token -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository - -class LoginUseCase(private val loginRepository: LoginRepository) { - suspend fun execute(login: Login): ResponseResults = loginRepository.login(login) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/UpdateCountProductInCartUseCase.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/UpdateCountProductInCartUseCase.kt deleted file mode 100644 index 8bf05495..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/domain/usecase/UpdateCountProductInCartUseCase.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.algokelvin.shoppingyuk.domain.usecase - -import com.algokelvin.shoppingyuk.domain.repository.CartRepository - -class UpdateCountProductInCartUseCase(private val cartRepository: CartRepository) { - suspend fun execute( - userId: Int, - productInt: Int, - count: Int - ): String = cartRepository.updateCountProductInCart(userId, productInt, count) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/App.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/App.kt deleted file mode 100644 index 518c0157..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/App.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation - -import android.app.Application -import com.algokelvin.shoppingyuk.BuildConfig -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.di.cart.CartSubComponent -import com.algokelvin.shoppingyuk.presentation.di.checkout.CheckoutSubComponent -import com.algokelvin.shoppingyuk.presentation.di.core.AppComponent -import com.algokelvin.shoppingyuk.presentation.di.core.AppModule -import com.algokelvin.shoppingyuk.presentation.di.core.DaggerAppComponent -import com.algokelvin.shoppingyuk.presentation.di.core.NetModule -import com.algokelvin.shoppingyuk.presentation.di.core.RemoteDataModule -import com.algokelvin.shoppingyuk.presentation.di.home.HomeSubComponent -import com.algokelvin.shoppingyuk.presentation.di.login.LoginSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductCategorySubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductDetailSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductSubComponent - -class App: Application(), Injector { - private lateinit var appComponent:AppComponent - - override fun onCreate() { - super.onCreate() - appComponent = DaggerAppComponent.builder() - .appModule(AppModule(applicationContext)) - .netModule(NetModule(BuildConfig.BASE_URL)) - .remoteDataModule(RemoteDataModule()) - .build() - } - - override fun createMovieSubComponent(): ProductSubComponent { - return appComponent.movieSubComponent().create() - } - - override fun createProductDetailSubComponent(): ProductDetailSubComponent { - return appComponent.productDetailSubComponent().create() - } - - override fun createLoginSubComponent(): LoginSubComponent { - return appComponent.loginSubComponent().create() - } - - override fun createProductCategorySubComponent(): ProductCategorySubComponent { - return appComponent.productCategorySubComponent().create() - } - - override fun createHomeSubComponent(): HomeSubComponent { - return appComponent.homeSubComponent().create() - } - - override fun createCartSubComponent(): CartSubComponent { - return appComponent.cartSubComponent().create() - } - - override fun createCheckoutSubComponent(): CheckoutSubComponent { - return appComponent.checkoutSubComponent().create() - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartActivity.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartActivity.kt deleted file mode 100644 index 41cd373e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartActivity.kt +++ /dev/null @@ -1,115 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.cart - -import android.content.Intent -import android.os.Bundle -import android.view.View -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider -import androidx.recyclerview.widget.LinearLayoutManager -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.databinding.ActivityCartBinding -import com.algokelvin.shoppingyuk.databinding.ItemCartLayoutBinding -import com.algokelvin.shoppingyuk.presentation.checkout.CheckoutActivity -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.onclick.OnClickItemCart -import com.algokelvin.shoppingyuk.utils.EncryptLocal -import javax.inject.Inject - -class CartActivity : AppCompatActivity(), OnClickItemCart { - @Inject - lateinit var factory: CartViewModelFactory - - private lateinit var cartViewModel: CartViewModel - private lateinit var binding: ActivityCartBinding - private lateinit var adapter: CartAdapter - - private var profileId: Int? = 0 - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = DataBindingUtil.setContentView(this, R.layout.activity_cart) - - (application as Injector).createCartSubComponent() - .inject(this) - cartViewModel = ViewModelProvider(this, factory)[CartViewModel::class] - - profileId = EncryptLocal.getIdProfile(this) - - initListCart() - - binding.btnCheckout.setOnClickListener { - val intentToCheckout = Intent(this, CheckoutActivity::class.java) - startActivity(intentToCheckout) - } - } - - private fun initListCart() { - binding.rvCart.layoutManager = LinearLayoutManager(this) - adapter = CartAdapter(this) - binding.rvCart.adapter = adapter - getListCart() - } - - override fun onClickIncrease(bindingItem: ItemCartLayoutBinding, cartDB: CartDB) { - val countNow = cartDB.count + 1 - bindingItem.itemCart.text = countNow.toString() - cartDB.apply { - updateListCart(userId, productId, countNow) - getListCart() - } - } - - override fun onClickDecrease(bindingItem: ItemCartLayoutBinding, cartDB: CartDB) { - val countNow = cartDB.count - 1 - bindingItem.itemCart.text = countNow.toString() - cartDB.apply { - updateListCart(userId, productId, countNow) - getListCart() - } - } - - override fun onClickDelete(cartDB: CartDB) { - cartDB.apply { - deleteProductInCart(userId, productId) - getListCart() - } - } - - private fun getListCart() { - profileId?.let { id -> - cartViewModel.getCartByUserId(id).observe(this) { cart -> - if (cart != null) { - cart.data?.let { listCart -> - if (listCart.isNotEmpty()) { - binding.messageEmptyCart.visibility = View.GONE - binding.btnCheckout.isEnabled = true - - adapter.setList(listCart) - adapter.notifyDataSetChanged() - } else { - binding.messageEmptyCart.visibility = View.VISIBLE - binding.btnCheckout.isEnabled = false - } - } - } else { - Toast.makeText(this, "No data cart", Toast.LENGTH_LONG).show() - } - } - } - } - - private fun updateListCart(userId: Int, productId: Int, count: Int) { - cartViewModel.updateCountProduct(userId, productId, count).observe(this) { - Toast.makeText(this, it.toString(), Toast.LENGTH_LONG).show() - } - } - - private fun deleteProductInCart(userId: Int, productId: Int) { - cartViewModel.deleteProduct(userId, productId). observe(this) { - Toast.makeText(this, it.toString(), Toast.LENGTH_LONG).show() - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartAdapter.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartAdapter.kt deleted file mode 100644 index 8dd8628b..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartAdapter.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.cart - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.databinding.DataBindingUtil -import androidx.recyclerview.widget.RecyclerView -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.databinding.ItemCartLayoutBinding -import com.algokelvin.shoppingyuk.presentation.onclick.OnClickItemCart -import com.bumptech.glide.Glide - - -class CartAdapter( - private val onClickItemCart: OnClickItemCart -):RecyclerView.Adapter() { - private val cartList = ArrayList() - - fun setList(cart:List){ - cartList.clear() - cartList.addAll(cart) - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CartViewHolder { - val layoutInflater = LayoutInflater.from(parent.context) - val binding : ItemCartLayoutBinding = DataBindingUtil.inflate( - layoutInflater, - R.layout.item_cart_layout, - parent, - false - ) - return CartViewHolder(binding, onClickItemCart) - } - - override fun getItemCount(): Int { - return cartList.size - } - - override fun onBindViewHolder(holder: CartViewHolder, position: Int) { - holder.bind(cartList[position]) - } -} - - - -class CartViewHolder( - private val binding: ItemCartLayoutBinding, - private val onClickItemCart: OnClickItemCart, -): RecyclerView.ViewHolder(binding.root) { - - fun bind(cartDB: CartDB){ - binding.nameCart.text = cartDB.productTitle - binding.itemCart.text = cartDB.count.toString() - Glide.with(binding.imgCart.context) - .load(cartDB.productImage) - .into(binding.imgCart) - - binding.imgIncrease.setOnClickListener { - onClickItemCart.onClickIncrease(binding, cartDB) - } - binding.imgDecrease.setOnClickListener { - onClickItemCart.onClickDecrease(binding, cartDB) - } - binding.imgDeleteItem.setOnClickListener { - onClickItemCart.onClickDelete(cartDB) - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModel.kt deleted file mode 100644 index 21df1590..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModel.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.cart - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.domain.usecase.DeleteProductInCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase -import com.algokelvin.shoppingyuk.domain.usecase.UpdateCountProductInCartUseCase - -class CartViewModel( - private val getCartByUserIdUseCase: GetCartByUserIdUseCase, - private val updateCountProductInCartUseCase: UpdateCountProductInCartUseCase, - private val deleteProductInCartUseCase: DeleteProductInCartUseCase, -): ViewModel() { - fun getCartByUserId(userId: Int) = liveData { - val listCart = getCartByUserIdUseCase.execute(userId) - emit(listCart) - } - fun updateCountProduct(userId: Int, productInt: Int, count: Int) = liveData { - val statusUpdateCountProduct = updateCountProductInCartUseCase - .execute(userId, productInt, count) - emit(statusUpdateCountProduct) - } - fun deleteProduct(userId: Int, productInt: Int) = liveData { - val statusDeleteProduct = deleteProductInCartUseCase.execute(userId, productInt) - emit(statusDeleteProduct) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModelFactory.kt deleted file mode 100644 index 09aa019b..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/cart/CartViewModelFactory.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.cart - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.DeleteProductInCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase -import com.algokelvin.shoppingyuk.domain.usecase.UpdateCountProductInCartUseCase - -@Suppress("UNCHECKED_CAST") -class CartViewModelFactory( - private val getCartByUserIdUseCase: GetCartByUserIdUseCase, - private val updateCountProductInCartUseCase: UpdateCountProductInCartUseCase, - private val deleteProductInCartUseCase: DeleteProductInCartUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return CartViewModel( - getCartByUserIdUseCase, - updateCountProductInCartUseCase, - deleteProductInCartUseCase - ) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutActivity.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutActivity.kt deleted file mode 100644 index e3dea310..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutActivity.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.checkout - -import android.content.Intent -import android.os.Bundle -import android.os.Handler -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider -import androidx.recyclerview.widget.LinearLayoutManager -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.databinding.ActivityCheckoutBinding -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.home.HomeActivity -import com.algokelvin.shoppingyuk.utils.EncryptLocal -import javax.inject.Inject - -class CheckoutActivity : AppCompatActivity() { - @Inject - lateinit var factory: CheckoutViewModelFactory - - private lateinit var binding: ActivityCheckoutBinding - private lateinit var checkoutViewModel: CheckoutViewModel - private lateinit var adapter: CheckoutAdapter - - private var profileId: Int? = 0 - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = DataBindingUtil.setContentView(this, R.layout.activity_checkout) - - (application as Injector).createCheckoutSubComponent() - .inject(this) - checkoutViewModel = ViewModelProvider(this, factory)[CheckoutViewModel::class] - - profileId = EncryptLocal.getIdProfile(this) - - initCheckout() - - binding.btnConfirm.setOnClickListener { - confirmCheckout() - } - } - - private fun confirmCheckout() { - binding.btnConfirm.setBackgroundColor(resources.getColor(R.color.green_00ff00)) - binding.btnConfirm.text = getString(R.string.done) - - profileId?.let { id -> - checkoutViewModel.confirmCheckout(id).observe(this) { - Toast.makeText(this, it, Toast.LENGTH_LONG).show() - Handler().postDelayed({ - val intentToHome = Intent(this, HomeActivity::class.java) - startActivity(intentToHome) - finishAffinity() - }, 5000) - } - } - } - - private fun initCheckout() { - binding.rvShopping.layoutManager = LinearLayoutManager(this) - adapter = CheckoutAdapter() - binding.rvShopping.adapter = adapter - getListCheckout() - } - - private fun getListCheckout() { - profileId?.let { id -> - checkoutViewModel.getCartByUserId(id).observe(this) { checkout -> - if (checkout != null) { - checkout.data?.let { listCart -> - getTotalAllPrice(listCart) - adapter.setList(listCart) - adapter.notifyDataSetChanged() - } - } else { - Toast.makeText(this, "No data checkout", Toast.LENGTH_LONG).show() - } - } - } - } - - private fun getTotalAllPrice(list: List) { - var totalAll = 0.0f - for (price in list) { - val total = price.count.toFloat() * price.productPrice?.toFloat()!! - totalAll += total - } - binding.totalAllPrice.text = getString(R.string.total_all_price, totalAll.toString()) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutAdapter.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutAdapter.kt deleted file mode 100644 index 79a7a165..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutAdapter.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.checkout - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.databinding.DataBindingUtil -import androidx.recyclerview.widget.RecyclerView -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.databinding.ItemShoppingLayoutBinding -import com.bumptech.glide.Glide - - -class CheckoutAdapter: RecyclerView.Adapter() { - private val cartList = ArrayList() - - fun setList(cart:List){ - cartList.clear() - cartList.addAll(cart) - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CheckoutViewHolder { - val layoutInflater = LayoutInflater.from(parent.context) - val binding : ItemShoppingLayoutBinding = DataBindingUtil.inflate( - layoutInflater, - R.layout.item_shopping_layout, - parent, - false - ) - return CheckoutViewHolder(binding) - } - - override fun getItemCount(): Int { - return cartList.size - } - - override fun onBindViewHolder(holder: CheckoutViewHolder, position: Int) { - holder.bind(cartList[position]) - } -} - - - -class CheckoutViewHolder( - private val binding: ItemShoppingLayoutBinding, -): RecyclerView.ViewHolder(binding.root) { - - fun bind(cartDB: CartDB){ - val count = cartDB.count - val price = cartDB.productPrice - val total = count.toFloat() * price!! - - binding.nameShop.text = cartDB.productTitle - binding.itemShop.text = itemView.context.getString(R.string.items_product, cartDB.count.toString()) - binding.priceShop.text = total.toString() - - Glide.with(binding.imgShop.context) - .load(cartDB.productImage) - .into(binding.imgShop) - - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModel.kt deleted file mode 100644 index a409465e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModel.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.checkout - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.domain.usecase.CheckoutUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase - -class CheckoutViewModel( - private val getCartByUserIdUseCase: GetCartByUserIdUseCase, - private val checkoutUseCase: CheckoutUseCase, -): ViewModel() { - fun getCartByUserId(userId: Int) = liveData { - val listCart = getCartByUserIdUseCase.execute(userId) - emit(listCart) - } - fun confirmCheckout(userId: Int) = liveData { - val statusConfirm = checkoutUseCase.execute(userId) - emit(statusConfirm) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModelFactory.kt deleted file mode 100644 index 8b6c2d7e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/checkout/CheckoutViewModelFactory.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.checkout - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.CheckoutUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase - -@Suppress("UNCHECKED_CAST") -class CheckoutViewModelFactory( - private val getCartByUserIdUseCase: GetCartByUserIdUseCase, - private val checkoutUseCase: CheckoutUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return CheckoutViewModel( - getCartByUserIdUseCase, - checkoutUseCase - ) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/Injector.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/Injector.kt deleted file mode 100644 index 31a65e30..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/Injector.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di - -import com.algokelvin.shoppingyuk.presentation.di.cart.CartSubComponent -import com.algokelvin.shoppingyuk.presentation.di.checkout.CheckoutSubComponent -import com.algokelvin.shoppingyuk.presentation.di.home.HomeSubComponent -import com.algokelvin.shoppingyuk.presentation.di.login.LoginSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductCategorySubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductDetailSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductSubComponent - -interface Injector { - fun createMovieSubComponent(): ProductSubComponent - fun createProductDetailSubComponent(): ProductDetailSubComponent - fun createLoginSubComponent(): LoginSubComponent - fun createProductCategorySubComponent(): ProductCategorySubComponent - fun createHomeSubComponent(): HomeSubComponent - fun createCartSubComponent(): CartSubComponent - fun createCheckoutSubComponent(): CheckoutSubComponent -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartModule.kt deleted file mode 100644 index 7523513f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartModule.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.cart - -import com.algokelvin.shoppingyuk.domain.usecase.DeleteProductInCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase -import com.algokelvin.shoppingyuk.domain.usecase.UpdateCountProductInCartUseCase -import com.algokelvin.shoppingyuk.presentation.cart.CartViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class CartModule { - @CartScope - @Provides - fun provideCartViewModelFactory( - getCartByUserIdUseCase: GetCartByUserIdUseCase, - updateCountProductInCartUseCase: UpdateCountProductInCartUseCase, - deleteProductInCartUseCase: DeleteProductInCartUseCase, - ): CartViewModelFactory = CartViewModelFactory( - getCartByUserIdUseCase, - updateCountProductInCartUseCase, - deleteProductInCartUseCase - ) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartScope.kt deleted file mode 100644 index 6d25a205..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.cart - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class CartScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartSubComponent.kt deleted file mode 100644 index 4732a690..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/cart/CartSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.cart - -import com.algokelvin.shoppingyuk.presentation.cart.CartActivity -import dagger.Subcomponent - -@CartScope -@Subcomponent(modules = [CartModule::class]) -interface CartSubComponent { - fun inject(cartActivity: CartActivity) - - @Subcomponent.Factory - interface Factory { - fun create(): CartSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutModule.kt deleted file mode 100644 index 1d42f604..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutModule.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.checkout - -import com.algokelvin.shoppingyuk.domain.usecase.CheckoutUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase -import com.algokelvin.shoppingyuk.presentation.checkout.CheckoutViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class CheckoutModule { - @CheckoutScope - @Provides - fun provideCheckoutViewModelFactory( - getCartByUserIdUseCase: GetCartByUserIdUseCase, - checkoutUseCase: CheckoutUseCase, - ): CheckoutViewModelFactory = CheckoutViewModelFactory( - getCartByUserIdUseCase, - checkoutUseCase - ) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutScope.kt deleted file mode 100644 index b11f78cd..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.checkout - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class CheckoutScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutSubComponent.kt deleted file mode 100644 index faa061b8..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/checkout/CheckoutSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.checkout - -import com.algokelvin.shoppingyuk.presentation.checkout.CheckoutActivity -import dagger.Subcomponent - -@CheckoutScope -@Subcomponent(modules = [CheckoutModule::class]) -interface CheckoutSubComponent { - fun inject(checkoutActivity: CheckoutActivity) - - @Subcomponent.Factory - interface Factory { - fun create(): CheckoutSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppComponent.kt deleted file mode 100644 index 39165852..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppComponent.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.presentation.di.cart.CartSubComponent -import com.algokelvin.shoppingyuk.presentation.di.checkout.CheckoutSubComponent -import com.algokelvin.shoppingyuk.presentation.di.home.HomeSubComponent -import com.algokelvin.shoppingyuk.presentation.di.login.LoginSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductCategorySubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductDetailSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductSubComponent -import dagger.Component -import javax.inject.Singleton - -@Singleton -@Component(modules = [ - AppModule::class, - NetModule::class, - DatabaseModule::class, - UseCaseModule::class, - RepositoryModule::class, - RemoteDataModule::class, - LocalDataModule::class, - CacheDataModule::class -]) -interface AppComponent { - fun movieSubComponent(): ProductSubComponent.Factory - fun productDetailSubComponent(): ProductDetailSubComponent.Factory - fun loginSubComponent(): LoginSubComponent.Factory - fun productCategorySubComponent(): ProductCategorySubComponent.Factory - fun homeSubComponent(): HomeSubComponent.Factory - fun cartSubComponent(): CartSubComponent.Factory - fun checkoutSubComponent(): CheckoutSubComponent.Factory -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppModule.kt deleted file mode 100644 index 5afd683d..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/AppModule.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import android.content.Context -import com.algokelvin.shoppingyuk.presentation.di.cart.CartSubComponent -import com.algokelvin.shoppingyuk.presentation.di.checkout.CheckoutSubComponent -import com.algokelvin.shoppingyuk.presentation.di.home.HomeSubComponent -import com.algokelvin.shoppingyuk.presentation.di.login.LoginSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductCategorySubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductDetailSubComponent -import com.algokelvin.shoppingyuk.presentation.di.product.ProductSubComponent -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module(subcomponents = [ - ProductSubComponent::class, - ProductDetailSubComponent::class, - LoginSubComponent::class, - ProductCategorySubComponent::class, - HomeSubComponent::class, - CartSubComponent::class, - CheckoutSubComponent::class, -]) -class AppModule(private val context: Context) { - @Singleton - @Provides - fun provideApplicationContext(): Context { - return context.applicationContext - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/CacheDataModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/CacheDataModule.kt deleted file mode 100644 index 0a9f6e1e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/CacheDataModule.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductCacheDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl.ProductCacheDataSourceImpl -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class CacheDataModule { - @Singleton - @Provides - fun provideProductCacheDataModule(): ProductCacheDataSource { - return ProductCacheDataSourceImpl() - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/DatabaseModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/DatabaseModule.kt deleted file mode 100644 index 99ee1b8c..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/DatabaseModule.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import android.content.Context -import androidx.room.Room -import com.algokelvin.shoppingyuk.data.db.CartDao -import com.algokelvin.shoppingyuk.data.db.ProductDB -import com.algokelvin.shoppingyuk.data.db.ProductDao -import com.algokelvin.shoppingyuk.data.db.UserDao -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class DatabaseModule { - @Singleton - @Provides - fun provideProductDatabase(context: Context): ProductDB { - return Room.databaseBuilder(context, ProductDB::class.java, "fakeproductdb") - .build() - } - - @Singleton - @Provides - fun provideProductDao(productDB: ProductDB): ProductDao { - return productDB.productDao() - } - - @Singleton - @Provides - fun provideUserDao(productDB: ProductDB): UserDao { - return productDB.userDao() - } - - @Singleton - @Provides - fun provideCartDao(productDB: ProductDB): CartDao { - return productDB.cartDao() - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/LocalDataModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/LocalDataModule.kt deleted file mode 100644 index a75396b1..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/LocalDataModule.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.data.db.CartDao -import com.algokelvin.shoppingyuk.data.db.ProductDao -import com.algokelvin.shoppingyuk.data.db.UserDao -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.cart.datasourceImpl.CartLocalDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.login.datasourceImpl.LoginLocalDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl.ProductLocalDataSourceImpl -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class LocalDataModule { - @Singleton - @Provides - fun provideMovieLocalDataModule(productDao: ProductDao): ProductLocalDataSource { - return ProductLocalDataSourceImpl(productDao) - } - - @Singleton - @Provides - fun provideLoginLocalDataModule(userDao: UserDao): LoginLocalDataSource { - return LoginLocalDataSourceImpl(userDao) - } - - @Singleton - @Provides - fun provideCartLocalDataModule(cartDao: CartDao): CartLocalDataSource { - return CartLocalDataSourceImpl(cartDao) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/NetModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/NetModule.kt deleted file mode 100644 index 4361ae1b..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/NetModule.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import dagger.Module -import dagger.Provides -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import javax.inject.Singleton - -@Module -class NetModule(private val baseUrl: String) { - @Singleton - @Provides - fun provideRetrofit(): Retrofit { - return Retrofit.Builder() - .addConverterFactory(GsonConverterFactory.create()) - .baseUrl(baseUrl) - .build() - } - - @Singleton - @Provides - fun provideProductApiService(retrofit: Retrofit): ProductApiService { - return retrofit.create(ProductApiService::class.java) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RemoteDataModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RemoteDataModule.kt deleted file mode 100644 index 81ebf7b2..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RemoteDataModule.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.data.api.ProductApiService -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.cart.datasourceImpl.CartRemoteDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.login.datasourceImpl.LoginRemoteDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasourceImpl.ProductRemoteDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.productCategory.datasource.ProductCategoryRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.productCategory.datasourceImpl.ProductCategoryRemoteDataSourceImpl -import com.algokelvin.shoppingyuk.data.repository.productDetail.datasource.ProductDetailRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.productDetail.datasourceImpl.ProductDetailRemoteDataSourceImpl -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class RemoteDataModule { - @Singleton - @Provides - fun provideMovieRemoteDataModule(productApiService: ProductApiService): ProductRemoteDataSource { - return ProductRemoteDataSourceImpl(productApiService) - } - - @Singleton - @Provides - fun provideProductDetailRemoteDataModule(productApiService: ProductApiService): ProductDetailRemoteDataSource { - return ProductDetailRemoteDataSourceImpl(productApiService) - } - - @Singleton - @Provides - fun provideLoginRemoteDataModule(productApiService: ProductApiService): LoginRemoteDataSource { - return LoginRemoteDataSourceImpl(productApiService) - } - - @Singleton - @Provides - fun provideProductCategoryRemoteDataModule(productApiService: ProductApiService): ProductCategoryRemoteDataSource { - return ProductCategoryRemoteDataSourceImpl(productApiService) - } - - @Singleton - @Provides - fun provideCartRemoteDataModule(productApiService: ProductApiService): CartRemoteDataSource { - return CartRemoteDataSourceImpl(productApiService) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RepositoryModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RepositoryModule.kt deleted file mode 100644 index 28a95b43..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/RepositoryModule.kt +++ /dev/null @@ -1,82 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.data.repository.cart.CartRepositoryImpl -import com.algokelvin.shoppingyuk.data.repository.cart.datasource.CartLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.login.LoginRepositoryImpl -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.login.datasource.LoginRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.product.ProductRepositoryImpl -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductCacheDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductLocalDataSource -import com.algokelvin.shoppingyuk.data.repository.product.datasource.ProductRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.productCategory.ProductCategoryRepositoryImpl -import com.algokelvin.shoppingyuk.data.repository.productCategory.datasource.ProductCategoryRemoteDataSource -import com.algokelvin.shoppingyuk.data.repository.productDetail.ProductDetailRepositoryImpl -import com.algokelvin.shoppingyuk.data.repository.productDetail.datasource.ProductDetailRemoteDataSource -import com.algokelvin.shoppingyuk.domain.repository.CartRepository -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductCategoryRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductDetailRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductRepository -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class RepositoryModule { - @Provides - @Singleton - fun provideMovieRepository( - productRemoteDataSource: ProductRemoteDataSource, - productLocalDataSource: ProductLocalDataSource, - productCacheDataSource: ProductCacheDataSource, - ): ProductRepository { - return ProductRepositoryImpl( - productRemoteDataSource, - productLocalDataSource, - productCacheDataSource - ) - } - - @Provides - @Singleton - fun provideProductDetailRepository( - productDetailRemoteDataSource: ProductDetailRemoteDataSource - ): ProductDetailRepository { - return ProductDetailRepositoryImpl( - productDetailRemoteDataSource - ) - } - - @Provides - @Singleton - fun provideLoginRepository( - loginRemoteDataSource: LoginRemoteDataSource, - loginLocalDataSource: LoginLocalDataSource, - ): LoginRepository { - return LoginRepositoryImpl( - loginRemoteDataSource, - loginLocalDataSource - ) - } - - @Provides - @Singleton - fun provideProductCategory( - productCategoryRemoteDataSource: ProductCategoryRemoteDataSource - ): ProductCategoryRepository { - return ProductCategoryRepositoryImpl( - productCategoryRemoteDataSource - ) - } - - @Provides - @Singleton - fun provideCartRepository( - cartLocalDataSource: CartLocalDataSource - ): CartRepository { - return CartRepositoryImpl( - cartLocalDataSource - ) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/UseCaseModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/UseCaseModule.kt deleted file mode 100644 index ed68d06a..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/core/UseCaseModule.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.core - -import com.algokelvin.shoppingyuk.domain.repository.CartRepository -import com.algokelvin.shoppingyuk.domain.repository.LoginRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductCategoryRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductDetailRepository -import com.algokelvin.shoppingyuk.domain.repository.ProductRepository -import com.algokelvin.shoppingyuk.domain.usecase.AddProductToCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.CheckoutUseCase -import com.algokelvin.shoppingyuk.domain.usecase.DeleteProductInCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetCartByUserIdUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductDetailUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsCategoryUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileFromDBUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileUseCase -import com.algokelvin.shoppingyuk.domain.usecase.LoginUseCase -import com.algokelvin.shoppingyuk.domain.usecase.UpdateCountProductInCartUseCase -import dagger.Module -import dagger.Provides - -@Module -class UseCaseModule { - @Provides - fun provideGetMovieUseCase(productRepository: ProductRepository): GetProductsUseCase { - return GetProductsUseCase(productRepository) - } - - @Provides - fun provideGetProductDetailUseCase(productDetailRepository: ProductDetailRepository): GetProductDetailUseCase { - return GetProductDetailUseCase(productDetailRepository) - } - - @Provides - fun provideLoginUseCase(loginRepository: LoginRepository): LoginUseCase { - return LoginUseCase(loginRepository) - } - - @Provides - fun provideGetProductsCategoryUseCase(productCategoryRepository: ProductCategoryRepository): GetProductsCategoryUseCase { - return GetProductsCategoryUseCase(productCategoryRepository) - } - - @Provides - fun provideGetProfileUseCase(loginRepository: LoginRepository): GetProfileUseCase { - return GetProfileUseCase(loginRepository) - } - - @Provides - fun provideGetProfileFromDBUseCase(loginRepository: LoginRepository): GetProfileFromDBUseCase { - return GetProfileFromDBUseCase(loginRepository) - } - - @Provides - fun provideGetCartByUserIdUseCase(cartRepository: CartRepository): GetCartByUserIdUseCase { - return GetCartByUserIdUseCase(cartRepository) - } - - @Provides - fun provideAddProductToCartUseCase(cartRepository: CartRepository): AddProductToCartUseCase { - return AddProductToCartUseCase(cartRepository) - } - - @Provides - fun provideUpdateCountProductInCartUseCase(cartRepository: CartRepository): UpdateCountProductInCartUseCase { - return UpdateCountProductInCartUseCase(cartRepository) - } - - @Provides - fun provideDeleteProductInCartUseCase(cartRepository: CartRepository): DeleteProductInCartUseCase { - return DeleteProductInCartUseCase(cartRepository) - } - - @Provides - fun provideCheckoutUseCase(cartRepository: CartRepository): CheckoutUseCase { - return CheckoutUseCase(cartRepository) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeModule.kt deleted file mode 100644 index cde13da4..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.home - -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileFromDBUseCase -import com.algokelvin.shoppingyuk.presentation.home.HomeViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class HomeModule { - @HomeScope - @Provides - fun provideHomeViewModelFactory( - getProfileFromDBUseCase: GetProfileFromDBUseCase, - ): HomeViewModelFactory = HomeViewModelFactory(getProfileFromDBUseCase) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeScope.kt deleted file mode 100644 index 301582c4..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.home - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class HomeScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeSubComponent.kt deleted file mode 100644 index e5224a8e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/home/HomeSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.home - -import com.algokelvin.shoppingyuk.presentation.home.HomeActivity -import dagger.Subcomponent - -@HomeScope -@Subcomponent(modules = [HomeModule::class]) -interface HomeSubComponent { - fun inject(homeActivity: HomeActivity) - - @Subcomponent.Factory - interface Factory { - fun create(): HomeSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginModule.kt deleted file mode 100644 index 10dc0682..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginModule.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.login - -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileUseCase -import com.algokelvin.shoppingyuk.domain.usecase.LoginUseCase -import com.algokelvin.shoppingyuk.presentation.login.LoginViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class LoginModule { - @LoginScope - @Provides - fun provideLoginViewModelFactory( - loginUseCase: LoginUseCase, - getProfileUseCase: GetProfileUseCase, - ): LoginViewModelFactory = LoginViewModelFactory(loginUseCase, getProfileUseCase) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginScope.kt deleted file mode 100644 index c8b1d12f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.login - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class LoginScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginSubComponent.kt deleted file mode 100644 index 3c8ae6e2..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/login/LoginSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.login - -import com.algokelvin.shoppingyuk.presentation.login.LoginActivity -import dagger.Subcomponent - -@LoginScope -@Subcomponent(modules = [LoginModule::class]) -interface LoginSubComponent { - fun inject(loginActivity: LoginActivity) - - @Subcomponent.Factory - interface Factory { - fun create(): LoginSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryModule.kt deleted file mode 100644 index d3fc72d4..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsCategoryUseCase -import com.algokelvin.shoppingyuk.presentation.productcategory.ProductCategoryViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class ProductCategoryModule { - @ProductCategoryScope - @Provides - fun provideProductCategoryViewModelFactory( - getProductsCategoryUseCase: GetProductsCategoryUseCase - ): ProductCategoryViewModelFactory = ProductCategoryViewModelFactory(getProductsCategoryUseCase) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryScope.kt deleted file mode 100644 index 71ba8ea9..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategoryScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class ProductCategoryScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategorySubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategorySubComponent.kt deleted file mode 100644 index b60831c8..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductCategorySubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.presentation.productcategory.ProductCategoryFragment -import dagger.Subcomponent - -@ProductCategoryScope -@Subcomponent(modules = [ProductCategoryModule::class]) -interface ProductCategorySubComponent { - fun inject(productCategoryFragment: ProductCategoryFragment) - - @Subcomponent.Factory - interface Factory { - fun create(): ProductCategorySubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailModule.kt deleted file mode 100644 index ad73edec..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailModule.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.domain.usecase.AddProductToCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductDetailUseCase -import com.algokelvin.shoppingyuk.presentation.productdetail.ProductDetailViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class ProductDetailModule { - @ProductDetailScope - @Provides - fun provideProductDetailViewModelFactory( - getProductDetailUseCase: GetProductDetailUseCase, - addProductToCartUseCase: AddProductToCartUseCase, - ): ProductDetailViewModelFactory = ProductDetailViewModelFactory( - getProductDetailUseCase, - addProductToCartUseCase - ) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailScope.kt deleted file mode 100644 index bd3a6b52..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class ProductDetailScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailSubComponent.kt deleted file mode 100644 index 3d1b6b17..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductDetailSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.presentation.productdetail.ProductDetailActivity -import dagger.Subcomponent - -@ProductDetailScope -@Subcomponent(modules = [ProductDetailModule::class]) -interface ProductDetailSubComponent { - fun inject(productDetailActivity: ProductDetailActivity) - - @Subcomponent.Factory - interface Factory { - fun create(): ProductDetailSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductModule.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductModule.kt deleted file mode 100644 index 4ca74c17..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsUseCase -import com.algokelvin.shoppingyuk.presentation.product.ProductViewModelFactory -import dagger.Module -import dagger.Provides - -@Module -class ProductModule { - @ProductScope - @Provides - fun provideProductViewModelFactory( - getProductsUseCase: GetProductsUseCase, - ): ProductViewModelFactory = ProductViewModelFactory(getProductsUseCase) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductScope.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductScope.kt deleted file mode 100644 index eb10a8ea..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class ProductScope \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductSubComponent.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductSubComponent.kt deleted file mode 100644 index d402d977..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/di/product/ProductSubComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.di.product - -import com.algokelvin.shoppingyuk.presentation.product.ProductFragment -import dagger.Subcomponent - -@ProductScope -@Subcomponent(modules = [ProductModule::class]) -interface ProductSubComponent { - fun inject(productFragment: ProductFragment) - - @Subcomponent.Factory - interface Factory { - fun create(): ProductSubComponent - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeActivity.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeActivity.kt deleted file mode 100644 index 6bd68c15..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeActivity.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.home - -import android.content.Intent -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.databinding.ActivityHome2Binding -import com.algokelvin.shoppingyuk.presentation.cart.CartActivity -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.profile.ProfileBottomSheetFragment -import com.algokelvin.shoppingyuk.utils.EncryptLocal -import com.google.android.material.tabs.TabLayoutMediator -import javax.inject.Inject - -class HomeActivity : AppCompatActivity() { - @Inject - lateinit var factory: HomeViewModelFactory - - private lateinit var binding: ActivityHome2Binding - private lateinit var homeViewModel: HomeViewModel - - private var profileId : Int? = 0 - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = DataBindingUtil.setContentView(this, R.layout.activity_home2) - - (application as Injector).createHomeSubComponent() - .inject(this) - homeViewModel = ViewModelProvider(this, factory)[HomeViewModel::class] - - profileId = EncryptLocal.getIdProfile(this) - - binding.imgProfile.setOnClickListener { - profileId?.let { id -> - homeViewModel.getProfileFromDB(id).observe(this) { user -> - val profileBottomSheetFragment = ProfileBottomSheetFragment(user) - profileBottomSheetFragment.show( - supportFragmentManager, - profileBottomSheetFragment.tag - ) - } - } - } - - binding.imgCart.setOnClickListener { - val intentToCart = Intent(this, CartActivity::class.java) - startActivity(intentToCart) - } - - initTabLayout() - } - - private fun initTabLayout() { - val adapter = ViewPagerAdapter(this) - binding.viewPager.adapter = adapter - - TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position -> - tab.text = when(position) { - 0 -> "Product" - 1 -> "Category" - else -> null - } - }.attach() - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModel.kt deleted file mode 100644 index 18bae703..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModel.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.home - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileFromDBUseCase - -class HomeViewModel( - private val getProfileFromDBUseCase: GetProfileFromDBUseCase, -): ViewModel() { - fun getProfileFromDB(id: Int) = liveData { - val profileUser = getProfileFromDBUseCase.execute(id) - emit(profileUser) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModelFactory.kt deleted file mode 100644 index 284fde29..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/HomeViewModelFactory.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.home - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileFromDBUseCase - -@Suppress("UNCHECKED_CAST") -class HomeViewModelFactory( - private val getProfileFromDBUseCase: GetProfileFromDBUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return HomeViewModel(getProfileFromDBUseCase) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/ViewPagerAdapter.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/ViewPagerAdapter.kt deleted file mode 100644 index 4c12e2b5..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/home/ViewPagerAdapter.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.home - -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentActivity -import androidx.viewpager2.adapter.FragmentStateAdapter -import com.algokelvin.shoppingyuk.presentation.product.ProductFragment -import com.algokelvin.shoppingyuk.presentation.productcategory.ProductCategoryFragment - -class ViewPagerAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) { - override fun getItemCount(): Int = 2 - - override fun createFragment(position: Int): Fragment { - return when (position) { - 0 -> ProductFragment() - 1 -> ProductCategoryFragment() - else -> throw IllegalArgumentException("Invalid tab position") - } - } -} diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginActivity.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginActivity.kt deleted file mode 100644 index 1beaa891..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginActivity.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.login - -import android.content.Intent -import android.os.Bundle -import android.view.View -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.databinding.ActivityLoginBinding -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.home.HomeActivity -import com.algokelvin.shoppingyuk.utils.EncryptLocal -import javax.inject.Inject - -class LoginActivity : AppCompatActivity() { - @Inject - lateinit var factory: LoginViewModelFactory - - private lateinit var binding: ActivityLoginBinding - private lateinit var loginViewModel: LoginViewModel - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - checkStatusLogin() - } - - private fun checkStatusLogin() { - val getToken = EncryptLocal.getToken(this) - if (getToken != null) { - Toast.makeText(this, "Anda sudah Login", Toast.LENGTH_SHORT).show() - val intentToHome = Intent(this, HomeActivity::class.java) - startActivity(intentToHome) - finish() - } else { - binding = DataBindingUtil.setContentView(this, R.layout.activity_login) - - (application as Injector).createLoginSubComponent() - .inject(this) - loginViewModel = ViewModelProvider(this, factory)[LoginViewModel::class] - - initLogin() - } - } - - private fun initLogin() { - binding.btnLogin.setOnClickListener { - binding.materialCardView.visibility = View.GONE - binding.layoutLoading.visibility = View.VISIBLE - - val username = binding.usernameData.text.toString() - val password = binding.passwordData.text.toString() - val login = Login(username, password) - - loginViewModel.login(login).observe(this) { token -> - if (token != null) { - if (token.errorMessage == null) { - val tokenStr = token.data?.token - tokenStr?.let { it1 -> EncryptLocal.saveToken(this, it1) } - loginViewModel.getProfile(login).observe(this) { profile -> - Toast.makeText(this, "Success Login", Toast.LENGTH_SHORT).show() - val profileId = profile.data?.id - profileId?.let { it1 -> EncryptLocal.saveIdProfile(this, it1) } - val intentToHome = Intent(this, HomeActivity::class.java) - intentToHome.putExtra("PROFILE_ID", profileId) - startActivity(intentToHome) - finish() - } - } else { - Toast.makeText(this, token.errorMessage, Toast.LENGTH_SHORT).show() - binding.materialCardView.visibility = View.VISIBLE - binding.layoutLoading.visibility = View.GONE - } - } - } - } - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModel.kt deleted file mode 100644 index 9fb79d2e..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModel.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.login - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.data.model.user.Login -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileUseCase -import com.algokelvin.shoppingyuk.domain.usecase.LoginUseCase - -class LoginViewModel( - private val loginUseCase: LoginUseCase, - private val getProfileUseCase: GetProfileUseCase, -): ViewModel() { - fun login(login: Login) = liveData { - val token = loginUseCase.execute(login) - emit(token) - } - fun getProfile(login: Login) = liveData { - val profile = getProfileUseCase.execute(login) - emit(profile) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModelFactory.kt deleted file mode 100644 index ef295b55..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/login/LoginViewModelFactory.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.login - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.GetProfileUseCase -import com.algokelvin.shoppingyuk.domain.usecase.LoginUseCase - -@Suppress("UNCHECKED_CAST") -class LoginViewModelFactory( - private val loginUseCase: LoginUseCase, - private val getProfileUseCase: GetProfileUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return LoginViewModel(loginUseCase, getProfileUseCase) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemCart.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemCart.kt deleted file mode 100644 index 148aad95..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemCart.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.onclick - -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.databinding.ItemCartLayoutBinding - -interface OnClickItemCart { - fun onClickIncrease(bindingItem: ItemCartLayoutBinding, cartDB: CartDB) - fun onClickDecrease(bindingItem: ItemCartLayoutBinding, cartDB: CartDB) - fun onClickDelete(cartDB: CartDB) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemProduct.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemProduct.kt deleted file mode 100644 index d6348040..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/onclick/OnClickItemProduct.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.onclick - -import com.algokelvin.shoppingyuk.data.model.product.Product - -interface OnClickItemProduct { - fun onClickItemProduct(product: Product) -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductAdapter.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductAdapter.kt deleted file mode 100644 index 2f50979f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductAdapter.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.product - -import android.view.LayoutInflater -import android.view.ViewGroup -import androidx.databinding.DataBindingUtil -import androidx.recyclerview.widget.RecyclerView -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.databinding.ItemProductLayoutBinding -import com.algokelvin.shoppingyuk.presentation.onclick.OnClickItemProduct -import com.bumptech.glide.Glide - - -class ProductAdapter( - private val onClickItemProduct: OnClickItemProduct -):RecyclerView.Adapter() { - private val productList = ArrayList() - - fun setList(products:List){ - productList.clear() - productList.addAll(products) - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { - val layoutInflater = LayoutInflater.from(parent.context) - val binding : ItemProductLayoutBinding = DataBindingUtil.inflate( - layoutInflater, - R.layout.item_product_layout, - parent, - false - ) - return MyViewHolder(binding, onClickItemProduct) - } - - override fun getItemCount(): Int { - return productList.size - } - - override fun onBindViewHolder(holder: MyViewHolder, position: Int) { - holder.bind(productList[position]) - } -} - - - -class MyViewHolder( - private val binding: ItemProductLayoutBinding, - private val onClickItemProduct: OnClickItemProduct, -): RecyclerView.ViewHolder(binding.root) { - - fun bind(product: Product){ - binding.titleProduct.text = product.title - binding.categoryProduct.text = product.category - binding.priceProduct.text = product.price.toString() - binding.rateProduct.text = product.rating?.rate.toString() - binding.countProduct.text = itemView.context.getString(R.string.item_sold, product.rating?.count.toString()) - Glide.with(binding.imageProduct.context) - .load(product.image) - .into(binding.imageProduct) - binding.cardView.setOnClickListener { - onClickItemProduct.onClickItemProduct(product) - } - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductFragment.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductFragment.kt deleted file mode 100644 index cfa4ce15..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductFragment.kt +++ /dev/null @@ -1,110 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.product - -import android.content.Intent -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Toast -import androidx.databinding.DataBindingUtil -import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider -import androidx.recyclerview.widget.GridLayoutManager -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.databinding.ActivityProductBinding -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.onclick.OnClickItemProduct -import com.algokelvin.shoppingyuk.presentation.productdetail.ProductDetailActivity -import javax.inject.Inject - -class ProductFragment : Fragment(), OnClickItemProduct { - @Inject - lateinit var factory: ProductViewModelFactory - - private lateinit var binding: ActivityProductBinding - private lateinit var productViewModel: ProductViewModel - private lateinit var adapter: ProductAdapter - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - binding = DataBindingUtil.inflate(inflater, R.layout.activity_product, container, false) - - (activity?.application as Injector).createMovieSubComponent() - .inject(this) - productViewModel = ViewModelProvider(this, factory)[ProductViewModel::class] - - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initRecyclerView() - - /*binding.imgProfile.setOnClickListener { - val profileId = intent.getIntExtra("PROFILE_ID", 0) - productViewModel.getProfileFromDB(profileId).observe(viewLifecycleOwner, Observer { user -> - Toast.makeText(context, "User: "+user.username, Toast.LENGTH_SHORT).show() - val profileBottomSheetFragment = ProfileBottomSheetFragment(user) - profileBottomSheetFragment.show(supportFragmentManager, profileBottomSheetFragment.tag) - }) - }*/ - } - - /*override fun onCreateOptionsMenu(menu: Menu?): Boolean { - val inflater: MenuInflater = menuInflater - inflater.inflate(R.menu.update, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.action_update -> { - //updateMovies() - true - } - else -> super.onOptionsItemSelected(item) - } - }*/ - - /*private fun updateMovies() { - *//*binding.productProgressBar.visibility = View.VISIBLE - val response = productViewModel.updateMovies() - response.observe(this, Observer { - if (it != null) { - adapter.setList(it) - adapter.notifyDataSetChanged() - binding.productProgressBar.visibility = View.GONE - } else { - binding.productProgressBar.visibility = View.GONE - } - })*//* - }*/ - - private fun initRecyclerView(){ - binding.productRecyclerView.layoutManager = GridLayoutManager(context, 2) - adapter = ProductAdapter(this) - binding.productRecyclerView.adapter = adapter - displayPopularMovies() - } - - private fun displayPopularMovies(){ - binding.productProgressBar.visibility = View.VISIBLE - val responseLiveData = productViewModel.getProducts() - responseLiveData.observe(viewLifecycleOwner) { - if (it != null) { - adapter.setList(it) - adapter.notifyDataSetChanged() - binding.productProgressBar.visibility = View.GONE - }else{ - binding.productProgressBar.visibility = View.GONE - Toast.makeText(context,"No data available", Toast.LENGTH_LONG).show() - } - } - } - - override fun onClickItemProduct(product: Product) { - val toProductDetailPage = Intent(context, ProductDetailActivity::class.java) - toProductDetailPage.putExtra("PRODUCT_ID", product.id) - startActivity(toProductDetailPage) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModel.kt deleted file mode 100644 index 9c27a838..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModel.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.product - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsUseCase - -class ProductViewModel( - private val getProductsUseCase: GetProductsUseCase, -): ViewModel() { - fun getProducts() = liveData { - val productList = getProductsUseCase.execute() - emit(productList) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModelFactory.kt deleted file mode 100644 index 89cdd464..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/product/ProductViewModelFactory.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.product - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsUseCase - -@Suppress("UNCHECKED_CAST") -class ProductViewModelFactory( - private val getProductsUseCase: GetProductsUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return ProductViewModel(getProductsUseCase) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryFragment.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryFragment.kt deleted file mode 100644 index 30a61714..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryFragment.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productcategory - -import android.content.Intent -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Toast -import androidx.databinding.DataBindingUtil -import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider -import androidx.recyclerview.widget.GridLayoutManager -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.databinding.ActivityProductCategoryBinding -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.presentation.onclick.OnClickItemProduct -import com.algokelvin.shoppingyuk.presentation.product.ProductAdapter -import com.algokelvin.shoppingyuk.presentation.productdetail.ProductDetailActivity -import javax.inject.Inject - -class ProductCategoryFragment : Fragment(), OnClickItemProduct { - @Inject - lateinit var factory: ProductCategoryViewModelFactory - - private lateinit var binding: ActivityProductCategoryBinding - private lateinit var productCategoryViewModel: ProductCategoryViewModel - private lateinit var adapter: ProductAdapter - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - binding = DataBindingUtil.inflate(inflater, R.layout.activity_product_category, container, false) - - (activity?.application as Injector).createProductCategorySubComponent() - .inject(this) - productCategoryViewModel = ViewModelProvider(this, factory)[ProductCategoryViewModel::class] - - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initProductCategory() - } - - /*override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - //binding = DataBindingUtil.setContentView(context, R.layout.activity_product_category) - - *//*(context as Injector).createProductCategorySubComponent() - .inject(this) - productCategoryViewModel = ViewModelProvider(this, factory)[ProductCategoryViewModel::class]*//* - - //initProductCategory() - }*/ - - private fun initProductCategory() { - binding.productRecyclerView.layoutManager = GridLayoutManager(context, 2) - adapter = ProductAdapter(this) - binding.productRecyclerView.adapter = adapter - displayProductsSortByCategory() - } - - private fun displayProductsSortByCategory() { - binding.productProgressBar.visibility = View.VISIBLE - val responseLiveData = productCategoryViewModel.getProductsSortByCategory() - responseLiveData.observe(viewLifecycleOwner) { - if (it != null) { - adapter.setList(it) - adapter.notifyDataSetChanged() - binding.productProgressBar.visibility = View.GONE - }else{ - binding.productProgressBar.visibility = View.GONE - Toast.makeText(context,"No data available", Toast.LENGTH_LONG).show() - } - } - } - - override fun onClickItemProduct(product: Product) { - val toProductDetailPage = Intent(context, ProductDetailActivity::class.java) - toProductDetailPage.putExtra("PRODUCT_ID", product.id) - startActivity(toProductDetailPage) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModel.kt deleted file mode 100644 index 86b85fbd..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModel.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productcategory - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsCategoryUseCase - -class ProductCategoryViewModel( - private val getProductsCategoryUseCase: GetProductsCategoryUseCase, -): ViewModel() { - - fun getProductsSortByCategory() = liveData { - val productsCategory = getProductsCategoryUseCase.execute() - emit(productsCategory) - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModelFactory.kt deleted file mode 100644 index 8aa81458..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productcategory/ProductCategoryViewModelFactory.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productcategory - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.GetProductsCategoryUseCase - -@Suppress("UNCHECKED_CAST") -class ProductCategoryViewModelFactory( - private val getProductsCategoryUseCase: GetProductsCategoryUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return ProductCategoryViewModel(getProductsCategoryUseCase) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailActivity.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailActivity.kt deleted file mode 100644 index d84709d1..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailActivity.kt +++ /dev/null @@ -1,72 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productdetail - -import android.os.Bundle -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.databinding.DataBindingUtil -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.data.model.product.Product -import com.algokelvin.shoppingyuk.databinding.ActivityProductDetailBinding -import com.algokelvin.shoppingyuk.presentation.di.Injector -import com.algokelvin.shoppingyuk.utils.EncryptLocal -import com.bumptech.glide.Glide -import javax.inject.Inject - -class ProductDetailActivity : AppCompatActivity() { - @Inject - lateinit var factory: ProductDetailViewModelFactory - - private lateinit var binding: ActivityProductDetailBinding - private lateinit var productDetailViewModel: ProductDetailViewModel - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = DataBindingUtil.setContentView(this, R.layout.activity_product_detail) - - (application as Injector).createProductDetailSubComponent() - .inject(this) - productDetailViewModel = ViewModelProvider(this, factory)[ProductDetailViewModel::class] - - initProductDetail() - } - - private fun initProductDetail() { - val id = intent.getIntExtra("PRODUCT_ID", 0) - productDetailViewModel.getProductDetail(id.toString()).observe(this) { - if (it != null) { - val product = it - Glide.with(binding.imageProduct.context) - .load(product.image) - .into(binding.imageProduct) - binding.nameProduct.text = product.title - binding.categoryProduct.text = product.category - binding.priceProduct.text = getString(R.string.total_all_price, product.price.toString()) - binding.descriptionProduct.text = product.description - addToCart(product) - } - } - } - - private fun addToCart(product: Product) { - binding.btnAddToCart.setOnClickListener { - EncryptLocal.getIdProfile(this).let { profileId -> - val cartDB = CartDB( - userId = profileId, - productId = product.id, - productTitle = product.title, - productImage = product.image, - productPrice = product.price, - count = 1 - ) - cartDB.let { data -> - productDetailViewModel.addProductToCart(data).observe(this) { - Toast.makeText(this, it, Toast.LENGTH_LONG).show() - } - } - } - } - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModel.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModel.kt deleted file mode 100644 index ffb2d2fa..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModel.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productdetail - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.liveData -import com.algokelvin.shoppingyuk.data.model.cart.CartDB -import com.algokelvin.shoppingyuk.domain.usecase.AddProductToCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductDetailUseCase - -class ProductDetailViewModel( - private val getProductDetailUseCase: GetProductDetailUseCase, - private val addProductToCartUseCase: AddProductToCartUseCase, -): ViewModel() { - - fun getProductDetail(id: String) = liveData { - val productDetail = getProductDetailUseCase.execute(id) - emit(productDetail) - } - - fun addProductToCart(cartDB: CartDB) = liveData { - val statusAddProductToCart = addProductToCartUseCase.execute(cartDB) - emit(statusAddProductToCart) - } - -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModelFactory.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModelFactory.kt deleted file mode 100644 index 8275e17c..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/productdetail/ProductDetailViewModelFactory.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.algokelvin.shoppingyuk.presentation.productdetail - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.algokelvin.shoppingyuk.domain.usecase.AddProductToCartUseCase -import com.algokelvin.shoppingyuk.domain.usecase.GetProductDetailUseCase - -@Suppress("UNCHECKED_CAST") -class ProductDetailViewModelFactory( - private val getProductDetailUseCase: GetProductDetailUseCase, - private val addProductToCartUseCase: AddProductToCartUseCase, -): ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return ProductDetailViewModel( - getProductDetailUseCase, - addProductToCartUseCase, - ) as T - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/profile/ProfileBottomSheetFragment.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/profile/ProfileBottomSheetFragment.kt deleted file mode 100644 index 198f609f..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/presentation/profile/ProfileBottomSheetFragment.kt +++ /dev/null @@ -1,29 +0,0 @@ -// BottomSheetFragment.kt -package com.algokelvin.shoppingyuk.presentation.profile - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.databinding.DataBindingUtil -import com.algokelvin.shoppingyuk.R -import com.algokelvin.shoppingyuk.data.model.user.User -import com.algokelvin.shoppingyuk.databinding.ProfilePageBottomSheetBinding -import com.google.android.material.bottomsheet.BottomSheetDialogFragment - -class ProfileBottomSheetFragment(private val user: User) : BottomSheetDialogFragment() { - private lateinit var binding: ProfilePageBottomSheetBinding - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - binding = DataBindingUtil.inflate(inflater, R.layout.profile_page_bottom_sheet, container, false) - return binding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val name = user.name.firstName+" "+user.name.lastName - binding.nameProfileUser.text = name - binding.emailProfileUser.text = user.email - binding.phoneProfileUser.text = user.phone - } -} diff --git a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/utils/EncryptLocal.kt b/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/utils/EncryptLocal.kt deleted file mode 100644 index 7b93ca09..00000000 --- a/ECommerce/app/src/main/java/com/algokelvin/shoppingyuk/utils/EncryptLocal.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.algokelvin.shoppingyuk.utils - -import android.content.Context -import android.content.SharedPreferences -import androidx.security.crypto.EncryptedSharedPreferences -import androidx.security.crypto.MasterKeys - -object EncryptLocal { - fun saveToken(context: Context, token: String) { - val sharedPreferences = getEncryptedPrefs(context) - with(sharedPreferences.edit()) { - putString("user_token", token) - apply() - } - } - - fun saveIdProfile(context: Context, id: Int) { - val sharedPreferences = getEncryptedPrefs(context) - with(sharedPreferences.edit()) { - putInt("user_id", id) - apply() - } - } - - fun getToken(context: Context): String? { - val sharedPreferences = getEncryptedPrefs(context) - return sharedPreferences.getString("user_token", null) - } - - fun getIdProfile(context: Context): Int { - val sharedPreferences = getEncryptedPrefs(context) - return sharedPreferences.getInt("user_id", 0) - } - - private fun getEncryptedPrefs(context: Context): SharedPreferences { - val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC) - - return EncryptedSharedPreferences.create( - "secure_prefs", - masterKeyAlias, - context, - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM - ) - } -} \ No newline at end of file diff --git a/ECommerce/app/src/main/res/drawable/bg_item_product.xml b/ECommerce/app/src/main/res/drawable/bg_item_product.xml deleted file mode 100644 index c80b19af..00000000 --- a/ECommerce/app/src/main/res/drawable/bg_item_product.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ECommerce/app/src/main/res/drawable/ic_cart.xml b/ECommerce/app/src/main/res/drawable/ic_cart.xml deleted file mode 100644 index 0fc77716..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_cart.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_category.xml b/ECommerce/app/src/main/res/drawable/ic_category.xml deleted file mode 100644 index 792fc551..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_category.xml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_decrease.xml b/ECommerce/app/src/main/res/drawable/ic_decrease.xml deleted file mode 100644 index 7f3b4ddb..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_decrease.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_delete.xml b/ECommerce/app/src/main/res/drawable/ic_delete.xml deleted file mode 100644 index d29a78a2..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_delete.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_dot_count.xml b/ECommerce/app/src/main/res/drawable/ic_dot_count.xml deleted file mode 100644 index a9d5ca5e..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_dot_count.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_increase.xml b/ECommerce/app/src/main/res/drawable/ic_increase.xml deleted file mode 100644 index dee8ffd3..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_increase.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_launcher_background.xml b/ECommerce/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_price.xml b/ECommerce/app/src/main/res/drawable/ic_price.xml deleted file mode 100644 index 3848f19c..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_price.xml +++ /dev/null @@ -1,1080 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_profile.xml b/ECommerce/app/src/main/res/drawable/ic_profile.xml deleted file mode 100644 index 4645efda..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_profile.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_rate.xml b/ECommerce/app/src/main/res/drawable/ic_rate.xml deleted file mode 100644 index d7eba10c..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_rate.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/drawable/ic_sample_photo_user.xml b/ECommerce/app/src/main/res/drawable/ic_sample_photo_user.xml deleted file mode 100644 index b0a426de..00000000 --- a/ECommerce/app/src/main/res/drawable/ic_sample_photo_user.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/ECommerce/app/src/main/res/layout/activity_cart.xml b/ECommerce/app/src/main/res/layout/activity_cart.xml deleted file mode 100644 index d970e114..00000000 --- a/ECommerce/app/src/main/res/layout/activity_cart.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - -