Closed amir14a closed 3 years ago
this bug only occurs when app:sv_withTremble="true"
I've tested it with Android 11 and 10 on a PointerSpeedometer where withTremble = true
and it has onSpeedChangeListener
.
The test is passed when I call speedTo(speed = 100, moveDuration = 6000)
it did take 6 seconds as expected!
Please share your speedview and the piece of code that runs it.
My Xml Code:
<com.github.anastr.speedviewlib.SpeedView
android:id="@+id/speedView"
android:layout_width="@dimen/_180sdp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:paddingTop="@dimen/_12sdp"
app:sv_centerCircleColor="@color/black"
app:sv_centerCircleRadius="@dimen/_5sdp"
app:sv_endDegree="360"
app:sv_indicator="KiteIndicator"
app:sv_indicatorColor="@color/black"
app:sv_indicatorWidth="@dimen/_4sdp"
app:sv_markColor="@color/black"
app:sv_markStyle="ROUND"
app:sv_markWidth="1dp"
app:sv_marksNumber="3"
app:sv_maxSpeed="100"
app:sv_minSpeed="0"
app:sv_speedTextColor="@android:color/transparent"
app:sv_speedometerMode="TOP"
app:sv_startDegree="180"
app:sv_tickNumber="5"
app:sv_tickPadding="@dimen/_minus12sdp"
app:sv_trembleDegree="1"
app:sv_trembleDuration="250"
app:sv_unit="%"
app:sv_unitTextColor="@android:color/transparent" />
My kotlin code:
@AndroidEntryPoint
class ProfileFragment : BaseFragment<FragmentProfileBinding, ProfileFragmentViewModel>(
R.layout.fragment_profile,
ProfileFragmentViewModel::class.java
) {
val score: MutableLiveData<String> by lazy { MutableLiveData("0") }
val scoreColor: MutableLiveData<Int> by lazy { MutableLiveData() }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val sm = binding.speedView
sm.clearSections()
sm.addSections(
listOf(
Section(0f, .5f, Color.parseColor("#F2726F"), sm.speedometerWidth),
Section(.5f, .75f, Color.parseColor("#FFC532"), sm.speedometerWidth),
Section(.75f, 1f, Color.parseColor("#62B58F"), sm.speedometerWidth),
)
)
sm.onSpeedChangeListener = { gauge, _, isT ->
score.value = gauge.currentIntSpeed.toString()
}
sm.onSectionChangeListener = { _, newSection ->
scoreColor.value = newSection?.color
}
Handler().postDelayed({
sm.speedTo(79f,50000)
}, 1000)
}
}
Again, not shown on my devices.
May you try the older version 1.5.5
.
No, My version is Version 1.5.51 I will test again in the next 2-3 days and share the full code and APK file
Hi again, I have prepared a repo to report the problem: https://github.com/amir14a/SpeedViewTest/
This problem is very confusing this only occurs when app:sv_withTremble="true" and use viewPager2 with FragmentStateAdapter, and use databinding to observe a liveDate which is changed by onSpeedChangeListener :O (see above repo)
The far I've got for this issue is that onVisibilityAggregated
method called frequently. In this method we expect a visibility change and stop/run tremble animation, but ViewPager2 keep calling it with visible = true
.
Something isn't right about this behavior, it could be an issue in ViewPager2. Make sure that you apply ViewPager2 correctly and try to contact Android Developers about this issue.
We've released version 1.5.52
, and I'm assuming that it'll fix your issue. I hope if anyone can confirm.
Describe the bug When I set onSpeedChangeListener or onSpeedTextListener , and after that I use speedTo function with moveDuration parameter, this parameter not apply and speed meter moves fast.
Smartphone : Mi A2