setProgressPercentage is not functional
Ryhat opened this issue · 9 comments
The progress bar number is rising but the background color is not.
I set shouldAnimate to false and it works normally
Could you post the code you used for the progress bar? Also what device and android level are you using? The progress bar should work with animations so if it isn't working for your configuration I'd like to fix that.
Hey @Ryhat could you post more info, or a video of your issue? I was unable to replicate the issue you described. If I can't get more details then I'll be closing out this issue soon.
Oops, didn't mean to hit close there. Keeping this open for a bit longer to potentially hear back from the OP
I'm so sorry that I haven't checked my mailbox for a long time. Here is my code for short.
I have a activity and service.
Activity for display and service for update position.
After I created this issue I found that my UI would freeze, but the service would keep running.
Then I change service to WorkManager
and nothing changes.
I try to change RoundedProgressBar
to normal ProgressBar
and it works fine.
activity
:
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessage(MessageEvent event) {
Log.d(TAG, "onMessageEvent: " + event.mMsg);
Log.d(TAG, "onMessageEvent: " + event.mPos);
Log.d(TAG, "onMessageEvent: " + event.mIsRunning);
Log.d(TAG, "onMessageEvent: " + event.mStatus);
}
boolean mBound = false;
WorkService mService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ufo);
progressBar = findViewById(R.id.progress_bar);
progressBar.setAnimationLength(100);
}
xml
<com.mackhartley.roundedprogressbar.RoundedProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:rpbAnimationLength="100"
app:rpbShowProgressText="true"
app:rpbTextSize="16sp"
app:rpbBgTextColor="@color/accent20"
/>
Hi Ryhat, thanks for the response. It's hard to tell, but from the looks of your code it seems like you might be trying to directly update the RoundedProgressBar
from a background thread. If that's the case, then you should avoid doing that on Android as that's not recommended. Here's a StackOverflow post with more info about how to safely update views with background threads: https://stackoverflow.com/a/5185155/5759305
If that is indeed the issue then this isn't a bug on the part of the RoundedProgressBar
library. However, please correct me if my above assumptions are wrong.
Sorry I'm not a professional Android Java programmer and may have made a very rookie mistake.
I am using eventbus
to pass my data. I checked the link and I realized that I used ThreadMode.BACKGROUND
but I should use ThreadMode.Main
.
Thank you for your patient reply and sorry for my poor English.
I still have a question. Why official ProgressBar
is working fine(I`ve been used 20+ days).
Haha no worries, I think your english is fine, you sound like a fluent speaker.
As for why the official progress bar works in this case I'm not sure, RoundedProgressBar
actually uses the "official" progress bar under the hood, it just adds a lot of tricks as well. In general very weird things happen when updating the UI from a background thread so it's hard to know what would be causing this issue.
From your other comment, it sounds like you were able to fix the problem which is great, so I'll close out this issue. If you're still having trouble and your code is on github feel free to send a link and I'll take a look. If it's something simple I'd be happy to take a look and help.