diff --git a/app/build.gradle b/app/build.gradle index 679dbba4..1ad0af3d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,13 +4,13 @@ plugins { } android { - compileSdkVersion 30 + compileSdkVersion 34 buildToolsVersion "30.0.3" defaultConfig { applicationId "otus.homework.coroutines" minSdkVersion 23 - targetSdkVersion 30 + targetSdkVersion 34 versionCode 1 versionName "1.0" @@ -42,4 +42,10 @@ dependencies { implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.squareup.picasso:picasso:2.71828' + + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" + + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" + testImplementation 'junit:junit:4.12' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fe34985b..fa531f7d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Coroutines"> - diff --git a/app/src/main/java/otus/homework/coroutines/CatsPresenter.kt b/app/src/main/java/otus/homework/coroutines/CatsPresenter.kt deleted file mode 100644 index e4b05120..00000000 --- a/app/src/main/java/otus/homework/coroutines/CatsPresenter.kt +++ /dev/null @@ -1,35 +0,0 @@ -package otus.homework.coroutines - -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response - -class CatsPresenter( - private val catsService: CatsService -) { - - private var _catsView: ICatsView? = null - - fun onInitComplete() { - catsService.getCatFact().enqueue(object : Callback { - - override fun onResponse(call: Call, response: Response) { - if (response.isSuccessful && response.body() != null) { - _catsView?.populate(response.body()!!) - } - } - - override fun onFailure(call: Call, t: Throwable) { - CrashMonitor.trackWarning() - } - }) - } - - fun attachView(catsView: ICatsView) { - _catsView = catsView - } - - fun detachView() { - _catsView = null - } -} \ No newline at end of file diff --git a/app/src/main/java/otus/homework/coroutines/CatsService.kt b/app/src/main/java/otus/homework/coroutines/CatsService.kt deleted file mode 100644 index 479b2cfb..00000000 --- a/app/src/main/java/otus/homework/coroutines/CatsService.kt +++ /dev/null @@ -1,10 +0,0 @@ -package otus.homework.coroutines - -import retrofit2.Call -import retrofit2.http.GET - -interface CatsService { - - @GET("fact") - fun getCatFact() : Call -} \ No newline at end of file diff --git a/app/src/main/java/otus/homework/coroutines/CatsView.kt b/app/src/main/java/otus/homework/coroutines/CatsView.kt deleted file mode 100644 index 30ac2531..00000000 --- a/app/src/main/java/otus/homework/coroutines/CatsView.kt +++ /dev/null @@ -1,32 +0,0 @@ -package otus.homework.coroutines - -import android.content.Context -import android.util.AttributeSet -import android.widget.Button -import android.widget.TextView -import androidx.constraintlayout.widget.ConstraintLayout - -class CatsView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), ICatsView { - - var presenter :CatsPresenter? = null - - override fun onFinishInflate() { - super.onFinishInflate() - findViewById