Reduce timer icon sizes, add animation for timer removal
This commit is contained in:
parent
94de14b52d
commit
666a9ef44d
|
@ -67,7 +67,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:a9e600f664'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:b6e2ffb710'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'com.shawnlin:number-picker:2.4.6'
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.facebook.stetho.Stetho
|
|||
import com.simplemobiletools.clock.extensions.getOpenTimerTabIntent
|
||||
import com.simplemobiletools.clock.extensions.getTimerNotification
|
||||
import com.simplemobiletools.clock.extensions.timerHelper
|
||||
import com.simplemobiletools.clock.helpers.INVALID_TIMER_ID
|
||||
import com.simplemobiletools.clock.models.TimerEvent
|
||||
import com.simplemobiletools.clock.models.TimerState
|
||||
import com.simplemobiletools.clock.services.TimerStopService
|
||||
|
@ -78,7 +77,7 @@ class App : Application(), LifecycleObserver {
|
|||
fun onMessageEvent(event: TimerEvent.Delete) {
|
||||
countDownTimers[event.timerId]?.cancel()
|
||||
timerHelper.deleteTimer(event.timerId){
|
||||
EventBus.getDefault().post(TimerEvent.Refresh(INVALID_TIMER_ID))
|
||||
EventBus.getDefault().post(TimerEvent.Refresh)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +119,7 @@ class App : Application(), LifecycleObserver {
|
|||
timerHelper.getTimer(timerId) { timer ->
|
||||
val newTimer = timer.copy(state = state)
|
||||
timerHelper.insertOrUpdateTimer(newTimer) {
|
||||
EventBus.getDefault().post(TimerEvent.Refresh(timerId))
|
||||
EventBus.getDefault().post(TimerEvent.Refresh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simplemobiletools.clock.dialogs.EditTimerDialog
|
|||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.createNewTimer
|
||||
import com.simplemobiletools.clock.extensions.timerHelper
|
||||
import com.simplemobiletools.clock.helpers.DisabledItemChangeAnimator
|
||||
import com.simplemobiletools.clock.models.Timer
|
||||
import com.simplemobiletools.clock.models.TimerEvent
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
|
@ -49,7 +50,7 @@ class TimerFragment : Fragment() {
|
|||
storeStateVariables()
|
||||
|
||||
timers_list.adapter = timerAdapter
|
||||
timers_list.itemAnimator = null
|
||||
timers_list.itemAnimator = DisabledItemChangeAnimator()
|
||||
|
||||
timer_add.setOnClickListener {
|
||||
activity?.run {
|
||||
|
@ -81,11 +82,13 @@ class TimerFragment : Fragment() {
|
|||
activity?.timerHelper?.getTimers { timers ->
|
||||
timerAdapter.submitList(timers) {
|
||||
view.timers_list.post {
|
||||
if (timerPositionToScrollTo != INVALID_POSITION && timerAdapter.itemCount > timerPositionToScrollTo) {
|
||||
view.timers_list.scrollToPosition(timerPositionToScrollTo)
|
||||
timerPositionToScrollTo = INVALID_POSITION
|
||||
} else if (scrollToLatest) {
|
||||
view.timers_list.scrollToPosition(timers.lastIndex)
|
||||
if (getView() != null) {
|
||||
if (timerPositionToScrollTo != INVALID_POSITION && timerAdapter.itemCount > timerPositionToScrollTo) {
|
||||
view.timers_list.scrollToPosition(timerPositionToScrollTo)
|
||||
timerPositionToScrollTo = INVALID_POSITION
|
||||
} else if (scrollToLatest) {
|
||||
view.timers_list.scrollToPosition(timers.lastIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.simplemobiletools.clock.helpers
|
||||
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
* Simple RecyclerView animator that disable itemChange animations
|
||||
*/
|
||||
class DisabledItemChangeAnimator : DefaultItemAnimator() {
|
||||
override fun animateChange(
|
||||
oldHolder: RecyclerView.ViewHolder,
|
||||
newHolder: RecyclerView.ViewHolder,
|
||||
preInfo: ItemHolderInfo,
|
||||
postInfo: ItemHolderInfo
|
||||
): Boolean {
|
||||
dispatchChangeFinished(oldHolder, false)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun animateChange(
|
||||
oldHolder: RecyclerView.ViewHolder?,
|
||||
newHolder: RecyclerView.ViewHolder?,
|
||||
fromX: Int,
|
||||
fromY: Int,
|
||||
toX: Int,
|
||||
toY: Int
|
||||
): Boolean {
|
||||
dispatchChangeFinished(oldHolder, false)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun canReuseUpdatedViewHolder(viewHolder: RecyclerView.ViewHolder): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun canReuseUpdatedViewHolder(viewHolder: RecyclerView.ViewHolder, payloads: MutableList<Any>): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package com.simplemobiletools.clock.models
|
||||
|
||||
import com.simplemobiletools.clock.helpers.INVALID_TIMER_ID
|
||||
|
||||
sealed class TimerEvent(open val timerId: Int) {
|
||||
data class Delete(override val timerId: Int) : TimerEvent(timerId)
|
||||
data class Reset(override val timerId: Int) : TimerEvent(timerId)
|
||||
data class Start(override val timerId: Int, val duration: Long) : TimerEvent(timerId)
|
||||
data class Pause(override val timerId: Int, val duration: Long) : TimerEvent(timerId)
|
||||
data class Finish(override val timerId: Int, val duration: Long) : TimerEvent(timerId)
|
||||
data class Refresh(override val timerId: Int) : TimerEvent(timerId)
|
||||
object Refresh : TimerEvent(INVALID_TIMER_ID)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
android:id="@+id/timer_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/stopwatch_text_size"
|
||||
android:textSize="@dimen/alarm_text_size"
|
||||
app:layout_constraintEnd_toStartOf="@id/timer_reset"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -43,8 +43,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/timer_reset"
|
||||
android:layout_width="@dimen/stopwatch_button_small_size"
|
||||
android:layout_height="@dimen/stopwatch_button_small_size"
|
||||
android:layout_width="@dimen/timer_button_small_size"
|
||||
android:layout_height="@dimen/timer_button_small_size"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginEnd="@dimen/bigger_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
|
@ -59,8 +59,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/timer_play_pause"
|
||||
android:layout_width="@dimen/stopwatch_button_size"
|
||||
android:layout_height="@dimen/stopwatch_button_size"
|
||||
android:layout_width="@dimen/timer_button_size"
|
||||
android:layout_height="@dimen/timer_button_size"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<dimen name="min_widget_width">180dp</dimen>
|
||||
<dimen name="min_widget_resize_width">110dp</dimen>
|
||||
<dimen name="fab_list_bottom_padding">68dp</dimen>
|
||||
<dimen name="timer_button_small_size">50dp</dimen>
|
||||
<dimen name="timer_button_size">56dp</dimen>
|
||||
|
||||
<dimen name="clock_text_size">70sp</dimen>
|
||||
<dimen name="clock_text_size_smaller">60sp</dimen>
|
||||
|
|
Loading…
Reference in New Issue