Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 867a8661 authored by Chet Haase's avatar Chet Haase
Browse files

Various fixes/cleanup in Scenes and Transitions

setDuration() wasn't handled correctly for TransitionGroup; it should
propagate the value to its children.

Also, videos with no ids were not being handled correctly. The transition code was
using the default id on those views (-1) to store start/end data about the view,
causing multiple non-id views to clobber values in the hashmaps. The correct approach
should be to ignore default id values - only store information about the view
instances, not about the unset ids.

Also, added a new test InterruptTest to be used to fix the current behavior of
not handling situations where new transitions start while old ones are still taking place.

Change-Id: I4e880bdbb33cc26d487bceb0d56e463e72f7621f
parent d1860798
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

@@ -42,6 +43,7 @@ public class Move extends Transition {
    int[] tempLocation = new int[2];
    boolean mResizeClip = false;
    boolean mReparent = false;
    private static final String LOG_TAG = "Move";

    private static RectEvaluator sRectEvaluator = new RectEvaluator();

@@ -114,6 +116,13 @@ public class Move extends Transition {
            int endHeight = endBottom - endTop;
            int numChanges = 0;
            if (startWidth != 0 && startHeight != 0 && endWidth != 0 && endHeight != 0) {
                if (Transition.DBG) {
                    Log.v(LOG_TAG, "Target = " + endValues.view);
                    Log.v(LOG_TAG, "    start bounds: " + startLeft + ", " + startTop + ", " +
                            startRight + ", " + startBottom);
                    Log.v(LOG_TAG, "    end bounds: " + endLeft + ", " + endTop + ", " +
                            endRight + ", " + endBottom);
                }
                if (startLeft != endLeft) ++numChanges;
                if (startTop != endTop) ++numChanges;
                if (startRight != endRight) ++numChanges;
+12 −4
Original line number Diff line number Diff line
@@ -534,14 +534,18 @@ public abstract class Transition {
                        captureValues(values, start);
                        if (start) {
                            mStartValues.put(view, values);
                            if (id >= 0) {
                                mStartIdValues.put(id, values);
                            }
                        } else {
                            mEndValues.put(view, values);
                            if (id >= 0) {
                                mEndIdValues.put(id, values);
                            }
                        }
                    }
                }
            }
            if (mTargets != null) {
                for (int i = 0; i < mTargets.length; ++i) {
                    View view = mTargets[i];
@@ -599,14 +603,18 @@ public abstract class Transition {
        if (start) {
            if (!isListViewItem) {
                mStartValues.put(view, values);
                if (id >= 0) {
                    mStartIdValues.put((int) id, values);
                }
            } else {
                mStartItemIdValues.put(id, values);
            }
        } else {
            if (!isListViewItem) {
                mEndValues.put(view, values);
                if (id >= 0) {
                    mEndIdValues.put((int) id, values);
                }
            } else {
                mEndItemIdValues.put(id, values);
            }
+22 −0
Original line number Diff line number Diff line
@@ -106,9 +106,31 @@ public class TransitionGroup extends Transition {
            int numTransitions = transitions.length;
            for (int i = 0; i < numTransitions; ++i) {
                mTransitions.add(transitions[i]);
                if (mDuration >= 0) {
                    transitions[0].setDuration(mDuration);
                }
            }
        }
    }

    /**
     * Setting a non-negative duration on a TransitionGroup causes all of the child
     * transitions (current and future) to inherit this duration.
     *
     * @param duration The length of the animation, in milliseconds.
     * @return This transitionGroup object.
     */
    @Override
    public Transition setDuration(long duration) {
        super.setDuration(duration);
        if (mDuration >= 0) {
            int numTransitions = mTransitions.size();
            for (int i = 0; i < numTransitions; ++i) {
                mTransitions.get(i).setDuration(duration);
            }
        }
        return this;
    }

    /**
     * Removes the specified child transition from this group.
+7 −0
Original line number Diff line number Diff line
@@ -205,6 +205,13 @@
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:label="InterruptionTest"
                  android:name="InterruptionTest">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

+45 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:id="@+id/container"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <RadioGroup android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
        <RadioButton android:id="@+id/scene1RB"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/state1"
                     android:onClick="onRadioButtonClicked"/>
        <RadioButton android:id="@+id/scene2RB"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/state2"
                     android:onClick="onRadioButtonClicked"/>
        <RadioButton android:id="@+id/scene3RB"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/state3"
                     android:onClick="onRadioButtonClicked"/>
        <RadioButton android:id="@+id/scene4RB"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/state4"
                     android:onClick="onRadioButtonClicked"/>
    </RadioGroup>

    <LinearLayout
            android:orientation="vertical"
            android:id="@+id/sceneRoot"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <include layout="@layout/interruption_inner_1"/>

    </LinearLayout>


</LinearLayout>
 No newline at end of file
Loading