Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

전남대학교 Android_이가현 3주차 step1 과제 #41

Open
wants to merge 9 commits into
base: leeghy
Choose a base branch
from
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
- 코드 복사
- API 받아오기

1단계
1단계 ✅

: 이전 단계와 기능은 비슷하나 카카오로컬 API를 사용한다.
- 검색어를 입력하면 검색 결과가 15개 이상 표시된다.
- 검색 결과 목록은 세로 스크롤이 된다.
Expand Down
13 changes: 13 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import java.util.Properties

fun getApiKey(key: String): String {
return gradleLocalProperties(rootDir, providers).getProperty(key) ?: ""
}

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())

android {
namespace = "campus.tech.kakao.map"
compileSdk = 34
Expand All @@ -15,6 +25,8 @@ android {
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "API_KEY", "\"${getApiKey("API_KEY")}\"")
}

buildTypes {
Expand All @@ -36,6 +48,7 @@ android {

buildFeatures {
viewBinding = true
buildConfig = true
}
}

Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/campus/tech/kakao/map/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import retrofit2.Call
import campus.tech.kakao.map.SearchResult

class MainActivity : AppCompatActivity() {
private val API_KEY = "KakaoAK 276613de22bf074fb398b9eed102f89b"

private lateinit var db: DataDbHelper
private lateinit var recyclerView: RecyclerView
Expand Down Expand Up @@ -138,10 +136,9 @@ class MainActivity : AppCompatActivity() {
saveSearchList()
Log.d("MainActivity", "Item clicked: ${locationData.name}")
}

private fun searchLocations(key: String) {
val apiService = RetrofitClient.instance
val call: Call<campus.tech.kakao.map.SearchResult> = apiService.searchPlaces(API_KEY, key)
val call: Call<campus.tech.kakao.map.SearchResult> = apiService.searchPlaces(BuildConfig.API_KEY, key)
call.enqueue(campus.tech.kakao.map.SearchCallback(this))
}

Expand Down
5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ dependencyResolutionManagement {
}
}

plugins {
id("com.android.application") version "8.3.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.0" apply false
}
rootProject.name = "android-map-search"
include(":app")