-
Notifications
You must be signed in to change notification settings - Fork 33
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주차 과제_Step2 #77
Open
jsh00325
wants to merge
14
commits into
kakao-tech-campus-2nd-step2:jsh00325
Choose a base branch
from
jsh00325:step2
base: jsh00325
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b06c856
feat: Get a Code From Week2 Project
jsh00325 c14ed1b
docs: Add Program Description & Step1 Feature
jsh00325 524e61c
feat: Add Kakao API Key at local.properties
jsh00325 7badd40
feat: Create API Response DTO
jsh00325 238db07
feat: Create Retrofit Service Interface for Kakao Local API
jsh00325 237808a
feat: Remove Location DB(SQLite)
jsh00325 b998d69
feat: Get Data from Kakao local API w. Retrofit
jsh00325 2680af7
Merge branch 'jsh00325' into step1
jsh00325 3b3cf10
feat: Remove Location DB
jsh00325 e05dbd5
feat: Remove LiveData at Repository class
jsh00325 ab203b3
feat: Apply Kakao Map SDK
jsh00325 413f170
docs: Add Step2 Feature
jsh00325 f13b9b2
feat: Add MapActivity & Layout
jsh00325 0920a5d
feat: Connect Kakao Map & When Click Search View, Move to SearchActivity
jsh00325 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# android-map-search | ||
|
||
## 📄 프로그램 설명 | ||
|
||
2주차 어플리케이션에서 local DB를 사용하는 것을, 카카오 로컬 API를 사용하여 서버에서 데이터를 받아오는 것으로 변경한 어플리케이션입니다. | ||
|
||
이후 지도 화면을 구현하여, 위치 검색과 지도를 볼 수 있는 어플리케이션을 제작합니다. | ||
|
||
## 🎯 1단계(카카오 로컬 API) 구현할 기능 | ||
|
||
- [X] 카카오 로컬 API를 사용하여 검색 결과를 받아오는 기능 구현 | ||
|
||
- [X] API에 맞는 DTO 클래스를 생성하기 | ||
|
||
- [X] Retrofit을 사용하여 API를 호출하는 인터페이스 생성하기 | ||
|
||
- [X] 기존의 SQLite를 사용하는 부분을 Retrofit으로 변경하기 | ||
|
||
- [X] API를 호출할 때, 결과가 15개 이상 표시되도록 구현하기 | ||
|
||
## 🎯 2단계(카카오 지도 API) 구현할 기능 | ||
|
||
- 카카오 맵 SDK를 현재 프로젝트에 적용하기 | ||
|
||
- [`공식 문서`](https://apis.map.kakao.com/android_v2/docs/getting-started/)를 참고해서 수행하기 | ||
|
||
- 지도 위에 검색창이 있는 레이아웃 제작하기 | ||
|
||
- 검색창을 클릭하는 경우, 기존의 검색과 검색 결과를 확인할 수 있는 화면으로 전환하기 | ||
|
||
- 검색 화면에서 뒤로가기를 누르는 경우, 다시 지도 화면으로 전환하기 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/campus/tech/kakao/map/KakaoMapApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package campus.tech.kakao.map | ||
|
||
import android.app.Application | ||
import com.kakao.vectormap.KakaoMapSdk | ||
|
||
class KakaoMapApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
KakaoMapSdk.init(this, getString(R.string.kakao_api_key)) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/campus/tech/kakao/map/model/LocalSearchDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package campus.tech.kakao.map.model | ||
|
||
data class LocalSearchResponse( | ||
val documents: List<LocalSearchDocument>, | ||
val meta: LocalSearchMeta | ||
) | ||
|
||
data class LocalSearchDocument( | ||
val address_name: String, | ||
val category_group_code: String, | ||
val category_group_name: String, | ||
val category_name: String, | ||
val distance: String, | ||
val id: String, | ||
val phone: String, | ||
val place_name: String, | ||
val place_url: String, | ||
val road_address_name: String, | ||
val x: String, | ||
val y: String | ||
) | ||
|
||
data class LocalSearchMeta( | ||
val is_end: Boolean, | ||
val pageable_count: Int, | ||
val same_name: LocalSearchSameName, | ||
val total_count: Int | ||
) | ||
|
||
data class LocalSearchSameName( | ||
val keyword: String, | ||
val region: List<String>, | ||
val selected_region: String | ||
) |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/campus/tech/kakao/map/model/LocalSearchService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package campus.tech.kakao.map.model | ||
|
||
import campus.tech.kakao.map.BuildConfig | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.Query | ||
|
||
interface LocalSearchService { | ||
@GET("search/keyword.json") | ||
suspend fun requestLocalSearch( | ||
@Header("Authorization") authorization: String = "KakaoAK ${BuildConfig.KAKAO_REST_API_KEY}", | ||
@Query("query") query: String, | ||
@Query("page") page: Int = 1, | ||
@Query("size") size: Int = 15 | ||
): Response<LocalSearchResponse> | ||
} |
11 changes: 0 additions & 11 deletions
11
app/src/main/java/campus/tech/kakao/map/model/LocationContract.kt
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
app/src/main/java/campus/tech/kakao/map/model/LocationDbHelper.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/campus/tech/kakao/map/view/MapActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package campus.tech.kakao.map.view | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import campus.tech.kakao.map.databinding.ActivityMapBinding | ||
import com.kakao.vectormap.KakaoMap | ||
import com.kakao.vectormap.KakaoMapReadyCallback | ||
import com.kakao.vectormap.MapAuthException | ||
import com.kakao.vectormap.MapLifeCycleCallback | ||
|
||
class MapActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityMapBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMapBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.kakaoMapView.start(object : MapLifeCycleCallback() { | ||
override fun onMapDestroy() { | ||
Log.d("MapActivity", "onMapDestroy") | ||
} | ||
|
||
override fun onMapError(e: Exception?) { | ||
Log.e("MapActivity", "onMapError", e) | ||
Toast.makeText( | ||
this@MapActivity, | ||
when ((e as MapAuthException).errorCode) { | ||
401 -> "API 인증에 실패했습니다.\n올바른 API 키를 설정해주세요." | ||
499 -> "서버와의 통신에 실패했습니다.\n인터넷 연결을 확인해주세요." | ||
else -> "오류가 발생했습니다. 다시 시도해주세요." | ||
}, | ||
Toast.LENGTH_SHORT | ||
).show() | ||
} | ||
}, object : KakaoMapReadyCallback() { | ||
override fun onMapReady(map: KakaoMap) { | ||
Log.d("MapActivity", "onMapReady") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (지금 대응하지 않으셔도 됩니다.) 엄밀히 따지면 맵과 관련된 서비스에서는 |
||
} | ||
}) | ||
|
||
binding.searchBackgroundView.setOnClickListener { | ||
val intent = Intent(this@MapActivity, SearchLocationActivity::class.java) | ||
startActivity(intent) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27c1.2,-1.4 1.82,-3.31 1.48,-5.34 -0.47,-2.78 -2.79,-5 -5.59,-5.34 -4.23,-0.52 -7.79,3.04 -7.27,7.27 0.34,2.8 2.56,5.12 5.34,5.59 2.03,0.34 3.94,-0.28 5.34,-1.48l0.27,0.28v0.79l4.25,4.25c0.41,0.41 1.08,0.41 1.49,0 0.41,-0.41 0.41,-1.08 0,-1.49L15.5,14zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> | ||
|
||
</vector> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에러처리 잘 해주셨네요 🎉
케이스별로 깔끔하게 잘 구현 해주신것 같습니다!
추가 코멘트를 드리자면
현업에서는 어떤 에러가 발생했는지 감지 하기위해
에러가 발생하면 서버로 전송해 어떤 에러가 났었는지 모니터링합니다.
대표적인툴로 Firebase Crashlytics가 있습니다. 시간나실때 한번 보시는걸 추천드려요!