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

Commit 606ce48b authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Register to receive onTrimMemory callbacks"

parents 35b38c04 34a676bd
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -383,6 +383,39 @@ public class WebView extends AbsoluteLayout
        }
    }

    private static class OnTrimMemoryListener implements ComponentCallbacks2 {
        private static OnTrimMemoryListener sInstance = null;

        static void init(Context c) {
            if (sInstance == null) {
                sInstance = new OnTrimMemoryListener(c.getApplicationContext());
            }
        }

        private OnTrimMemoryListener(Context c) {
            c.registerComponentCallbacks(this);
        }

        @Override
        public void onConfigurationChanged(Configuration newConfig) {
            // Ignore
        }

        @Override
        public void onLowMemory() {
            // Ignore
        }

        @Override
        public void onTrimMemory(int level) {
            if (DebugFlags.WEB_VIEW) {
                Log.d("WebView", "onTrimMemory: " + level);
            }
            WebView.nativeOnTrimMemory(level);
        }

    }

    // A final CallbackProxy shared by WebViewCore and BrowserFrame.
    private final CallbackProxy mCallbackProxy;

@@ -1195,6 +1228,8 @@ public class WebView extends AbsoluteLayout
    }

    private void init() {
        OnTrimMemoryListener.init(getContext());

        setWillNotDraw(false);
        setFocusable(true);
        setFocusableInTouchMode(true);