Comments (3)
As a quick fix I made following changes in view in my project:
private Handler spinHandler = new SpinHandler(this);
private static class SpinHandler extends Handler {
private final WeakReference<ProgressWheelView> viewRef;
public SpinHandler(final ProgressWheelView view) {
viewRef = new WeakReference<ProgressWheelView>(view);
}
/**
* This is the code that will increment the progress variable
* and so spin the wheel
*/
@Override
public void handleMessage(final Message msg) {
final ProgressWheelView progressView = viewRef.get();
if (progressView != null) {
progressView.invalidate();
if (progressView.isSpinning) {
progressView.progress += progressView.spinSpeed;
if (progressView.progress > 360) {
progressView.progress = 0;
}
progressView.spinHandler.sendEmptyMessageDelayed(0, progressView.delayMillis);
}
}
}
}
and:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
setupBounds();
setupPaints();
invalidate();
if (isSpinning) {
spinHandler.sendEmptyMessage(0);
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
spinHandler.removeMessages(0);
}
With static handler nothing will stop gc from collecting view, and when it gets collected handler will just stop sending messages to itself.
When we get detached, but not yet gced we should stop messages so they won't lag the ui thread (since there could be a gridview with progresses and if each will send messages every now and then ui will lag)
from progresswheel.
Aleksandrs, that looks great. I can't see any problems with the code.
You should submit a pull request for review.
Thanks.
from progresswheel.
Hi guys,
I have problems in a Samsung Galasy S3 device. I start spinning the progressWheel without problems, and even stopping it, if the screen of the phone turns off, the mobile phone doesn't come back from that state.
I have also tried on a HTC One X and works like a charm.
Some ideas?
from progresswheel.
Related Issues (20)
- How to install this ? HOT 2
- Change bar color dynamically HOT 1
- How do I create it programmatically
- Set attribute values programnatically won't change the visual of the progress wheel. HOT 2
- Why I can't use this library on eclipse HOT 1
- GitHub release HOT 2
- License ambiguity HOT 1
- How to set bar to full width (whole radius) ?
- Attribute "radius" has already been defined HOT 2
- How to set maximum value for the progress bar? HOT 1
- Gradle dependency causes AndroidManifest errors HOT 8
- Double application HOT 15
- AndroidStudio suggests different xmlns:ProgressWheel HOT 3
- Text with multiple line doesn't work HOT 4
- Failed to resolve Gradle dependency
- readme's demo is wrong HOT 2
- Add to Home Widget
- barLength conflicts HOT 10
- Cancellable HOT 1
- ERROR: Failed to resolve: ProgressWheel 1.2 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from progresswheel.