diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt index 208be250..0c6d42c1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/TimerAdapter.kt @@ -7,7 +7,6 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import com.simplemobiletools.clock.R import com.simplemobiletools.clock.activities.SimpleActivity -import com.simplemobiletools.clock.dialogs.MyTimePickerDialogDialog import com.simplemobiletools.clock.extensions.getFormattedDuration import com.simplemobiletools.clock.extensions.hideTimerNotification import com.simplemobiletools.clock.extensions.secondsToMillis @@ -25,7 +24,7 @@ class TimerAdapter( private val simpleActivity: SimpleActivity, recyclerView: MyRecyclerView, onRefresh: () -> Unit, - private val onItemClick: (Timer) -> Unit, + onItemClick: (Timer) -> Unit, ) : MyRecyclerViewListAdapter(simpleActivity, recyclerView, diffUtil, null, onItemClick, onRefresh) { companion object { @@ -75,12 +74,10 @@ class TimerAdapter( return position } - override fun onActionModeCreated() {} override fun onActionModeDestroyed() {} - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_timer, parent) override fun onBindViewHolder(holder: ViewHolder, position: Int) { @@ -101,7 +98,6 @@ class TimerAdapter( } } - private fun setupView(view: View, timer: Timer) { view.apply { val isSelected = selectedKeys.contains(timer.id) @@ -118,23 +114,12 @@ class TimerAdapter( is TimerState.Paused -> timer.state.tick.getFormattedDuration() is TimerState.Running -> timer.state.tick.getFormattedDuration() } - timer_time.setOnClickListener { - changeDuration(timer) - } - - timer_delete.applyColorFilter(textColor) - timer_delete.setOnClickListener { - simpleActivity.timerHelper.deleteTimer(timer.id!!) { - onRefresh.invoke() - } - } timer_reset.applyColorFilter(textColor) timer_reset.setOnClickListener { stopTimer(timer) } - timer_play_pause.background = simpleActivity.resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, adjustedPrimaryColor) timer_play_pause.applyColorFilter(if (adjustedPrimaryColor == Color.WHITE) Color.BLACK else Color.WHITE) timer_play_pause.setOnClickListener { when (val state = timer.state) { @@ -148,31 +133,14 @@ class TimerAdapter( val state = timer.state val resetPossible = state is TimerState.Running || state is TimerState.Paused || state is TimerState.Finished timer_reset.beInvisibleIf(!resetPossible) - timer_delete.beInvisibleIf(!(!resetPossible && itemCount > 1)) val drawableId = if (state is TimerState.Running) R.drawable.ic_pause_vector else R.drawable.ic_play_vector val iconColor = if (adjustedPrimaryColor == Color.WHITE) Color.BLACK else Color.WHITE timer_play_pause.setImageDrawable(simpleActivity.resources.getColoredDrawableWithColor(drawableId, iconColor)) } } - private fun changeDuration(timer: Timer) { - MyTimePickerDialogDialog(simpleActivity, timer.seconds) { seconds -> - val timerSeconds = if (seconds <= 0) 10 else seconds - updateTimer(timer.copy(seconds = timerSeconds)) - } - } - - private fun updateTimer(timer: Timer, refresh: Boolean = true) { - simpleActivity.timerHelper.insertOrUpdateTimer(timer) { - if (refresh) { - onRefresh.invoke() - } - } - } - private fun stopTimer(timer: Timer) { EventBus.getDefault().post(TimerEvent.Reset(timer.id!!, timer.seconds.secondsToMillis)) simpleActivity.hideTimerNotification() } - } diff --git a/app/src/main/res/layout/item_timer.xml b/app/src/main/res/layout/item_timer.xml index f8e80a18..8a710a00 100644 --- a/app/src/main/res/layout/item_timer.xml +++ b/app/src/main/res/layout/item_timer.xml @@ -12,34 +12,30 @@ + android:layout_height="wrap_content" + android:paddingLeft="@dimen/activity_margin" + android:paddingTop="@dimen/medium_margin" + android:paddingBottom="@dimen/medium_margin"> @@ -49,28 +45,17 @@ android:id="@+id/timer_reset" android:layout_width="@dimen/stopwatch_button_small_size" android:layout_height="@dimen/stopwatch_button_small_size" + android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginEnd="@dimen/bigger_margin" android:background="?attr/selectableItemBackgroundBorderless" android:padding="@dimen/normal_margin" android:src="@drawable/ic_reset_vector" android:visibility="visible" app:layout_constraintBottom_toBottomOf="@+id/timer_play_pause" app:layout_constraintEnd_toStartOf="@+id/timer_play_pause" - app:layout_constraintStart_toStartOf="parent" + app:layout_constraintStart_toEndOf="@id/timer_time" app:layout_constraintTop_toTopOf="@id/timer_play_pause" /> - + app:layout_constraintStart_toEndOf="@id/timer_reset" + app:layout_constraintTop_toTopOf="parent" />