Skip to content
This repository was archived by the owner on Apr 19, 2018. It is now read-only.
This repository was archived by the owner on Apr 19, 2018. It is now read-only.

getViewTreeObserver and ObjectAnimator by using Nineoldandroids in api 8 doesn't work #70

@Jongz

Description

@Jongz

getViewTreeObserver() and ObjectAnimator by using Nineoldandroids in api 8 doesn't work.

It work in higher API (Ex. API 19)

Here is my code.

final LayoutInflater inflater = (LayoutInflater)Home.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMessage = (TextView) inflater.inflate(R.layout.refresh_message, null);
        mMessage.setBackgroundColor(getResources().getColor(R.color.holo_green_light));
        mMessage.setText(msg);

        getWindowManager().addView(mMessage, getActionBarLayoutParams());

        mMessage.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){

            @Override
            public void onGlobalLayout() {
                // Get the height of the view
                final int h = mMessage.getHeight();
                //Remove Global Layout Listener
                removeOnGlobalLayoutListener(mMessage,this);
                // Slide down from the top
                ObjectAnimator.ofFloat(mMessage, "translationY", -h, 0f).setDuration(250).start();
            }
        });

My LOGCAT ::

05-09 19:28:47.942      507-507/com.bis.org.auInsight E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.ClassCastException: android.view.ViewRoot
            at com.nineoldandroids.view.animation.AnimatorProxy.invalidateAfterUpdate(AnimatorProxy.java:245)
            at com.nineoldandroids.view.animation.AnimatorProxy.setTranslationY(AnimatorProxy.java:199)
            at com.nineoldandroids.animation.PreHoneycombCompat$5.setValue(PreHoneycombCompat.java:57)
            at com.nineoldandroids.animation.PreHoneycombCompat$5.setValue(PreHoneycombCompat.java:54)
            at com.nineoldandroids.util.FloatProperty.set(FloatProperty.java:43)
            at com.nineoldandroids.util.FloatProperty.set(FloatProperty.java:29)
            at com.nineoldandroids.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:967)
            at com.nineoldandroids.animation.ObjectAnimator.animateValue(ObjectAnimator.java:500)
            at com.nineoldandroids.animation.ValueAnimator.animationFrame(ValueAnimator.java:1139)
            at com.nineoldandroids.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:545)
            at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:928)
            at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:951)
            at com.nineoldandroids.animation.ObjectAnimator.start(ObjectAnimator.java:391)
            at com.bis.org.auInsight.Home$3.onGlobalLayout(Home.java:187)
            at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:549)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1094)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:123)
            at android.app.ActivityThread.main(ActivityThread.java:4627)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:521)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
            at dalvik.system.NativeStart.main(Native Method)

NOTE::

  1. I have test between API8 and API 19.

  2. I have test nineoldandroids (ObjectAnimator) in both API and it work.

  3. I have test ObjectAnimator and view that get from getViewTreeObserver()

RESULT API 19 - WORK!, API 8 - Force Close;
4) I have try solution from this guy [ http://stackoverflow.com/questions/19607703/nineoldandroids-animation-not-working-on-api10/19712846#19712846 ]

However, it solve my force close but still animation doesn't play and there're somethings wrong in animation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions