diff --git a/DevSprint/.gitignore b/DevSprint/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/DevSprint/.gitignore @@ -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 diff --git a/DevSprint/.idea/.gitignore b/DevSprint/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/DevSprint/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/DevSprint/app/.gitignore b/DevSprint/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/DevSprint/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/DevSprint/app/build.gradle.kts b/DevSprint/app/build.gradle.kts new file mode 100644 index 0000000..ec557cc --- /dev/null +++ b/DevSprint/app/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "com.example.devsprint" + compileSdk = 36 + + defaultConfig { + applicationId = "com.example.devsprint" + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} + +dependencies { + + 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) + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("com.squareup.retrofit2:converter-gson:2.9.0") + implementation("com.github.bumptech.glide:glide:4.16.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") +} \ No newline at end of file diff --git a/DevSprint/app/proguard-rules.pro b/DevSprint/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/DevSprint/app/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/DevSprint/app/src/androidTest/java/com/example/devsprint/ExampleInstrumentedTest.kt b/DevSprint/app/src/androidTest/java/com/example/devsprint/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..b7f3f9e --- /dev/null +++ b/DevSprint/app/src/androidTest/java/com/example/devsprint/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.devsprint + +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.devsprint", appContext.packageName) + } +} \ No newline at end of file diff --git a/DevSprint/app/src/main/AndroidManifest.xml b/DevSprint/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1e28647 --- /dev/null +++ b/DevSprint/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DevSprint/app/src/main/ic_launcher-playstore.png b/DevSprint/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..a276fed Binary files /dev/null and b/DevSprint/app/src/main/ic_launcher-playstore.png differ diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/api/ApiService.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/api/ApiService.kt new file mode 100644 index 0000000..b8c2fe8 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/api/ApiService.kt @@ -0,0 +1,18 @@ +package com.example.devsprint.data.api + +import com.example.devsprint.data.model.* +import retrofit2.http.* + +interface ApiService { + + @GET("https://evilinsult.com/generate_insult.php?lang=en&type=json") + suspend fun getInsult(): InsultResponse + + @GET("https://rickandmortyapi.com/api/character/{id}") + suspend fun getRickMorty( + @Path("id") id: Int + ): RickMortyResponse + + @GET("https://api.thecatapi.com/v1/images/search") + suspend fun getCatImage(): List +} \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/api/RetrofitInstance.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/api/RetrofitInstance.kt new file mode 100644 index 0000000..bd22b0d --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/api/RetrofitInstance.kt @@ -0,0 +1,14 @@ +package com.example.devsprint.data.api + +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +object RetrofitInstance { + val api: ApiService by lazy { + Retrofit.Builder() + .baseUrl("https://example.com/") + .addConverterFactory(GsonConverterFactory.create()) + .build() + .create(ApiService::class.java) + } +} \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/CatResponseItem.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/CatResponseItem.kt new file mode 100644 index 0000000..98031cc --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/CatResponseItem.kt @@ -0,0 +1,5 @@ +package com.example.devsprint.data.model + +data class CatResponseItem( + val url: String +) diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/InsultResponse.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/InsultResponse.kt new file mode 100644 index 0000000..cf339e2 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/InsultResponse.kt @@ -0,0 +1,5 @@ +package com.example.devsprint.data.model + +data class InsultResponse( + val insult: String +) diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/JokeResponse.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/JokeResponse.kt new file mode 100644 index 0000000..238a2ca --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/JokeResponse.kt @@ -0,0 +1,5 @@ +package com.example.devsprint.data.model + +data class JokeResponse( + val joke: String +) \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/NasaResponse.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/NasaResponse.kt new file mode 100644 index 0000000..bc556d9 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/NasaResponse.kt @@ -0,0 +1,5 @@ +package com.example.devsprint.data.model + +data class NasaResponse( + val url: String +) \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/PokemonResponse.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/PokemonResponse.kt new file mode 100644 index 0000000..111bfe3 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/PokemonResponse.kt @@ -0,0 +1,5 @@ +package com.example.devsprint.data.model + +data class PokemonResponse( + val name: String +) \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/model/RickMortyResponse.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/model/RickMortyResponse.kt new file mode 100644 index 0000000..48cc9ae --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/model/RickMortyResponse.kt @@ -0,0 +1,6 @@ +package com.example.devsprint.data.model + +data class RickMortyResponse( + val name: String, + val image: String +) diff --git a/DevSprint/app/src/main/java/com/example/devsprint/data/repository/MashupRepository.kt b/DevSprint/app/src/main/java/com/example/devsprint/data/repository/MashupRepository.kt new file mode 100644 index 0000000..45e66f2 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/data/repository/MashupRepository.kt @@ -0,0 +1,30 @@ +package com.example.devsprint.data.repository + +import com.example.devsprint.data.api.RetrofitInstance +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope +import com.example.devsprint.util.Constants + +data class MashupResult( + val insult: String, + val rickMortyName: String, + val rickMortyImage: String, + val catImage: String +) + +class MashupRepository { + + suspend fun getData(): MashupResult = coroutineScope { + + val insult = async { RetrofitInstance.api.getInsult() } + val rickMorty = async { RetrofitInstance.api.getRickMorty((1..826).random()) } + val cat = async { RetrofitInstance.api.getCatImage() } + + MashupResult( + insult = insult.await().insult, + rickMortyName = rickMorty.await().name, + rickMortyImage = rickMorty.await().image, + catImage = cat.await().first().url + ) + } +} \ No newline at end of file diff --git a/DevSprint/app/src/main/java/com/example/devsprint/ui/MainActivity.kt b/DevSprint/app/src/main/java/com/example/devsprint/ui/MainActivity.kt new file mode 100644 index 0000000..dbd31e6 --- /dev/null +++ b/DevSprint/app/src/main/java/com/example/devsprint/ui/MainActivity.kt @@ -0,0 +1,47 @@ +package com.example.devsprint.ui + +import android.os.Bundle +import android.widget.* +import androidx.appcompat.app.AppCompatActivity +import com.bumptech.glide.Glide +import com.example.devsprint.R +import com.example.devsprint.data.repository.MashupRepository +import kotlinx.coroutines.* + +class MainActivity : AppCompatActivity() { + + private val repo = MashupRepository() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val button = findViewById