Giter Club home page Giter Club logo

expectanim's Introduction

ExpectAnim

Android Arsenal CircleCI

Describe your animation and run !

Android app on Google Play

gif

new ExpectAnim()

                .expect(avatar)
                .toBe(
                    Expectations...
                )
                .toAnimation()
                .start();

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:expectanim:1.0.8'

This code describe the video above

new ExpectAnim()

                .expect(avatar)
                .toBe(
                        bottomOfParent().withMarginDp(16),
                        leftOfParent().withMarginDp(16),
                        width(40).toDp().keepRatio()
                )

                .expect(name)
                .toBe(
                        toRightOf(avatar).withMarginDp(16),
                        sameCenterVerticalAs(avatar),
                        toHaveTextColor(Color.WHITE)
                )

                .expect(subname)
                .toBe(
                        toRightOf(name).withMarginDp(5),
                        sameCenterVerticalAs(name),
                        toHaveTextColor(Color.WHITE)
                )

                .expect(follow)
                .toBe(
                        rightOfParent().withMarginDp(4),
                        bottomOfParent().withMarginDp(12),
                        toHaveBackgroundAlpha(0f)
                )

                .expect(message)
                .toBe(
                        aboveOf(follow).withMarginDp(4),
                        rightOfParent().withMarginDp(4),
                        toHaveBackgroundAlpha(0f)
                )

                .expect(bottomLayout)
                .toBe(
                        atItsOriginalPosition()
                )

                .expect(content)
                .toBe(
                        atItsOriginalPosition(),
                        visible()
                )

                .toAnimation()
                .setDuration(1500)

                .start();

Follow scroll

gif

Use setPercent to apply modify the current step of the animation

Exemple with a scrollview

this.expectAnimMove = new ExpectAnim()
                .expect(username)
                .toBe(
                        toRightOf(avatar).withMarginDp(16),
                        sameCenterVerticalAs(avatar),
                        alpha(0.5f)
                )

                .expect(avatar)
                .toBe(
                        topOfParent(),
                        leftOfParent().withMarginDp(16),
                        scale(0.5f, 0.5f)
                )
                .expect(follow)
                .toBe(
                        rightOfParent().withMarginDp(16),
                        sameCenterVerticalAs(avatar)
                )

                .expect(backbground)
                .toBe(
                        height(height).withGravity(Gravity.LEFT|Gravity.START, Gravity.TOP)
                )

                .toAnimation();

scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        final float percent = (scrollY * 1f) / v.getMaxScrollAmount();

        expectAnimMove.setPercent(percent);
    }
});

Concat

You can play an anim after one other using ExpectAnim.concat (static method)

ExpectAnim.concat(
                new ExpectAnim()
                        .expect(image1)
                        .toBe(
                                withCameraDistance(500f),
                                flippedHorizontally()
                        )
                        .toAnimation()
                        .setDuration(1000),
                new ExpectAnim()
                        .expect(image2)
                        .toBe(
                                withCameraDistance(1000f),
                                flippedVertically()
                        )
                        .toAnimation()
                        .setDuration(500)
                )
                .start()

Apply directly

Use setNow to apply directly the transformation

new ExpectAnim()
                .expect(view)
                .toBe(
                        outOfScreen(Gravity.BOTTOM)
                )
                .toAnimation()
                .setNow();

Reset

Use reset to return to the initial state of views

expectAnim.reset():

List of expectations

new ExpectAnim()
                .expect(view)
                .toBe(

                    //.withMargin(marginPx)
                    //.withMarginDp(margin)
                    //.withMarginDimen(R.dimen.margin)

                    toRightOf(view)
                    toLeftOf(view)
                    belowOf(view)
                    aboveOf(view)

                    atItsOriginalPosition()


                    sameCenterAs(view, horizontal, vertical)
                    sameCenterHorizontalAs(view)
                    sameCenterVerticalAs(view)
                    centerInParent(horizontal, vertical)
                    centerVerticalInParent()
                    centerHorizontalInParent()

                    centerBetweenViews(view1, view2, horizontal, vertical)
                    centerBetweenViewAndParent(otherView, horizontal, vertical, toBeOnRight, toBeOnBottom)

                    topOfParent()
                    rightOfParent()
                    bottomOfParent()
                    leftOfParent()

                    alignBottom(otherView)
                    alignTop(otherView)
                    alignLeft(otherView)
                    alignRight(otherView)

                    outOfScreen(gravitiy)  //Gravity.LEFT / Gravity.RIGHT / Gravity.TOP / Gravity.BOTTOM

                    alpha(alpha)
                    sameAlphaAs(otherView)
                    visible()
                    invisible()

                    //.keepRatio()
                    //.withGravity(horizontalGravity, verticalGravity)

                    atItsOriginalScale()

                    scale(scaleX, scaleY)
                    height(height)
                    width(width)
                    sameScaleAs(otherView)
                    sameWidthAs(otherView)
                    sameHeightAs(otherView)


                    toHaveTextColor(textColor)
                    toHaveBackgroundAlpha(alpha)

                    rotated(rotation)
                    vertical(bottomOfViewAtLeft)
                    atItsOriginalRotation()
                )

Proguard

-keep class com.github.florent37.expectanim.*{ *; }
-dontwarn com.github.florent37.expectanim.**

Changelog

1.0.7

Added startDelay

1.0.6

Added ExpectAnim.concat

1.0.4

Fixed listeners references

1.0.3

Alpha 0 force view to be INVISIBLE`

1.0.2

Added flips rotations

flippedHorizontally() flippedVertically() flippedHorizontallyAndVertically() withCameraDistance(1000f)

1.0.1

Added rotations

gif

Credits

Author: Florent Champigny

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2017 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

expectanim's People

Contributors

florent37 avatar gamedevllama avatar hugogresse avatar vjubert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expectanim's Issues

the background of user contents is not being resized

I saw your post on Google plus and found this lib a great resource to use in my future project, I forked and imported in Android Studio, I wanted the result as shown here

[gif

on my device I got this
some

the background of user contents is not being resized as shown in first git demo, how can I solve this issue please help...

Add posibility to make animations in queue order

Add posibility to make animations as queue
for example now to make animations in queue order I make this:

 new ExpectAnim()
                .expect(mButtonsView)
                .toBe(
                        Expectations.atItsOriginalPosition()
                ).toAnimation()
                .setDuration(1000)
                .setEndListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(ExpectAnim expectAnim) {
                        new ExpectAnim()
                                .expect(mPlayerMediaView)
                                .toBe(
                                        Expectations.visible()
                                )
                                .toAnimation()
                                .setDuration(1000)
                                .start();
                    }
                }).start();

Please make an builder(maybe like in rxjava) to make it easy for example:

ExpectAnim firstAnim = new ExpectAnim()
                .expect(mButtonsView)
                .toBe(
                        Expectations.atItsOriginalPosition()
                ).toAnimation()
                .setDuration(1000);
        
        ExpectAnim secondAnim = new ExpectAnim().expect(mPlayerMediaView)
                .toBe(
                        Expectations.visible()
                ).toAnimation()
                .setDuration(1000);

ExpectAnim commonAnim = firstAnim.concatWith(secondAnim);

OR

        ExpectAnim commonAnim = ExpectAnim.concat(firstAnim,secondAnim);
commonAnim.start();

Flash

Run soon after the flash and then back to the previous interface,My phone is Samsung 6.0 system

ExpectAnim listener method add removal may be more appropriate?

ExpectAnim listener method add removal may be more appropriate?
ExpectAnim Listener 或许加上对应的移除方法更合适
Like this :

  public ExpectAnim removeEndListener(AnimationEndListener listener) {
        this.endListeners.remove(listener);
        return this;
    }

    public ExpectAnim removeStartListener(AnimationStartListener listener) {
        this.startListeners.remove(listener);
        return this;
    }

Support other/mix animations

Hi.
Thank you for this great library, it makes writing animations extremely easy and saves a lot of time.
Could you please add some other animations like these ones or help me on how can I implement it?
And the possibility of mixing them together, like fading in a view while playing ZoomIn technique on it.
Again thanks for your great contribution :)

AnimationEndListener sometimes becomes null and onAnimationEnd is never called

AnimationEndListener sometimes becomes null in your lib at the line:

final AnimationEndListener listener = endListenerWeakReference.get();

For example

new ExpectAnim()
                .expect(mView)
                .toBe(
                       .atItsOriginalPosition()
                ).toAnimation()
                .setDuration(1000)
                .setEndListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(ExpectAnim expectAnim) {
//NB: sometimes AnimationEndListener is null in your lib and the method doesn't work
                        //do smth
                    }
                }).start();

Use it in other viewGrroup

change xml of activity_scroll from Framlayout to Linerlayout,change layout size when we scroll,and the animation of back is not at original location

Add method .setDelay(long period /*ms*/) for ExpectAnim

Currently we can only set Duration. But how to set delay before start?
expectation:

new ExpectAnim()
                        .expect(mPlayerMediaView)
                        .toBe(
                                Expectations.visible()
                        ).toAnimation()
                        .setDelay(500)//<-----
                        .setDuration(500)
                        .addStartListener(new AnimationStartListener() {
                    @Override
                    public void onAnimationStart(ExpectAnim expectAnim) {
                         startTime = System.currentTimeMillis()
                    }
                })
                        .addEndListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(ExpectAnim expectAnim) {
                       endTime = System.currentTimeMillis()
                        }
                })

Total time = Delay + Duration = 500+500 = 1000 ms. == endTime - startTime 

Add Visibility GONE when alpha is 0f

@florent37 please can you add an option that set the view visibility to GONE when use the
Expectations.alpha(0f) or Expectations.invisible?
This because a view with alpha 0f can be touched and clicked by user and send the onClick or touch events.

Thank you

How to autoresize view, sticked to another moved view?

Sorry for bad english. I have a problem - like in example with scrollView I need to resize my recyclerView list. But, only I can do - is to move it after another view. And it is not fill empty space (in layout xml it has constraints - height="0dp", Top_toBottomOf="animated_view", Bottom_toBottomOf="parent", weight="1"). I can use height method from expectAnim, but it scales, and I need to know new size for view, so, it's not a good variant.

Can you advice me thomething to solve this problem?

What about proguard?

Warning: com.github.florent37.expectanim.core.Expectations: can't find referenced class com.github.florent37.expectanim.core.Expectations$GravityIntDef

stop and end animation

Hi
1- I want to stop it in the middle of the animation In the same state , But how?
2- I want to finish the animation faster than the time it finishes , But how?
tanks

How to set height between view and parent?

How to set height between view and parent?
I tried Expectations.height(0), but it doesn'r recalculate new height:

            .expect(recyclerView)
            .toBe(
                Expectations.belowOf(contentLayout),Expectations.bottomOfParent(), Expectations.height(0)
            )

sameCenterHorizontalAs not work

@OverRide
public Float getCalculatedValueX(View viewToMove) {
if(horizontal) {

        final float x = viewCalculator.finalPositionLeftOfView(otherView);
        final float myWidth = viewToMove.getWidth() / 2f;
        final float hisWidth = viewCalculator.finalWidthOfView(otherView) / 2f;

        if (myWidth > hisWidth) {
            return x - myWidth + hisWidth;
        } else {
            return x - hisWidth + myWidth;                       [HERE]
        }
    } else return null;
}

does 'return x - hisWidth + myWidth' -> 'return x + hisWidth + myWidth' ?
I think + is right.

Add Expectations

Please can you add some expectations like translationX, translationY, translationZ?

Suggest adding proguard rules to readme

Getting the following error while using proguard.

Warning:com.github.florent37.expectanim.core.Expectations: can't find referenced class com.github.florent37.expectanim.core.Expectations$GravityIntDef

It can be fixed by adding the below lines in proguard-rules.pro file

-keep class com.github.florent37.expectanim.*{ *; }
-dontwarn com.github.florent37.expectanim.**

Suggest using neutral pronoun

I suggest renaming this:

atHisOriginalPosition()

to this:

atItsOriginalPosition()

In English objects don't have a gender, so using "his" to refer to a layout is not done.

Huge lag running the project

I'm not sure what I configure is wrong, but when I check out the project from Github, then run it in Android Emulator and on the real device, the animation runs with huge lag.

Width() with centerInParent() gets wrong

When I use width() with centerInParent() or any similar method, the new position does not take in account new width.

So instead of becoming center it is slightly misaligned because it still has old width.
Is this expected outcome or I am the only one getting it?

Gradle instruction readme.md fix

Hi there!

I love your library from the first sight. But it might be that there are users that won't be able to correctly install your app via gradle since the gradle compile statement is not correct in the readme.md file.

Instead of using
compile 'com.github.florent37:expectanim:v1.0.1'
the v is missing and it is stated to use
compile 'com.github.florent37:expectanim:1.0.1'

Keep on the great work!

Version 1.0.2 found on jitpack

Hi there! It's me again ;)

I tried to compile the newest version via the compile statement, but it won't find 1.0.2. Not sure what causes the issue, but it might be due a missing tag or something?

Visibility of view

Not an issue but on loading of screen invisible method displays view and then makes it invisible .

Views are blinking if call visible twice

for example:

public void exec(){
new ExpectAnim()
                .expect(mView)
                .toBe(
                       .visible()
                ).toAnimation().setNow();
}

if you call exec() twice view will be blinking

exec();
exec();

Add a check for example if (view.alpha!=100) perform animation

Does it work with Google Maps and ViewPager?

I have an activity (which contains the code to enlarge / minimise the layout) with a fragment at the bottom. It works fine with normal views, but if I change the fragment to a google maps fragment, there it will minimise the layout, but won't enlarge the map view at the bottom to fill the remaining space
Screen Shot 2019-03-19 at 6 50 38 PM

Documentation & margins

can you add documentation for the project or at-least for the public methods? I have two layouts in a frame layout with both widths as match_parent. I want to animate top layout to bottom and I achieved it. I want the animated view to have margin 10dp in left and right with width as match_parent. I tried it but can't achieve it. Can you please help.

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.