Skip to content

Commit

Permalink
[TIMOB-25678] Amend hasActivityTransitions() for transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Oct 17, 2018
1 parent 2c2cd2f commit 0ce1ddd
Showing 1 changed file with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2013 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -39,6 +39,8 @@
import android.util.Pair;
import android.view.Display;
import android.view.View;
import android.view.Window;

// clang-format off
@Kroll.proxy(propertyAccessors = {
TiC.PROPERTY_EXIT_ON_CLOSE,
Expand Down Expand Up @@ -477,11 +479,27 @@ public KrollProxy getParentForBubbling()
return super.getParentForBubbling();
}

// clang-format off
@Kroll.method
@Override
public void add(Object args)
// clang-format on
{
super.add(args);

if (args instanceof TiViewProxy) {
TiViewProxy child = (TiViewProxy) args;
if (child.getProperties().containsKeyAndNotNull(TiC.PROPERTY_TRANSITION_NAME)) {
addSharedElement(child, child.getProperties().getString(TiC.PROPERTY_TRANSITION_NAME));
}
}
}

@Kroll.method
public void addSharedElement(TiViewProxy view, String transitionName)
{
if (LOLLIPOP_OR_GREATER) {
TiUIView v = view.peekView();
TiUIView v = view.getOrCreateView();
if (v != null) {
Pair<View, String> p = new Pair<View, String>(v.getNativeView(), transitionName);
sharedElementPairs.add(p);
Expand All @@ -506,7 +524,7 @@ public void removeAllSharedElements()
@Nullable
protected Bundle createActivityOptionsBundle(Activity activity)
{
if (hasActivityTransitions()) {
if (hasActivityTransitions() && sharedElementPairs != null && !sharedElementPairs.isEmpty()) {
Bundle b = ActivityOptions
.makeSceneTransitionAnimation(
activity, sharedElementPairs.toArray(new Pair[sharedElementPairs.size()]))
Expand All @@ -522,7 +540,16 @@ protected Bundle createActivityOptionsBundle(Activity activity)
*/
protected boolean hasActivityTransitions()
{
final boolean animated = TiConvert.toBoolean(getProperties(), TiC.PROPERTY_ANIMATED, true);
return (LOLLIPOP_OR_GREATER && animated && sharedElementPairs != null && !sharedElementPairs.isEmpty());
if (LOLLIPOP_OR_GREATER) {
final Window win = getActivity() != null ? getActivity().getWindow() : null;
final boolean isAnimated = TiConvert.toBoolean(getProperties(), TiC.PROPERTY_ANIMATED, true);
final boolean hasSharedElements = sharedElementPairs != null && !sharedElementPairs.isEmpty();
final boolean hasTransitions =
win != null
&& (win.getEnterTransition() != null || win.getExitTransition() != null
|| win.getReenterTransition() != null || win.getReturnTransition() != null);
return isAnimated && (hasSharedElements || hasTransitions);
}
return false;
}
}

0 comments on commit 0ce1ddd

Please sign in to comment.