Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[경북대 Android 권성찬] 3주차 과제_STEP 2 #90

Open
wants to merge 42 commits into
base: ksc1008
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
278e0ec
integrate files from previous project
MyStoryG Jul 7, 2024
cff708e
project: setup gradle repository
ksc1008 Jul 8, 2024
3b9a499
feat: removed unused activity, setup build.gradle for API support
ksc1008 Jul 8, 2024
b8ea5bf
docs: updated READ.md
ksc1008 Jul 8, 2024
23c9495
feat: add KeywordSearch DTO
ksc1008 Jul 8, 2024
8d90216
BREAKING CHANGE: renamed package name to ksc.campus.tech.kakao.map
ksc1008 Jul 8, 2024
a3e146a
feat: removed methods about SearchResultTable
ksc1008 Jul 8, 2024
1f5be4f
feat: now support batch searching
ksc1008 Jul 8, 2024
5c3372b
feat: now support batch searching
ksc1008 Jul 8, 2024
da98320
refactor: removed log for debugging
ksc1008 Jul 8, 2024
8305fd1
refactor($SearchResultRepository): added instance property for simple…
ksc1008 Jul 8, 2024
7d18f90
style: fixed result item size issue
ksc1008 Jul 8, 2024
59c7f4c
fix ($SearchResultRepository): restored to original code due to compi…
ksc1008 Jul 8, 2024
09dcd50
feat ($SearchKakaoHelper): implement better category parsing algorithm
ksc1008 Jul 8, 2024
bdf72ab
refactor: removed unused dummy data
ksc1008 Jul 8, 2024
16adacd
feat: now SearchResult data class contains id got from search API
ksc1008 Jul 8, 2024
03d3030
fix: fixed bug that duplicate result showed when searching same keywo…
ksc1008 Jul 8, 2024
ee98ddb
fix: fixed bug that same page appeared on search
ksc1008 Jul 8, 2024
341c5d4
refactor: grouped several procedure to one function
ksc1008 Jul 8, 2024
ba4769d
refactor($SearchKeywordAdapter): replaced two callbacks with an inter…
ksc1008 Jul 8, 2024
c6039a9
style: reformatted all codes
ksc1008 Jul 8, 2024
f2ad63d
docs: added documentary for lastSearchId property
ksc1008 Jul 8, 2024
449df9a
feat: add Kakao Map Fragment
ksc1008 Jul 10, 2024
931fdc9
docs: update README.md
ksc1008 Jul 10, 2024
0b4376c
feat: implement kakaomap function
ksc1008 Jul 10, 2024
2112810
feat: implement switch from map to search menu on search button click
ksc1008 Jul 10, 2024
8c6ac17
feat: implement switch to map from search menu on back button click
ksc1008 Jul 10, 2024
63c6f01
feat: implement kakaomap function
ksc1008 Jul 10, 2024
fa4674b
feat: implement switch from map to search menu on search button click
ksc1008 Jul 10, 2024
a48c8d2
feat: implement switch to map from search menu on back button click
ksc1008 Jul 10, 2024
ec1e3b7
Merge remote-tracking branch 'origin/step2' into step2
ksc1008 Jul 10, 2024
01b5151
style: reformatted codes
ksc1008 Jul 12, 2024
a8f03c5
refactor: removed unused parameter for callback
ksc1008 Jul 12, 2024
ae75eed
style: resolved TO-DO
ksc1008 Jul 12, 2024
94ceb80
refactor: added @Serializable annotation to DTO
ksc1008 Jul 15, 2024
9c0374b
fix: add dependency for serialization feature
ksc1008 Jul 15, 2024
9555032
refactor($KeywordSearchResponse): renamed to camel-case name
ksc1008 Jul 15, 2024
80eabb8
style: used emptyList(), instead of listOf() for empty list initializ…
ksc1008 Jul 15, 2024
1337557
refactor: removed DiffUtil, used ListAdapter instead.
ksc1008 Jul 15, 2024
74c3d4b
refactor: moved enum class out of the companion object
ksc1008 Jul 15, 2024
a8bfdfb
refactor: now SearchResultAdapter inherits listAdapter
ksc1008 Jul 15, 2024
c58deff
feat: synced lifecycle of kakaoMapView to lifecycle of fragment
ksc1008 Jul 15, 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
refactor: now SearchResultAdapter inherits listAdapter
ksc1008 committed Jul 15, 2024
commit a8bfdfbaca27812c7158f4cbb9788110066c96c2
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() {
setKeywordRecyclerViewActive(it.isNotEmpty())
}
searchViewModel.activeContent.observe(this) {
if (it == SearchActivityViewModel.Companion.ContentType.MAP) {
if (it == SearchActivityViewModel.ContentType.MAP) {
switchToMapMenu()
} else {
switchToSearchMenu()
@@ -99,7 +99,7 @@ class MainActivity : AppCompatActivity() {

searchInput.setOnQueryTextFocusChangeListener { _, hasFocus ->
if (hasFocus) {
searchViewModel.switchContent(SearchActivityViewModel.Companion.ContentType.SEARCH_LIST)
searchViewModel.switchContent(SearchActivityViewModel.ContentType.SEARCH_LIST)
}
}
}
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ class SearchResultFragment : Fragment() {

private fun setInitialValueToAdapter() {
viewModel.searchResult.value?.let {
(searchResultRecyclerView.adapter as? SearchResultAdapter)?.updateResult(it)
(searchResultRecyclerView.adapter as? SearchResultAdapter)?.submitList(it)
}
}

@@ -53,7 +53,7 @@ class SearchResultFragment : Fragment() {

private fun initiateSearchResultLiveDataObservation() {
viewModel.searchResult.observe(viewLifecycleOwner) {
(searchResultRecyclerView.adapter as? SearchResultAdapter)?.updateResult(it)
(searchResultRecyclerView.adapter as? SearchResultAdapter)?.submitList(it)
setNoResultHelpTextActive(it.isEmpty())
}
}
@@ -77,7 +77,7 @@ class SearchResultFragment : Fragment() {
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
viewModel.switchContent(SearchActivityViewModel.Companion.ContentType.MAP)
viewModel.switchContent(SearchActivityViewModel.ContentType.MAP)
}

})
Original file line number Diff line number Diff line change
@@ -5,36 +5,24 @@ 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 ksc.campus.tech.kakao.map.R
import ksc.campus.tech.kakao.map.models.SearchResult

class SearchResultDiffUtil(
private val oldList: List<SearchResult>,
private val newList: List<SearchResult>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int = oldList.size

override fun getNewListSize(): Int = newList.size

override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldList[oldItemPosition]
val newItem = newList[newItemPosition]
return (oldItem.id == newItem.id)
}

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
val oldItem = oldList[oldItemPosition]
val newItem = newList[newItemPosition]
return (oldItem.type == newItem.type && oldItem.address == newItem.address && oldItem.name == newItem.name)
}

}

class SearchResultAdapter(
val onItemClicked: ((item: SearchResult, index: Int) -> Unit)
) :
RecyclerView.Adapter<SearchResultAdapter.SearchResultViewHolder>() {
ListAdapter<SearchResult, SearchResultAdapter.SearchResultViewHolder>(object :
DiffUtil.ItemCallback<SearchResult>() {
override fun areItemsTheSame(oldItem: SearchResult, newItem: SearchResult): Boolean =
oldItem.id == newItem.id

override fun areContentsTheSame(oldItem: SearchResult, newItem: SearchResult): Boolean =
oldItem == newItem

}) {
class SearchResultViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val resultName: TextView
val resultAddress: TextView
@@ -48,17 +36,6 @@ class SearchResultAdapter(
}
}

var results: List<SearchResult> = listOf()

override fun getItemCount(): Int = results.size

fun updateResult(results: List<SearchResult>) {
val diffUtil = SearchResultDiffUtil(this.results, results)
val diffResult = DiffUtil.calculateDiff(diffUtil)
this.results = results
diffResult.dispatchUpdatesTo(this)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchResultViewHolder {
val view =
LayoutInflater.from(parent.context).inflate(R.layout.item_search_result, parent, false)
@@ -79,7 +56,7 @@ class SearchResultAdapter(


override fun onBindViewHolder(holder: SearchResultViewHolder, position: Int) {
val item = results[position]
val item = currentList[position]
holder.resultId = item.id
holder.resultAddress.text = item.address
holder.resultName.text = item.name