diff --git a/app/build.gradle.kts b/app/build.gradle.kts index db6fbc29..aef2c867 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -39,6 +39,7 @@ android { buildFeatures { viewBinding = true + dataBinding = true buildConfig = true } } diff --git a/app/src/main/java/campus/tech/kakao/map/ui/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/ui/MapActivity.kt index 1b764414..a3d71ead 100644 --- a/app/src/main/java/campus/tech/kakao/map/ui/MapActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/ui/MapActivity.kt @@ -4,17 +4,18 @@ import android.content.Intent import android.content.SharedPreferences import android.content.SharedPreferences.Editor import android.os.Bundle -import android.widget.EditText import android.widget.ImageButton import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil import campus.tech.kakao.map.R +import campus.tech.kakao.map.databinding.ErrorLayoutBinding +import campus.tech.kakao.map.databinding.MapLayoutBinding 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.CameraAnimation import com.kakao.vectormap.camera.CameraUpdateFactory import com.kakao.vectormap.label.LabelManager @@ -23,9 +24,8 @@ import com.kakao.vectormap.label.LabelStyle import com.kakao.vectormap.label.LabelStyles class MapActivity : AppCompatActivity() { - - lateinit var mapView: MapView - lateinit var etSearch: EditText + lateinit var mapBinding: MapLayoutBinding + lateinit var errorBinding: ErrorLayoutBinding private lateinit var labelManager: LabelManager private val startZoomLevel = 15 var latitude: String? = "35.234" @@ -140,11 +140,9 @@ class MapActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.map_layout) - mapView = findViewById(R.id.mapView) - etSearch = findViewById(R.id.etSearch) - mapView.start(lifeCycleCallback, readyCallback) - etSearch.setOnClickListener { + mapBinding = DataBindingUtil.setContentView(this, R.layout.map_layout) + mapBinding.mapView.start(lifeCycleCallback, readyCallback) + mapBinding.etSearch.setOnClickListener { val searchIntent = Intent(this, PlaceActivity::class.java) startActivity(searchIntent) } @@ -152,15 +150,15 @@ class MapActivity : AppCompatActivity() { override fun onResume() { super.onResume() - mapView.resume() + mapBinding.mapView.resume() } override fun onPause() { super.onPause() - mapView.pause() + mapBinding.mapView.pause() } private fun initializeMap() { - mapView.start(lifeCycleCallback, readyCallback) + mapBinding.mapView.start(lifeCycleCallback, readyCallback) } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/ui/PlaceActivity.kt b/app/src/main/java/campus/tech/kakao/map/ui/PlaceActivity.kt index ae92687f..9f42432a 100644 --- a/app/src/main/java/campus/tech/kakao/map/ui/PlaceActivity.kt +++ b/app/src/main/java/campus/tech/kakao/map/ui/PlaceActivity.kt @@ -6,23 +6,17 @@ import android.text.Editable import android.text.TextWatcher import android.util.Log import android.view.View -import android.widget.EditText -import android.widget.ImageButton -import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import campus.tech.kakao.map.domain.PlaceDataModel import campus.tech.kakao.map.data.PlaceDatabaseAccess import campus.tech.kakao.map.data.PlaceRepository import campus.tech.kakao.map.R +import campus.tech.kakao.map.databinding.SearchLayoutBinding class PlaceActivity : AppCompatActivity() { - lateinit var etSearch: EditText - lateinit var btnErase: ImageButton - lateinit var tvNoData: TextView - lateinit var rvPlaceList: RecyclerView - lateinit var rvSearchList: RecyclerView + lateinit var binding: SearchLayoutBinding lateinit var placeAdapter: PlaceRecyclerViewAdapter private lateinit var searchAdapter: SearchRecyclerViewAdapter var searchDatabaseAccess = PlaceDatabaseAccess(this, "Search.db") @@ -31,12 +25,7 @@ class PlaceActivity : AppCompatActivity() { public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.search_layout) - etSearch = findViewById(R.id.etSearch) - btnErase = findViewById(R.id.btnErase) - tvNoData = findViewById(R.id.tvNoData) - rvPlaceList = findViewById(R.id.rvPlaceList) - rvSearchList = findViewById(R.id.rvSearchList) + binding = DataBindingUtil.setContentView(this, R.layout.search_layout) val searchList: MutableList = searchDatabaseAccess.getAllPlace() val keywordList: MutableList = mutableListOf() @@ -45,23 +34,23 @@ class PlaceActivity : AppCompatActivity() { // Search 어댑터 searchAdapter = searchRecyclerViewAdapter(searchList) - rvSearchList.adapter = searchAdapter - rvSearchList.layoutManager = + binding.rvSearchList.adapter = searchAdapter + binding.rvSearchList.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) // Place 어댑터 placeAdapter = placeRecyclerViewAdapter(keywordList, searchList) - rvPlaceList.adapter = placeAdapter - rvPlaceList.layoutManager = LinearLayoutManager(this) + binding.rvPlaceList.adapter = placeAdapter + binding.rvPlaceList.layoutManager = LinearLayoutManager(this) controlPlaceVisibility(keywordList) controlSearchVisibility(searchList) - btnErase.setOnClickListener { - etSearch.setText("") + binding.btnErase.setOnClickListener { + binding.etSearch.setText("") } - etSearch.addTextChangedListener(object : TextWatcher { + binding.etSearch.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { } @@ -118,8 +107,8 @@ class PlaceActivity : AppCompatActivity() { searchList, // 저장 목록 선택 시, 검색칸에 장소명 표시 onItemClick = { place -> - etSearch.setText(place.name) - etSearch.setSelection(place.name.length) + binding.etSearch.setText(place.name) + binding.etSearch.setSelection(place.name.length) }, // X 선택 시, 저장 목록에서 삭제 onCloseButtonClick = { place -> @@ -145,21 +134,21 @@ class PlaceActivity : AppCompatActivity() { // visibility 조작 fun controlPlaceVisibility(placeList: List) { if (placeList.isEmpty()) { - rvPlaceList.visibility = View.INVISIBLE - tvNoData.visibility = View.VISIBLE + binding.rvPlaceList.visibility = View.INVISIBLE + binding.tvNoData.visibility = View.VISIBLE } else { - rvPlaceList.visibility = View.VISIBLE - tvNoData.visibility = View.GONE + binding.rvPlaceList.visibility = View.VISIBLE + binding.tvNoData.visibility = View.GONE } } fun controlSearchVisibility(searchList: List) { if (searchList.isEmpty()) { - rvSearchList.visibility = View.GONE + binding.rvSearchList.visibility = View.GONE } else { - rvSearchList.visibility = View.VISIBLE + binding.rvSearchList.visibility = View.VISIBLE } } } \ No newline at end of file diff --git a/app/src/main/res/layout/map_layout.xml b/app/src/main/res/layout/map_layout.xml index 15d7f24f..3cf49442 100644 --- a/app/src/main/res/layout/map_layout.xml +++ b/app/src/main/res/layout/map_layout.xml @@ -1,59 +1,62 @@ - - - - - - + + android:layout_height="match_parent" + tools:context=".ui.MapActivity"> - + + - - - - - - - - - - \ No newline at end of file + android:layout_height="50dp" + android:layout_margin="30dp" + app:cardElevation="10dp" + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/search_layout.xml b/app/src/main/res/layout/search_layout.xml index 031b480b..10273b9d 100644 --- a/app/src/main/res/layout/search_layout.xml +++ b/app/src/main/res/layout/search_layout.xml @@ -1,87 +1,89 @@ - - - + + android:layout_height="match_parent" + tools:context=".ui.PlaceActivity"> - + android:layout_margin="30dp" + android:layout_marginTop="120dp" + android:orientation="horizontal" + android:weightSum="10" + app:layout_constraintTop_toTopOf="parent" + tools:layout_editor_absoluteX="30dp"> - + - + - + - + - + - + + - - + + + - + + \ No newline at end of file