-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
id 'kotlin-kapt' | ||
id 'kotlin-android-extensions' | ||
} | ||
|
||
android { | ||
compileSdkVersion 29 | ||
defaultConfig { | ||
applicationId "com.androiddevs.grocerylist" | ||
minSdkVersion 16 | ||
targetSdkVersion 29 | ||
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' | ||
} | ||
namespace 'com.example.shoppinglist' | ||
} | ||
|
||
dependencies { | ||
|
||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.core:core-ktx:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
|
||
def room_version = "2.2.1" | ||
def kodein_version = "6.4.0" | ||
def lifecycle_version = "2.0.0" | ||
|
||
// Room and Architectural Components | ||
implementation "androidx.room:room-runtime:$room_version" | ||
implementation "androidx.legacy:legacy-support-v4:1.0.0" | ||
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' | ||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0' | ||
implementation "androidx.room:room-ktx:2.2.1" | ||
kapt "androidx.room:room-compiler:$room_version" | ||
|
||
// Coroutines | ||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0" | ||
|
||
// New Material Design | ||
implementation "com.google.android.material:material:1.4.0" | ||
|
||
// ViewModel | ||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" | ||
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" | ||
|
||
// Kodein | ||
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version" | ||
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version" | ||
|
||
//Retrofit | ||
implementation 'com.squareup.retrofit2:converter-gson:2.4.0' | ||
//Gson | ||
implementation 'com.google.code.gson:gson:2.8.5' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.shoppinglist | ||
|
||
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.example.shoppinglist", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.ShoppingList"> | ||
<activity | ||
android:name=".DetailsActivity" | ||
android:exported="false" /> | ||
<activity | ||
android:name=".ShoppingListActivity" | ||
android:exported="false" /> | ||
<activity android:name=".SplashActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.shoppinglist | ||
|
||
import com.example.shoppinglist.Data.ShoppingItem | ||
|
||
interface AddDialogListener { | ||
fun onAddButtomClicked(item:ShoppingItem){ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.shoppinglist | ||
|
||
|
||
import com.example.shoppinglist.Data.MoneyRate | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface ApiInterface { | ||
|
||
@GET("/latest") | ||
fun getMoney() : Call<MoneyRate> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.shoppinglist.Data | ||
|
||
data class MoneyRate( | ||
val amount: Double, | ||
val base: String, | ||
val date: String, | ||
val rates: Rates | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.shoppinglist.Data | ||
|
||
data class Rates( | ||
val AUD: Double, | ||
val BGN: Double, | ||
val BRL: Double, | ||
val CAD: Double, | ||
val CHF: Double, | ||
val CNY: Double, | ||
val CZK: Double, | ||
val DKK: Double, | ||
val GBP: Double, | ||
val HKD: Double, | ||
val HRK: Double, | ||
val HUF: Double, | ||
val IDR: Int, | ||
val ILS: Double, | ||
val INR: Double, | ||
val ISK: Double, | ||
val JPY: Double, | ||
val KRW: Double, | ||
val MXN: Double, | ||
val MYR: Double, | ||
val NOK: Double, | ||
val NZD: Double, | ||
val PHP: Double, | ||
val PLN: Double, | ||
val RON: Double, | ||
val RUB: Double, | ||
val SEK: Double, | ||
val SGD: Double, | ||
val THB: Double, | ||
val TRY: Double, | ||
val USD: Double, | ||
val ZAR: Double | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.shoppinglist.Data | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.* | ||
|
||
|
||
@Dao | ||
interface ShoppingDAO { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) // insert and update | ||
fun upsert(item:ShoppingItem) | ||
|
||
@Delete | ||
fun delete(item: ShoppingItem) | ||
|
||
@Query("SELECT * FROM shopping_items") | ||
fun getAllItems(): LiveData<List<ShoppingItem>> | ||
|
||
@Query("DELETE FROM shopping_items") | ||
fun deleteAll() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.shoppinglist.Data | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import java.io.Serializable | ||
|
||
|
||
@Entity(tableName = "shopping_items") | ||
data class ShoppingItem( | ||
@ColumnInfo(name = "category") var category: String, | ||
@ColumnInfo(name = "name") var name: String, | ||
@ColumnInfo(name = "description") var description: String, | ||
@ColumnInfo(name = "price") var price: Float, | ||
@ColumnInfo(name = "status") var status: Boolean, | ||
){ | ||
@PrimaryKey(autoGenerate = true) var itemId : Long?=null | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.shoppinglist.Data | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import java.security.AccessControlContext | ||
|
||
@Database(entities = arrayOf(ShoppingItem::class),version = 1) | ||
abstract class ShoppingListDataBase: RoomDatabase () { | ||
|
||
abstract fun ShoppingDao(): ShoppingDAO | ||
|
||
companion object{ | ||
@Volatile | ||
private var instance: ShoppingListDataBase? = null | ||
private var lock = Any() | ||
|
||
operator fun invoke(context: Context) = instance ?: synchronized(lock){ // check if the instance is null, if it is null | ||
instance?: createDatabase(context).also { instance = it} // create a database. | ||
} | ||
|
||
|
||
private fun createDatabase(context: Context) = | ||
Room.databaseBuilder(context.applicationContext, | ||
ShoppingListDataBase::class.java,"ShoppingList.db").build() | ||
} | ||
} |