From 8ae483b5608fdf6c2bc64bc816b2613e04768933 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 15 Jul 2024 14:01:05 +0900 Subject: [PATCH 01/29] =?UTF-8?q?Rename[]:=20=EC=9D=B4=EB=8F=99=203?= =?UTF-8?q?=EC=A3=BC=EC=B0=A8=20=EA=B3=BC=EC=A0=9C=20=EB=82=B4=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 18 ++- app/src/main/AndroidManifest.xml | 8 +- .../tech/kakao/map/Adapter/DocumentAdapter.kt | 56 +++++++++ .../tech/kakao/map/Adapter/WordAdapter.kt | 53 +++++++++ .../kakao/map/DBHelper/SearchWordDbHelper.kt | 110 ++++++++++++++++++ .../campus/tech/kakao/map/DTO/Document.kt | 22 ++++ .../java/campus/tech/kakao/map/DTO/Meta.kt | 14 +++ .../tech/kakao/map/DTO/PlaceResponse.kt | 6 + .../campus/tech/kakao/map/DTO/SameName.kt | 7 ++ .../campus/tech/kakao/map/DTO/SearchWord.kt | 3 + .../tech/kakao/map/DTO/SearchWordContract.kt | 11 ++ .../campus/tech/kakao/map/DTO/UrlContract.kt | 8 ++ .../campus/tech/kakao/map/MainViewModel.kt | 42 +++++++ .../java/campus/tech/kakao/map/MapActivity.kt | 54 +++++++++ .../campus/tech/kakao/map/MyApplication.kt | 11 ++ .../campus/tech/kakao/map/RetrofitData.kt | 54 +++++++++ .../campus/tech/kakao/map/RetrofitService.kt | 15 +++ .../campus/tech/kakao/map/SearchActivity.kt | 86 ++++++++++++++ app/src/main/res/drawable/magnifier.png | Bin 0 -> 9712 bytes app/src/main/res/drawable/marker.png | Bin 0 -> 16096 bytes app/src/main/res/drawable/x.png | Bin 0 -> 3272 bytes app/src/main/res/layout/activity_map.xml | 36 ++++++ app/src/main/res/layout/activity_search.xml | 61 ++++++++++ app/src/main/res/layout/place_item.xml | 47 ++++++++ app/src/main/res/layout/word_item.xml | 23 ++++ app/src/main/res/values/strings.xml | 2 + .../main/res/xml/network_security_config.xml | 6 + settings.gradle.kts | 1 + 28 files changed, 752 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/Document.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/MainViewModel.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/MapActivity.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/MyApplication.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/RetrofitData.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/RetrofitService.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/SearchActivity.kt create mode 100644 app/src/main/res/drawable/magnifier.png create mode 100644 app/src/main/res/drawable/marker.png create mode 100644 app/src/main/res/drawable/x.png create mode 100644 app/src/main/res/layout/activity_map.xml create mode 100644 app/src/main/res/layout/activity_search.xml create mode 100644 app/src/main/res/layout/place_item.xml create mode 100644 app/src/main/res/layout/word_item.xml create mode 100644 app/src/main/res/xml/network_security_config.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 33c4ca53..9b4327c9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -15,6 +17,14 @@ android { versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + buildConfigField("String", "KAKAO_API_KEY", getApiKey("KAKAO_API_KEY")) + buildConfigField("String", "KAKAO_REST_API_KEY", getApiKey("KAKAO_REST_API_KEY")) + ndk { + abiFilters.add("arm64-v8a") + abiFilters.add("armeabi-v7a") + abiFilters.add("x86") + abiFilters.add("x86_64") + } } buildTypes { @@ -36,19 +46,24 @@ android { buildFeatures { viewBinding = true + buildConfig = true } } dependencies { - + val lifecycle_version = "2.8.3" + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version") implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.11.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.recyclerview:recyclerview:1.3.2") + implementation("androidx.datastore:datastore-preferences:1.0.0") implementation("com.squareup.retrofit2:retrofit:2.11.0") implementation("com.squareup.retrofit2:converter-gson:2.11.0") implementation("com.kakao.maps.open:android:2.9.5") + implementation("com.kakao.sdk:v2-all:2.20.3") implementation("androidx.activity:activity:1.8.0") implementation("androidx.test:core-ktx:1.5.0") testImplementation("junit:junit:4.13.2") @@ -61,3 +76,4 @@ dependencies { androidTestImplementation("androidx.test:rules:1.5.0") androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1") } +fun getApiKey(key: String): String = gradleLocalProperties(rootDir, providers).getProperty(key) \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6bca2f54..ec1a5ec1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,18 +2,22 @@ + + @@ -21,6 +25,8 @@ + diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt new file mode 100644 index 00000000..74492c58 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt @@ -0,0 +1,56 @@ +package campus.tech.kakao.map.Adapter + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.DTO.Document +import campus.tech.kakao.map.R + +class DocumentAdapter( + val addWord: (Document) -> Unit +): ListAdapter( + object : DiffUtil.ItemCallback(){ + override fun areItemsTheSame(oldItem: Document, newItem: Document): Boolean { + return oldItem === newItem + } + + override fun areContentsTheSame(oldItem: Document, newItem: Document): Boolean { + return oldItem == newItem + } + + } +) { + private var placeClicked = { position:Int -> + val document: Document = getItem(position) + addWord(document) + } + inner class ViewHolder( + itemView: View + ): RecyclerView.ViewHolder(itemView) { + val name:TextView = itemView.findViewById(R.id.name) + val address:TextView = itemView.findViewById(R.id.address) + val type:TextView = itemView.findViewById(R.id.type) + init { + itemView.setOnClickListener { + placeClicked(bindingAdapterPosition) + } + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.place_item, parent, false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val document: Document = getItem(position) + holder.name.text = document.placeName + holder.address.text = document.addressName + holder.type.text = document.categoryGroupName + } +} + + diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt new file mode 100644 index 00000000..9b051e3d --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt @@ -0,0 +1,53 @@ +package campus.tech.kakao.map.Adapter + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.R +import campus.tech.kakao.map.DTO.SearchWord + +class WordAdapter( + val deleteWord: (SearchWord) -> Unit +): ListAdapter( + object : DiffUtil.ItemCallback(){ + override fun areItemsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { + return oldItem === newItem + } + + override fun areContentsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { + return oldItem == newItem + } + + } +) { + inner class ViewHolder( + itemView: View + ): RecyclerView.ViewHolder(itemView) { + val searchWord: TextView = itemView.findViewById(R.id.search_word) + val delete: ImageView = itemView.findViewById(R.id.x) + init { + delete.setOnClickListener { + deletedWords(bindingAdapterPosition) + } + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.word_item, parent, false)) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val word = getItem(position) + holder.searchWord.text = word.name + } + + private val deletedWords = { position:Int -> + val word = getItem(position) + deleteWord(word) + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt new file mode 100644 index 00000000..a736d865 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt @@ -0,0 +1,110 @@ +package campus.tech.kakao.map.DBHelper + +import android.content.ContentValues +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteOpenHelper +import android.util.Log +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import campus.tech.kakao.map.DTO.SearchWord +import campus.tech.kakao.map.DTO.SearchWordContract +import campus.tech.kakao.map.DTO.SearchWordContract.DB_VERSION + +class SearchWordDbHelper(context: Context): SQLiteOpenHelper( + context, SearchWordContract.DB_NAME, null, DB_VERSION) { + private val _searchWords = MutableLiveData>() + val searchSameSelection = "${SearchWordContract.COLUMN_NAME_NAME} = ? AND " + + "${SearchWordContract.COLUMN_NAME_ADDRESS} = ? AND " + + "${SearchWordContract.COLUMN_NAME_TYPE} = ?" + override fun onCreate(db: SQLiteDatabase?) { + createTable(db) + } + + private fun createTable(db: SQLiteDatabase?) { + db?.execSQL( + "CREATE TABLE ${SearchWordContract.TABLE_NAME} " + + "(${SearchWordContract.COLUMN_NAME_NAME} TEXT, " + + "${SearchWordContract.COLUMN_NAME_ADDRESS} TEXT, " + + "${SearchWordContract.COLUMN_NAME_TYPE} TEXT)" + ) + } + + override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { + db?.execSQL("DROP TABLE IF EXISTS ${SearchWordContract.TABLE_NAME}") + createTable(db) + } + + fun getSearchWords(): LiveData> { + return _searchWords + } + + fun addWord(word: SearchWord) { + val db = writableDatabase + if (existWord(word, db)){ + deleteWord(word) + } + val values = ContentValues() + values.put(SearchWordContract.COLUMN_NAME_NAME, word.name) + values.put(SearchWordContract.COLUMN_NAME_ADDRESS, word.address) + values.put(SearchWordContract.COLUMN_NAME_TYPE, word.type) + db.insert(SearchWordContract.TABLE_NAME, null, values) + db.close() + updateSearchWords() + } + + fun existWord(word: SearchWord, db: SQLiteDatabase): Boolean{ + val selection = searchSameSelection + val cursor = db.query( + SearchWordContract.TABLE_NAME, + arrayOf(SearchWordContract.COLUMN_NAME_NAME), + selection, + arrayOf(word.name, word.address, word.type), + null, + null, + "${SearchWordContract.COLUMN_NAME_NAME} DESC" + ).use { + it.moveToFirst() + } + return cursor + } + + fun deleteWord(word: SearchWord){ + val db = writableDatabase + val selection = searchSameSelection + val selectionArgs = arrayOf(word.name, word.address, word.type) + db.delete(SearchWordContract.TABLE_NAME, selection, selectionArgs) + updateSearchWords() + } + + fun updateSearchWords(){ + val db = readableDatabase + val resultList = mutableListOf() + val cursor = db.query( + SearchWordContract.TABLE_NAME, + arrayOf( + SearchWordContract.COLUMN_NAME_NAME, + SearchWordContract.COLUMN_NAME_ADDRESS, + SearchWordContract.COLUMN_NAME_TYPE + ), + null, + null, + null, + null, + null + ).use {cursor -> + while (cursor.moveToNext()) { + val name = cursor.getString( + cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_NAME) + ) + val address = cursor.getString( + cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_ADDRESS) + ) + val type = cursor.getString( + cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_TYPE)) + resultList.add(SearchWord(name, address, type)) + } + } + _searchWords.value = resultList + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt b/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt new file mode 100644 index 00000000..1b33c093 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt @@ -0,0 +1,22 @@ +package campus.tech.kakao.map.DTO + +import com.google.gson.annotations.SerializedName + +//필요 없는 데이터 주석화 +data class Document( + //val id: String, + @SerializedName("place_name") + val placeName: String, + //val category_name: String, + //val category_group_code: String, + @SerializedName("category_group_name") + val categoryGroupName: String, + //val phone: String, + @SerializedName("address_name") + val addressName: String, + //val road_address_name: String, + //val x: String, + //val y: String, + //val place_url: String, + //val distance: String, +) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt b/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt new file mode 100644 index 00000000..e34d3048 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt @@ -0,0 +1,14 @@ +package campus.tech.kakao.map.DTO + +import com.google.gson.annotations.SerializedName + +data class Meta( + @SerializedName("total_count") + val totalCount: Int, + @SerializedName("pageable_count") + val pageableCount: Int, + @SerializedName("is_end") + val isEnd: Boolean, + @SerializedName("same_name") + val sameName: SameName +) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt b/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt new file mode 100644 index 00000000..9ab49a5d --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt @@ -0,0 +1,6 @@ +package campus.tech.kakao.map.DTO + +data class PlaceResponse( + val meta: Meta, + val documents: List +) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt b/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt new file mode 100644 index 00000000..b3b9f3bc --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt @@ -0,0 +1,7 @@ +package campus.tech.kakao.map.DTO + +data class SameName( + val region: List, + val keyword: String, + val selected_region: String +) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt new file mode 100644 index 00000000..2823ba00 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt @@ -0,0 +1,3 @@ +package campus.tech.kakao.map.DTO + +data class SearchWord(val name: String, val address: String, val type: String) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt new file mode 100644 index 00000000..5c97b8cd --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt @@ -0,0 +1,11 @@ +package campus.tech.kakao.map.DTO + +object SearchWordContract { + const val DB_NAME = "search_word.db" + const val DB_VERSION = 1 + const val TABLE_NAME = "SearchWord" + const val COLUMN_NAME_NAME = "name" + const val COLUMN_NAME_ADDRESS = "address" + const val COLUMN_NAME_TYPE = "type" + +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt new file mode 100644 index 00000000..88d057c7 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt @@ -0,0 +1,8 @@ +package campus.tech.kakao.map.DTO + +import campus.tech.kakao.map.BuildConfig + +object UrlContract { + const val BASE_URL = "https://dapi.kakao.com/v2/local/search/" + const val AUTHORIZATION = "KakaoAK ${BuildConfig.KAKAO_REST_API_KEY}" +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt new file mode 100644 index 00000000..d5344630 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -0,0 +1,42 @@ +package campus.tech.kakao.map + +import android.app.Application +import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.LiveData +import campus.tech.kakao.map.DBHelper.SearchWordDbHelper +import campus.tech.kakao.map.DTO.Document +import campus.tech.kakao.map.DTO.SearchWord +import campus.tech.kakao.map.RetrofitData.Companion.getInstance + +class MainViewModel(application: Application): AndroidViewModel(application) { + + private val wordDbHelper = SearchWordDbHelper(application) + val wordList: LiveData> get() = wordDbHelper.getSearchWords() + + private val retrofitData = getInstance() + val documentList: LiveData> get() = retrofitData.getDocuments() + + fun addWord(document: Document){ + wordDbHelper.addWord(wordfromDocument(document)) + } + + private fun wordfromDocument(document: Document): SearchWord { + return SearchWord(document.placeName, document.categoryGroupName, document.addressName) + } + fun deleteWord(word: SearchWord){ + wordDbHelper.deleteWord(word) + } + + fun loadWord(){ + wordDbHelper.updateSearchWords() + } + + fun searchLocalAPI(query: String){ + retrofitData.searchPlace(query) + } + + override fun onCleared() { + super.onCleared() + wordDbHelper.close() + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt new file mode 100644 index 00000000..f71c0cb5 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -0,0 +1,54 @@ +package campus.tech.kakao.map + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.widget.LinearLayout +import androidx.appcompat.app.AppCompatActivity +import com.kakao.vectormap.KakaoMap +import com.kakao.vectormap.KakaoMapReadyCallback +import com.kakao.vectormap.MapLifeCycleCallback +import com.kakao.vectormap.MapView +import java.lang.Exception + +class MapActivity : AppCompatActivity() { + private lateinit var mapView: MapView + private var map: KakaoMap? = null + private lateinit var searchBar: LinearLayout + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_map) + mapView = findViewById(R.id.map_view) + mapView.start(object : MapLifeCycleCallback() { + override fun onMapDestroy() { + + } + + override fun onMapError(p0: Exception?) { + Log.e("MapActivity", "onMapError: ${p0?.message}", p0) + } + + }, object: KakaoMapReadyCallback() { + override fun onMapReady(kakaoMap: KakaoMap) { + map = kakaoMap + } + + }) + searchBar = findViewById(R.id.search_bar) + searchBar.setOnClickListener { + val intent = Intent(this@MapActivity, SearchActivity::class.java) + startActivity(intent) + } + } + + override fun onResume() { + super.onResume() + mapView.resume() + } + + override fun onPause() { + super.onPause() + mapView.pause() + } + +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt new file mode 100644 index 00000000..2d2aa825 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -0,0 +1,11 @@ +package campus.tech.kakao.map + +import android.app.Application +import com.kakao.vectormap.KakaoMapSdk + +class MyApplication : Application() { + override fun onCreate() { + super.onCreate() + KakaoMapSdk.init(this, BuildConfig.KAKAO_API_KEY) + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt new file mode 100644 index 00000000..de3f13a0 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt @@ -0,0 +1,54 @@ +package campus.tech.kakao.map + +import androidx.lifecycle.MutableLiveData +import campus.tech.kakao.map.DTO.Document +import campus.tech.kakao.map.DTO.PlaceResponse +import campus.tech.kakao.map.DTO.UrlContract +import campus.tech.kakao.map.DTO.UrlContract.AUTHORIZATION +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +class RetrofitData private constructor() { + private val _documents = MutableLiveData>() + val retrofitService = Retrofit.Builder() + .baseUrl(UrlContract.BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .build() + .create(RetrofitService::class.java) + + fun searchPlace(query : String){ + retrofitService.requestPlaces(AUTHORIZATION,query).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + val documentList = mutableListOf() + val body = response.body() + body?.documents?.forEach { + documentList.add(Document(it.placeName, it.categoryGroupName, it.addressName)) + } + _documents.value = documentList + } + } + + override fun onFailure(call: Call, t: Throwable) { + } + }) + } + fun getDocuments() = _documents + + companion object { + private var instance: RetrofitData? = null + + fun getInstance(): RetrofitData { + if (instance == null) { + instance = RetrofitData() + } + return instance!! + } + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt new file mode 100644 index 00000000..7f4e7be9 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt @@ -0,0 +1,15 @@ +package campus.tech.kakao.map + +import campus.tech.kakao.map.DTO.PlaceResponse +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Query + +interface RetrofitService { + @GET("keyword.json") + fun requestPlaces( + @Header("Authorization") authorization: String, + @Query("query") query: String + ): Call +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt new file mode 100644 index 00000000..3a10cb0b --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -0,0 +1,86 @@ +package campus.tech.kakao.map + +import android.os.Bundle +import android.view.View +import android.widget.EditText +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import androidx.core.widget.doOnTextChanged +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.Adapter.DocumentAdapter +import campus.tech.kakao.map.Adapter.WordAdapter + +class SearchActivity : AppCompatActivity() { + + private lateinit var model: MainViewModel + private lateinit var search:EditText + private lateinit var clear: TextView + private lateinit var noResult: TextView + private lateinit var searchResult: RecyclerView + private lateinit var searchWordResult: RecyclerView + private lateinit var documentAdapter: DocumentAdapter + private lateinit var wordAdapter: WordAdapter + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_search) + setupUI() + searchResult.layoutManager = LinearLayoutManager(this) + searchWordResult.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) + documentAdapter = DocumentAdapter(){ Document -> + model.addWord(Document) + } + wordAdapter = WordAdapter() { SearchWord -> + model.deleteWord(SearchWord) + } + search.doOnTextChanged { text, start, before, count -> + val query = text.toString() + if (query.isEmpty()){ + noResult.visibility = View.VISIBLE + searchResult.visibility = View.GONE + }else{ + noResult.visibility = View.GONE + searchResult.visibility = View.VISIBLE + model.searchLocalAPI(query) + } + } + model = ViewModelProvider(this)[MainViewModel::class.java] + model.documentList.observe(this, Observer {documents -> + if (documents.isNullOrEmpty()){ + noResult.visibility = View.VISIBLE + searchResult.visibility = View.GONE + }else{ + noResult.visibility = View.GONE + searchResult.visibility = View.VISIBLE + documentAdapter.submitList(documents) + searchResult.adapter = documentAdapter + } + }) + model.loadWord() + model.wordList.observe(this, Observer {searchWords -> + if (searchWords.isNullOrEmpty()){ + searchWordResult.visibility = View.GONE + } + else{ + searchWordResult.visibility = View.VISIBLE + wordAdapter.submitList(searchWords) + searchWordResult.adapter = wordAdapter + } + }) + } + + fun setupUI(){ + search = findViewById(R.id.search) + clear = findViewById(R.id.search_clear) + noResult = findViewById(R.id.no_search_result) + searchResult = findViewById(R.id.search_result_recycler_view) + searchWordResult = findViewById(R.id.search_word_recycler_view) + clear.setOnClickListener { + search.setText("") + } + } + + +} diff --git a/app/src/main/res/drawable/magnifier.png b/app/src/main/res/drawable/magnifier.png new file mode 100644 index 0000000000000000000000000000000000000000..3dad26ecb6fbb28a250e63e9bec157d755148306 GIT binary patch literal 9712 zcmdUVi9eL>*Z4g%me5#3_Q5b^7a~ieMP?{!5VB1R9ukV|W=49lC5&A%#h_6SLRqqm zC-FqcNU~2#ma+`W$l$%F=lgp<@9$6e_R(jqJa1;8h-JHHxM2kuHzSYHRSTeU~iqE8@~6K%w+)p0boxabBriloQSNOx*0pmnr#_@ zU9^Q_MNiY`{apXPaExvv=BnjrEwVtfweY|BWpBK9z(D>&`!fZZvU$ery4I*0RWBD@0 z7-sfsXVdDT^he$R=nL4l3pG*^tus>;{`0`tq4jgPR965K{|zbySf{tnNw05@?DmJm zj~Zn;(N|la{_!SgYv+5aUkr7{Q3mwOVFot-r zaBs-Nviy_3$Y{99gLSJmM4i?39M}dd90-SQK+I0KA!(Pj0LO3xk^{*AdJ;eIFn z+Bkzap*SHD?1Y-GL^EALew zRIo*`PV1jYY^tG5gvg2>%gaVxJuS0HGWeo8)}OSE$=n(2AVTtQTrrx5-)j2ag24Je z0~(U+@=mWy-#h4g7~-X}*l++_(eMhB`Rnj>8~(IW4Xi;*dOw+JQ*b6~AzG8=b)c+Z zL|6;@RT-<%;!4%s>FprK+K6<$iYI=k=_Pz zb%|*kn`cI9APu+cGO~~~%Pyb|K`1u%X&4ufPeuBTt7nAGg(xdIWPeArB%AVL8F__# zT55#j#y(n+@+J~k+*nzLlqX9W?eJqA@B+$Iu(BTp=&%m^@y>nurF0hNSGYv6+(X73 z^yr=#N?lxZoHq2oa8aL=THMqqt@huA-MR) zoUo8Hzz%9fntfz{+F$e=49`7J;%-uJ`A?7nmba#ekCyuts2)qePl)=)_F7yl(GKDx z{LlAR^eiAm+HBD8i&%$Jl&|T%ml&6#eJ*6*_mf&tVE!0@(-J+X&fSVoMZO|L?58S3 z?7Vfs2@M{pb#LWhtratRM}v=3_g{2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taHjOp@}(h?-dK$O)CuH7b%q&VPhb7}qVYN>N3jWs9JkDP`1 zN#93O-0?O)e&5NhonQ)<>AcHx%0onxs$^xSY=_Eys61UnJsMP^T4YrKdHDEpzB^KV zoyJm0bSS*c9W4X0V5OF0ai{@Iz*av|bb&n>jispsYT!#y8{05yujK&!C^+_fR|3fm zj);O!iG!)xi?8Hj&;&_zD;GFv=mp035a~Df)XdUT`Xy5NrI;7eK21r06DYbes$6^k z!7kGURjq!D#n>3AilApRYXQSg(3s4L1)um8Gqr>+w;Vi&F4zrI|FHZY zvZ(_MgOG6+bQ}buWlNT5IsD6kE#+a5Z{RnCeBc3}^1ueXELm3Ld!lfW`5J?Lc4{fQ z?WI0=p?&2|7krE1aAiUAkyq~Omv!uh(a8|tF&x$a$}vX0wh&66G0v9+imTHW8EPGP z2XS!er;Eq~d8WVVmjj=JLdB0H#>@Qq=pI(yJ+f#VG)n_@;gu%%lfJu-@Qi}y)US^sI%&P(d`G(n=S*(Bq= zTxJ=%OH1r`o92(`R;^E@D=<9YLF!m9!`p55k8iC>lT4V=I}I*$-%T zMKeSPABuyd_f^v^`yE+$G8CoamjebWO^^?thsLSIM;&;osN-~8yr2>4=9+gzsK*CO7<}?CUq2U)2@h&Ow4wAS* zzj^~fykY`nQFL?%o&YbQ$|XEX<3d^pfd_Rx=NS;F-+;oMh@%UsU`;GqTf$!?= zn9Rq`C5y~);jzS^&z-jPDs!`#)so!f&QG-0N+0?9M9Qc0d_!wZM%vC#ALw12m{xA8 zuc`7w6qWoK_2zW;O~qd|eQhGHzN+-h_|r<8H8a&WOHFJ}pZd8&cR!6=x7Bs(9A*+7 W(6f^&lH?Fy(B59Yo<$$ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml new file mode 100644 index 00000000..97d7e02e --- /dev/null +++ b/app/src/main/res/layout/activity_search.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/place_item.xml b/app/src/main/res/layout/place_item.xml new file mode 100644 index 00000000..fa5da065 --- /dev/null +++ b/app/src/main/res/layout/place_item.xml @@ -0,0 +1,47 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/word_item.xml b/app/src/main/res/layout/word_item.xml new file mode 100644 index 00000000..a14c1c28 --- /dev/null +++ b/app/src/main/res/layout/word_item.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e5ba5b9c..290224da 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,5 @@ Map + 검색어를 입력해 주세요. + 검색 결과가 없습니다. \ No newline at end of file diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 00000000..96ed3bbe --- /dev/null +++ b/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,6 @@ + + + + 54.180.95.212 + + diff --git a/settings.gradle.kts b/settings.gradle.kts index ff9d5255..e556d5a4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,6 +10,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven (url = "https://devrepo.kakao.com/nexus/content/groups/public/") } } From 7c76c973b90e7faa9382a6d2396c0d6308d93d56 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 15 Jul 2024 14:25:51 +0900 Subject: [PATCH 02/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20warnin?= =?UTF-8?q?g=20=EB=B6=80=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/word_item.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/word_item.xml b/app/src/main/res/layout/word_item.xml index a14c1c28..7b543d86 100644 --- a/app/src/main/res/layout/word_item.xml +++ b/app/src/main/res/layout/word_item.xml @@ -14,7 +14,7 @@ android:id="@+id/search_word" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="word" + android:text="@string/word_item_default_text" android:textSize="25sp" android:gravity="center" android:layout_margin="8dp"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 290224da..bfa0bb3e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,5 @@ Map 검색어를 입력해 주세요. 검색 결과가 없습니다. + word \ No newline at end of file From ba17eaf234aabc582513b32d6f567bdb22b5399f Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 15 Jul 2024 14:39:21 +0900 Subject: [PATCH 03/29] =?UTF-8?q?Docs[README.md]:=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EC=9A=94=EA=B5=AC=20=EC=82=AC=ED=95=AD=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 91dbd079..dc23030f 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ # android-map-location + +## 1단계 - 카카오맵 API 심화 +### 기능 요구 사항 +- 저장된 검색어를 선택하면 해당 검색어의 검색 결과가 표시된다. +- 검색 결과 목록 중 하나의 항목을 선택하면 해당 항목의 위치를 지도에 표시한다. +- 앱 종료 시 마지막 위치를 저장하여 다시 앱 실행 시 해당 위치로 포커스 한다. +- 카카오지도 onMapError() 호출 시 에러 화면을 보여준다. +### 프로그래밍 요구 사항 +- BottomSheet를 사용한다. +- 카카오 API 사용을 위한 앱 키를 외부에 노출하지 않는다. +- 가능한 MVVM 아키텍처 패턴을 적용하도록 한다. +- 코드 컨벤션을 준수하며 프로그래밍한다. \ No newline at end of file From 4c2c1117176391c9b3fa11674c34279854746414 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Tue, 16 Jul 2024 15:19:47 +0900 Subject: [PATCH 04/29] =?UTF-8?q?Feat[]:=20=EC=B6=94=EA=B0=80=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=ED=95=AD=EB=AA=A9=20=EC=9C=84=EC=B9=98,=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A7=80=EB=8F=84=EC=97=90=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 라벨과 바텀시트 사용 --- .../campus/tech/kakao/map/MainActivity.kt | 11 --- .../campus/tech/kakao/map/MainViewModel.kt | 15 ++- .../java/campus/tech/kakao/map/MapActivity.kt | 96 +++++++++++++++++++ .../campus/tech/kakao/map/MyApplication.kt | 6 ++ .../campus/tech/kakao/map/RetrofitData.kt | 17 ++-- .../campus/tech/kakao/map/RetrofitService.kt | 2 +- .../campus/tech/kakao/map/SearchActivity.kt | 11 ++- .../{Adapter => adapter}/DocumentAdapter.kt | 10 +- .../map/{Adapter => adapter}/WordAdapter.kt | 4 +- .../SearchWordDbHelper.kt | 9 +- .../tech/kakao/map/{DTO => dto}/Document.kt | 8 +- .../tech/kakao/map/dto/MapPositionContract.kt | 9 ++ .../kakao/map/dto/MapPositionPreferences.kt | 17 ++++ .../tech/kakao/map/{DTO => dto}/Meta.kt | 2 +- .../kakao/map/{DTO => dto}/PlaceResponse.kt | 2 +- .../tech/kakao/map/{DTO => dto}/SameName.kt | 2 +- .../tech/kakao/map/{DTO => dto}/SearchWord.kt | 2 +- .../map/{DTO => dto}/SearchWordContract.kt | 2 +- .../kakao/map/{DTO => dto}/UrlContract.kt | 2 +- app/src/main/res/layout/activity_main.xml | 19 ---- app/src/main/res/layout/activity_map.xml | 68 ++++++------- app/src/main/res/layout/bottom_sheet.xml | 30 ++++++ app/src/main/res/values/strings.xml | 2 + 23 files changed, 251 insertions(+), 95 deletions(-) delete mode 100644 app/src/main/java/campus/tech/kakao/map/MainActivity.kt rename app/src/main/java/campus/tech/kakao/map/{Adapter => adapter}/DocumentAdapter.kt (84%) rename app/src/main/java/campus/tech/kakao/map/{Adapter => adapter}/WordAdapter.kt (94%) rename app/src/main/java/campus/tech/kakao/map/{DBHelper => dbHelper}/SearchWordDbHelper.kt (93%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/Document.kt (79%) create mode 100644 app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt create mode 100644 app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/Meta.kt (89%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/PlaceResponse.kt (69%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/SameName.kt (75%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/SearchWord.kt (70%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/SearchWordContract.kt (87%) rename app/src/main/java/campus/tech/kakao/map/{DTO => dto}/UrlContract.kt (85%) delete mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/bottom_sheet.xml diff --git a/app/src/main/java/campus/tech/kakao/map/MainActivity.kt b/app/src/main/java/campus/tech/kakao/map/MainActivity.kt deleted file mode 100644 index 95b43803..00000000 --- a/app/src/main/java/campus/tech/kakao/map/MainActivity.kt +++ /dev/null @@ -1,11 +0,0 @@ -package campus.tech.kakao.map - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - } -} diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index d5344630..a875368b 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -3,9 +3,11 @@ package campus.tech.kakao.map import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData -import campus.tech.kakao.map.DBHelper.SearchWordDbHelper -import campus.tech.kakao.map.DTO.Document -import campus.tech.kakao.map.DTO.SearchWord +import campus.tech.kakao.map.dbHelper.SearchWordDbHelper +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.MapPositionContract +import campus.tech.kakao.map.dto.SearchWord +import campus.tech.kakao.map.MyApplication.Companion.mapPosition import campus.tech.kakao.map.RetrofitData.Companion.getInstance class MainViewModel(application: Application): AndroidViewModel(application) { @@ -39,4 +41,11 @@ class MainViewModel(application: Application): AndroidViewModel(application) { super.onCleared() wordDbHelper.close() } + + fun getMapInfo(document: Document){ + mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_LATITUDE, document.latitude) + mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_LONGITUDE, document.longitude) + mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_PLACENAME, document.placeName) + mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_ADDRESSNAME, document.addressName) + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index f71c0cb5..7cdb2025 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -1,24 +1,58 @@ package campus.tech.kakao.map import android.content.Intent +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.graphics.Color import android.os.Bundle import android.util.Log +import android.view.View import android.widget.LinearLayout +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import campus.tech.kakao.map.MyApplication.Companion.mapPosition +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.kakao.vectormap.KakaoMap import com.kakao.vectormap.KakaoMapReadyCallback +import com.kakao.vectormap.LatLng import com.kakao.vectormap.MapLifeCycleCallback import com.kakao.vectormap.MapView +import com.kakao.vectormap.camera.CameraUpdate +import com.kakao.vectormap.camera.CameraUpdateFactory +import com.kakao.vectormap.label.Label +import com.kakao.vectormap.label.LabelLayer +import com.kakao.vectormap.label.LabelOptions +import com.kakao.vectormap.label.LabelStyle +import com.kakao.vectormap.label.LabelStyles import java.lang.Exception class MapActivity : AppCompatActivity() { private lateinit var mapView: MapView private var map: KakaoMap? = null private lateinit var searchBar: LinearLayout + private var latitude = 37.402005 + private var longitude = 127.108621 + private lateinit var placeName:String + private lateinit var addressName:String + private var styles: LabelStyles? = null + private lateinit var options:LabelOptions + private var layer: LabelLayer? = null + private var label: Label? = null + private lateinit var bitmapImage: Bitmap + private lateinit var markerImage: Bitmap + private lateinit var bottomSheetBehavior: BottomSheetBehavior + private val bottomSheet by lazy { findViewById(R.id.bottom_sheet) } + private val bottomSheetName by lazy { findViewById(R.id.name) } + private val bottomSheetAddress by lazy { findViewById(R.id.address) } + companion object{ + var documentClicked = false + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) mapView = findViewById(R.id.map_view) + setMapInfo() mapView.start(object : MapLifeCycleCallback() { override fun onMapDestroy() { @@ -33,17 +67,37 @@ class MapActivity : AppCompatActivity() { map = kakaoMap } + override fun getPosition(): LatLng { + return LatLng.from(latitude, longitude) + } + + override fun getZoomLevel(): Int { + return 17 + } }) searchBar = findViewById(R.id.search_bar) searchBar.setOnClickListener { val intent = Intent(this@MapActivity, SearchActivity::class.java) startActivity(intent) } + initBottomSheet() } override fun onResume() { super.onResume() + setMapInfo() mapView.resume() + if(documentClicked){ + makeMarker() + setBottomSheet() + documentClicked = false + } + else{ + layer?.remove(label) + bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN + } + val cameraUpdate: CameraUpdate = CameraUpdateFactory.newCenterPosition(LatLng.from(latitude, longitude)) + map?.moveCamera(cameraUpdate) } override fun onPause() { @@ -51,4 +105,46 @@ class MapActivity : AppCompatActivity() { mapView.pause() } + private fun setMapInfo(){ + latitude = mapPosition.getPreferences("latitude","37.406960").toDouble() + longitude = mapPosition.getPreferences("longitude","127.110030").toDouble() + placeName = mapPosition.getPreferences("placeName","") + addressName = mapPosition.getPreferences("addressName","") + } + + private fun makeMarker(){ + bitmapImage = BitmapFactory.decodeResource(resources, R.drawable.marker) + markerImage = Bitmap.createScaledBitmap(bitmapImage, 100, 100, true) + styles = map?.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(markerImage).setTextStyles(40, Color.BLACK))) + if(styles != null){ + options = LabelOptions.from(LatLng.from(latitude, longitude)).setStyles(styles).setTexts(placeName) + layer = map?.labelManager?.layer + if(label != null){ + layer?.remove(label) + } + label = layer?.addLabel(options) + } + else{ + Log.e("MapActivity", "makeMarker: styles is null") + } + } + + private fun initBottomSheet(){ + bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet) + bottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback(){ + override fun onStateChanged(bottomSheet: View, newState: Int) { + } + + override fun onSlide(bottomSheet: View, slideOffset: Float) { + } + + }) + bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN + } + + private fun setBottomSheet(){ + bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED + bottomSheetName.text = placeName + bottomSheetAddress.text = addressName + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index 2d2aa825..343ca5f8 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -1,11 +1,17 @@ package campus.tech.kakao.map import android.app.Application +import campus.tech.kakao.map.dto.MapPositionPreferences import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { override fun onCreate() { super.onCreate() + mapPosition = MapPositionPreferences(this) KakaoMapSdk.init(this, BuildConfig.KAKAO_API_KEY) } + + companion object{ + lateinit var mapPosition : MapPositionPreferences + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt index de3f13a0..c9a232ee 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt @@ -1,10 +1,10 @@ package campus.tech.kakao.map import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.DTO.Document -import campus.tech.kakao.map.DTO.PlaceResponse -import campus.tech.kakao.map.DTO.UrlContract -import campus.tech.kakao.map.DTO.UrlContract.AUTHORIZATION +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.PlaceResponse +import campus.tech.kakao.map.dto.UrlContract +import campus.tech.kakao.map.dto.UrlContract.AUTHORIZATION import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -28,8 +28,13 @@ class RetrofitData private constructor() { if (response.isSuccessful) { val documentList = mutableListOf() val body = response.body() - body?.documents?.forEach { - documentList.add(Document(it.placeName, it.categoryGroupName, it.addressName)) + body?.documents?.forEach {document -> + documentList.add(Document( + document.placeName, + document.categoryGroupName, + document.addressName, + document.longitude, + document.latitude)) } _documents.value = documentList } diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt index 7f4e7be9..d2101f00 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt @@ -1,6 +1,6 @@ package campus.tech.kakao.map -import campus.tech.kakao.map.DTO.PlaceResponse +import campus.tech.kakao.map.dto.PlaceResponse import retrofit2.Call import retrofit2.http.GET import retrofit2.http.Header diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index 3a10cb0b..0f8f34a6 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -10,8 +10,8 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.Adapter.DocumentAdapter -import campus.tech.kakao.map.Adapter.WordAdapter +import campus.tech.kakao.map.adapter.DocumentAdapter +import campus.tech.kakao.map.adapter.WordAdapter class SearchActivity : AppCompatActivity() { @@ -29,9 +29,12 @@ class SearchActivity : AppCompatActivity() { setupUI() searchResult.layoutManager = LinearLayoutManager(this) searchWordResult.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) - documentAdapter = DocumentAdapter(){ Document -> + documentAdapter = DocumentAdapter({ Document -> model.addWord(Document) - } + },{Document -> + model.getMapInfo(Document) + finish() + }) wordAdapter = WordAdapter() { SearchWord -> model.deleteWord(SearchWord) } diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt similarity index 84% rename from app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index 74492c58..b141f6b9 100644 --- a/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.Adapter +package campus.tech.kakao.map.adapter import android.view.LayoutInflater import android.view.View @@ -7,11 +7,13 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.DTO.Document +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.MapActivity.Companion.documentClicked import campus.tech.kakao.map.R class DocumentAdapter( - val addWord: (Document) -> Unit + val addWord: (Document) -> Unit, + val sendDocumentInfo: (Document) -> Unit ): ListAdapter( object : DiffUtil.ItemCallback(){ override fun areItemsTheSame(oldItem: Document, newItem: Document): Boolean { @@ -27,6 +29,8 @@ class DocumentAdapter( private var placeClicked = { position:Int -> val document: Document = getItem(position) addWord(document) + sendDocumentInfo(document) + documentClicked = true } inner class ViewHolder( itemView: View diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt similarity index 94% rename from app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index 9b051e3d..7af25014 100644 --- a/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.Adapter +package campus.tech.kakao.map.adapter import android.view.LayoutInflater import android.view.View @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import campus.tech.kakao.map.R -import campus.tech.kakao.map.DTO.SearchWord +import campus.tech.kakao.map.dto.SearchWord class WordAdapter( val deleteWord: (SearchWord) -> Unit diff --git a/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt similarity index 93% rename from app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt rename to app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt index a736d865..bf22f9bf 100644 --- a/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt +++ b/app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt @@ -1,15 +1,14 @@ -package campus.tech.kakao.map.DBHelper +package campus.tech.kakao.map.dbHelper import android.content.ContentValues import android.content.Context import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.DTO.SearchWord -import campus.tech.kakao.map.DTO.SearchWordContract -import campus.tech.kakao.map.DTO.SearchWordContract.DB_VERSION +import campus.tech.kakao.map.dto.SearchWord +import campus.tech.kakao.map.dto.SearchWordContract +import campus.tech.kakao.map.dto.SearchWordContract.DB_VERSION class SearchWordDbHelper(context: Context): SQLiteOpenHelper( context, SearchWordContract.DB_NAME, null, DB_VERSION) { diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt similarity index 79% rename from app/src/main/java/campus/tech/kakao/map/DTO/Document.kt rename to app/src/main/java/campus/tech/kakao/map/dto/Document.kt index 1b33c093..637f7059 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto import com.google.gson.annotations.SerializedName @@ -15,8 +15,10 @@ data class Document( @SerializedName("address_name") val addressName: String, //val road_address_name: String, - //val x: String, - //val y: String, + @SerializedName("x") + val longitude : String, + @SerializedName("y") + val latitude: String, //val place_url: String, //val distance: String, ) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt new file mode 100644 index 00000000..b0af0619 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt @@ -0,0 +1,9 @@ +package campus.tech.kakao.map.dto + +object MapPositionContract { + const val PREFERENCE_NAME = "MapPosition" + const val PREFERENCE_KEY_LATITUDE = "latitude" + const val PREFERENCE_KEY_LONGITUDE = "longitude" + const val PREFERENCE_KEY_PLACENAME = "placeName" + const val PREFERENCE_KEY_ADDRESSNAME = "addressName" +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt new file mode 100644 index 00000000..bb52e031 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt @@ -0,0 +1,17 @@ +package campus.tech.kakao.map.dto + +import android.content.Context + +class MapPositionPreferences(context: Context) { + + private val mapPosition = context.getSharedPreferences(MapPositionContract.PREFERENCE_NAME, Context.MODE_PRIVATE) + + fun setPreferences(key: String, value: String) { + mapPosition.edit().putString(key, value).apply() + } + + fun getPreferences(key: String, defaultValue: String): String { + return mapPosition.getString(key, defaultValue).toString() + } + +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt b/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt similarity index 89% rename from app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt rename to app/src/main/java/campus/tech/kakao/map/dto/Meta.kt index e34d3048..60b41d75 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt b/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt similarity index 69% rename from app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt rename to app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt index 9ab49a5d..3abf2475 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto data class PlaceResponse( val meta: Meta, diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt similarity index 75% rename from app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SameName.kt index b3b9f3bc..833cddfe 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto data class SameName( val region: List, diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt b/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt similarity index 70% rename from app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt index 2823ba00..8ee333ed 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt @@ -1,3 +1,3 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto data class SearchWord(val name: String, val address: String, val type: String) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt similarity index 87% rename from app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt index 5c97b8cd..2acdb952 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto object SearchWordContract { const val DB_NAME = "search_word.db" diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt similarity index 85% rename from app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt rename to app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt index 88d057c7..2d46eb85 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map.dto import campus.tech.kakao.map.BuildConfig diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 24d17df2..00000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index 4c302a6f..8b7646e4 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -1,36 +1,40 @@ - - + - - - - - - \ No newline at end of file + android:layout_height="match_parent" + tools:context=".MapActivity"> + + + + + + + + diff --git a/app/src/main/res/layout/bottom_sheet.xml b/app/src/main/res/layout/bottom_sheet.xml new file mode 100644 index 00000000..4c14d032 --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet.xml @@ -0,0 +1,30 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bfa0bb3e..4d7654b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,4 +3,6 @@ 검색어를 입력해 주세요. 검색 결과가 없습니다. word + 카카오 + 경기 성남시 분당구 백현동 532 \ No newline at end of file From c69b1815a3059714915e086c6b1521d97dff0b37 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Tue, 16 Jul 2024 15:22:45 +0900 Subject: [PATCH 05/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20warnin?= =?UTF-8?q?g=20=EC=9A=94=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/SearchActivity.kt | 16 ++++++++-------- app/src/main/res/layout/bottom_sheet.xml | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index 0f8f34a6..0837c69d 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -29,16 +29,16 @@ class SearchActivity : AppCompatActivity() { setupUI() searchResult.layoutManager = LinearLayoutManager(this) searchWordResult.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) - documentAdapter = DocumentAdapter({ Document -> - model.addWord(Document) - },{Document -> - model.getMapInfo(Document) + documentAdapter = DocumentAdapter({ document -> + model.addWord(document) + },{document -> + model.getMapInfo(document) finish() }) - wordAdapter = WordAdapter() { SearchWord -> - model.deleteWord(SearchWord) + wordAdapter = WordAdapter { searchWord -> + model.deleteWord(searchWord) } - search.doOnTextChanged { text, start, before, count -> + search.doOnTextChanged { text, _, _, _ -> val query = text.toString() if (query.isEmpty()){ noResult.visibility = View.VISIBLE @@ -74,7 +74,7 @@ class SearchActivity : AppCompatActivity() { }) } - fun setupUI(){ + private fun setupUI(){ search = findViewById(R.id.search) clear = findViewById(R.id.search_clear) noResult = findViewById(R.id.no_search_result) diff --git a/app/src/main/res/layout/bottom_sheet.xml b/app/src/main/res/layout/bottom_sheet.xml index 4c14d032..dc44d733 100644 --- a/app/src/main/res/layout/bottom_sheet.xml +++ b/app/src/main/res/layout/bottom_sheet.xml @@ -5,6 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="20dp" + android:paddingEnd="20dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" app:behavior_hideable = "true" app:behavior_peekHeight="100dp" From 2613a7d4cee30dc3c4623b88808a0b910823daf0 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Tue, 16 Jul 2024 15:32:36 +0900 Subject: [PATCH 06/29] =?UTF-8?q?Design[bottom=5Fsheet]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=ED=8C=A8=EB=94=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/bottom_sheet.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/bottom_sheet.xml b/app/src/main/res/layout/bottom_sheet.xml index dc44d733..a020f694 100644 --- a/app/src/main/res/layout/bottom_sheet.xml +++ b/app/src/main/res/layout/bottom_sheet.xml @@ -4,11 +4,10 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="20dp" - android:paddingEnd="20dp" + android:padding="10dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" app:behavior_hideable = "true" - app:behavior_peekHeight="100dp" + app:behavior_peekHeight="120dp" android:focusable="true" android:id="@+id/bottom_sheet" android:background="@color/white"> From daefd3549d5fd23a91cffe0ad0f75dcfee025e31 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Tue, 16 Jul 2024 15:51:39 +0900 Subject: [PATCH 07/29] =?UTF-8?q?Feat[]:=20=EC=B6=94=EA=B0=80=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=EB=90=9C=20=EA=B2=80=EC=83=89=EC=96=B4=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=EA=B2=80=EC=83=89?= =?UTF-8?q?=EC=96=B4=20=EA=B2=80=EC=83=89=20=EA=B2=B0=EA=B3=BC=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/SearchActivity.kt | 10 +++++++--- .../campus/tech/kakao/map/adapter/WordAdapter.kt | 12 +++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index 0837c69d..d3098e30 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -35,9 +35,13 @@ class SearchActivity : AppCompatActivity() { model.getMapInfo(document) finish() }) - wordAdapter = WordAdapter { searchWord -> - model.deleteWord(searchWord) - } + wordAdapter = WordAdapter( + { searchWord -> + model.deleteWord(searchWord) + },{ searchWord -> + model.searchLocalAPI(searchWord.name) + } + ) search.doOnTextChanged { text, _, _, _ -> val query = text.toString() if (query.isEmpty()){ diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index 7af25014..7f9a30da 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -12,7 +12,8 @@ import campus.tech.kakao.map.R import campus.tech.kakao.map.dto.SearchWord class WordAdapter( - val deleteWord: (SearchWord) -> Unit + val deleteWord: (SearchWord) -> Unit, + val clickWord: (SearchWord) -> Unit ): ListAdapter( object : DiffUtil.ItemCallback(){ override fun areItemsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { @@ -34,6 +35,9 @@ class WordAdapter( delete.setOnClickListener { deletedWords(bindingAdapterPosition) } + searchWord.setOnClickListener { + clickedWord(bindingAdapterPosition) + } } } @@ -50,4 +54,10 @@ class WordAdapter( val word = getItem(position) deleteWord(word) } + + private val clickedWord = { position:Int -> + val word = getItem(position) + clickWord(word) + } + } \ No newline at end of file From 4bc4784eaaf9d628655d0a9ebfdf90c1b851c4b9 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Wed, 17 Jul 2024 14:31:29 +0900 Subject: [PATCH 08/29] =?UTF-8?q?Feat[]:=20=EC=B6=94=EA=B0=80=20=EC=B9=B4?= =?UTF-8?q?=EC=B9=B4=EC=98=A4=EC=A7=80=EB=8F=84=20onMapError()=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/MapActivity.kt | 4 ++- app/src/main/res/layout/map_error.xml | 32 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/map_error.xml diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 7cdb2025..d979b1dc 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -59,7 +59,9 @@ class MapActivity : AppCompatActivity() { } override fun onMapError(p0: Exception?) { - Log.e("MapActivity", "onMapError: ${p0?.message}", p0) + setContentView(R.layout.map_error) + val errorText = findViewById(R.id.map_error_text) + errorText.text = p0?.message } }, object: KakaoMapReadyCallback() { diff --git a/app/src/main/res/layout/map_error.xml b/app/src/main/res/layout/map_error.xml new file mode 100644 index 00000000..4d0a94b9 --- /dev/null +++ b/app/src/main/res/layout/map_error.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4d7654b1..9175c622 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,5 @@ word 카카오 경기 성남시 분당구 백현동 532 + 오류가 발생했습니다.\n다시 시도해 주세요. \ No newline at end of file From 91bb4457870812fe62a2e363226ab62ca63f5778 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 17:26:32 +0900 Subject: [PATCH 09/29] =?UTF-8?q?Feat[]:=20=EC=B6=94=EA=B0=80=20MapPrefere?= =?UTF-8?q?nces=EC=97=90=EC=84=9C=20Document=EB=A5=BC=20=EB=B0=9B=EC=95=84?= =?UTF-8?q?=EC=84=9C=20=EC=A0=80=EC=9E=A5=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 6 +- .../tech/kakao/map/Adapter/DocumentAdapter.kt | 56 --------- .../tech/kakao/map/Adapter/WordAdapter.kt | 53 --------- .../kakao/map/DBHelper/SearchWordDbHelper.kt | 110 ------------------ .../campus/tech/kakao/map/DTO/Document.kt | 22 ---- .../campus/tech/kakao/map/DTO/SearchWord.kt | 3 - .../tech/kakao/map/DTO/SearchWordContract.kt | 11 -- .../campus/tech/kakao/map/DTO/UrlContract.kt | 8 -- .../tech/kakao/map/{dto => }/Document.kt | 2 +- .../map/{adapter => }/DocumentAdapter.kt | 4 +- .../campus/tech/kakao/map/MainViewModel.kt | 11 +- .../map/{dto => }/MapPositionContract.kt | 2 +- .../map/{dto => }/MapPositionPreferences.kt | 9 +- .../campus/tech/kakao/map/{DTO => }/Meta.kt | 2 +- .../campus/tech/kakao/map/MyApplication.kt | 1 - .../tech/kakao/map/{DTO => }/PlaceResponse.kt | 2 +- .../campus/tech/kakao/map/RetrofitData.kt | 11 +- .../campus/tech/kakao/map/RetrofitService.kt | 1 - .../tech/kakao/map/{DTO => }/SameName.kt | 2 +- .../campus/tech/kakao/map/SearchActivity.kt | 4 +- .../tech/kakao/map/{dto => }/SearchWord.kt | 2 +- .../kakao/map/{dto => }/SearchWordContract.kt | 2 +- .../map/{dbHelper => }/SearchWordDbHelper.kt | 6 +- .../tech/kakao/map/{dto => }/UrlContract.kt | 2 +- .../kakao/map/{adapter => }/WordAdapter.kt | 4 +- .../java/campus/tech/kakao/map/dto/Meta.kt | 14 --- .../tech/kakao/map/dto/PlaceResponse.kt | 6 - .../campus/tech/kakao/map/dto/SameName.kt | 7 -- 28 files changed, 33 insertions(+), 330 deletions(-) delete mode 100644 app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/Document.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt rename app/src/main/java/campus/tech/kakao/map/{dto => }/Document.kt (94%) rename app/src/main/java/campus/tech/kakao/map/{adapter => }/DocumentAdapter.kt (93%) rename app/src/main/java/campus/tech/kakao/map/{dto => }/MapPositionContract.kt (89%) rename app/src/main/java/campus/tech/kakao/map/{dto => }/MapPositionPreferences.kt (51%) rename app/src/main/java/campus/tech/kakao/map/{DTO => }/Meta.kt (89%) rename app/src/main/java/campus/tech/kakao/map/{DTO => }/PlaceResponse.kt (69%) rename app/src/main/java/campus/tech/kakao/map/{DTO => }/SameName.kt (75%) rename app/src/main/java/campus/tech/kakao/map/{dto => }/SearchWord.kt (70%) rename app/src/main/java/campus/tech/kakao/map/{dto => }/SearchWordContract.kt (87%) rename app/src/main/java/campus/tech/kakao/map/{dbHelper => }/SearchWordDbHelper.kt (94%) rename app/src/main/java/campus/tech/kakao/map/{dto => }/UrlContract.kt (85%) rename app/src/main/java/campus/tech/kakao/map/{adapter => }/WordAdapter.kt (93%) delete mode 100644 app/src/main/java/campus/tech/kakao/map/dto/Meta.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt delete mode 100644 app/src/main/java/campus/tech/kakao/map/dto/SameName.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9b4327c9..7240e4b1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,10 +48,13 @@ android { viewBinding = true buildConfig = true } + testOptions { + animationsDisabled = true + } } dependencies { - val lifecycle_version = "2.8.3" + val lifecycle_version = "2.8.3" implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version") implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version") implementation("androidx.core:core-ktx:1.12.0") @@ -75,5 +78,6 @@ dependencies { androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation("androidx.test:rules:1.5.0") androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1") + androidTestImplementation("androidx.test.espresso:espresso-contrib:3.5.1") } fun getApiKey(key: String): String = gradleLocalProperties(rootDir, providers).getProperty(key) \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt deleted file mode 100644 index 74492c58..00000000 --- a/app/src/main/java/campus/tech/kakao/map/Adapter/DocumentAdapter.kt +++ /dev/null @@ -1,56 +0,0 @@ -package campus.tech.kakao.map.Adapter - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.DTO.Document -import campus.tech.kakao.map.R - -class DocumentAdapter( - val addWord: (Document) -> Unit -): ListAdapter( - object : DiffUtil.ItemCallback(){ - override fun areItemsTheSame(oldItem: Document, newItem: Document): Boolean { - return oldItem === newItem - } - - override fun areContentsTheSame(oldItem: Document, newItem: Document): Boolean { - return oldItem == newItem - } - - } -) { - private var placeClicked = { position:Int -> - val document: Document = getItem(position) - addWord(document) - } - inner class ViewHolder( - itemView: View - ): RecyclerView.ViewHolder(itemView) { - val name:TextView = itemView.findViewById(R.id.name) - val address:TextView = itemView.findViewById(R.id.address) - val type:TextView = itemView.findViewById(R.id.type) - init { - itemView.setOnClickListener { - placeClicked(bindingAdapterPosition) - } - } - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.place_item, parent, false)) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val document: Document = getItem(position) - holder.name.text = document.placeName - holder.address.text = document.addressName - holder.type.text = document.categoryGroupName - } -} - - diff --git a/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt deleted file mode 100644 index 9b051e3d..00000000 --- a/app/src/main/java/campus/tech/kakao/map/Adapter/WordAdapter.kt +++ /dev/null @@ -1,53 +0,0 @@ -package campus.tech.kakao.map.Adapter - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.R -import campus.tech.kakao.map.DTO.SearchWord - -class WordAdapter( - val deleteWord: (SearchWord) -> Unit -): ListAdapter( - object : DiffUtil.ItemCallback(){ - override fun areItemsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { - return oldItem === newItem - } - - override fun areContentsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { - return oldItem == newItem - } - - } -) { - inner class ViewHolder( - itemView: View - ): RecyclerView.ViewHolder(itemView) { - val searchWord: TextView = itemView.findViewById(R.id.search_word) - val delete: ImageView = itemView.findViewById(R.id.x) - init { - delete.setOnClickListener { - deletedWords(bindingAdapterPosition) - } - } - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.word_item, parent, false)) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val word = getItem(position) - holder.searchWord.text = word.name - } - - private val deletedWords = { position:Int -> - val word = getItem(position) - deleteWord(word) - } -} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt deleted file mode 100644 index a736d865..00000000 --- a/app/src/main/java/campus/tech/kakao/map/DBHelper/SearchWordDbHelper.kt +++ /dev/null @@ -1,110 +0,0 @@ -package campus.tech.kakao.map.DBHelper - -import android.content.ContentValues -import android.content.Context -import android.database.sqlite.SQLiteDatabase -import android.database.sqlite.SQLiteOpenHelper -import android.util.Log -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.DTO.SearchWord -import campus.tech.kakao.map.DTO.SearchWordContract -import campus.tech.kakao.map.DTO.SearchWordContract.DB_VERSION - -class SearchWordDbHelper(context: Context): SQLiteOpenHelper( - context, SearchWordContract.DB_NAME, null, DB_VERSION) { - private val _searchWords = MutableLiveData>() - val searchSameSelection = "${SearchWordContract.COLUMN_NAME_NAME} = ? AND " + - "${SearchWordContract.COLUMN_NAME_ADDRESS} = ? AND " + - "${SearchWordContract.COLUMN_NAME_TYPE} = ?" - override fun onCreate(db: SQLiteDatabase?) { - createTable(db) - } - - private fun createTable(db: SQLiteDatabase?) { - db?.execSQL( - "CREATE TABLE ${SearchWordContract.TABLE_NAME} " + - "(${SearchWordContract.COLUMN_NAME_NAME} TEXT, " + - "${SearchWordContract.COLUMN_NAME_ADDRESS} TEXT, " + - "${SearchWordContract.COLUMN_NAME_TYPE} TEXT)" - ) - } - - override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { - db?.execSQL("DROP TABLE IF EXISTS ${SearchWordContract.TABLE_NAME}") - createTable(db) - } - - fun getSearchWords(): LiveData> { - return _searchWords - } - - fun addWord(word: SearchWord) { - val db = writableDatabase - if (existWord(word, db)){ - deleteWord(word) - } - val values = ContentValues() - values.put(SearchWordContract.COLUMN_NAME_NAME, word.name) - values.put(SearchWordContract.COLUMN_NAME_ADDRESS, word.address) - values.put(SearchWordContract.COLUMN_NAME_TYPE, word.type) - db.insert(SearchWordContract.TABLE_NAME, null, values) - db.close() - updateSearchWords() - } - - fun existWord(word: SearchWord, db: SQLiteDatabase): Boolean{ - val selection = searchSameSelection - val cursor = db.query( - SearchWordContract.TABLE_NAME, - arrayOf(SearchWordContract.COLUMN_NAME_NAME), - selection, - arrayOf(word.name, word.address, word.type), - null, - null, - "${SearchWordContract.COLUMN_NAME_NAME} DESC" - ).use { - it.moveToFirst() - } - return cursor - } - - fun deleteWord(word: SearchWord){ - val db = writableDatabase - val selection = searchSameSelection - val selectionArgs = arrayOf(word.name, word.address, word.type) - db.delete(SearchWordContract.TABLE_NAME, selection, selectionArgs) - updateSearchWords() - } - - fun updateSearchWords(){ - val db = readableDatabase - val resultList = mutableListOf() - val cursor = db.query( - SearchWordContract.TABLE_NAME, - arrayOf( - SearchWordContract.COLUMN_NAME_NAME, - SearchWordContract.COLUMN_NAME_ADDRESS, - SearchWordContract.COLUMN_NAME_TYPE - ), - null, - null, - null, - null, - null - ).use {cursor -> - while (cursor.moveToNext()) { - val name = cursor.getString( - cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_NAME) - ) - val address = cursor.getString( - cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_ADDRESS) - ) - val type = cursor.getString( - cursor.getColumnIndexOrThrow(SearchWordContract.COLUMN_NAME_TYPE)) - resultList.add(SearchWord(name, address, type)) - } - } - _searchWords.value = resultList - } -} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt b/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt deleted file mode 100644 index 1b33c093..00000000 --- a/app/src/main/java/campus/tech/kakao/map/DTO/Document.kt +++ /dev/null @@ -1,22 +0,0 @@ -package campus.tech.kakao.map.DTO - -import com.google.gson.annotations.SerializedName - -//필요 없는 데이터 주석화 -data class Document( - //val id: String, - @SerializedName("place_name") - val placeName: String, - //val category_name: String, - //val category_group_code: String, - @SerializedName("category_group_name") - val categoryGroupName: String, - //val phone: String, - @SerializedName("address_name") - val addressName: String, - //val road_address_name: String, - //val x: String, - //val y: String, - //val place_url: String, - //val distance: String, -) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt deleted file mode 100644 index 2823ba00..00000000 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWord.kt +++ /dev/null @@ -1,3 +0,0 @@ -package campus.tech.kakao.map.DTO - -data class SearchWord(val name: String, val address: String, val type: String) diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt b/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt deleted file mode 100644 index 5c97b8cd..00000000 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SearchWordContract.kt +++ /dev/null @@ -1,11 +0,0 @@ -package campus.tech.kakao.map.DTO - -object SearchWordContract { - const val DB_NAME = "search_word.db" - const val DB_VERSION = 1 - const val TABLE_NAME = "SearchWord" - const val COLUMN_NAME_NAME = "name" - const val COLUMN_NAME_ADDRESS = "address" - const val COLUMN_NAME_TYPE = "type" - -} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt deleted file mode 100644 index 88d057c7..00000000 --- a/app/src/main/java/campus/tech/kakao/map/DTO/UrlContract.kt +++ /dev/null @@ -1,8 +0,0 @@ -package campus.tech.kakao.map.DTO - -import campus.tech.kakao.map.BuildConfig - -object UrlContract { - const val BASE_URL = "https://dapi.kakao.com/v2/local/search/" - const val AUTHORIZATION = "KakaoAK ${BuildConfig.KAKAO_REST_API_KEY}" -} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/Document.kt b/app/src/main/java/campus/tech/kakao/map/Document.kt similarity index 94% rename from app/src/main/java/campus/tech/kakao/map/dto/Document.kt rename to app/src/main/java/campus/tech/kakao/map/Document.kt index 637f7059..aee28646 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/Document.kt +++ b/app/src/main/java/campus/tech/kakao/map/Document.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt similarity index 93% rename from app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt index b141f6b9..69ed47d0 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.adapter +package campus.tech.kakao.map import android.view.LayoutInflater import android.view.View @@ -7,9 +7,7 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.MapActivity.Companion.documentClicked -import campus.tech.kakao.map.R class DocumentAdapter( val addWord: (Document) -> Unit, diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index a875368b..d21003e4 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -3,10 +3,6 @@ package campus.tech.kakao.map import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData -import campus.tech.kakao.map.dbHelper.SearchWordDbHelper -import campus.tech.kakao.map.dto.Document -import campus.tech.kakao.map.dto.MapPositionContract -import campus.tech.kakao.map.dto.SearchWord import campus.tech.kakao.map.MyApplication.Companion.mapPosition import campus.tech.kakao.map.RetrofitData.Companion.getInstance @@ -42,10 +38,7 @@ class MainViewModel(application: Application): AndroidViewModel(application) { wordDbHelper.close() } - fun getMapInfo(document: Document){ - mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_LATITUDE, document.latitude) - mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_LONGITUDE, document.longitude) - mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_PLACENAME, document.placeName) - mapPosition.setPreferences(MapPositionContract.PREFERENCE_KEY_ADDRESSNAME, document.addressName) + fun setMapInfo(document: Document){ + mapPosition.setMapInfo(document) } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt b/app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt similarity index 89% rename from app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt rename to app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt index b0af0619..d49c76ed 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map object MapPositionContract { const val PREFERENCE_NAME = "MapPosition" diff --git a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt b/app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt similarity index 51% rename from app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt rename to app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt index bb52e031..5932b1db 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map import android.content.Context @@ -14,4 +14,11 @@ class MapPositionPreferences(context: Context) { return mapPosition.getString(key, defaultValue).toString() } + fun setMapInfo(document: Document){ + setPreferences(MapPositionContract.PREFERENCE_KEY_LATITUDE, document.latitude) + setPreferences(MapPositionContract.PREFERENCE_KEY_LONGITUDE, document.longitude) + setPreferences(MapPositionContract.PREFERENCE_KEY_PLACENAME, document.placeName) + setPreferences(MapPositionContract.PREFERENCE_KEY_ADDRESSNAME, document.addressName) + } + } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt b/app/src/main/java/campus/tech/kakao/map/Meta.kt similarity index 89% rename from app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt rename to app/src/main/java/campus/tech/kakao/map/Meta.kt index e34d3048..6c35f5d3 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/Meta.kt +++ b/app/src/main/java/campus/tech/kakao/map/Meta.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index 343ca5f8..2be60dfd 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -1,7 +1,6 @@ package campus.tech.kakao.map import android.app.Application -import campus.tech.kakao.map.dto.MapPositionPreferences import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt b/app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt similarity index 69% rename from app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt rename to app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt index 9ab49a5d..d1c025a6 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/PlaceResponse.kt +++ b/app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map data class PlaceResponse( val meta: Meta, diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt index c9a232ee..925e32a5 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt @@ -1,10 +1,7 @@ package campus.tech.kakao.map import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.dto.Document -import campus.tech.kakao.map.dto.PlaceResponse -import campus.tech.kakao.map.dto.UrlContract -import campus.tech.kakao.map.dto.UrlContract.AUTHORIZATION +import campus.tech.kakao.map.UrlContract.AUTHORIZATION import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -29,12 +26,14 @@ class RetrofitData private constructor() { val documentList = mutableListOf() val body = response.body() body?.documents?.forEach {document -> - documentList.add(Document( + documentList.add( + Document( document.placeName, document.categoryGroupName, document.addressName, document.longitude, - document.latitude)) + document.latitude) + ) } _documents.value = documentList } diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt index d2101f00..97f1af21 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt @@ -1,6 +1,5 @@ package campus.tech.kakao.map -import campus.tech.kakao.map.dto.PlaceResponse import retrofit2.Call import retrofit2.http.GET import retrofit2.http.Header diff --git a/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt b/app/src/main/java/campus/tech/kakao/map/SameName.kt similarity index 75% rename from app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt rename to app/src/main/java/campus/tech/kakao/map/SameName.kt index b3b9f3bc..54a9146d 100644 --- a/app/src/main/java/campus/tech/kakao/map/DTO/SameName.kt +++ b/app/src/main/java/campus/tech/kakao/map/SameName.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.DTO +package campus.tech.kakao.map data class SameName( val region: List, diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index d3098e30..e6647094 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -10,8 +10,6 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.adapter.DocumentAdapter -import campus.tech.kakao.map.adapter.WordAdapter class SearchActivity : AppCompatActivity() { @@ -32,7 +30,7 @@ class SearchActivity : AppCompatActivity() { documentAdapter = DocumentAdapter({ document -> model.addWord(document) },{document -> - model.getMapInfo(document) + model.setMapInfo(document) finish() }) wordAdapter = WordAdapter( diff --git a/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt b/app/src/main/java/campus/tech/kakao/map/SearchWord.kt similarity index 70% rename from app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt rename to app/src/main/java/campus/tech/kakao/map/SearchWord.kt index 8ee333ed..980b1625 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchWord.kt @@ -1,3 +1,3 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map data class SearchWord(val name: String, val address: String, val type: String) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt b/app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt similarity index 87% rename from app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt rename to app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt index 2acdb952..9e28ec13 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map object SearchWordContract { const val DB_NAME = "search_word.db" diff --git a/app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt similarity index 94% rename from app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt rename to app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt index bf22f9bf..0763b1bf 100644 --- a/app/src/main/java/campus/tech/kakao/map/dbHelper/SearchWordDbHelper.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dbHelper +package campus.tech.kakao.map import android.content.ContentValues import android.content.Context @@ -6,9 +6,7 @@ import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.dto.SearchWord -import campus.tech.kakao.map.dto.SearchWordContract -import campus.tech.kakao.map.dto.SearchWordContract.DB_VERSION +import campus.tech.kakao.map.SearchWordContract.DB_VERSION class SearchWordDbHelper(context: Context): SQLiteOpenHelper( context, SearchWordContract.DB_NAME, null, DB_VERSION) { diff --git a/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/UrlContract.kt similarity index 85% rename from app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt rename to app/src/main/java/campus/tech/kakao/map/UrlContract.kt index 2d46eb85..af2524c7 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/UrlContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map import campus.tech.kakao.map.BuildConfig diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/WordAdapter.kt similarity index 93% rename from app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/WordAdapter.kt index 7f9a30da..b3c5527f 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/WordAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.adapter +package campus.tech.kakao.map import android.view.LayoutInflater import android.view.View @@ -8,8 +8,6 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.R -import campus.tech.kakao.map.dto.SearchWord class WordAdapter( val deleteWord: (SearchWord) -> Unit, diff --git a/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt b/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt deleted file mode 100644 index 60b41d75..00000000 --- a/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt +++ /dev/null @@ -1,14 +0,0 @@ -package campus.tech.kakao.map.dto - -import com.google.gson.annotations.SerializedName - -data class Meta( - @SerializedName("total_count") - val totalCount: Int, - @SerializedName("pageable_count") - val pageableCount: Int, - @SerializedName("is_end") - val isEnd: Boolean, - @SerializedName("same_name") - val sameName: SameName -) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt b/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt deleted file mode 100644 index 3abf2475..00000000 --- a/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt +++ /dev/null @@ -1,6 +0,0 @@ -package campus.tech.kakao.map.dto - -data class PlaceResponse( - val meta: Meta, - val documents: List -) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt deleted file mode 100644 index 833cddfe..00000000 --- a/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt +++ /dev/null @@ -1,7 +0,0 @@ -package campus.tech.kakao.map.dto - -data class SameName( - val region: List, - val keyword: String, - val selected_region: String -) From 9a521a27690e277da0b8e91b18a5630a2910ff72 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 18:39:44 +0900 Subject: [PATCH 10/29] =?UTF-8?q?Refactor[MapActivity]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=B7=B0=20lazy=20=EC=B4=88=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lateinit으로 변경 --- app/src/main/java/campus/tech/kakao/map/MapActivity.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index d979b1dc..5619ec96 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -41,9 +41,9 @@ class MapActivity : AppCompatActivity() { private lateinit var bitmapImage: Bitmap private lateinit var markerImage: Bitmap private lateinit var bottomSheetBehavior: BottomSheetBehavior - private val bottomSheet by lazy { findViewById(R.id.bottom_sheet) } - private val bottomSheetName by lazy { findViewById(R.id.name) } - private val bottomSheetAddress by lazy { findViewById(R.id.address) } + private lateinit var bottomSheet :LinearLayout + private lateinit var bottomSheetName:TextView + private lateinit var bottomSheetAddress :TextView companion object{ var documentClicked = false } @@ -132,6 +132,9 @@ class MapActivity : AppCompatActivity() { } private fun initBottomSheet(){ + bottomSheet = findViewById(R.id.bottom_sheet) + bottomSheetName = findViewById(R.id.name) + bottomSheetAddress = findViewById(R.id.address) bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet) bottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback(){ override fun onStateChanged(bottomSheet: View, newState: Int) { From 7e68e17724253d524f5645d9313b1369118b6ef4 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 22:28:46 +0900 Subject: [PATCH 11/29] =?UTF-8?q?Refactor[MainViewModel]:=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20initLatitude,=20initLongitude?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/MainViewModel.kt | 6 ++++++ .../java/campus/tech/kakao/map/MapActivity.kt | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index d21003e4..b01938f9 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -14,6 +14,12 @@ class MainViewModel(application: Application): AndroidViewModel(application) { private val retrofitData = getInstance() val documentList: LiveData> get() = retrofitData.getDocuments() + private val initLatitude = 37.402005 + private val initLongitude = 127.108621 + + fun getInitLatitude() = initLatitude + fun getInitLongitude() = initLongitude + fun addWord(document: Document){ wordDbHelper.addWord(wordfromDocument(document)) } diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 5619ec96..ee31209f 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -30,8 +30,7 @@ class MapActivity : AppCompatActivity() { private lateinit var mapView: MapView private var map: KakaoMap? = null private lateinit var searchBar: LinearLayout - private var latitude = 37.402005 - private var longitude = 127.108621 + private lateinit var model: MainViewModel private lateinit var placeName:String private lateinit var addressName:String private var styles: LabelStyles? = null @@ -44,6 +43,8 @@ class MapActivity : AppCompatActivity() { private lateinit var bottomSheet :LinearLayout private lateinit var bottomSheetName:TextView private lateinit var bottomSheetAddress :TextView + private var longitude:Double = 0.0 + private var latitude:Double = 0.0 companion object{ var documentClicked = false } @@ -52,7 +53,8 @@ class MapActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) mapView = findViewById(R.id.map_view) - setMapInfo() + model = MainViewModel(application) + getMapInfo() mapView.start(object : MapLifeCycleCallback() { override fun onMapDestroy() { @@ -87,7 +89,7 @@ class MapActivity : AppCompatActivity() { override fun onResume() { super.onResume() - setMapInfo() + getMapInfo() mapView.resume() if(documentClicked){ makeMarker() @@ -107,9 +109,9 @@ class MapActivity : AppCompatActivity() { mapView.pause() } - private fun setMapInfo(){ - latitude = mapPosition.getPreferences("latitude","37.406960").toDouble() - longitude = mapPosition.getPreferences("longitude","127.110030").toDouble() + private fun getMapInfo(){ + latitude = mapPosition.getPreferences("latitude",model.getInitLatitude().toString()).toDouble() + longitude = mapPosition.getPreferences("longitude",model.getInitLongitude().toString()).toDouble() placeName = mapPosition.getPreferences("placeName","") addressName = mapPosition.getPreferences("addressName","") } From 668d1001d105820f050b5780790db1c179cf682f Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 22:49:29 +0900 Subject: [PATCH 12/29] =?UTF-8?q?Refactor[MainViewModel]:=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20getMapInfo=20=ED=95=A8=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/MainViewModel.kt | 12 ++++++++++-- .../main/java/campus/tech/kakao/map/MapActivity.kt | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index b01938f9..c9f3988f 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -14,8 +14,8 @@ class MainViewModel(application: Application): AndroidViewModel(application) { private val retrofitData = getInstance() val documentList: LiveData> get() = retrofitData.getDocuments() - private val initLatitude = 37.402005 - private val initLongitude = 127.108621 + private val initLatitude = "37.402005" + private val initLongitude = "127.108621" fun getInitLatitude() = initLatitude fun getInitLongitude() = initLongitude @@ -47,4 +47,12 @@ class MainViewModel(application: Application): AndroidViewModel(application) { fun setMapInfo(document: Document){ mapPosition.setMapInfo(document) } + + fun getMapInfo():List{ + val latitude = mapPosition.getPreferences("latitude",initLatitude) + val longitude = mapPosition.getPreferences("longitude",initLongitude) + val placeName = mapPosition.getPreferences("placeName","") + val addressName = mapPosition.getPreferences("addressName","") + return listOf(latitude, longitude, placeName, addressName) + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index ee31209f..24c69443 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -10,7 +10,6 @@ import android.view.View import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity -import campus.tech.kakao.map.MyApplication.Companion.mapPosition import com.google.android.material.bottomsheet.BottomSheetBehavior import com.kakao.vectormap.KakaoMap import com.kakao.vectormap.KakaoMapReadyCallback @@ -110,10 +109,11 @@ class MapActivity : AppCompatActivity() { } private fun getMapInfo(){ - latitude = mapPosition.getPreferences("latitude",model.getInitLatitude().toString()).toDouble() - longitude = mapPosition.getPreferences("longitude",model.getInitLongitude().toString()).toDouble() - placeName = mapPosition.getPreferences("placeName","") - addressName = mapPosition.getPreferences("addressName","") + val mapInfoList = model.getMapInfo() + latitude = mapInfoList[0].toDouble() + longitude = mapInfoList[1].toDouble() + placeName = mapInfoList[2] + addressName = mapInfoList[3] } private fun makeMarker(){ From b7891d43236bbae875a3c196c67a05b06698dec1 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 23:19:26 +0900 Subject: [PATCH 13/29] =?UTF-8?q?Refactor[MapActivity]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=A9=A4=EB=B2=84=EB=B3=80=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/MapActivity.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 24c69443..4bf188d1 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -32,12 +32,8 @@ class MapActivity : AppCompatActivity() { private lateinit var model: MainViewModel private lateinit var placeName:String private lateinit var addressName:String - private var styles: LabelStyles? = null - private lateinit var options:LabelOptions private var layer: LabelLayer? = null private var label: Label? = null - private lateinit var bitmapImage: Bitmap - private lateinit var markerImage: Bitmap private lateinit var bottomSheetBehavior: BottomSheetBehavior private lateinit var bottomSheet :LinearLayout private lateinit var bottomSheetName:TextView @@ -117,11 +113,11 @@ class MapActivity : AppCompatActivity() { } private fun makeMarker(){ - bitmapImage = BitmapFactory.decodeResource(resources, R.drawable.marker) - markerImage = Bitmap.createScaledBitmap(bitmapImage, 100, 100, true) - styles = map?.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(markerImage).setTextStyles(40, Color.BLACK))) + val bitmapImage = BitmapFactory.decodeResource(resources, R.drawable.marker) + val markerImage = Bitmap.createScaledBitmap(bitmapImage, 100, 100, true) + val styles = map?.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(markerImage).setTextStyles(40, Color.BLACK))) if(styles != null){ - options = LabelOptions.from(LatLng.from(latitude, longitude)).setStyles(styles).setTexts(placeName) + val options = LabelOptions.from(LatLng.from(latitude, longitude)).setStyles(styles).setTexts(placeName) layer = map?.labelManager?.layer if(label != null){ layer?.remove(label) From f224649e6886e860b7c7385afef1d7991d9433f6 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 23:20:32 +0900 Subject: [PATCH 14/29] =?UTF-8?q?Refactor[MainViewModel]:=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20initLatitude,=20initLongitude=20getter=20=ED=95=A8?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/MainViewModel.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index c9f3988f..8bdf5240 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -17,8 +17,6 @@ class MainViewModel(application: Application): AndroidViewModel(application) { private val initLatitude = "37.402005" private val initLongitude = "127.108621" - fun getInitLatitude() = initLatitude - fun getInitLongitude() = initLongitude fun addWord(document: Document){ wordDbHelper.addWord(wordfromDocument(document)) From cd1e93e540d083dea0baf76e360abe029ae692c5 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sat, 20 Jul 2024 23:44:50 +0900 Subject: [PATCH 15/29] =?UTF-8?q?Refactor[MapActivity]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20Initial=20Value=EB=93=A4=20=EC=83=81=EC=88=98?= =?UTF-8?q?=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/MapActivity.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 4bf188d1..0e0ccd2f 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -25,6 +25,10 @@ import com.kakao.vectormap.label.LabelStyle import com.kakao.vectormap.label.LabelStyles import java.lang.Exception +const val MARKER_WIDTH = 100 +const val MARKER_HEIGHT = 100 +const val MARKER_TEXT_SIZE = 40 +const val ZOOM_LEVEL = 17 class MapActivity : AppCompatActivity() { private lateinit var mapView: MapView private var map: KakaoMap? = null @@ -71,7 +75,7 @@ class MapActivity : AppCompatActivity() { } override fun getZoomLevel(): Int { - return 17 + return ZOOM_LEVEL } }) searchBar = findViewById(R.id.search_bar) @@ -114,8 +118,9 @@ class MapActivity : AppCompatActivity() { private fun makeMarker(){ val bitmapImage = BitmapFactory.decodeResource(resources, R.drawable.marker) - val markerImage = Bitmap.createScaledBitmap(bitmapImage, 100, 100, true) - val styles = map?.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(markerImage).setTextStyles(40, Color.BLACK))) + val markerImage = Bitmap.createScaledBitmap(bitmapImage, MARKER_WIDTH, MARKER_HEIGHT, true) + val styles = map?.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(markerImage).setTextStyles( + MARKER_TEXT_SIZE, Color.BLACK))) if(styles != null){ val options = LabelOptions.from(LatLng.from(latitude, longitude)).setStyles(styles).setTexts(placeName) layer = map?.labelManager?.layer From 988f859faec01da829a5ade5bc891bee3f586274 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sun, 21 Jul 2024 14:00:55 +0900 Subject: [PATCH 16/29] =?UTF-8?q?Refactor[MapActivity]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20ViewModel=20=EB=A7=B4=EC=95=A1=ED=8B=B0=EB=B9=84?= =?UTF-8?q?=ED=8B=B0=EB=A5=BC=20=EC=98=A4=EB=84=88=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/MapActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 0e0ccd2f..02a948f9 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -10,6 +10,7 @@ import android.view.View import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import androidx.lifecycle.ViewModelProvider import com.google.android.material.bottomsheet.BottomSheetBehavior import com.kakao.vectormap.KakaoMap import com.kakao.vectormap.KakaoMapReadyCallback @@ -52,7 +53,7 @@ class MapActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) mapView = findViewById(R.id.map_view) - model = MainViewModel(application) + model = ViewModelProvider(this)[MainViewModel::class.java] getMapInfo() mapView.start(object : MapLifeCycleCallback() { override fun onMapDestroy() { From 244c9fdd6ef3f0dfff4fd28ba41aba969a956ad7 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sun, 21 Jul 2024 19:19:50 +0900 Subject: [PATCH 17/29] =?UTF-8?q?Refactor[MapActivity]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20KakaoMap=20=EB=82=B4=EC=97=90=20=EC=9E=88=EB=8A=94?= =?UTF-8?q?=20=EB=A9=A4=EB=B2=84=20=EB=B3=80=EC=88=98=EB=93=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/MapActivity.kt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index 02a948f9..cd326c85 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -19,8 +19,6 @@ import com.kakao.vectormap.MapLifeCycleCallback import com.kakao.vectormap.MapView import com.kakao.vectormap.camera.CameraUpdate import com.kakao.vectormap.camera.CameraUpdateFactory -import com.kakao.vectormap.label.Label -import com.kakao.vectormap.label.LabelLayer import com.kakao.vectormap.label.LabelOptions import com.kakao.vectormap.label.LabelStyle import com.kakao.vectormap.label.LabelStyles @@ -37,8 +35,6 @@ class MapActivity : AppCompatActivity() { private lateinit var model: MainViewModel private lateinit var placeName:String private lateinit var addressName:String - private var layer: LabelLayer? = null - private var label: Label? = null private lateinit var bottomSheetBehavior: BottomSheetBehavior private lateinit var bottomSheet :LinearLayout private lateinit var bottomSheetName:TextView @@ -97,7 +93,7 @@ class MapActivity : AppCompatActivity() { documentClicked = false } else{ - layer?.remove(label) + map?.labelManager?.layer?.removeAll() bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN } val cameraUpdate: CameraUpdate = CameraUpdateFactory.newCenterPosition(LatLng.from(latitude, longitude)) @@ -124,11 +120,8 @@ class MapActivity : AppCompatActivity() { MARKER_TEXT_SIZE, Color.BLACK))) if(styles != null){ val options = LabelOptions.from(LatLng.from(latitude, longitude)).setStyles(styles).setTexts(placeName) - layer = map?.labelManager?.layer - if(label != null){ - layer?.remove(label) - } - label = layer?.addLabel(options) + map?.labelManager?.layer?.removeAll() + map?.labelManager?.layer?.addLabel(options) } else{ Log.e("MapActivity", "makeMarker: styles is null") From 505088c866d67a16e9acb0bc1752b1224f8d6d1f Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sun, 21 Jul 2024 19:55:09 +0900 Subject: [PATCH 18/29] =?UTF-8?q?Refactor[MyApplication]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20mapPosition=20=EC=8B=B1=EA=B8=80=ED=86=A4=20?= =?UTF-8?q?=ED=8C=A8=ED=84=B4=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/MyApplication.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index 2be60dfd..fa362df0 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -6,11 +6,16 @@ import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { override fun onCreate() { super.onCreate() - mapPosition = MapPositionPreferences(this) KakaoMapSdk.init(this, BuildConfig.KAKAO_API_KEY) } - companion object{ - lateinit var mapPosition : MapPositionPreferences + companion object { + val mapPosition: MapPositionPreferences by lazy { + MapPositionPreferences(getInstance()) + } + + private fun getInstance(): MyApplication { + return this as MyApplication + } } } \ No newline at end of file From 66d2aac3ee1ecd07cb55ce964a80cc3cd3cc2f77 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Sun, 21 Jul 2024 23:07:18 +0900 Subject: [PATCH 19/29] =?UTF-8?q?Rename[]:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=ED=9B=84=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/MainViewModel.kt | 4 +++- app/src/main/java/campus/tech/kakao/map/MyApplication.kt | 1 + app/src/main/java/campus/tech/kakao/map/RetrofitService.kt | 1 + app/src/main/java/campus/tech/kakao/map/SearchActivity.kt | 2 ++ .../main/java/campus/tech/kakao/map/SearchWordDbHelper.kt | 4 +++- .../campus/tech/kakao/map/{ => adapter}/DocumentAdapter.kt | 4 +++- .../java/campus/tech/kakao/map/{ => adapter}/WordAdapter.kt | 4 +++- .../main/java/campus/tech/kakao/map/{ => dto}/Document.kt | 2 +- .../campus/tech/kakao/map/{ => dto}/MapPositionContract.kt | 2 +- .../tech/kakao/map/{ => dto}/MapPositionPreferences.kt | 2 +- app/src/main/java/campus/tech/kakao/map/{ => dto}/Meta.kt | 2 +- .../java/campus/tech/kakao/map/{ => dto}/PlaceResponse.kt | 2 +- .../java/campus/tech/kakao/map/{ => dto}/RetrofitData.kt | 5 +++-- .../main/java/campus/tech/kakao/map/{ => dto}/SameName.kt | 2 +- .../main/java/campus/tech/kakao/map/{ => dto}/SearchWord.kt | 2 +- .../campus/tech/kakao/map/{ => dto}/SearchWordContract.kt | 2 +- .../main/java/campus/tech/kakao/map/{ => dto}/UrlContract.kt | 2 +- 17 files changed, 28 insertions(+), 15 deletions(-) rename app/src/main/java/campus/tech/kakao/map/{ => adapter}/DocumentAdapter.kt (93%) rename app/src/main/java/campus/tech/kakao/map/{ => adapter}/WordAdapter.kt (93%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/Document.kt (94%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/MapPositionContract.kt (89%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/MapPositionPreferences.kt (95%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/Meta.kt (89%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/PlaceResponse.kt (69%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/RetrofitData.kt (91%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/SameName.kt (75%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/SearchWord.kt (70%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/SearchWordContract.kt (87%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/UrlContract.kt (85%) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index 8bdf5240..a03838a7 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -4,7 +4,9 @@ import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData import campus.tech.kakao.map.MyApplication.Companion.mapPosition -import campus.tech.kakao.map.RetrofitData.Companion.getInstance +import campus.tech.kakao.map.dto.RetrofitData.Companion.getInstance +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.SearchWord class MainViewModel(application: Application): AndroidViewModel(application) { diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index fa362df0..b5991688 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -1,6 +1,7 @@ package campus.tech.kakao.map import android.app.Application +import campus.tech.kakao.map.dto.MapPositionPreferences import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt index 97f1af21..d2101f00 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt +++ b/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt @@ -1,5 +1,6 @@ package campus.tech.kakao.map +import campus.tech.kakao.map.dto.PlaceResponse import retrofit2.Call import retrofit2.http.GET import retrofit2.http.Header diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index e6647094..8733fa0d 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -10,6 +10,8 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.adapter.DocumentAdapter +import campus.tech.kakao.map.adapter.WordAdapter class SearchActivity : AppCompatActivity() { diff --git a/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt index 0763b1bf..0ed2add3 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt @@ -6,7 +6,9 @@ import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.SearchWordContract.DB_VERSION +import campus.tech.kakao.map.dto.SearchWordContract.DB_VERSION +import campus.tech.kakao.map.dto.SearchWord +import campus.tech.kakao.map.dto.SearchWordContract class SearchWordDbHelper(context: Context): SQLiteOpenHelper( context, SearchWordContract.DB_NAME, null, DB_VERSION) { diff --git a/app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt similarity index 93% rename from app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index 69ed47d0..b141f6b9 100644 --- a/app/src/main/java/campus/tech/kakao/map/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.adapter import android.view.LayoutInflater import android.view.View @@ -7,7 +7,9 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.MapActivity.Companion.documentClicked +import campus.tech.kakao.map.R class DocumentAdapter( val addWord: (Document) -> Unit, diff --git a/app/src/main/java/campus/tech/kakao/map/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt similarity index 93% rename from app/src/main/java/campus/tech/kakao/map/WordAdapter.kt rename to app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index b3c5527f..7f9a30da 100644 --- a/app/src/main/java/campus/tech/kakao/map/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.adapter import android.view.LayoutInflater import android.view.View @@ -8,6 +8,8 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.R +import campus.tech.kakao.map.dto.SearchWord class WordAdapter( val deleteWord: (SearchWord) -> Unit, diff --git a/app/src/main/java/campus/tech/kakao/map/Document.kt b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt similarity index 94% rename from app/src/main/java/campus/tech/kakao/map/Document.kt rename to app/src/main/java/campus/tech/kakao/map/dto/Document.kt index aee28646..637f7059 100644 --- a/app/src/main/java/campus/tech/kakao/map/Document.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt similarity index 89% rename from app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt rename to app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt index d49c76ed..b0af0619 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapPositionContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto object MapPositionContract { const val PREFERENCE_NAME = "MapPosition" diff --git a/app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt similarity index 95% rename from app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt rename to app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt index 5932b1db..487ded95 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapPositionPreferences.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/MapPositionPreferences.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import android.content.Context diff --git a/app/src/main/java/campus/tech/kakao/map/Meta.kt b/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt similarity index 89% rename from app/src/main/java/campus/tech/kakao/map/Meta.kt rename to app/src/main/java/campus/tech/kakao/map/dto/Meta.kt index 6c35f5d3..60b41d75 100644 --- a/app/src/main/java/campus/tech/kakao/map/Meta.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/Meta.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import com.google.gson.annotations.SerializedName diff --git a/app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt b/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt similarity index 69% rename from app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt rename to app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt index d1c025a6..3abf2475 100644 --- a/app/src/main/java/campus/tech/kakao/map/PlaceResponse.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/PlaceResponse.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto data class PlaceResponse( val meta: Meta, diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt b/app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt similarity index 91% rename from app/src/main/java/campus/tech/kakao/map/RetrofitData.kt rename to app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt index 925e32a5..c7166970 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitData.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt @@ -1,7 +1,8 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.UrlContract.AUTHORIZATION +import campus.tech.kakao.map.RetrofitService +import campus.tech.kakao.map.dto.UrlContract.AUTHORIZATION import retrofit2.Call import retrofit2.Callback import retrofit2.Response diff --git a/app/src/main/java/campus/tech/kakao/map/SameName.kt b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt similarity index 75% rename from app/src/main/java/campus/tech/kakao/map/SameName.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SameName.kt index 54a9146d..833cddfe 100644 --- a/app/src/main/java/campus/tech/kakao/map/SameName.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto data class SameName( val region: List, diff --git a/app/src/main/java/campus/tech/kakao/map/SearchWord.kt b/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt similarity index 70% rename from app/src/main/java/campus/tech/kakao/map/SearchWord.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt index 980b1625..8ee333ed 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchWord.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SearchWord.kt @@ -1,3 +1,3 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto data class SearchWord(val name: String, val address: String, val type: String) diff --git a/app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt similarity index 87% rename from app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt index 9e28ec13..2acdb952 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchWordContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto object SearchWordContract { const val DB_NAME = "search_word.db" diff --git a/app/src/main/java/campus/tech/kakao/map/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt similarity index 85% rename from app/src/main/java/campus/tech/kakao/map/UrlContract.kt rename to app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt index af2524c7..2d46eb85 100644 --- a/app/src/main/java/campus/tech/kakao/map/UrlContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import campus.tech.kakao.map.BuildConfig From 5949ab815c606fe5a3373dc8066b9c105b83708f Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 13:53:57 +0900 Subject: [PATCH 20/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20mapPos?= =?UTF-8?q?ition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/MainViewModel.kt | 12 ++++++------ .../java/campus/tech/kakao/map/MapPosition.kt | 15 +++++++++++++++ .../java/campus/tech/kakao/map/MyApplication.kt | 10 +--------- 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/campus/tech/kakao/map/MapPosition.kt diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index a03838a7..fd0cf6da 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -3,7 +3,7 @@ package campus.tech.kakao.map import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData -import campus.tech.kakao.map.MyApplication.Companion.mapPosition +import campus.tech.kakao.map.MapPosition.getMapPosition import campus.tech.kakao.map.dto.RetrofitData.Companion.getInstance import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.dto.SearchWord @@ -45,14 +45,14 @@ class MainViewModel(application: Application): AndroidViewModel(application) { } fun setMapInfo(document: Document){ - mapPosition.setMapInfo(document) + getMapPosition(getApplication()).setMapInfo(document) } fun getMapInfo():List{ - val latitude = mapPosition.getPreferences("latitude",initLatitude) - val longitude = mapPosition.getPreferences("longitude",initLongitude) - val placeName = mapPosition.getPreferences("placeName","") - val addressName = mapPosition.getPreferences("addressName","") + val latitude = getMapPosition(getApplication()).getPreferences("latitude",initLatitude) + val longitude = getMapPosition(getApplication()).getPreferences("longitude",initLongitude) + val placeName = getMapPosition(getApplication()).getPreferences("placeName","") + val addressName = getMapPosition(getApplication()).getPreferences("addressName","") return listOf(latitude, longitude, placeName, addressName) } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MapPosition.kt b/app/src/main/java/campus/tech/kakao/map/MapPosition.kt new file mode 100644 index 00000000..0f1f60fa --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/MapPosition.kt @@ -0,0 +1,15 @@ +package campus.tech.kakao.map + +import android.content.Context +import campus.tech.kakao.map.dto.MapPositionPreferences + +object MapPosition { + private var mapPosition: MapPositionPreferences? = null + + fun getMapPosition(context: Context): MapPositionPreferences { + if (mapPosition == null) { + mapPosition = MapPositionPreferences(context) + } + return mapPosition!! + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index b5991688..dbdd63f9 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -7,16 +7,8 @@ import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { override fun onCreate() { super.onCreate() + MapPosition.getMapPosition(this) KakaoMapSdk.init(this, BuildConfig.KAKAO_API_KEY) } - companion object { - val mapPosition: MapPositionPreferences by lazy { - MapPositionPreferences(getInstance()) - } - - private fun getInstance(): MyApplication { - return this as MyApplication - } - } } \ No newline at end of file From 6049de64818fc5a825c4abe954c5d9d636811ede Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 13:54:11 +0900 Subject: [PATCH 21/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20mapPos?= =?UTF-8?q?ition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/MyApplication.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index dbdd63f9..595063b7 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -1,7 +1,6 @@ package campus.tech.kakao.map import android.app.Application -import campus.tech.kakao.map.dto.MapPositionPreferences import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { From 3ad3f787c4faa3c828179032618224471f1b64a8 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 14:13:41 +0900 Subject: [PATCH 22/29] =?UTF-8?q?Refactor[]:=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EC=BD=9C=EB=B0=B1=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/tech/kakao/map/AdapterCallback.kt | 11 ++++++ .../campus/tech/kakao/map/SearchActivity.kt | 36 +++++++++++-------- .../tech/kakao/map/adapter/DocumentAdapter.kt | 8 ++--- .../tech/kakao/map/adapter/WordAdapter.kt | 8 ++--- 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt diff --git a/app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt b/app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt new file mode 100644 index 00000000..d9d92db5 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt @@ -0,0 +1,11 @@ +package campus.tech.kakao.map + +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.SearchWord + +interface AdapterCallback { + fun onWordAdded(document: Document) + fun onDocumentInfoSet(document: Document) + fun onWordDeleted(searchWord: SearchWord) + fun onWordSearched(searchWord: SearchWord) +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index 8733fa0d..52d77ea5 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -12,8 +12,10 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import campus.tech.kakao.map.adapter.DocumentAdapter import campus.tech.kakao.map.adapter.WordAdapter +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.SearchWord -class SearchActivity : AppCompatActivity() { +class SearchActivity : AppCompatActivity(), AdapterCallback { private lateinit var model: MainViewModel private lateinit var search:EditText @@ -29,19 +31,8 @@ class SearchActivity : AppCompatActivity() { setupUI() searchResult.layoutManager = LinearLayoutManager(this) searchWordResult.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) - documentAdapter = DocumentAdapter({ document -> - model.addWord(document) - },{document -> - model.setMapInfo(document) - finish() - }) - wordAdapter = WordAdapter( - { searchWord -> - model.deleteWord(searchWord) - },{ searchWord -> - model.searchLocalAPI(searchWord.name) - } - ) + documentAdapter = DocumentAdapter(this) + wordAdapter = WordAdapter(this) search.doOnTextChanged { text, _, _, _ -> val query = text.toString() if (query.isEmpty()){ @@ -89,5 +80,22 @@ class SearchActivity : AppCompatActivity() { } } + override fun onWordAdded(document: Document) { + model.addWord(document) + } + + override fun onDocumentInfoSet(document: Document) { + model.setMapInfo(document) + finish() + } + + override fun onWordDeleted(searchWord: SearchWord) { + model.deleteWord(searchWord) + } + + override fun onWordSearched(searchWord: SearchWord) { + model.searchLocalAPI(searchWord.name) + } + } diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index b141f6b9..831b9885 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -7,13 +7,13 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.AdapterCallback import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.MapActivity.Companion.documentClicked import campus.tech.kakao.map.R class DocumentAdapter( - val addWord: (Document) -> Unit, - val sendDocumentInfo: (Document) -> Unit + private val callback: AdapterCallback ): ListAdapter( object : DiffUtil.ItemCallback(){ override fun areItemsTheSame(oldItem: Document, newItem: Document): Boolean { @@ -28,8 +28,8 @@ class DocumentAdapter( ) { private var placeClicked = { position:Int -> val document: Document = getItem(position) - addWord(document) - sendDocumentInfo(document) + callback.onWordAdded(document) + callback.onDocumentInfoSet(document) documentClicked = true } inner class ViewHolder( diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index 7f9a30da..4a2e02df 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -8,12 +8,12 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.AdapterCallback import campus.tech.kakao.map.R import campus.tech.kakao.map.dto.SearchWord class WordAdapter( - val deleteWord: (SearchWord) -> Unit, - val clickWord: (SearchWord) -> Unit + private val callback: AdapterCallback ): ListAdapter( object : DiffUtil.ItemCallback(){ override fun areItemsTheSame(oldItem: SearchWord, newItem: SearchWord): Boolean { @@ -52,12 +52,12 @@ class WordAdapter( private val deletedWords = { position:Int -> val word = getItem(position) - deleteWord(word) + callback.onWordDeleted(word) } private val clickedWord = { position:Int -> val word = getItem(position) - clickWord(word) + callback.onWordSearched(word) } } \ No newline at end of file From 556aef4d8d9a782d8fc64ae38a3eba5af8fbcd52 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 14:29:54 +0900 Subject: [PATCH 23/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20var?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index 831b9885..471adb5b 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -26,7 +26,7 @@ class DocumentAdapter( } ) { - private var placeClicked = { position:Int -> + private val placeClicked = { position:Int -> val document: Document = getItem(position) callback.onWordAdded(document) callback.onDocumentInfoSet(document) From 82b07ff9c69b8fb1711a543d7db17a0d06d9b0a7 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 14:43:38 +0900 Subject: [PATCH 24/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=9E=8C=EB=8B=A4=20=ED=98=95=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/campus/tech/kakao/map/adapter/DocumentAdapter.kt | 2 +- .../main/java/campus/tech/kakao/map/adapter/WordAdapter.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index 471adb5b..e2563d94 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -26,7 +26,7 @@ class DocumentAdapter( } ) { - private val placeClicked = { position:Int -> + private fun placeClicked(position:Int){ val document: Document = getItem(position) callback.onWordAdded(document) callback.onDocumentInfoSet(document) diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index 4a2e02df..7ed03250 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -50,12 +50,12 @@ class WordAdapter( holder.searchWord.text = word.name } - private val deletedWords = { position:Int -> + private fun deletedWords(position:Int){ val word = getItem(position) callback.onWordDeleted(word) } - private val clickedWord = { position:Int -> + private fun clickedWord(position:Int){ val word = getItem(position) callback.onWordSearched(word) } From 829170b2d07abf66038a8d202128625e63de40cc Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 14:45:15 +0900 Subject: [PATCH 25/29] =?UTF-8?q?Comment[]:=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/campus/tech/kakao/map/dto/Document.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/Document.kt b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt index 637f7059..7873ce81 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/Document.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/Document.kt @@ -2,23 +2,15 @@ package campus.tech.kakao.map.dto import com.google.gson.annotations.SerializedName -//필요 없는 데이터 주석화 data class Document( - //val id: String, @SerializedName("place_name") val placeName: String, - //val category_name: String, - //val category_group_code: String, @SerializedName("category_group_name") val categoryGroupName: String, - //val phone: String, @SerializedName("address_name") val addressName: String, - //val road_address_name: String, @SerializedName("x") val longitude : String, @SerializedName("y") - val latitude: String, - //val place_url: String, - //val distance: String, + val latitude: String ) From 21f5470f97d5a29581fd2d192dfdfbbab72e61e6 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 14:47:17 +0900 Subject: [PATCH 26/29] =?UTF-8?q?Refactor[SameName]:=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20selectedRegion=20=EC=9D=B4=EB=A6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/dto/SameName.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt index 833cddfe..457cb4fe 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SameName.kt @@ -1,7 +1,10 @@ package campus.tech.kakao.map.dto +import com.google.gson.annotations.SerializedName + data class SameName( val region: List, val keyword: String, - val selected_region: String + @SerializedName("selected_region") + val selectedRegion: String ) From 17e03c33ef3d41b1220b2d6f0d2f914f076c598a Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 18:49:48 +0900 Subject: [PATCH 27/29] =?UTF-8?q?Rename[]:=20=EC=83=9D=EC=84=B1=20url=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/campus/tech/kakao/map/MainViewModel.kt | 5 +++-- app/src/main/java/campus/tech/kakao/map/MyApplication.kt | 1 + app/src/main/java/campus/tech/kakao/map/SearchActivity.kt | 1 + .../campus/tech/kakao/map/{ => adapter}/AdapterCallback.kt | 2 +- .../java/campus/tech/kakao/map/adapter/DocumentAdapter.kt | 1 - .../main/java/campus/tech/kakao/map/adapter/WordAdapter.kt | 1 - .../java/campus/tech/kakao/map/{ => dto}/MapPosition.kt | 3 +-- .../campus/tech/kakao/map/{ => dto}/SearchWordDbHelper.kt | 4 +--- .../campus/tech/kakao/map/{dto => url}/RetrofitData.kt | 7 ++++--- .../campus/tech/kakao/map/{ => url}/RetrofitService.kt | 2 +- .../java/campus/tech/kakao/map/{dto => url}/UrlContract.kt | 2 +- 11 files changed, 14 insertions(+), 15 deletions(-) rename app/src/main/java/campus/tech/kakao/map/{ => adapter}/AdapterCallback.kt (88%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/MapPosition.kt (76%) rename app/src/main/java/campus/tech/kakao/map/{ => dto}/SearchWordDbHelper.kt (96%) rename app/src/main/java/campus/tech/kakao/map/{dto => url}/RetrofitData.kt (88%) rename app/src/main/java/campus/tech/kakao/map/{ => url}/RetrofitService.kt (90%) rename app/src/main/java/campus/tech/kakao/map/{dto => url}/UrlContract.kt (85%) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index fd0cf6da..fe317490 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -3,10 +3,11 @@ package campus.tech.kakao.map import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData -import campus.tech.kakao.map.MapPosition.getMapPosition -import campus.tech.kakao.map.dto.RetrofitData.Companion.getInstance +import campus.tech.kakao.map.dto.MapPosition.getMapPosition +import campus.tech.kakao.map.url.RetrofitData.Companion.getInstance import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.dto.SearchWord +import campus.tech.kakao.map.dto.SearchWordDbHelper class MainViewModel(application: Application): AndroidViewModel(application) { diff --git a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt index 595063b7..54201a5b 100644 --- a/app/src/main/java/campus/tech/kakao/map/MyApplication.kt +++ b/app/src/main/java/campus/tech/kakao/map/MyApplication.kt @@ -1,6 +1,7 @@ package campus.tech.kakao.map import android.app.Application +import campus.tech.kakao.map.dto.MapPosition import com.kakao.vectormap.KakaoMapSdk class MyApplication : Application() { diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt index 52d77ea5..609e9c82 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -10,6 +10,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.adapter.AdapterCallback import campus.tech.kakao.map.adapter.DocumentAdapter import campus.tech.kakao.map.adapter.WordAdapter import campus.tech.kakao.map.dto.Document diff --git a/app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt b/app/src/main/java/campus/tech/kakao/map/adapter/AdapterCallback.kt similarity index 88% rename from app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt rename to app/src/main/java/campus/tech/kakao/map/adapter/AdapterCallback.kt index d9d92db5..18088d1a 100644 --- a/app/src/main/java/campus/tech/kakao/map/AdapterCallback.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/AdapterCallback.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.adapter import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.dto.SearchWord diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index e2563d94..f133c27a 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -7,7 +7,6 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.AdapterCallback import campus.tech.kakao.map.dto.Document import campus.tech.kakao.map.MapActivity.Companion.documentClicked import campus.tech.kakao.map.R diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt index 7ed03250..1584dd17 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/WordAdapter.kt @@ -8,7 +8,6 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import campus.tech.kakao.map.AdapterCallback import campus.tech.kakao.map.R import campus.tech.kakao.map.dto.SearchWord diff --git a/app/src/main/java/campus/tech/kakao/map/MapPosition.kt b/app/src/main/java/campus/tech/kakao/map/dto/MapPosition.kt similarity index 76% rename from app/src/main/java/campus/tech/kakao/map/MapPosition.kt rename to app/src/main/java/campus/tech/kakao/map/dto/MapPosition.kt index 0f1f60fa..1d63e21a 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapPosition.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/MapPosition.kt @@ -1,7 +1,6 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import android.content.Context -import campus.tech.kakao.map.dto.MapPositionPreferences object MapPosition { private var mapPosition: MapPositionPreferences? = null diff --git a/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordDbHelper.kt similarity index 96% rename from app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt rename to app/src/main/java/campus/tech/kakao/map/dto/SearchWordDbHelper.kt index 0ed2add3..a92efb21 100644 --- a/app/src/main/java/campus/tech/kakao/map/SearchWordDbHelper.kt +++ b/app/src/main/java/campus/tech/kakao/map/dto/SearchWordDbHelper.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.dto import android.content.ContentValues import android.content.Context @@ -7,8 +7,6 @@ import android.database.sqlite.SQLiteOpenHelper import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import campus.tech.kakao.map.dto.SearchWordContract.DB_VERSION -import campus.tech.kakao.map.dto.SearchWord -import campus.tech.kakao.map.dto.SearchWordContract class SearchWordDbHelper(context: Context): SQLiteOpenHelper( context, SearchWordContract.DB_NAME, null, DB_VERSION) { diff --git a/app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt b/app/src/main/java/campus/tech/kakao/map/url/RetrofitData.kt similarity index 88% rename from app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt rename to app/src/main/java/campus/tech/kakao/map/url/RetrofitData.kt index c7166970..3eddd6f5 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/RetrofitData.kt +++ b/app/src/main/java/campus/tech/kakao/map/url/RetrofitData.kt @@ -1,8 +1,9 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map.url import androidx.lifecycle.MutableLiveData -import campus.tech.kakao.map.RetrofitService -import campus.tech.kakao.map.dto.UrlContract.AUTHORIZATION +import campus.tech.kakao.map.dto.Document +import campus.tech.kakao.map.dto.PlaceResponse +import campus.tech.kakao.map.url.UrlContract.AUTHORIZATION import retrofit2.Call import retrofit2.Callback import retrofit2.Response diff --git a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt b/app/src/main/java/campus/tech/kakao/map/url/RetrofitService.kt similarity index 90% rename from app/src/main/java/campus/tech/kakao/map/RetrofitService.kt rename to app/src/main/java/campus/tech/kakao/map/url/RetrofitService.kt index d2101f00..c6a1765b 100644 --- a/app/src/main/java/campus/tech/kakao/map/RetrofitService.kt +++ b/app/src/main/java/campus/tech/kakao/map/url/RetrofitService.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map +package campus.tech.kakao.map.url import campus.tech.kakao.map.dto.PlaceResponse import retrofit2.Call diff --git a/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt b/app/src/main/java/campus/tech/kakao/map/url/UrlContract.kt similarity index 85% rename from app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt rename to app/src/main/java/campus/tech/kakao/map/url/UrlContract.kt index 2d46eb85..ca34affa 100644 --- a/app/src/main/java/campus/tech/kakao/map/dto/UrlContract.kt +++ b/app/src/main/java/campus/tech/kakao/map/url/UrlContract.kt @@ -1,4 +1,4 @@ -package campus.tech.kakao.map.dto +package campus.tech.kakao.map.url import campus.tech.kakao.map.BuildConfig From 1b75544638acb5de77405437aca7c09996db98aa Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 18:53:54 +0900 Subject: [PATCH 28/29] =?UTF-8?q?Refactor[]:=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=83=81=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/tech/kakao/map/MainViewModel.kt | 20 +++++++++++++------ .../java/campus/tech/kakao/map/MapActivity.kt | 9 +++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index fe317490..320b53ce 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -17,8 +17,7 @@ class MainViewModel(application: Application): AndroidViewModel(application) { private val retrofitData = getInstance() val documentList: LiveData> get() = retrofitData.getDocuments() - private val initLatitude = "37.402005" - private val initLongitude = "127.108621" + fun addWord(document: Document){ @@ -50,10 +49,19 @@ class MainViewModel(application: Application): AndroidViewModel(application) { } fun getMapInfo():List{ - val latitude = getMapPosition(getApplication()).getPreferences("latitude",initLatitude) - val longitude = getMapPosition(getApplication()).getPreferences("longitude",initLongitude) - val placeName = getMapPosition(getApplication()).getPreferences("placeName","") - val addressName = getMapPosition(getApplication()).getPreferences("addressName","") + val latitude = getMapPosition(getApplication()).getPreferences(LATITUDE,INIT_LATITUDE) + val longitude = getMapPosition(getApplication()).getPreferences(LONGITUDE,INIT_LONGITUDE) + val placeName = getMapPosition(getApplication()).getPreferences(PLACE_NAME,"") + val addressName = getMapPosition(getApplication()).getPreferences(ADDRESS_NAME,"") return listOf(latitude, longitude, placeName, addressName) } + + companion object{ + const val INIT_LATITUDE = "37.402005" + const val INIT_LONGITUDE = "127.108621" + const val LATITUDE = "latitude" + const val LONGITUDE = "longitude" + const val PLACE_NAME = "placeName" + const val ADDRESS_NAME = "addressName" + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index cd326c85..ab002e85 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -24,10 +24,7 @@ import com.kakao.vectormap.label.LabelStyle import com.kakao.vectormap.label.LabelStyles import java.lang.Exception -const val MARKER_WIDTH = 100 -const val MARKER_HEIGHT = 100 -const val MARKER_TEXT_SIZE = 40 -const val ZOOM_LEVEL = 17 + class MapActivity : AppCompatActivity() { private lateinit var mapView: MapView private var map: KakaoMap? = null @@ -43,6 +40,10 @@ class MapActivity : AppCompatActivity() { private var latitude:Double = 0.0 companion object{ var documentClicked = false + const val MARKER_WIDTH = 100 + const val MARKER_HEIGHT = 100 + const val MARKER_TEXT_SIZE = 40 + const val ZOOM_LEVEL = 17 } override fun onCreate(savedInstanceState: Bundle?) { From da9269758ca69b770aee437adedad9d2e18883b0 Mon Sep 17 00:00:00 2001 From: jmc98 Date: Mon, 22 Jul 2024 19:59:12 +0900 Subject: [PATCH 29/29] =?UTF-8?q?Refactor[DocumentAdapter]:=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20placeClicked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campus/tech/kakao/map/MainViewModel.kt | 15 +++++++++++++ .../java/campus/tech/kakao/map/MapActivity.kt | 21 +++++++++++-------- .../tech/kakao/map/adapter/DocumentAdapter.kt | 8 +++---- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt index 320b53ce..b1658c30 100644 --- a/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/MainViewModel.kt @@ -3,6 +3,8 @@ package campus.tech.kakao.map import android.app.Application import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import campus.tech.kakao.map.adapter.AdapterCallback import campus.tech.kakao.map.dto.MapPosition.getMapPosition import campus.tech.kakao.map.url.RetrofitData.Companion.getInstance import campus.tech.kakao.map.dto.Document @@ -17,6 +19,9 @@ class MainViewModel(application: Application): AndroidViewModel(application) { private val retrofitData = getInstance() val documentList: LiveData> get() = retrofitData.getDocuments() + private val _documentClicked = MutableLiveData() + val documentClicked: LiveData get() = _documentClicked + @@ -56,6 +61,16 @@ class MainViewModel(application: Application): AndroidViewModel(application) { return listOf(latitude, longitude, placeName, addressName) } + fun placeClicked(document: Document, callback:AdapterCallback){ + callback.onWordAdded(document) + callback.onDocumentInfoSet(document) + _documentClicked.value = true + } + + fun documentClickedDone(){ + _documentClicked.value = false + } + companion object{ const val INIT_LATITUDE = "37.402005" const val INIT_LONGITUDE = "127.108621" diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt index ab002e85..a90b0a99 100644 --- a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -39,7 +39,6 @@ class MapActivity : AppCompatActivity() { private var longitude:Double = 0.0 private var latitude:Double = 0.0 companion object{ - var documentClicked = false const val MARKER_WIDTH = 100 const val MARKER_HEIGHT = 100 const val MARKER_TEXT_SIZE = 40 @@ -88,15 +87,18 @@ class MapActivity : AppCompatActivity() { super.onResume() getMapInfo() mapView.resume() - if(documentClicked){ - makeMarker() - setBottomSheet() - documentClicked = false - } - else{ - map?.labelManager?.layer?.removeAll() - bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN + model.documentClicked.observe(this){documentClicked-> + if(documentClicked){ + makeMarker() + setBottomSheet() + model.documentClickedDone() + } + else{ + map?.labelManager?.layer?.removeAll() + bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN + } } + val cameraUpdate: CameraUpdate = CameraUpdateFactory.newCenterPosition(LatLng.from(latitude, longitude)) map?.moveCamera(cameraUpdate) } @@ -112,6 +114,7 @@ class MapActivity : AppCompatActivity() { longitude = mapInfoList[1].toDouble() placeName = mapInfoList[2] addressName = mapInfoList[3] + model.documentClickedDone() } private fun makeMarker(){ diff --git a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt index f133c27a..a165cabb 100644 --- a/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/adapter/DocumentAdapter.kt @@ -7,8 +7,9 @@ import android.widget.TextView import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.MainViewModel import campus.tech.kakao.map.dto.Document -import campus.tech.kakao.map.MapActivity.Companion.documentClicked +import campus.tech.kakao.map.MyApplication import campus.tech.kakao.map.R class DocumentAdapter( @@ -27,9 +28,8 @@ class DocumentAdapter( ) { private fun placeClicked(position:Int){ val document: Document = getItem(position) - callback.onWordAdded(document) - callback.onDocumentInfoSet(document) - documentClicked = true + val viewModel = MainViewModel(MyApplication()) + viewModel.placeClicked(document, callback) } inner class ViewHolder( itemView: View