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 #52

Open
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

tlsgptj
Copy link

@tlsgptj tlsgptj commented Jul 10, 2024

기능 요구 사항

  1. 이전 단계와 기능은 비슷하나 카카오로컬 API를 사용한다.
  2. 검색어를 입력하면 검색 결과가 15개 이상 표시된다.
  3. 검색 결과 목록은 세로 스크롤이 된다.
  4. 입력한 검색어는 X를 눌러서 삭제할 수 있다.
  5. 검색 결과 목록에서 하나의 항목을 선택할 수 있다.
  6. 선택된 항목은 검색어 저장 목록에 추가된다.
  7. 저장된 검색어 목록은 가로 스크롤이 된다.
  8. 저장된 검색어는 X를 눌러서 삭제할 수 있다.
  9. 저장된 검색어는 앱을 재실행하여도 유지된다.

프로그래밍 요구 사항

  1. 검색 데이터는 카카오로컬 API를 사용한다.
  2. 카카오 API 사용을 위한 앱 키를 외부에 노출하지 않는다.
  3. 가능한 MVVM 아키텍처 패턴을 적용하도록 한다.
  4. 코드 컨벤션을 준수하며 프로그래밍한다.

How to make

  1. 우선 테스트를 위해 전에 만들었던 더미 데이터를 삭제해 줍니다.
  2. 카카오 로컬 api를 가져오기 전에 Retrofit 라이브러리를 설치해줍니다.
  3. Retrofit 라이브러리를 설치한 후 manifest에 권한을 표시해줍니다.
  4. 카카오 api에서 받아올 객체를 생성해줍니다. 저같은 경우에는 Document 파일을 생성했습니다.
    (Response 파일에 생성해도 좋았을텐데 약간 돌고돌아오는(?) 느낌입니다!! 쓸데없이 파일을 많이 생성한 느낌)
  5. 데이터를 searchAndDisplayResults 함수에서 결과값을 나타낼 수 있도록 만듭니다.

코드를 보면서 조금 아쉬웠던(?) 점 입니다.

  1. MapContract.COLUMN_NAME to (document.placeName ?: "No Name"),
    MapContract.COLUMN_ADDRESS to (document.addressName ?: "No Address"),
    MapContract.COLUMN_CATEGORY to (document.categoryName ?: "No Category")
    이 함수의 경우 그냥 MapContract를 삭제하고 document.categoryName ?: "No Category" 라고 해도 괜찮았을 것 같습니당...STEP2에 고쳐볼께용
  2. NotifydataSetChanged()를 피드백 반영해서 고쳐보려고 했었는데 뭔지 모르게 자꾸 오류가 발생하더라고요..ㅜㅜ 더 서칭하고 공부하고 있는 중입니당
  3. 앟 그리고 저희 조 영빈님의 도움을 받아 한글 폰트 설치를 완료했습니다!!
    image

@bigstark bigstark self-requested a review July 14, 2024 15:19
Copy link

@bigstark bigstark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혜서님 3주차도 고생 많으셨습니다. 전반적으로 실행하시는 것에 집중해주신 것 같아요. 조금만 더 힘내보죠!

코딩 컨벤션에 대해서는 조금만 더 신경써주세요! 클래스 이름도 조금 더 용도에 맞게 명확하게 짓는 부분도요!

Comment on lines +6 to +9
@SerializedName("category_group_name") val categoryName: String,
@SerializedName("id") val id: String,
@SerializedName("address_name") val addressName: String,
@SerializedName("place_name") val placeName: String?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gson 을 사용한다면 null safety 하지 않을 수 있어요. 모두 null 처리해주시면 조금 더 안전하게 사용할 수 있어요.

Comment on lines +4 to +6
val place_name: String,
val address_name: String,
val category_group_name: String

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camel case 로 변경 부탁드려요!

Comment on lines +5 to +26
class SearchViewModel private constructor(private val searchRepository: SearchRepo) : ViewModel() {
companion object {
@Volatile private var instance: SearchViewModel? = null

fun getInstance(searchRepository: SearchRepo): SearchViewModel {
return instance ?: synchronized(this) {
instance ?: SearchViewModel(searchRepository).also { instance = it }
}
}
}
fun insertSearchData(data: String) {
searchRepository.insertSearchData(data)
}

fun getAllSearchData(): List<String> {
return searchRepository.getAllSearchData()
}

fun bind(s: String) {

}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용되지 않는 코드


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
KakaoSdk.init(this, "e6a7c826ae7a55df129b8be2c636e213")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이러한 api key 들은 코드에 노출되면 안됩니다. 요 블로그 한번 읽어보시면 도움이 될 듯 합니다.

private lateinit var searchResultAdapter: PlaceAdapter
private lateinit var savedSearchAdapter: SavedSearchAdapter
private lateinit var databaseHelper: MyDatabaseHelper
private lateinit var MapViewKakao: MapView

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수는 소문자로 시작해주세요!

Comment on lines +57 to +79
private fun createKakaoApiService(): KakaoApiService {
val logging = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BASIC
}

val okHttpClient = OkHttpClient.Builder()
.addInterceptor(logging)
.addInterceptor { chain ->
val request = chain.request().newBuilder()
.addHeader("Authorization", "KakaoAK 13c6b4e1c003d0f42b3b07888391c355")
.build()
chain.proceed(request)
}
.build()

val retrofit = Retrofit.Builder()
.baseUrl("https://dapi.kakao.com")
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build()

return retrofit.create(KakaoApiService::class.java)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KakaoApiService 는 Activity 에서 생성하면 안될 것 같습니다. kakao api service 를 사용하는 부분은 최대한 viewModel 로 로직을 옮겨주시면 좋을 것 같습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants