@@ -163,18 +163,23 @@ class MapFragment : Fragment(), MapHandler {
163
163
override fun onStateChanged (bottomSheet : View , newState : Int ) = Unit
164
164
165
165
override fun onSlide (bottomSheet : View , slideOffset : Float ) {
166
- binding.homeBottomSheet.layoutStateExpanded.layoutBottomSheetHomeStateExpanded.alpha = slideOffset
167
- binding.homeBottomSheet.textViewAlarmState.alpha = 1 - slideOffset
166
+ with (binding.homeBottomSheet) {
167
+ layoutStateExpanded.layoutBottomSheetHomeStateExpanded.alpha = slideOffset
168
+ textViewAlarmState.alpha = 1 - slideOffset
169
+ }
168
170
}
169
171
})
170
172
}
171
173
172
174
private fun initBottomSheetView () {
173
175
binding.homeBottomSheet.layoutStateExpanded.viewAlarm.setOnClickListener {
176
+ val notificationManager =
177
+ requireContext().getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
174
178
val behavior = BottomSheetBehavior .from(binding.layoutHomeBottomSheet)
175
179
val intent = Intent (requireContext(), SoundService ::class .java)
176
180
177
181
alarmViewModel.deleteAlarm()
182
+ notificationManager.cancel(AlarmSettingFragment .ALARM_NOTIFICATION_HIGH_ID )
178
183
behavior.state = BottomSheetBehavior .STATE_COLLAPSED
179
184
requireContext().stopService(intent)
180
185
SoundService .normalExit = true
@@ -241,34 +246,13 @@ class MapFragment : Fragment(), MapHandler {
241
246
}
242
247
243
248
private fun setViewVisibility () {
244
- with (binding) {
249
+ with (binding) {
245
250
textViewSearch.visibility = mapUIVisibility
246
251
layoutCompass.visibility = mapUIVisibility
247
252
layoutCurrent.visibility = mapUIVisibility
248
253
}
249
254
}
250
255
251
- private fun listenButtonClick () {
252
- binding.homeBottomSheet.layoutStateExpanded.buttonAlarmTurnOff.setOnClickListener {
253
- alarmViewModel.deleteAlarm()
254
- cancelNotification()
255
- turnOffSoundService()
256
- val behavior = BottomSheetBehavior .from(binding.layoutHomeBottomSheet)
257
- behavior.state = BottomSheetBehavior .STATE_COLLAPSED
258
- }
259
- }
260
-
261
- private fun cancelNotification () {
262
- val notificationManager = requireContext().getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
263
- notificationManager.cancel(AlarmSettingFragment .ALARM_NOTIFICATION_HIGH_ID )
264
- }
265
-
266
- private fun turnOffSoundService () {
267
- val intent = Intent (requireContext(), SoundService ::class .java)
268
- requireContext().stopService(intent)
269
- SoundService .normalExit = true
270
- }
271
-
272
256
override fun onResume () {
273
257
super .onResume()
274
258
0 commit comments