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

Commit 39e991bd authored by Chet Haase's avatar Chet Haase Committed by Android Git Automerger
Browse files

am f8525caf: am 02e4c3a1: Merge "Cache Scene objects by layout ID on the scene root" into klp-dev

* commit 'f8525caf':
  Cache Scene objects by layout ID on the scene root
parents 6b32736f f8525caf
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -36,27 +36,28 @@ public final class Scene {
    private ViewGroup mSceneRoot;
    private ViewGroup mLayout; // alternative to layoutId
    Runnable mEnterAction, mExitAction;
    private static ThreadLocal<SparseArray<Scene>> sScenes = new ThreadLocal<SparseArray<Scene>>();

    /**
     * Returns a Scene described by the resource file associated with the given
     * <code>layoutId</code> parameter. If such a Scene has already been created,
     * that same Scene will be returned. This caching of layoutId-based scenes enables
     * sharing of common scenes between those created in code and those referenced
     * by {@link TransitionManager} XML resource files.
     * <code>layoutId</code> parameter. If such a Scene has already been created for
     * the given <code>sceneRoot</code>, that same Scene will be returned.
     * This caching of layoutId-based scenes enables sharing of common scenes
     * between those created in code and those referenced by {@link TransitionManager}
     * XML resource files.
     *
     * @param sceneRoot The root of the hierarchy in which scene changes
     * and transitions will take place.
     * @param layoutId The id of a standard layout resource file.
     * @param context The context used in the process of inflating
     * the layout resource.
     * @return
     * @return The scene for the given root and layout id
     */
    public static Scene getSceneForLayout(ViewGroup sceneRoot, int layoutId, Context context) {
        SparseArray<Scene> scenes = sScenes.get();
        SparseArray<Scene> scenes = (SparseArray<Scene>) sceneRoot.getTag(
                com.android.internal.R.id.scene_layoutid_cache);
        if (scenes == null) {
            scenes = new SparseArray<Scene>();
            sScenes.set(scenes);
            sceneRoot.setTag(com.android.internal.R.id.scene_layoutid_cache, scenes);
        }
        Scene scene = scenes.get(layoutId);
        if (scene != null) {
+1 −0
Original line number Diff line number Diff line
@@ -81,4 +81,5 @@
  <item type="id" name="popup_submenu_presenter" />
  <item type="id" name="action_bar_spinner" />
  <item type="id" name="current_scene" />
  <item type="id" name="scene_layoutid_cache" />
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
  <java-symbol type="id" name="clearDefaultHint" />
  <java-symbol type="id" name="contentPanel" />
  <java-symbol type="id" name="current_scene" />
  <java-symbol type="id" name="scene_layoutid_cache" />
  <java-symbol type="id" name="customPanel" />
  <java-symbol type="id" name="datePicker" />
  <java-symbol type="id" name="day" />