Code Monkey home page Code Monkey logo

Comments (5)

eku avatar eku commented on August 24, 2024

@zhanyongsheng any idea what could be the reason for this?

from brokenview.

metaphyze avatar metaphyze commented on August 24, 2024

I'm seeing the same issue on Android 8. Doesn't happen on Android 6.

from brokenview.

metaphyze avatar metaphyze commented on August 24, 2024

The problem seems to be in BrokenAnimator here:

        if (fraction > 0.8 && bPressed) {
            canReverse = false;
            setRepeatCount(1);
        }

Not exactly sure what the problem is, but I think this is where the repeated animation is set up.

from brokenview.

metaphyze avatar metaphyze commented on August 24, 2024

Here's a hack that gets around the repeating animation. It's probably not the best solution, but it works so I'll use it for now. In BrokenAnimator.draw change:

public boolean draw(Canvas canvas) {

    if (!isStarted()) {
        return false;
    }

    float fraction = getAnimatedFraction();

To this:

private HashMap<Integer,Float> stageToPercentageMap = new HashMap<>();

public boolean draw(Canvas canvas) {

    if (!isStarted()) {
        return false;
    }

    float whatAndroidThinksThePercentageIs = getAnimatedFraction();

    if (stageToPercentageMap.get(getStage()) == null ||
            stageToPercentageMap.get(getStage()) < whatAndroidThinksThePercentageIs)
    {
        stageToPercentageMap.put(getStage(),whatAndroidThinksThePercentageIs);
    }

    float fraction = stageToPercentageMap.get(getStage());

Android 8 seems to be running the animation too quickly and we end up getting a repeated FALLING state. Basically, this just makes sure that the percentage completion for each state is always going UP, not down.

from brokenview.

eku avatar eku commented on August 24, 2024

@metaphyze thx. How about a Pull Request, so the owner of this project will hopefully review and merge it.

from brokenview.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.