-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
183 additions
and
31 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
61 changes: 61 additions & 0 deletions
61
...id/app/src/main/java/net/pengcook/android/presentation/step/TimerSettingDialogFragment.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,61 @@ | ||
package net.pengcook.android.presentation.step | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.DialogFragment | ||
import net.pengcook.android.databinding.DialogTimerSettingBinding | ||
|
||
class TimerSettingDialogFragment : DialogFragment() { | ||
|
||
private var _binding: DialogTimerSettingBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
interface TimerSettingListener { | ||
fun onTimeSet(minutes: Int, seconds: Int) | ||
} | ||
|
||
var listener: TimerSettingListener? = null | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
_binding = DialogTimerSettingBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
setupNumberPickers() | ||
|
||
binding.btnConfirm.setOnClickListener { | ||
val minutes = binding.npMinutes.value | ||
val seconds = binding.npSeconds.value | ||
listener?.onTimeSet(minutes, seconds) | ||
dismiss() | ||
} | ||
|
||
binding.btnCancel.setOnClickListener { | ||
dismiss() | ||
} | ||
} | ||
|
||
private fun setupNumberPickers() { | ||
binding.npMinutes.minValue = 0 | ||
binding.npMinutes.maxValue = 59 | ||
binding.npMinutes.wrapSelectorWheel = true | ||
|
||
binding.npSeconds.minValue = 0 | ||
binding.npSeconds.maxValue = 59 | ||
binding.npSeconds.wrapSelectorWheel = true | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
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,63 @@ | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp"> | ||
|
||
<TextView | ||
android:id="@+id/tv_description" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="8dp" | ||
android:text="Set Timer" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<!-- 분 설정 NumberPicker --> | ||
<NumberPicker | ||
android:id="@+id/np_minutes" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
app:layout_constraintEnd_toStartOf="@+id/np_seconds" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_description" /> | ||
|
||
<!-- 초 설정 NumberPicker --> | ||
<NumberPicker | ||
android:id="@+id/np_seconds" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/np_minutes" | ||
app:layout_constraintTop_toBottomOf="@id/tv_description" /> | ||
|
||
<!-- 확인 및 취소 버튼 --> | ||
<Button | ||
android:id="@+id/btn_cancel" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="8dp" | ||
android:backgroundTint="@color/yellow_strong" | ||
android:text="cancle" | ||
app:layout_constraintEnd_toStartOf="@id/btn_confirm" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/np_minutes" /> | ||
|
||
<Button | ||
android:id="@+id/btn_confirm" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:backgroundTint="@color/yellow_strong" | ||
android:text="confirm" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/btn_cancel" | ||
app:layout_constraintTop_toBottomOf="@id/np_minutes" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
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