From 9e5489d84871b458e061b100891dc1573dd47f0b Mon Sep 17 00:00:00 2001 From: JustinLee02 <164829006+JustinLee02@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:28:13 +0900 Subject: [PATCH] =?UTF-8?q?#86=20Chore:=20=EC=BD=94=EB=93=9C=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/kaupark/view/fragment/HomeView.kt | 20 +++++++++---------- .../kaupark/view/fragment/ManageProfile.kt | 5 ++--- KAUPark/app/src/main/res/layout/home_view.xml | 4 ++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/HomeView.kt b/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/HomeView.kt index b15ec4d..fa7c24c 100644 --- a/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/HomeView.kt +++ b/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/HomeView.kt @@ -37,10 +37,8 @@ class HomeView : Fragment(), OnMapReadyCallback { // HomeViewModel 을 Fragment 에 연결. ViewModel 은 데이터를 관리하고 UI로 동기화 private val viewModel: HomeViewModel by viewModels() - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - } @RequiresApi(Build.VERSION_CODES.O) @@ -56,10 +54,8 @@ class HomeView : Fragment(), OnMapReadyCallback { binding.textviewCurrenttime.text = date.toString() // 지도를 초기화하고 Fragment와 연결 - val mapFragment = childFragmentManager.findFragmentById(R.id.containerview_mapimage) as MapFragment? - ?: MapFragment.newInstance().also { - childFragmentManager.beginTransaction().add(R.id.containerview_mapimage, it).commit() - } + val mapFragment = childFragmentManager.findFragmentById(R.id.containerview_mapimage) + as MapFragment? ?: MapFragment.newInstance() mapFragment.getMapAsync(this) // buttonMangeProfile 버튼 클릭 시 ManageProfile Fragment 로 이동 @@ -81,6 +77,7 @@ class HomeView : Fragment(), OnMapReadyCallback { ) // ArrayAdapter 를 사용해 Spinner 에 주차장 리스트를 설정. + // parkingLots 배열을 dropdown 항목에 연결 val adapter = ArrayAdapter( requireContext(), android.R.layout.simple_spinner_item, parkingLots).also { arrayAdapter -> arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) @@ -105,10 +102,10 @@ class HomeView : Fragment(), OnMapReadyCallback { val parkingLot = binding.spinnerParkinglot.selectedItem?.toString() if(!parkingLot.isNullOrBlank()) { viewModel.decreaseCarNum(parkingLot) + viewModel.recordExitTime() } else { ToastHelper.showToast(requireContext(), "주차장 이름을 입력하세요") } - viewModel.recordExitTime() } // ViewModel의 LiveData 관찰을 통해 UI를 업데이트. @@ -151,10 +148,10 @@ class HomeView : Fragment(), OnMapReadyCallback { } // InfoWindow 설정 (마커 클릭 시 표시되는 정보창). - val infoWindow = InfoWindow().apply { - adapter = object : InfoWindow.DefaultTextAdapter(requireContext()) { - override fun getText(infoWindow: InfoWindow): CharSequence { - return infoWindow.marker?.tag as? CharSequence ?: "정보 없음" + val infoWindow = InfoWindow().apply { // InfoWindow() : 네이버 지도에서 제공하는 객체, 마커를 클릭했을 때 정보를 보여주는 창 + adapter = object : InfoWindow.DefaultTextAdapter(requireContext()) { // 텍스트 어댑터 클래스 상속 (익명 객체) + override fun getText(infoWindow: InfoWindow): String { + return infoWindow.marker?.tag as? String ?: "정보 없음" } } } @@ -179,6 +176,7 @@ class HomeView : Fragment(), OnMapReadyCallback { val initialPosition = LatLng(37.6000000, 126.8656335) // 위도 경도 지정 val cameraUpdate = CameraUpdate.scrollTo(initialPosition) naverMap.moveCamera(cameraUpdate) + val zoomUpdate = CameraUpdate.zoomTo(15.8) // Zoom 레벨 설정 naverMap.moveCamera(zoomUpdate) } diff --git a/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/ManageProfile.kt b/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/ManageProfile.kt index 987625b..543b4a5 100644 --- a/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/ManageProfile.kt +++ b/KAUPark/app/src/main/java/com/example/kaupark/view/fragment/ManageProfile.kt @@ -5,10 +5,10 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Toast import androidx.fragment.app.viewModels import androidx.recyclerview.widget.LinearLayoutManager import com.example.kaupark.ParkingRecordAdapter +import com.example.kaupark.ToastHelper import com.example.kaupark.databinding.FragmentManageProfileBinding import com.example.kaupark.viewmodel.ManageProfileViewModel @@ -20,7 +20,6 @@ class ManageProfile : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - } override fun onCreateView( @@ -43,7 +42,7 @@ class ManageProfile : Fragment() { viewModel.toastMessage.observe(viewLifecycleOwner) { message -> message?.let { - Toast.makeText(requireContext(), it, Toast.LENGTH_SHORT).show() + ToastHelper.showToast(requireContext(), it) viewModel.clearToastMessage() } } diff --git a/KAUPark/app/src/main/res/layout/home_view.xml b/KAUPark/app/src/main/res/layout/home_view.xml index 02385b1..fe024a2 100644 --- a/KAUPark/app/src/main/res/layout/home_view.xml +++ b/KAUPark/app/src/main/res/layout/home_view.xml @@ -153,7 +153,9 @@ android:layout_height="90dp" android:layout_marginStart="0dp" android:layout_marginTop="18dp" + android:background="@color/kaucolor" android:text="입차" + android:textColor="@color/white" app:layout_constraintStart_toStartOf="@id/containerview_mapimage" app:layout_constraintTop_toBottomOf="@id/spinner_parkinglot" /> @@ -163,7 +165,9 @@ android:layout_height="90dp" android:layout_marginStart="24dp" android:layout_marginTop="0dp" + android:background="@color/kaucolor" android:text="출차" + android:textColor="@color/white" app:layout_constraintStart_toEndOf="@id/button_in" app:layout_constraintTop_toTopOf="@id/button_in" />