Bug 1254468 - Post: Remove unused TransitionsTracker r=sebastian

This is no longer needed - TransitionAwareCursorLoaderCallbacks was the only
consumer - it was removed as it caused race conditions. The ideal future solution
is probably to use recyclerviews to avoid jank, rather than trying to wait for
transitions to happen.

It's also extremely difficult to use this correctly - the
TransitionAwareCursorLoaderCallbacks simply held the cursor that would usually
be swapped in onLoadFinished until transitions have finished (which is incorrect,
since cursors need to be swapped in before onLoadFinished returns). It's hard to imagine
any alternative solutions, short of avoiding loading cursors in the first place (which
isn't too useful, since cursor loading happens in the background, at which point the UI
status is irrelevant), or hacking the CursorLoader to not return from its worker thread
until UI transitions are done (which would require a new thread-safe implementation of
TransitionsTracker), or maybe even hacking Android Framework's AsyncTaskLoader  to not run Loader.deliverResult
while transitions are running (which seems awfully brittle and hacky).

MozReview-Commit-ID: 3JWDcznYL4Y

--HG--
extra : rebase_source : 1b4f52d84b21e4d93ebfb2d5c8d633c6ad12cf8e
extra : histedit_source : 2625e74aa08efa085733d3d34c6a2fa8550cf9f9
This commit is contained in:
Andrzej Hunt 2016-03-15 09:06:46 -07:00
parent a208332101
commit 2f56539665
8 changed files with 0 additions and 143 deletions

View File

@ -15,7 +15,6 @@ import org.mozilla.gecko.DynamicToolbar.VisibilityTransition;
import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
import org.mozilla.gecko.Tabs.TabEvents;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.TransitionsTracker;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.db.BrowserDB;
@ -1469,7 +1468,6 @@ public class BrowserApp extends GeckoApp
final Animator alphaAnimator = ObjectAnimator.ofFloat(mDoorhangerOverlay, "alpha", 1);
alphaAnimator.setDuration(250);
TransitionsTracker.track(alphaAnimator);
alphaAnimator.start();
}
@ -1479,8 +1477,6 @@ public class BrowserApp extends GeckoApp
final Animator alphaAnimator = ObjectAnimator.ofFloat(mDoorhangerOverlay, "alpha", 0);
alphaAnimator.setDuration(200);
TransitionsTracker.track(alphaAnimator);
alphaAnimator.start();
}
@ -2289,8 +2285,6 @@ public class BrowserApp extends GeckoApp
final PropertyAnimator animator = new PropertyAnimator(250);
animator.setUseHardwareLayer(false);
TransitionsTracker.track(animator);
mBrowserToolbar.startEditing(url, animator);
final boolean isUserSearchTerm = selectedTab != null &&

View File

@ -1,119 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.animation;
import android.animation.Animator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
import org.mozilla.gecko.util.ThreadUtils;
/**
* {@link TransitionsTracker} provides a simple API to avoid running layout code
* during UI transitions. You should use it whenever you need to time-shift code
* that will likely trigger a layout traversal during an animation.
*/
public class TransitionsTracker {
private static final ArrayList<Runnable> pendingActions = new ArrayList<>();
private static int transitionCount;
private static final PropertyAnimationListener propertyAnimatorListener =
new PropertyAnimationListener() {
@Override
public void onPropertyAnimationStart() {
pushTransition();
}
@Override
public void onPropertyAnimationEnd() {
popTransition();
}
};
private static final Animator.AnimatorListener animatorListener =
new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
pushTransition();
}
@Override
public void onAnimationEnd(Animator animation) {
popTransition();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
};
private static void runPendingActions() {
ThreadUtils.assertOnUiThread();
final int size = pendingActions.size();
for (int i = 0; i < size; i++) {
pendingActions.get(i).run();
}
pendingActions.clear();
}
public static void pushTransition() {
ThreadUtils.assertOnUiThread();
transitionCount++;
}
public static void popTransition() {
ThreadUtils.assertOnUiThread();
transitionCount--;
if (transitionCount < 0) {
throw new IllegalStateException("Invalid transition stack update");
}
if (transitionCount == 0) {
runPendingActions();
}
}
public static boolean areTransitionsRunning() {
ThreadUtils.assertOnUiThread();
return (transitionCount > 0);
}
public static void track(PropertyAnimator animator) {
ThreadUtils.assertOnUiThread();
animator.addPropertyAnimationListener(propertyAnimatorListener);
}
public static void track(Animator animator) {
ThreadUtils.assertOnUiThread();
animator.addListener(animatorListener);
}
public static boolean cancelPendingAction(Runnable action) {
ThreadUtils.assertOnUiThread();
return pendingActions.removeAll(Collections.singleton(action));
}
public static void runAfterTransitions(Runnable action) {
ThreadUtils.assertOnUiThread();
if (transitionCount == 0) {
action.run();
} else {
pendingActions.add(action);
}
}
}

View File

@ -17,7 +17,6 @@ import android.animation.ObjectAnimator;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.animation.TransitionsTracker;
import org.mozilla.gecko.util.Experiments;
/**
@ -80,8 +79,6 @@ public class FirstrunAnimationContainer extends LinearLayout {
}
});
TransitionsTracker.track(alphaAnimator);
alphaAnimator.start();
}

View File

@ -20,7 +20,6 @@ import android.animation.ObjectAnimator;
import org.mozilla.gecko.Restrictions;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.animation.TransitionsTracker;
import org.mozilla.gecko.home.HomePager.Decor;
import org.mozilla.gecko.home.TabMenuStrip;
@ -134,7 +133,6 @@ public class FirstrunPager extends ViewPager {
final AnimatorSet set = new AnimatorSet();
set.playTogether(alphaAnimator, translateAnimator);
set.setStartDelay(400);
TransitionsTracker.track(set);
set.start();
}

View File

@ -9,7 +9,6 @@ import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.animation.TransitionsTracker;
import android.annotation.TargetApi;
import android.content.Intent;
@ -108,7 +107,6 @@ public class TabQueuePrompt extends Locales.LocaleAwareActivity {
final AnimatorSet set = new AnimatorSet();
set.playTogether(alphaAnimator, translateAnimator);
set.setStartDelay(400);
TransitionsTracker.track(set);
set.start();
}
@ -134,7 +132,6 @@ public class TabQueuePrompt extends Locales.LocaleAwareActivity {
final AnimatorSet set = new AnimatorSet();
set.playTogether(buttonsAlphaAnimator, messagesAlphaAnimator);
TransitionsTracker.track(set);
set.addListener(new AnimatorListenerAdapter() {

View File

@ -26,7 +26,6 @@ import android.animation.ObjectAnimator;
import java.util.ArrayList;
import java.util.List;
import org.mozilla.gecko.animation.TransitionsTracker;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
@ -146,8 +145,6 @@ public class TabStripView extends TwoWayView {
animatorSet.setInterpolator(ANIM_INTERPOLATOR);
animatorSet.addListener(animatorListener);
TransitionsTracker.track(animatorSet);
animatorSet.start();
return true;
@ -198,8 +195,6 @@ public class TabStripView extends TwoWayView {
animatorSet.setInterpolator(ANIM_INTERPOLATOR);
animatorSet.addListener(animatorListener);
TransitionsTracker.track(animatorSet);
animatorSet.start();
return true;
@ -230,8 +225,6 @@ public class TabStripView extends TwoWayView {
animatorSet.setInterpolator(ANIM_INTERPOLATOR);
animatorSet.addListener(animatorListener);
TransitionsTracker.track(animatorSet);
animatorSet.start();
return true;

View File

@ -7,7 +7,6 @@ package org.mozilla.gecko.trackingprotection;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.R;
import org.mozilla.gecko.animation.TransitionsTracker;
import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.util.HardwareUtils;
@ -75,7 +74,6 @@ public class TrackingProtectionPrompt extends Locales.LocaleAwareActivity {
final AnimatorSet set = new AnimatorSet();
set.playTogether(alphaAnimator, translateAnimator);
set.setStartDelay(400);
TransitionsTracker.track(set);
set.start();
}

View File

@ -198,7 +198,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'animation/HeightChangeAnimation.java',
'animation/PropertyAnimator.java',
'animation/Rotate3DAnimation.java',
'animation/TransitionsTracker.java',
'animation/ViewHelper.java',
'ANRReporter.java',
'AppNotificationClient.java',