mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1254468 - Post: Remove unused TransitionsTracker r=sebastian a=ritu
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
This commit is contained in:
parent
e01296ef75
commit
6d2f532b6e
@ -16,7 +16,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.BrowserContract.Combined;
|
||||
@ -1485,7 +1484,6 @@ public class BrowserApp extends GeckoApp
|
||||
|
||||
final Animator alphaAnimator = ObjectAnimator.ofFloat(mDoorhangerOverlay, "alpha", 1);
|
||||
alphaAnimator.setDuration(250);
|
||||
TransitionsTracker.track(alphaAnimator);
|
||||
|
||||
alphaAnimator.start();
|
||||
}
|
||||
@ -1499,8 +1497,6 @@ public class BrowserApp extends GeckoApp
|
||||
final Animator alphaAnimator = ObjectAnimator.ofFloat(mDoorhangerOverlay, "alpha", 0);
|
||||
alphaAnimator.setDuration(200);
|
||||
|
||||
TransitionsTracker.track(alphaAnimator);
|
||||
|
||||
alphaAnimator.start();
|
||||
}
|
||||
|
||||
@ -2319,8 +2315,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 = !TextUtils.isEmpty(selectedTab.getUserRequested());
|
||||
|
@ -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 com.nineoldandroids.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);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ import com.nineoldandroids.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();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import com.nineoldandroids.view.ViewHelper;
|
||||
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;
|
||||
|
||||
@ -135,7 +134,6 @@ public class FirstrunPager extends ViewPager {
|
||||
final AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(alphaAnimator, translateAnimator);
|
||||
set.setStartDelay(400);
|
||||
TransitionsTracker.track(set);
|
||||
|
||||
set.start();
|
||||
}
|
||||
|
@ -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;
|
||||
@ -109,7 +108,6 @@ public class TabQueuePrompt extends Locales.LocaleAwareActivity {
|
||||
final AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(alphaAnimator, translateAnimator);
|
||||
set.setStartDelay(400);
|
||||
TransitionsTracker.track(set);
|
||||
|
||||
set.start();
|
||||
}
|
||||
@ -135,7 +133,6 @@ public class TabQueuePrompt extends Locales.LocaleAwareActivity {
|
||||
|
||||
final AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(buttonsAlphaAnimator, messagesAlphaAnimator);
|
||||
TransitionsTracker.track(set);
|
||||
|
||||
set.addListener(new AnimatorListenerAdapter() {
|
||||
|
||||
|
@ -26,7 +26,6 @@ import com.nineoldandroids.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;
|
||||
|
@ -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;
|
||||
|
||||
@ -76,7 +75,6 @@ public class TrackingProtectionPrompt extends Locales.LocaleAwareActivity {
|
||||
final AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(alphaAnimator, translateAnimator);
|
||||
set.setStartDelay(400);
|
||||
TransitionsTracker.track(set);
|
||||
|
||||
set.start();
|
||||
}
|
||||
|
@ -200,7 +200,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',
|
||||
|
Loading…
Reference in New Issue
Block a user