Skip to content

Commit

Permalink
#86 Chore: 코드 주석
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinLee02 committed Dec 15, 2024
1 parent c2eb1b4 commit 9e5489d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 로 이동
Expand All @@ -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)
Expand All @@ -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를 업데이트.
Expand Down Expand Up @@ -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 ?: "정보 없음"
}
}
}
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -20,7 +20,6 @@ class ManageProfile : Fragment() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

}

override fun onCreateView(
Expand All @@ -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()
}
}
Expand Down
4 changes: 4 additions & 0 deletions KAUPark/app/src/main/res/layout/home_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

Expand All @@ -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" />

Expand Down

0 comments on commit 9e5489d

Please sign in to comment.