Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

부산대 Android 김민혁 5주차 STEP1 #89

Open
wants to merge 72 commits into
base: kyleidea1
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
04c907f
Initial commit
MyStoryG Jun 15, 2024
8b097b3
Initial commit
MyStoryG Jun 15, 2024
9f4d9a7
docs: add project overview of STEP1 to README
kyleidea1 Jul 1, 2024
b2b33de
feat(view): Add activity_search.xml view for SearchView
kyleidea1 Jul 1, 2024
8eac791
feat(view): Add SearchMainActivity.kt
kyleidea1 Jul 1, 2024
a21a7c2
feat(view): Add DBHelper.kt which is local storage of places.
kyleidea1 Jul 2, 2024
f5e9623
feat: Added 9 data into Place.db
kyleidea1 Jul 2, 2024
b3a1339
docs: Modified README.md
kyleidea1 Jul 2, 2024
deb1a3c
feat: Create STEP1 branch and move existing work to it
kyleidea1 Jul 2, 2024
d3adda3
docs: Modified README.md for STEP2
kyleidea1 Jul 2, 2024
b959286
feat(db): add SearchHistoryDBHelper and initial place data
kyleidea1 Jul 5, 2024
a03fdc7
refactor(db): extract Place data class to separate file
kyleidea1 Jul 5, 2024
84ad89b
feat(ui): add SearchHistoryRecyclerViewAdapter for displaying search …
kyleidea1 Jul 5, 2024
496dd1d
fix(SearchActivity): Fix filtering logic to correctly filter search r…
kyleidea1 Jul 5, 2024
a62f21e
refactor: Split DBHelper into PlaceDBHelper and SearchHistoryDBHelper
kyleidea1 Jul 5, 2024
b043982
Refactor XML layout to fix visibility bug in SearchActivity
kyleidea1 Jul 5, 2024
7c26fd4
Add: Extracted Korean strings into string resources and updated decla…
kyleidea1 Jul 5, 2024
e404119
Add: Extracted Korean strings into string resources and updated decla…
kyleidea1 Jul 5, 2024
61d5adc
Refactor: Changed variable names to enhance consistency
kyleidea1 Jul 5, 2024
62e3846
docs: Modified README.md
kyleidea1 Jul 5, 2024
bbf77e9
Initial commit
MyStoryG Jul 7, 2024
9dd9533
Added missing files
kyleidea1 Jul 8, 2024
f62e568
chore(project): import code from android-map-keyword project
kyleidea1 Jul 9, 2024
811b9bc
docs: Added README.md of android-search-STEP1
kyleidea1 Jul 9, 2024
7499b1c
임시저장
kyleidea1 Jul 9, 2024
f898541
임시저장
kyleidea1 Jul 9, 2024
bb225cd
feat: Add Kakao Local API dependencies to Gradle files
kyleidea1 Jul 9, 2024
a5f25d9
feat(dto): Add DTO classes for Kakao API response
kyleidea1 Jul 10, 2024
cf5667f
feat(network): Implement KakaoLocalApi interface for API communication
kyleidea1 Jul 10, 2024
0d7f0e6
feat(repository): Create KakaoRepository for data retrieval from Kaka…
kyleidea1 Jul 10, 2024
81059af
feat: Added KyleMaps application class with Retrofit instance
kyleidea1 Jul 10, 2024
ec020cd
feat: added application icon image resources
kyleidea1 Jul 10, 2024
e4f5aa3
feat: added retrofit instance into KyleMaps.kt
kyleidea1 Jul 10, 2024
bebe6de
feat: remove activity_main_search
kyleidea1 Jul 12, 2024
e4839e6
remove: PlaceDBHelper.kt
kyleidea1 Jul 12, 2024
d7d4f93
feat: Added dto package and its elements
kyleidea1 Jul 12, 2024
70486ba
chore: added dependencies to use Kakao APIs
kyleidea1 Jul 12, 2024
a0be820
feat: Added KakaoRepository.kt
kyleidea1 Jul 12, 2024
cde3ac6
feat: Added KyleMaps.kt
kyleidea1 Jul 12, 2024
4f8a9f6
feat: Added drawable resources
kyleidea1 Jul 12, 2024
43a339a
feat: Added MapActivity and its layout
kyleidea1 Jul 12, 2024
2fb4d24
feat: Modified activity_search.xml and DBHelpers
kyleidea1 Jul 12, 2024
6b912fa
docs: updated README.md
kyleidea1 Jul 12, 2024
7bcbe37
commit before fixing bug
kyleidea1 Jul 16, 2024
a5a9a26
finished STEP0
kyleidea1 Jul 16, 2024
2c28c03
docs: updated README.md
kyleidea1 Jul 16, 2024
7260c3e
temporal save point
kyleidea1 Jul 17, 2024
0f1c076
feat: updated result recycler view's item click event
kyleidea1 Jul 17, 2024
b9ec7b4
부산대 Android_김민혁_4주차 과제_0단계 (#40)
kyleidea1 Jul 17, 2024
2a4502e
feat: added marker when selected an item of result recycler view
kyleidea1 Jul 17, 2024
f002a98
feat: implemented function that remembering last place's position whe…
kyleidea1 Jul 17, 2024
a30c46c
feat: added activity appears when error occurs
kyleidea1 Jul 18, 2024
807dc2d
feat: added bottom sheet dialog and its components
kyleidea1 Jul 18, 2024
34cf47c
style: get rid of paddings of bottomsheet layout
kyleidea1 Jul 18, 2024
4594193
Merge branch 'kyleidea1' into STEP1
kyleidea1 Jul 18, 2024
7c5707f
fix: fixed bug that MapActivities doesn't destory
kyleidea1 Jul 18, 2024
873df85
Merge remote-tracking branch 'origin/STEP1' into STEP1
kyleidea1 Jul 18, 2024
32ef74e
docs: updated README.md for android-location-STEP2
kyleidea1 Jul 18, 2024
2ded205
Feat: added UITest for MapActivity and SearchActivity
kyleidea1 Jul 19, 2024
68a947f
Feat: added UnitTest for MapActivity
kyleidea1 Jul 19, 2024
b06d783
modified trivial
kyleidea1 Jul 19, 2024
30e1b68
modified trivial
kyleidea1 Jul 19, 2024
15d1975
fix: fixed bug that Intent doesn't work
kyleidea1 Jul 22, 2024
dcf47d6
Merge remote-tracking branch 'location/STEP2'
kyleidea1 Jul 22, 2024
5e05b95
feat: finished STEP0
kyleidea1 Jul 22, 2024
92b279a
feat: added SearchHistory data class
kyleidea1 Jul 26, 2024
fcc536d
feat: added DataBase.kt and SearchHistoryDao.kt
kyleidea1 Jul 26, 2024
283d481
remove: Removed files supposed not to be used
kyleidea1 Jul 26, 2024
4da4f92
feat: Start to use Hilt
kyleidea1 Jul 26, 2024
847494d
feat: Added Appmodule.kt
kyleidea1 Jul 26, 2024
34d4b63
feat: Modified SearchHistoryRecyclerViewAdapter.kt
kyleidea1 Jul 26, 2024
ce24c63
docs: Updated README.md
kyleidea1 Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Start to use Hilt
- Applied annotation to KyleMaps and removed constructor part
- Injected dependencies into SearchActivity.kt instead
kyleidea1 committed Jul 26, 2024
commit 4da4f925ef5ab976945db12c60af1cd4e99678a6
16 changes: 4 additions & 12 deletions app/src/main/java/campus/tech/kakao/map/KyleMaps.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
package campus.tech.kakao.map

import android.app.Application
import campus.tech.kakao.map.repository.KakaoRepository
import campus.tech.kakao.map.db.AppModule
import campus.tech.kakao.map.db.DataBase
import com.kakao.vectormap.KakaoMapSdk
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class KyleMaps : Application() {

lateinit var kakaoRepository: KakaoRepository
// var isTestMode: Boolean = false

lateinit var database: DataBase
override fun onCreate() {
super.onCreate()
KakaoMapSdk.init(this, getString(R.string.kakao_api_key))
val retrofit = Retrofit.Builder()
.baseUrl("https://dapi.kakao.com")
.addConverterFactory(GsonConverterFactory.create())
.build()
kakaoRepository = KakaoRepository(retrofit)
database = AppModule.provideDatabase(this)
}
}


86 changes: 50 additions & 36 deletions app/src/main/java/campus/tech/kakao/map/SearchActivity.kt
Original file line number Diff line number Diff line change
@@ -10,20 +10,31 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.addTextChangedListener
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import campus.tech.kakao.map.db.AppModule
import campus.tech.kakao.map.db.DataBase
import campus.tech.kakao.map.db.SearchHistory
import campus.tech.kakao.map.db.SearchHistoryDao
import campus.tech.kakao.map.dto.Place
import campus.tech.kakao.map.repository.KakaoRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import retrofit2.Retrofit

class SearchActivity : AppCompatActivity() {

private val coroutineScope = CoroutineScope(Dispatchers.Main)
private lateinit var searchEditText: EditText
private lateinit var resultRecyclerView: RecyclerView
private lateinit var searchHistoryRecyclerView: RecyclerView
private lateinit var noResults: TextView
private lateinit var retrofit: Retrofit
private lateinit var kakaoRepository: KakaoRepository
private lateinit var database: DataBase
private lateinit var searchHistoryDao: SearchHistoryDao
private lateinit var resultRecyclerViewAdapter: ResultRecyclerViewAdapter
private lateinit var searchHistoryRecyclerViewAdapter: SearchHistoryRecyclerViewAdapter
private lateinit var placeList: List<Place>
private lateinit var searchHistoryList: MutableList<Place>
private lateinit var kakaoRepository: KakaoRepository
private lateinit var searchHistoryList: MutableList<SearchHistory>
private lateinit var backButton: ImageButton
private lateinit var mapX: String
private lateinit var mapY: String
@@ -41,43 +52,49 @@ class SearchActivity : AppCompatActivity() {
noResults = findViewById(R.id.no_results)
backButton = findViewById(R.id.back_button)

placeList = emptyList()
kakaoRepository = (application as KyleMaps).kakaoRepository
retrofit = AppModule.provideRetrofit()
database = (application as KyleMaps).database
searchHistoryDao = AppModule.provideSearchHistoryDao(database)
kakaoRepository = AppModule.provideKakaoRepository(retrofit)

coroutineScope.launch {
searchHistoryList = searchHistoryDao.getAllSearchHistory().toMutableList()
searchHistoryRecyclerViewAdapter = SearchHistoryRecyclerViewAdapter(
searchHistory = searchHistoryList,
onItemClick = { history ->
searchEditText.setText(history.placeName)
searchEditText.clearFocus()
searchEditText.isFocusable = false
},
onItemDelete = { history ->
coroutineScope.launch {
searchHistoryDao.deleteSearchHistoryById(history.id)
searchHistoryList.remove(history)
searchHistoryRecyclerViewAdapter.notifyDataSetChanged()
}
}
)

val searchHistoryDB = SearchHistoryDBHelper(this)
searchHistoryList = searchHistoryDB.getAllSearchHistory()
searchHistoryRecyclerView.adapter = searchHistoryRecyclerViewAdapter
searchHistoryRecyclerView.layoutManager = LinearLayoutManager(this@SearchActivity, LinearLayoutManager.HORIZONTAL, false)
}

resultRecyclerViewAdapter = ResultRecyclerViewAdapter(
places = emptyList(),
onItemClick = { place ->
searchHistoryDB.insertSearchHistory(place)
updateSearchHistoryRecyclerView(place)
updateMapPosition(place)
goBackToMap()
coroutineScope.launch {
val searchHistory = SearchHistory(placeName = place.place_name)
searchHistoryDao.insertSearchHistory(searchHistory)
updateSearchHistoryRecyclerView(searchHistory)
updateMapPosition(place)
goBackToMap()
}
}
)

resultRecyclerView.adapter = resultRecyclerViewAdapter
resultRecyclerView.layoutManager = LinearLayoutManager(this)

searchHistoryRecyclerViewAdapter = SearchHistoryRecyclerViewAdapter(
searchHistory = searchHistoryList,
onItemClick = { index ->
searchEditText.setText(searchHistoryList[index].place_name)
searchEditText.clearFocus()
searchEditText.isFocusable = false
},
onItemDelete = { index ->
if (index >= 0 && index < searchHistoryList.size) {
val deletedItemName = searchHistoryList[index].place_name
searchHistoryList.removeAt(index)
searchHistoryDB.deleteSearchHistoryByName(deletedItemName)
searchHistoryRecyclerViewAdapter.notifyItemRemoved(index)
}
}
)
searchHistoryRecyclerView.adapter = searchHistoryRecyclerViewAdapter
searchHistoryRecyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)

searchEditText.addTextChangedListener { text ->
text?.let { searchPlaces(it.toString()) }
}
@@ -107,12 +124,12 @@ class SearchActivity : AppCompatActivity() {
noResults.visibility = TextView.GONE
resultRecyclerView.visibility = RecyclerView.VISIBLE
Log.d("visibility", "noresult: ${noResults.visibility}, recycler: ${resultRecyclerView.visibility} ")

}
}

private fun updateSearchHistoryRecyclerView(place: Place) {
searchHistoryList.add(place)
private fun updateSearchHistoryRecyclerView(searchHistory: SearchHistory) {
Log.d("updateSearchHistoryRecyclerView", "I'm executed")
searchHistoryList.add(searchHistory)
searchHistoryRecyclerViewAdapter.notifyDataSetChanged()
}

@@ -123,11 +140,8 @@ class SearchActivity : AppCompatActivity() {
searchToMapIntent.putExtra("name", name)
searchToMapIntent.putExtra("address", address)
Log.d("goBackToMap", "goBackToMap: $mapX, $mapY")

// if (!(application as KyleMaps).isTestMode) {
finish()
startActivity(searchToMapIntent)
// }
}

private fun updateMapPosition(place: Place) {