diff --git a/.idea/gradle.xml b/.idea/gradle.xml index c8bc96c..95c9dc8 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -11,11 +11,11 @@ diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/example/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle new file mode 100644 index 0000000..596cc26 --- /dev/null +++ b/example/build.gradle @@ -0,0 +1,53 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "dohun.kim.gatabuta.example" + minSdkVersion 21 + 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' + } + buildFeatures { + dataBinding true + } +} + +dependencies { + implementation project(':gatabuta-livedata') + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3' + testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3' + 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' + testImplementation 'junit:junit:4.+' + testImplementation "androidx.arch.core:core-testing:2.1.0" + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/example/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9735bf1 --- /dev/null +++ b/example/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/src/main/java/dohun/kim/gatabuta/example/MainActivity.kt b/example/src/main/java/dohun/kim/gatabuta/example/MainActivity.kt new file mode 100644 index 0000000..d02cba1 --- /dev/null +++ b/example/src/main/java/dohun/kim/gatabuta/example/MainActivity.kt @@ -0,0 +1,23 @@ +package dohun.kim.gatabuta.example + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import androidx.databinding.DataBindingUtil +import androidx.lifecycle.ViewModelProvider +import dohun.kim.gatabuta.example.databinding.ActivityMainBinding + +class MainActivity : AppCompatActivity() { + + private lateinit var binding: ActivityMainBinding + + private val viewModel: MainViewModel by lazy { + MainViewModel() + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + binding.lifecycleOwner = this + binding.viewModel = viewModel + } +} diff --git a/example/src/main/java/dohun/kim/gatabuta/example/MainViewModel.kt b/example/src/main/java/dohun/kim/gatabuta/example/MainViewModel.kt new file mode 100644 index 0000000..41ac298 --- /dev/null +++ b/example/src/main/java/dohun/kim/gatabuta/example/MainViewModel.kt @@ -0,0 +1,19 @@ +package dohun.kim.gatabuta.example + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class MainViewModel : ViewModel() { + + private val _money = MutableLiveData() + val money: LiveData = _money + + private val _nonNullableMoney = MutableLiveData(0) + val nonNullableMoney: LiveData = _nonNullableMoney + + fun increaseMoney() { + _money.value = money.value?.plus(1) ?: 1 + _nonNullableMoney.value = nonNullableMoney.value?.plus(1) ?: 1 + } +} \ No newline at end of file diff --git a/example/src/main/res/drawable-v24/ic_launcher_foreground.xml b/example/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/example/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/example/src/main/res/drawable/ic_launcher_background.xml b/example/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/example/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/src/main/res/layout/activity_main.xml b/example/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..bed99fe --- /dev/null +++ b/example/src/main/res/layout/activity_main.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + +