Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions DevSprint/.gitignore
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
3 changes: 3 additions & 0 deletions DevSprint/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions DevSprint/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions DevSprint/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
21 changes: 21 additions & 0 deletions DevSprint/app/proguard-rules.pro
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.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)
}
}
27 changes: 27 additions & 0 deletions DevSprint/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DevSprint">
<activity
android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added DevSprint/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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<CatResponseItem>
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.devsprint.data.model

data class CatResponseItem(
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.devsprint.data.model

data class InsultResponse(
val insult: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.devsprint.data.model

data class JokeResponse(
val joke: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.devsprint.data.model

data class NasaResponse(
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.devsprint.data.model

data class PokemonResponse(
val name: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.devsprint.data.model

data class RickMortyResponse(
val name: String,
val image: String
)
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
@@ -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<Button>(R.id.generateBtn)
val insultText = findViewById<TextView>(R.id.insultText)
val rickMortyText = findViewById<TextView>(R.id.rickMortyText)
val rickMortyImage = findViewById<ImageView>(R.id.rickMortyImage)
val catImage = findViewById<ImageView>(R.id.catImage)

button.setOnClickListener {
CoroutineScope(Dispatchers.Main).launch {
try {
val result = repo.getData()

insultText.text = result.insult
rickMortyText.text = result.rickMortyName

Glide.with(this@MainActivity)
.load(result.rickMortyImage)
.into(rickMortyImage)

Glide.with(this@MainActivity)
.load(result.catImage)
.into(catImage)

} catch (e: Exception) {
insultText.text = "Error 😅"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.devsprint.util

object Constants {

// 🌐 Base URL (dummy for Retrofit)
const val BASE_URL = "https://example.com/"

// 🔑 API Keys
const val NASA_API_KEY = "WOxzU9Y6OS2bS8JVU5lyepXH4AhRjcO1xmmzIqc8"

// 🎲 Pokemon Range
const val POKEMON_MIN = 1
const val POKEMON_MAX = 151

// ⏱ Timeout (optional future use)
const val NETWORK_TIMEOUT = 30L

// 🧪 Debug Tag
const val TAG = "MashupApp"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading