-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from LJG7123/feature-aos/주소-검색
Feature(#34): 주소 검색 및 카메라 이동
- Loading branch information
Showing
12 changed files
with
244 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...n/java/com/boostcampwm2023/snappoint/presentation/main/search/AutoCompletionViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.boostcampwm2023.snappoint.presentation.main.search | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import com.boostcampwm2023.snappoint.databinding.ItemSearchAutoCompleteBinding | ||
|
||
class AutoCompletionViewHolder( | ||
private val binding: ItemSearchAutoCompleteBinding, | ||
private val onAutoCompleteItemClicked: (Int) -> Unit, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(string: String, index: Int) { | ||
|
||
with(binding) { | ||
item = string | ||
root.setOnClickListener { onAutoCompleteItemClicked(index) } | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...main/java/com/boostcampwm2023/snappoint/presentation/main/search/SearchViewListAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.boostcampwm2023.snappoint.presentation.main.search | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.databinding.BindingAdapter | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.boostcampwm2023.snappoint.databinding.ItemSearchAutoCompleteBinding | ||
|
||
class AutoCompletionListAdapter( | ||
private val onAutoCompleteItemClicked: (Int) -> Unit | ||
) : ListAdapter<String, AutoCompletionViewHolder>(diffUtil) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AutoCompletionViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
return AutoCompletionViewHolder( | ||
binding = ItemSearchAutoCompleteBinding.inflate(inflater, parent, false), | ||
onAutoCompleteItemClicked = onAutoCompleteItemClicked | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: AutoCompletionViewHolder, position: Int) { | ||
holder.bind(getItem(position), position) | ||
} | ||
|
||
companion object { | ||
val diffUtil = object : DiffUtil.ItemCallback<String>() { | ||
override fun areItemsTheSame(oldItem: String, newItem: String): Boolean { | ||
return oldItem == newItem | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: String, newItem: String): Boolean { | ||
return oldItem == newItem | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
@BindingAdapter("autoCompleteTexts", "onAutoCompleteItemClick") | ||
fun RecyclerView.bindRecyclerViewAdapter(texts: List<String>, onAutoCompleteItemClicked:(Int) -> Unit) { | ||
if (adapter == null) adapter = AutoCompletionListAdapter(onAutoCompleteItemClicked) | ||
(adapter as AutoCompletionListAdapter).submitList(texts) | ||
} |
6 changes: 6 additions & 0 deletions
6
...src/main/java/com/boostcampwm2023/snappoint/presentation/main/search/SearchViewUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.boostcampwm2023.snappoint.presentation.main.search | ||
|
||
data class SearchViewUiState( | ||
val texts: List<String> = emptyList(), | ||
val onAutoCompleteItemClicked: (Int) -> Unit = {}, | ||
) |
3 changes: 3 additions & 0 deletions
3
android/app/src/main/java/com/boostcampwm2023/snappoint/presentation/util/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.boostcampwm2023.snappoint.presentation.util | ||
|
||
import com.boostcampwm2023.snappoint.BuildConfig | ||
|
||
object Constants { | ||
const val BOTTOM_SHEET_HALF_EXPANDED_RATIO: Float = 0.45f | ||
const val API_KEY = BuildConfig.MAPS_API_KEY | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
android/app/src/main/res/layout/item_search_auto_complete.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="item" | ||
type="String" /> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:foreground="?attr/selectableItemBackground" | ||
android:padding="16dp"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_marker" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/icon_location_pin" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
|
||
<TextView | ||
android:id="@+id/tv_auto_complete" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:text="@{item}" | ||
android:textSize="16sp" | ||
android:ellipsize="marquee" | ||
android:maxLines="1" | ||
android:layout_marginStart="16dp" | ||
app:layout_constraintStart_toEndOf="@id/iv_marker" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="@id/iv_marker" | ||
app:layout_constraintBottom_toBottomOf="@id/iv_marker"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Oops, something went wrong.