lopspower / circularprogressbar Goto Github PK
View Code? Open in Web Editor NEWCreate circular ProgressBar in Android ⭕
License: Apache License 2.0
Create circular ProgressBar in Android ⭕
License: Apache License 2.0
Spawn in a position outside the map results in a kick. For example x * 6000, y * 6000
When I set cpb_indeterminate_mode="true"
then cpb_progress_direction is always to_left
, even if I set it to to_right
it also displays toLeft
Caused by kotlin.UninitializedPropertyAccessException
lateinit property initialState has not been initialized
br.com.simplepass.loadingbutton.customViews.CircularProgressButton.access$getInitialState$p (CircularProgressButton.kt:21)
br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke (CircularProgressButton.kt:70)
br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke (CircularProgressButton.kt:21)
kotlin.SynchronizedLazyImpl.getValue (LazyJVM.kt:74)
br.com.simplepass.loadingbutton.customViews.CircularProgressButton.getMorphAnimator (Fonte desconhecida:7)
br.com.simplepass.loadingbutton.customViews.CircularProgressButton.dispose (CircularProgressButton.kt:171)
java.lang.reflect.Method.invoke (Method.java)
androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback (ClassesInfoCache.java:216)
androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent (ClassesInfoCache.java:194)
androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks (ClassesInfoCache.java:185)
androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged (ReflectiveGenericLifecycleObserver.java:37)
androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent (LifecycleRegistry.java:361)
androidx.lifecycle.LifecycleRegistry.backwardPass (LifecycleRegistry.java:316)
androidx.lifecycle.LifecycleRegistry.sync (LifecycleRegistry.java:334)
androidx.lifecycle.LifecycleRegistry.moveToState (LifecycleRegistry.java:145)
androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent (LifecycleRegistry.java:131)
androidx.lifecycle.ReportFragment.dispatch (ReportFragment.java:68)
androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreDestroyed (ReportFragment.java:216)
android.app.Activity.dispatchActivityPreDestroyed (Activity.java:1415)
android.app.Activity.performDestroy (Activity.java:8174)
android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1342)
android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5019)
android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:5063)
android.app.servertransaction.DestroyActivityItem.execute (DestroyActivityItem.java:44)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2044)
android.os.Handler.dispatchMessage (Handler.java:107)
android.os.Looper.loop (Looper.java:224)
android.app.ActivityThread.main (ActivityThread.java:7562)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
i am find a progress.setMax() code but couldnt find it.Thanks
Your lib dependency :
./gradlew -q app:dependencies
Output:
debugCompileClasspath - Compile classpath for compilation 'developDebug' (target (androidJvm)).
+--- com.mikhaellopez:circularprogressbar:3.0.3
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 -> 1.3.72 (*)
As title.
After using proguard, the animation is not working.
Thanks.
In gradient, there's a option to set startColor, centerColor and endColor. How do i set center color using this library ?
Tell me please how to put text in center of progressbar
Hi can we add the center color inside the circle ?
How to set progress max .
It is possible if yes then how and not then what is max progress.
For some reason, the build fails while using databindng feature with the progress bar.
I was using the binding variable to set the progress value on the progressbar. The code is as follows
<com.mikhaellopez.circularprogressbar.CircularProgressBar
app:cpb_background_progressbar_color="@color/c_light_orange_ff"
app:cpb_background_progressbar_width="@dimen/spacing_4"
.
.
.
app:cpb_progress="@{vm.progress}"
/>
Above vm
is the binding variable and progress
is a variable of type Float
I use databinding in my project heavily and every other databinding expression is working fine. Only when I try to use the binding with CircularProgressBar
the build fails with a very generic error BindingClassImpl symbol not found
(Thanks DataBinding it was very helpful -_- ).
Can someone please guide what am I probably doing wrong?
Environment Specs:
Dependency:implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
Android Studio: 3.5.2
Gradle Distribution: gradle-5.1.1-all.zip
Mac Os: Catalina 10.15.5
Model: MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)
Processor: 2.3 GHz Dual-Core Intel Core i5
this library could be support loading ?
Hello.
In this code:
progressBar.setOnProgressChangedListener(new CircularProgressBar.ProgressChangeListener() {
@Override
public void onProgressChanged(float progress) {
}
});
float progress
I need to work with Double number but your library just support float progress number.
Is there any way to fix it?
CircularProgressBar.kt
has use of Handler()
which is deprecated
Line 144
indeterminateModeHandler = Handler()
Sometimes the progress bar animation duration is just half of the specified duration.
How to restart animation?
setProgressWithAnimation(float progress) just do nothing.
I need it for progressbar for recyclerview because I don't want recreate progressbar just to show animation.
It works fine with android pie but when tested on lower devices it fails to render
Does it support Android Databinding?
Thanks to your open source, I now want to set ‘’cpb_progressbar_color‘’ to a gradient color effect. To make it look cooler, how do I do it?
While in animation we cant set the progress programatically
the issue is present in stack over flow by another user as well :
https://stackoverflow.com/questions/56200896/unable-to-destroy-activity-failed-to-call-observer-method
when you call Activity.finish(), the app crashes and these are the logs that holds the root cause :
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property initialState has not been initialized
at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.access$getInitialState$p(CircularProgressButton.kt:21)
at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:70)
at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:21)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.getMorphAnimator(Unknown Source:7)
at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.dispose(CircularProgressButton.kt:171)
at java.lang.reflect.Method.invoke(Native Method)
at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216)
at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194)
at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185)
at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:316)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:123)
at androidx.lifecycle.ReportFragment.onDestroy(ReportFragment.java:108)
at android.app.Fragment.performDestroy(Fragment.java:2870)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1424)
at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1554)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1616)
at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3044)
at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3024)
at android.app.FragmentController.dispatchDestroy(FragmentController.java:244)
at android.app.Activity.performDestroy(Activity.java:7251)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1249)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4492)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4523)
at android.app.ActivityThread.-wrap5(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1683)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6701)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
When you set the indeterminateMode
to true
you spawn a handler that continuously updates the state of the progress bar.
var indeterminateMode = false
set(value) {
field = value
onIndeterminateModeChangeListener?.invoke(field)
progressIndeterminateMode = 0f
progressDirectionIndeterminateMode = ProgressDirection.TO_RIGHT
startAngleIndeterminateMode = DEFAULT_START_ANGLE
indeterminateModeHandler?.removeCallbacks(indeterminateModeRunnable)
progressAnimator?.cancel()
indeterminateModeHandler = Handler()
if (field) {
indeterminateModeHandler?.post(indeterminateModeRunnable)
}
}
The problem is that this handler gets cleared only in onDetachedFromWindow
. Hence you get the leak if the view was never attached.
ObjectAnimator uses reflection to call its method, which won't work if a user proguards their application. Either ignore this class for proguard, or check if ValueAnimator can be used. Example:
ValueAnimator animator = ValueAnimator.ofFloat(currentAngle, newAngle);
animator.setDuration(duration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
...
invalidate();
}
});
animator.start();
How to Implement circular Progress bar into Arc ProgressBar....
Add possibility to change DEFAULT_ANIMATION_DURATION, because I want to create indeterminate ProgressBar, but in result "loading" process looks like it is slow
Is it possible to add gradient on the progress bar colours ?
is it possible to add a thumb on the edge of the progress? just like the one in seekbar.
maybe ObjectAnimator automatically set the progress not work,so should add a update Listener?
can't build project.
it finish with error :
Error:(2) Attribute "progress" has already been defined
Any plans to support indeterminate mode ? or offset ?
It looks quite simple to implement, would you take a pull request for this functionality ?
Thanks
How i can get Progress State ?
i used :
CircularProgressBar circularProgressBar = view.findViewById(R.id.cpg_verify_code_fragment);
circularProgressBar.setProgressWithAnimation(100, 120000);
I need to know how many steps passed And how many reminds, progress And duration ?
How can one listen for when the progress is completed?
<com.mikhaellopez.circularprogressbar.CircularProgressBar
android:id="@+id/progress_bar"
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_40sdp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="visible"
app:cpb_background_progressbar_color="@android:color/transparent"
app:cpb_background_progressbar_width="2dp"
app:cpb_indeterminate_mode="true"
app:cpb_progress_direction="to_right"
app:cpb_progressbar_color="@color/white"
app:cpb_progressbar_width="6dp"/>
I think there is a small bug in this library. For example: when you set the max progress to 20 and the progress to 15, then set the max progress to 10 and the progress to 5, the actual progress will be set to 10 because of this line.
This is a very easy fix, just change if (progress ...
to if (value ...
so that it checks the actual progress you set.
The use case where i am facing this is in a recyclerview. Here i have different max progress and progress values in each entry for a leveling system. As rows get recycled the max progress is changed before the progress.
A quick workaround (without changing the library) is to set the progress to 0 before changing the maxProgress.
public class CircularProgressBarExtended extends CircularProgressBar {
private ObjectAnimator objectAnimator;
public CircularProgressBarExtended(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setProgressWithAnimation(float progress, int duration, TimeInterpolator interpolator) {
objectAnimator = ObjectAnimator.ofFloat(this, "progress", progress);
objectAnimator.setDuration(duration);
objectAnimator.setInterpolator(interpolator);
objectAnimator.start();
}
public void cancelAnimation(){
if(objectAnimator != null){
objectAnimator.cancel();
}
}
}
Is there a way for animation to be set from 0 to the progress level or vice-versa?
When I use circularProgressBar.setProgressWithAnimation(65f, 1000);
I get error - "Wrong 2nd argument type, found int, required Java.lang.long "
Is it possible to use CircularProgressBar as CountDown progressbar automatically ?
or should to set it manually ?
hi.
i don't set progress in xml with data binding??
please help me!
<com.mikhaellopez.circularprogressbar.CircularProgressBar android:id="@+id/pb_improvement_fragmentStateProfile" android:layout_width="wrap_content" android:layout_height="0dp" android:scrollbarFadeDuration="1000" app:cpb_background_progressbar_color="@color/shadowOrange" app:cpb_background_progressbar_width="5dp" app:cpb_progress="@{data.improvementPercent}" app:cpb_progress_direction="to_right" app:cpb_progressbar_color="@color/orange" app:cpb_progressbar_width="5dp" app:cpb_round_border="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" />
i try by any type of variable(int,float,...),but not working
Hello, Jcenter is bound to shut down soon. Please place your library on MavenCentral for it to be used :)
When I make:
./gradlew -q app:dependencies
Your lib has kotlin dependency
+--- com.mikhaellopez:circularprogressbar:3.0.3
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 -> 1.3.60 (*)
But lib rxanimation doesn't
+--- com.mikhaellopez:rxanimation:0.0.7
This library is in version 3.0.2
Why don't you create a Release?
Progress bar cannot cast from a parent Constraint Layout!
Hello,
I define the CircularProgressBar in the Kotlin class and not in the xml file. In the previous versions I was able to initialize it passing null as attributeSet while with the new version I can't. Can you please make it possible to initialize it with a null attributeSet parameter again?
Many thanks for your time.
when i set the root layout to relative layout progress bar goes off itself when app started .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.