├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── drawable │ │ │ │ ├── bg_splash.png │ │ │ │ ├── cat_img.png │ │ │ │ ├── btn_bg.xml │ │ │ │ ├── btn_bg2.xml │ │ │ │ ├── btn_bg3.xml │ │ │ │ ├── search_bg.xml │ │ │ │ ├── ic_back.xml │ │ │ │ ├── ic_baseline_access_time_24.xml │ │ │ │ ├── ic_fav_unfill.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── font │ │ │ │ ├── gilroy_bold.otf │ │ │ │ └── gilroy_light.otf │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── layout │ │ │ │ ├── item_rv_sub_category.xml │ │ │ │ ├── activity_splash.xml │ │ │ │ ├── item_rv_main_category.xml │ │ │ │ ├── activity_home.xml │ │ │ │ └── activity_detail.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── codingwithme │ │ │ │ └── recipeapp │ │ │ │ ├── entities │ │ │ │ ├── Recipes.kt │ │ │ │ ├── Category.kt │ │ │ │ ├── Meal.kt │ │ │ │ ├── MealsItems.kt │ │ │ │ ├── CategoryItems.kt │ │ │ │ ├── converter │ │ │ │ │ ├── CategoryListConverter.kt │ │ │ │ │ └── MealListConverter.kt │ │ │ │ └── MealResponse.kt │ │ │ │ ├── interfaces │ │ │ │ └── GetDataService.kt │ │ │ │ ├── retofitclient │ │ │ │ └── RetrofitClientInstance.kt │ │ │ │ ├── BaseActivity.kt │ │ │ │ ├── dao │ │ │ │ └── RecipeDao.kt │ │ │ │ ├── database │ │ │ │ └── RecipeDatabase.kt │ │ │ │ ├── adapter │ │ │ │ ├── MainCategoryAdapter.kt │ │ │ │ └── SubCategoryAdapter.kt │ │ │ │ ├── HomeActivity.kt │ │ │ │ ├── DetailActivity.kt │ │ │ │ └── SplashActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── codingwithme │ │ │ └── recipeapp │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── codingwithme │ │ └── recipeapp │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── .gitignore ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── compiler.xml ├── misc.xml ├── gradle.xml ├── jarRepositories.xml ├── markdown-navigator-enh.xml └── markdown-navigator.xml ├── RecipeApp.zip ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "RecipeApp" -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /RecipeApp.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/RecipeApp.zip -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RecipeApp 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/drawable/bg_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/cat_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/drawable/cat_img.png -------------------------------------------------------------------------------- /app/src/main/res/font/gilroy_bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/font/gilroy_bold.otf -------------------------------------------------------------------------------- /app/src/main/res/font/gilroy_light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/font/gilroy_light.otf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/RecipeApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_bg2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_bg3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/search_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jan 07 19:28:06 PKT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/Recipes.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import java.io.Serializable 7 | 8 | @Entity(tableName = "Recipes") 9 | data class Recipes( 10 | @PrimaryKey(autoGenerate = true) 11 | var id:Int, 12 | 13 | @ColumnInfo(name = "dishName") 14 | var dishName:String 15 | ) : Serializable -------------------------------------------------------------------------------- /app/src/test/java/com/codingwithme/recipeapp/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF9A00 4 | #433232 5 | #FF000000 6 | #00000000 7 | #FFFFFFFF 8 | #F6DEDE 9 | #C64141 10 | #f5f5f5 11 | #3A3939 12 | #787878 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/Category.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities 2 | 3 | import androidx.room.* 4 | import com.codingwithme.recipeapp.entities.converter.CategoryListConverter 5 | import com.google.gson.annotations.Expose 6 | import com.google.gson.annotations.SerializedName 7 | 8 | @Entity(tableName = "Category") 9 | data class Category( 10 | @PrimaryKey(autoGenerate = true) 11 | var id:Int, 12 | 13 | @ColumnInfo(name = "categoryItems") 14 | @Expose 15 | @SerializedName("categories") 16 | @TypeConverters(CategoryListConverter::class) 17 | var categorieitems: List? = null 18 | ) 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_access_time_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_fav_unfill.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/Meal.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import androidx.room.TypeConverters 7 | import com.codingwithme.recipeapp.entities.converter.MealListConverter 8 | import com.google.gson.annotations.Expose 9 | import com.google.gson.annotations.SerializedName 10 | 11 | @Entity(tableName = "Meal") 12 | class Meal( 13 | 14 | @PrimaryKey(autoGenerate = true) 15 | var id:Int, 16 | 17 | @ColumnInfo(name = "meals") 18 | @Expose 19 | @SerializedName("meals") 20 | @TypeConverters(MealListConverter::class) 21 | var mealsItem: List? = null 22 | 23 | ) 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/interfaces/GetDataService.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.interfaces 2 | 3 | import com.codingwithme.recipeapp.entities.Category 4 | import com.codingwithme.recipeapp.entities.CategoryItems 5 | import com.codingwithme.recipeapp.entities.Meal 6 | import com.codingwithme.recipeapp.entities.MealResponse 7 | import retrofit2.Call 8 | import retrofit2.http.GET 9 | import retrofit2.http.Query 10 | 11 | interface GetDataService { 12 | @GET("categories.php") 13 | fun getCategoryList(): Call 14 | 15 | @GET("filter.php") 16 | fun getMealList(@Query("c") category: String): Call 17 | 18 | @GET("lookup.php") 19 | fun getSpecificItem(@Query("i") id: String): Call 20 | 21 | 22 | } -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/retofitclient/RetrofitClientInstance.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.retofitclient 2 | 3 | import retrofit2.Retrofit 4 | import retrofit2.converter.gson.GsonConverterFactory 5 | 6 | 7 | class RetrofitClientInstance { 8 | companion object{ 9 | val BASE_URL = "https://www.themealdb.com/api/json/v1/1/" 10 | private var retrofit: Retrofit? = null 11 | val retrofitInstance: Retrofit? 12 | get() { 13 | if (retrofit == null) { 14 | retrofit = Retrofit.Builder() 15 | .baseUrl(BASE_URL) 16 | .addConverterFactory(GsonConverterFactory.create()) 17 | .build() 18 | } 19 | return retrofit 20 | } 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/codingwithme/recipeapp/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.codingwithme.recipeapp", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp 2 | 3 | import android.app.job.JobInfo 4 | import android.content.Intent 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | import kotlinx.coroutines.CoroutineScope 8 | import kotlinx.coroutines.Dispatchers 9 | import kotlinx.coroutines.Job 10 | import kotlin.coroutines.CoroutineContext 11 | 12 | open class BaseActivity : AppCompatActivity(),CoroutineScope { 13 | private lateinit var job: Job 14 | override val coroutineContext:CoroutineContext 15 | get() = job +Dispatchers.Main 16 | 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | job = Job() 21 | } 22 | 23 | override fun onDestroy() { 24 | super.onDestroy() 25 | job.cancel() 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/MealsItems.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import com.google.gson.annotations.Expose 7 | import com.google.gson.annotations.SerializedName 8 | @Entity(tableName = "MealItems") 9 | data class MealsItems( 10 | @PrimaryKey(autoGenerate = true) 11 | var id:Int, 12 | 13 | @ColumnInfo(name = "idMeal") 14 | @Expose 15 | @SerializedName("idMeal") 16 | val idMeal: String, 17 | 18 | @ColumnInfo(name = "categoryName") 19 | val categoryName: String, 20 | 21 | @ColumnInfo(name = "strmeal") 22 | @Expose 23 | @SerializedName("strMeal") 24 | val strMeal: String, 25 | 26 | @ColumnInfo(name = "strmealthumb") 27 | @Expose 28 | @SerializedName("strMealThumb") 29 | val strMealThumb: String 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # Kotlin code style for this project: "official" or "obsolete": 15 | kotlin.code.style=official 16 | android.useAndroidX=true 17 | android.enableJetifier=true -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/CategoryItems.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities 2 | 3 | import androidx.room.ColumnInfo 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import com.google.gson.annotations.Expose 7 | import com.google.gson.annotations.SerializedName 8 | @Entity(tableName = "CategoryItems") 9 | data class CategoryItems( 10 | @PrimaryKey(autoGenerate = true) 11 | var id:Int, 12 | 13 | @ColumnInfo(name = "idcategory") 14 | @Expose 15 | @SerializedName("idCategory") 16 | val idcategory: String, 17 | 18 | @ColumnInfo(name = "strcategory") 19 | @Expose 20 | @SerializedName("strCategory") 21 | val strcategory: String, 22 | 23 | @ColumnInfo(name = "strcategorythumb") 24 | @Expose 25 | @SerializedName("strCategoryThumb") 26 | val strcategorythumb: String, 27 | 28 | @ColumnInfo(name = "strcategorydescription") 29 | @Expose 30 | @SerializedName("strCategoryDescription") 31 | val strcategorydescription: String 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/dao/RecipeDao.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.dao 2 | 3 | import androidx.room.Dao 4 | import androidx.room.Insert 5 | import androidx.room.OnConflictStrategy 6 | import androidx.room.Query 7 | import com.codingwithme.recipeapp.entities.Category 8 | import com.codingwithme.recipeapp.entities.CategoryItems 9 | import com.codingwithme.recipeapp.entities.MealsItems 10 | 11 | @Dao 12 | interface RecipeDao { 13 | 14 | @Query("SELECT * FROM categoryitems ORDER BY id DESC") 15 | suspend fun getAllCategory() : List 16 | 17 | @Insert(onConflict = OnConflictStrategy.REPLACE) 18 | suspend fun insertCategory(categoryItems: CategoryItems?) 19 | 20 | @Insert(onConflict = OnConflictStrategy.REPLACE) 21 | suspend fun insertMeal(mealsItems: MealsItems?) 22 | 23 | @Query("DELETE FROM categoryitems") 24 | suspend fun clearDb() 25 | 26 | @Query("SELECT * FROM MealItems WHERE categoryName = :categoryName ORDER BY id DESC") 27 | suspend fun getSpecificMealList(categoryName:String) : List 28 | } -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/converter/CategoryListConverter.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities.converter 2 | 3 | import androidx.room.TypeConverter 4 | import androidx.room.TypeConverters 5 | import com.codingwithme.recipeapp.entities.Category 6 | import com.codingwithme.recipeapp.entities.CategoryItems 7 | import com.google.gson.Gson 8 | import com.google.gson.reflect.TypeToken 9 | 10 | class CategoryListConverter { 11 | @TypeConverter 12 | fun fromCategoryList(category: List):String?{ 13 | if (category == null){ 14 | return (null) 15 | }else{ 16 | val gson = Gson() 17 | val type = object : TypeToken(){ 18 | 19 | }.type 20 | return gson.toJson(category,type) 21 | } 22 | } 23 | 24 | @TypeConverter 25 | fun toCategoryList ( categoryString: String):List?{ 26 | if (categoryString == null){ 27 | return (null) 28 | }else{ 29 | val gson = Gson() 30 | val type = object :TypeToken(){ 31 | 32 | }.type 33 | return gson.fromJson(categoryString,type) 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/entities/converter/MealListConverter.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.entities.converter 2 | 3 | import androidx.room.TypeConverter 4 | import androidx.room.TypeConverters 5 | import com.codingwithme.recipeapp.entities.Category 6 | import com.codingwithme.recipeapp.entities.CategoryItems 7 | import com.codingwithme.recipeapp.entities.MealsItems 8 | import com.google.gson.Gson 9 | import com.google.gson.reflect.TypeToken 10 | 11 | class MealListConverter { 12 | @TypeConverter 13 | fun fromCategoryList(category: List):String?{ 14 | if (category == null){ 15 | return (null) 16 | }else{ 17 | val gson = Gson() 18 | val type = object : TypeToken(){ 19 | 20 | }.type 21 | return gson.toJson(category,type) 22 | } 23 | } 24 | 25 | @TypeConverter 26 | fun toCategoryList ( categoryString: String):List?{ 27 | if (categoryString == null){ 28 | return (null) 29 | }else{ 30 | val gson = Gson() 31 | val type = object :TypeToken(){ 32 | 33 | }.type 34 | return gson.fromJson(categoryString,type) 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/recipeapp/database/RecipeDatabase.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.recipeapp.database 2 | 3 | import android.content.Context 4 | import androidx.room.Database 5 | import androidx.room.Room 6 | import androidx.room.RoomDatabase 7 | import androidx.room.TypeConverters 8 | import com.codingwithme.recipeapp.dao.RecipeDao 9 | import com.codingwithme.recipeapp.entities.* 10 | import com.codingwithme.recipeapp.entities.converter.CategoryListConverter 11 | import com.codingwithme.recipeapp.entities.converter.MealListConverter 12 | 13 | @Database(entities = [Recipes::class,CategoryItems::class,Category::class,Meal::class,MealsItems::class],version = 1,exportSchema = false) 14 | @TypeConverters(CategoryListConverter::class,MealListConverter::class) 15 | abstract class RecipeDatabase: RoomDatabase() { 16 | 17 | companion object{ 18 | 19 | var recipesDatabase:RecipeDatabase? = null 20 | 21 | @Synchronized 22 | fun getDatabase(context: Context): RecipeDatabase{ 23 | if (recipesDatabase == null){ 24 | recipesDatabase = Room.databaseBuilder( 25 | context, 26 | RecipeDatabase::class.java, 27 | "recipe.db" 28 | ).build() 29 | } 30 | return recipesDatabase!! 31 | } 32 | } 33 | 34 | abstract fun recipeDao():RecipeDao 35 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_rv_sub_category.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 26 | 27 |