diff --git a/README.md b/README.md index df2a6477..82294c05 100644 --- a/README.md +++ b/README.md @@ -1 +1,41 @@ # android-map-keyword + +## ๐Ÿ“„ ํ”„๋กœ๊ทธ๋žจ ์„ค๋ช… + +์นด์นด์˜ค๋งต์˜ ํด๋ก  ์ฝ”๋”ฉ์„ ์œ„ํ•ด, ๊ฒ€์ƒ‰ ๋ ˆ์ด์•„์›ƒ์„ ์ œ์ž‘ํ•˜์˜€์Šต๋‹ˆ๋‹ค. + +์ด๋•Œ ๋‚ด๋ถ€ ์ €์žฅ์†Œ์ธ SQLite๋ฅผ ํ†ตํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ , ๊ธฐ๋ก์„ ์ €์žฅํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค. + +## ๐ŸŽฏ 1๋‹จ๊ณ„(๋กœ์ปฌ ๋ฐ์ดํ„ฐ) ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ + +- [X] ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ณ  ๋ณด์—ฌ์ฃผ๋Š” ๋ ˆ์ด์•„์›ƒ ์ œ์ž‘ + + - [X] ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅ ๋ฐ›๋Š” EditText ์ œ์ž‘ + + - [X] X ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ฒ€์ƒ‰์–ด๋ฅผ ์ดˆ๊ธฐํ™”ํ•  ์ˆ˜ ์žˆ๋„๋ก ImageButton ์ œ์ž‘ + + - [X] ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๋ ˆ์ด์•„์›ƒ ์ œ์ž‘ + + - [X] ์ด์ „์˜ ๊ฒ€์ƒ‰ ๊ธฐ๋ก์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋ ˆ์ด์•„์›ƒ ์ œ์ž‘ + +- [X] ๊ฒ€์ƒ‰์— ์‚ฌ์šฉ๋  ๋ฐ์ดํ„ฐ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ SQLite์— ์ €์žฅ + +## ๐ŸŽฏ 2๋‹จ๊ณ„(๊ฒ€์ƒ‰) ๊ตฌํ˜„ํ•  ๊ธฐ๋Šฅ + +- [X] X๋ฒ„ํŠผ ํด๋ฆญ ์‹œ, ์ž…๋ ฅ๋œ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ง€์šฐ๊ธฐ + +- [X] ๊ฒ€์ƒ‰์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋ฅผ ๋„์›Œ ์ฃผ๊ธฐ + + - [X] ์—…์ข…(`COLUMN_CATEGORY`)๊ณผ ์ผ์น˜ํ•œ ๊ฒฐ๊ณผ๋ฅผ DB์—์„œ ๋ฆฌ์ŠคํŠธ๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ + + - [X] ๊ฐ€์ ธ์˜จ ๋ฆฌ์ŠคํŠธ๋ฅผ RecyclerView์— ์ ์šฉํ•˜์—ฌ ๋ณด์—ฌ์ฃผ๊ธฐ + +- [X] ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ์ค‘ ํ•˜๋‚˜๋ฅผ ํด๋ฆญํ•˜๋Š” ๊ฒฝ์šฐ, ํ•ด๋‹น ์žฅ์†Œ๋ฅผ ๊ฒ€์ƒ‰ ๊ธฐ๋ก์— ์ถ”๊ฐ€ํ•˜๊ธฐ + + - [X] ๊ฒ€์ƒ‰ ๊ธฐ๋ก์„ ๋ณด์—ฌ์ฃผ๋Š” item์˜ ๋ ˆ์ด์•„์›ƒ ์ œ์ž‘ํ•˜๊ธฐ + + - [X] ์ด๋ฏธ DB์— ์กด์žฌํ•œ๋‹ค๋ฉด, ํ•ด๋‹น ๊ฐ’์„ ์ง€์šฐ๊ณ  ์ƒˆ๋กœ ์ €์žฅํ•ด์„œ ๋งจ ๋’ค๋กœ ๊ฐ€๋„๋ก ๊ตฌํ˜„ํ•˜๊ธฐ + + - [X] DB์— ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, ์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€ํ•˜๊ณ  ๋งจ ๋’ค์—์„œ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ + +- [X] ๊ฒ€์ƒ‰ ๊ธฐ๋ก์˜ X๋ฒ„ํŠผ ํด๋ฆญ ์‹œ, ํ•ด๋‹น ๊ฒ€์ƒ‰ ๊ธฐ๋ก์„ ์‚ญ์ œํ•˜๊ธฐ \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9932d6bb..06f1b539 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -47,6 +47,7 @@ dependencies { implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.recyclerview:recyclerview:1.3.2") implementation("androidx.datastore:datastore-preferences:1.0.0") + implementation("androidx.activity:activity:1.8.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6bca2f54..37c62043 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:theme="@style/Theme.Map" tools:targetApi="31"> @@ -23,4 +23,4 @@ - + \ No newline at end of file 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/model/HistoryContract.kt b/app/src/main/java/campus/tech/kakao/map/model/HistoryContract.kt new file mode 100644 index 00000000..1b309d26 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/HistoryContract.kt @@ -0,0 +1,8 @@ +package campus.tech.kakao.map.model + +import android.provider.BaseColumns + +object HistoryContract : BaseColumns { + const val TABLE_NAME = "HISTORY" + const val COLUMN_NAME = "name" +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/model/HistoryDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/model/HistoryDbHelper.kt new file mode 100644 index 00000000..c36f7f0e --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/HistoryDbHelper.kt @@ -0,0 +1,27 @@ +package campus.tech.kakao.map.model + +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteOpenHelper + +class HistoryDbHelper(context: Context) : + SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) { + + override fun onCreate(db: SQLiteDatabase?) { + db?.let { + val query = "CREATE TABLE ${HistoryContract.TABLE_NAME} (" + + "${HistoryContract.COLUMN_NAME} VARCHAR(50))" + it.execSQL(query) + } + } + + override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { + db?.execSQL("DROP TABLE IF EXISTS ${HistoryContract.TABLE_NAME}") + onCreate(db) + } + + companion object { + const val DATABASE_NAME = "history.db" + const val DATABASE_VERSION = 1 + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/model/Location.kt b/app/src/main/java/campus/tech/kakao/map/model/Location.kt new file mode 100644 index 00000000..21529b85 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/Location.kt @@ -0,0 +1,7 @@ +package campus.tech.kakao.map.model + +data class Location( + val name: String, + val address: String, + val category: String +) \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/model/LocationContract.kt b/app/src/main/java/campus/tech/kakao/map/model/LocationContract.kt new file mode 100644 index 00000000..12b27a59 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/LocationContract.kt @@ -0,0 +1,10 @@ +package campus.tech.kakao.map.model + +import android.provider.BaseColumns + +object LocationContract : BaseColumns { + const val TABLE_NAME = "LOCATION" + const val COLUMN_NAME = "name" + const val COLUMN_ADDRESS = "address" + const val COLUMN_CATEGORY = "category" +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/model/LocationDbHelper.kt b/app/src/main/java/campus/tech/kakao/map/model/LocationDbHelper.kt new file mode 100644 index 00000000..0d3cd4cd --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/LocationDbHelper.kt @@ -0,0 +1,51 @@ +package campus.tech.kakao.map.model + +import android.content.ContentValues +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteOpenHelper + +class LocationDbHelper(context: Context) : + SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) { + override fun onCreate(db: SQLiteDatabase?) { + db?.let { + val query = "CREATE TABLE ${LocationContract.TABLE_NAME} (" + + "${LocationContract.COLUMN_NAME} VARCHAR(50)," + + "${LocationContract.COLUMN_ADDRESS} VARCHAR(50)," + + "${LocationContract.COLUMN_CATEGORY} VARCHAR(20))" + it.execSQL(query) + + createLocationData(it) + } + } + + override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { + db?.execSQL("DROP TABLE IF EXISTS ${LocationContract.TABLE_NAME}") + onCreate(db) + } + + private fun createLocationData(db: SQLiteDatabase) { + // ์ž„์˜์˜ ์นดํŽ˜ ๋ฐ์ดํ„ฐ 15๊ฐœ ์ƒ์„ฑ + for (i in 1..15) { + val values = ContentValues() + values.put(LocationContract.COLUMN_NAME, "์นดํŽ˜$i") + values.put(LocationContract.COLUMN_ADDRESS, "์„œ์šธ ์„ฑ๋™๊ตฌ ์„ฑ์ˆ˜๋™ $i") + values.put(LocationContract.COLUMN_CATEGORY, "์นดํŽ˜") + db.insert(LocationContract.TABLE_NAME, null, values) + } + + // ์ž„์˜์˜ ์•ฝ๊ตญ ๋ฐ์ดํ„ฐ 15๊ฐœ ์ƒ์„ฑ + for (i in 1..15) { + val values = ContentValues() + values.put(LocationContract.COLUMN_NAME, "์•ฝ๊ตญ$i") + values.put(LocationContract.COLUMN_ADDRESS, "์„œ์šธ ๊ฐ•๋‚จ๊ตฌ ๋Œ€์น˜๋™ $i") + values.put(LocationContract.COLUMN_CATEGORY, "์•ฝ๊ตญ") + db.insert(LocationContract.TABLE_NAME, null, values) + } + } + + companion object { + const val DATABASE_NAME = "location.db" + const val DATABASE_VERSION = 1 + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/model/SearchLocationRepository.kt b/app/src/main/java/campus/tech/kakao/map/model/SearchLocationRepository.kt new file mode 100644 index 00000000..f9dc1b69 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/model/SearchLocationRepository.kt @@ -0,0 +1,80 @@ +package campus.tech.kakao.map.model + +import android.content.ContentValues +import android.content.Context + +class SearchLocationRepository(context: Context) { + private val locationDbHelper: LocationDbHelper = LocationDbHelper(context) + private val historyDbHelper: HistoryDbHelper = HistoryDbHelper(context) + + fun searchLocation(category: String): List { + val db = locationDbHelper.readableDatabase + val searchQuery = "SELECT * FROM ${LocationContract.TABLE_NAME} " + + "WHERE ${LocationContract.COLUMN_CATEGORY} = '$category'" + val cursor = db.rawQuery(searchQuery, null) + + val result = mutableListOf() + while (cursor.moveToNext()) { + result.add( + Location( + name = cursor.getString(cursor.getColumnIndexOrThrow(LocationContract.COLUMN_NAME)), + address = cursor.getString(cursor.getColumnIndexOrThrow(LocationContract.COLUMN_ADDRESS)), + category = cursor.getString(cursor.getColumnIndexOrThrow(LocationContract.COLUMN_CATEGORY)) + ) + ) + } + cursor.close() + db.close() + + return result.toList() + } + + fun addHistory(locationName: String) { + if (isExistHistory(locationName)) { + removeHistory(locationName) + } + + val db = historyDbHelper.writableDatabase + val historyValues = ContentValues() + historyValues.put(HistoryContract.COLUMN_NAME, locationName) + db.insert(HistoryContract.TABLE_NAME, null, historyValues) + + db.close() + } + + fun getHistory(): List { + val db = historyDbHelper.readableDatabase + val searchQuery = "SELECT * FROM ${HistoryContract.TABLE_NAME}" + val cursor = db.rawQuery(searchQuery, null) + + val result = mutableListOf() + while (cursor.moveToNext()) { + result.add(cursor.getString(cursor.getColumnIndexOrThrow(HistoryContract.COLUMN_NAME))) + } + + cursor.close() + db.close() + return result.toList() + } + + private fun isExistHistory(locationName: String): Boolean { + val db = historyDbHelper.readableDatabase + val searchQuery = "SELECT * FROM ${HistoryContract.TABLE_NAME} " + + "WHERE ${HistoryContract.COLUMN_NAME} = '$locationName'" + val cursor = db.rawQuery(searchQuery, null) + + val result = cursor.count > 0 + cursor.close() + db.close() + + return result + } + + fun removeHistory(locationName: String) { + val db = historyDbHelper.writableDatabase + val deleteQuery = "DELETE FROM ${HistoryContract.TABLE_NAME} " + + "WHERE ${HistoryContract.COLUMN_NAME} = '$locationName'" + db.execSQL(deleteQuery) + db.close() + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/view/HistoryAdapter.kt b/app/src/main/java/campus/tech/kakao/map/view/HistoryAdapter.kt new file mode 100644 index 00000000..721a08f5 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/view/HistoryAdapter.kt @@ -0,0 +1,52 @@ +package campus.tech.kakao.map.view + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.databinding.ItemHistoryBinding +import campus.tech.kakao.map.viewmodel.SearchLocationViewModel + +class HistoryAdapter( + private var dataList: List, + private val context: Context, + private val viewModel: SearchLocationViewModel +) : RecyclerView.Adapter() { + + inner class MyViewHolder(private val binding: ItemHistoryBinding) : + RecyclerView.ViewHolder(binding.root) { + init { + binding.removeLocationHistoryButton.setOnClickListener { + viewModel.removeHistory(dataList[bindingAdapterPosition]) + } + } + fun binding(historyData: String) { + binding.locationHistoryNameTextView.text = historyData + } + } + + fun updateDataList(newDataList: List) { + val diffUtil = HistoryDiffUtilCallback(dataList, newDataList) + val diffResult = DiffUtil.calculateDiff(diffUtil) + + dataList = newDataList + diffResult.dispatchUpdatesTo(this) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { + return MyViewHolder( + ItemHistoryBinding.inflate( + LayoutInflater.from(context), + parent, + false + ) + ) + } + + override fun onBindViewHolder(holder: MyViewHolder, position: Int) { + holder.binding(dataList[position]) + } + + override fun getItemCount(): Int = dataList.size +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/view/HistoryDiffUtilCallback.kt b/app/src/main/java/campus/tech/kakao/map/view/HistoryDiffUtilCallback.kt new file mode 100644 index 00000000..d70fd405 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/view/HistoryDiffUtilCallback.kt @@ -0,0 +1,18 @@ +package campus.tech.kakao.map.view + +import androidx.recyclerview.widget.DiffUtil + +class HistoryDiffUtilCallback( + private val oldList: List, + private val newList: List +) : DiffUtil.Callback() { + override fun getOldListSize(): Int = oldList.size + + override fun getNewListSize(): Int = newList.size + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition] == newList[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = + oldList[oldItemPosition] == newList[newItemPosition] +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/view/SearchLocationActivity.kt b/app/src/main/java/campus/tech/kakao/map/view/SearchLocationActivity.kt new file mode 100644 index 00000000..630b9956 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/view/SearchLocationActivity.kt @@ -0,0 +1,59 @@ +package campus.tech.kakao.map.view + +import android.os.Bundle +import android.text.Editable +import android.text.TextWatcher +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.isVisible +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.LinearLayoutManager +import campus.tech.kakao.map.databinding.ActivitySearchLocationBinding +import campus.tech.kakao.map.model.SearchLocationRepository +import campus.tech.kakao.map.viewmodel.SearchLocationViewModel + +class SearchLocationActivity : AppCompatActivity() { + private lateinit var viewModel: SearchLocationViewModel + private lateinit var binding: ActivitySearchLocationBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + viewModel = ViewModelProvider(this)[SearchLocationViewModel::class.java] + viewModel.setRepository(SearchLocationRepository(this)) + binding = ActivitySearchLocationBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.removeSearchInputButton.setOnClickListener { + binding.searchInputEditText.text.clear() + } + + binding.searchInputEditText.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} + override fun afterTextChanged(s: Editable?) { + viewModel.searchLocation(s.toString()) + } + }) + + viewModel.location.observe(this) { + it?.let { locationData -> + binding.searchResultRecyclerView.adapter = SearchLocationAdapter(locationData, this, viewModel) + binding.searchResultRecyclerView.layoutManager = LinearLayoutManager(this) + binding.emptyResultTextView.isVisible = locationData.isEmpty() + } + } + + viewModel.history.observe(this) { + it?.let { historyData -> + val adapter = binding.searchHistoryRecyclerView.adapter as? HistoryAdapter + + if (adapter == null) { + binding.searchHistoryRecyclerView.adapter = HistoryAdapter(historyData, this, viewModel) + } else { + adapter.updateDataList(historyData) + } + + binding.searchHistoryRecyclerView.isVisible = historyData.isNotEmpty() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/view/SearchLocationAdapter.kt b/app/src/main/java/campus/tech/kakao/map/view/SearchLocationAdapter.kt new file mode 100644 index 00000000..14c2928c --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/view/SearchLocationAdapter.kt @@ -0,0 +1,47 @@ +package campus.tech.kakao.map.view + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.databinding.ItemLocationBinding +import campus.tech.kakao.map.model.Location +import campus.tech.kakao.map.viewmodel.SearchLocationViewModel + +class SearchLocationAdapter( + private val dataList: List, + private val context: Context, + private val viewModel: SearchLocationViewModel +) : RecyclerView.Adapter() { + + inner class MyViewHolder(private val binding: ItemLocationBinding) : + RecyclerView.ViewHolder(binding.root) { + init { + binding.root.setOnClickListener { + viewModel.addHistory(dataList[bindingAdapterPosition].name) + } + } + + fun bind(locationData: Location) { + binding.locationNameTextView.text = locationData.name + binding.locationAddressTextView.text = locationData.address + binding.locationTypeTextView.text = locationData.category + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { + return MyViewHolder( + ItemLocationBinding.inflate( + LayoutInflater.from(context), + parent, + false + ) + ) + } + + override fun onBindViewHolder(holder: MyViewHolder, position: Int) { + holder.bind(dataList[position]) + } + + override fun getItemCount(): Int = dataList.size +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchLocationViewModel.kt b/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchLocationViewModel.kt new file mode 100644 index 00000000..a3080a5e --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchLocationViewModel.kt @@ -0,0 +1,35 @@ +package campus.tech.kakao.map.viewmodel + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import campus.tech.kakao.map.model.Location +import campus.tech.kakao.map.model.SearchLocationRepository + +class SearchLocationViewModel : ViewModel() { + private lateinit var repository: SearchLocationRepository + fun setRepository(repository: SearchLocationRepository) { + this.repository = repository + _history.value = repository.getHistory() + } + + private val _location = MutableLiveData>() + val location: LiveData> = _location + + private val _history = MutableLiveData>() + val history: LiveData> = _history + + fun searchLocation(category: String) { + _location.value = repository.searchLocation(category) + } + + fun addHistory(locationName: String) { + repository.addHistory(locationName) + _history.value = repository.getHistory() + } + + fun removeHistory(locationName: String) { + repository.removeHistory(locationName) + _history.value = repository.getHistory() + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/background_round.xml b/app/src/main/res/drawable/background_round.xml new file mode 100644 index 00000000..bf633b04 --- /dev/null +++ b/app/src/main/res/drawable/background_round.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/round_close_24.xml b/app/src/main/res/drawable/round_close_24.xml new file mode 100644 index 00000000..13608b6a --- /dev/null +++ b/app/src/main/res/drawable/round_close_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/round_place_24.xml b/app/src/main/res/drawable/round_place_24.xml new file mode 100644 index 00000000..eca274a7 --- /dev/null +++ b/app/src/main/res/drawable/round_place_24.xml @@ -0,0 +1,5 @@ + + + + + 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_search_location.xml b/app/src/main/res/layout/activity_search_location.xml new file mode 100644 index 00000000..2a4a86dd --- /dev/null +++ b/app/src/main/res/layout/activity_search_location.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_history.xml b/app/src/main/res/layout/item_history.xml new file mode 100644 index 00000000..1f2ed09e --- /dev/null +++ b/app/src/main/res/layout/item_history.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_location.xml b/app/src/main/res/layout/item_location.xml new file mode 100644 index 00000000..aa280dcb --- /dev/null +++ b/app/src/main/res/layout/item_location.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 768b058a..ab247e2f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,4 +2,6 @@ #FF000000 #FFFFFFFF + #FF9E9E9E + #74C99F diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e5ba5b9c..688e5e1f 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