Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3372)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/DisplayStyleObserverAdapter.java

Issue 2654193002: [Android History] List item shadows and width constrained styling (Closed)
Patch Set: Changes from dgn@ and dfalcantara@ reviews Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/DisplayStyleObserverAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/DisplayStyleObserverAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/DisplayStyleObserverAdapter.java
deleted file mode 100644
index 1db900b09f19486503bb35ab92ed446ed8a7ba9e..0000000000000000000000000000000000000000
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/DisplayStyleObserverAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.ntp.cards;
-
-import android.view.View;
-
-import org.chromium.chrome.browser.ntp.DisplayStyleObserver;
-import org.chromium.chrome.browser.ntp.UiConfig;
-
-/**
- * Implementation of {@link DisplayStyleObserver} designed to play nicely with
- * {@link android.support.v7.widget.RecyclerView}. It will not notify of changes when the
- * associated view is not attached to the window.
- */
-public class DisplayStyleObserverAdapter
- implements DisplayStyleObserver, View.OnAttachStateChangeListener {
- private final DisplayStyleObserver mObserver;
-
- /** Current display style, gets updated as the UiConfig detects changes and notifies us. */
- @UiConfig.DisplayStyle
- private int mCurrentDisplayStyle;
-
- /**
- * Latest value that we transmitted to the adapted observer. If we didn't transfer any yet,
- * the value is null. @see UiConfig.DisplayStyle.
- */
- @UiConfig.DisplayStyle
- private Integer mNotifiedDisplayStyle;
-
- private boolean mIsViewAttached;
-
- /**
- * @param view the view whose lifecycle is tracked to determine when to not fire the
- * observer.
- * @param config the {@link UiConfig} object to subscribe to.
- * @param observer the observer to adapt. It's {#onDisplayStyleChanged} will be called when
- * the configuration changes, provided that {@code view} is attached to the
- * window.
- */
- public DisplayStyleObserverAdapter(View view, UiConfig config, DisplayStyleObserver observer) {
- mObserver = observer;
-
- // TODO(dgn): getParent() is not a good way to test that, but isAttachedToWindow()
- // requires API 19.
- mIsViewAttached = view.getParent() != null;
-
- view.addOnAttachStateChangeListener(this);
-
- // This call will also assign the initial value to |mCurrentDisplayStyle|
- config.addObserver(this);
- }
-
- @Override
- public void onDisplayStyleChanged(@UiConfig.DisplayStyle int newDisplayStyle) {
- mCurrentDisplayStyle = newDisplayStyle;
-
- if (!mIsViewAttached) return;
- if (mNotifiedDisplayStyle != null && mCurrentDisplayStyle == mNotifiedDisplayStyle) return;
-
- mNotifiedDisplayStyle = mCurrentDisplayStyle;
-
- mObserver.onDisplayStyleChanged(mCurrentDisplayStyle);
- }
-
- @Override
- public void onViewAttachedToWindow(View v) {
- mIsViewAttached = true;
- onDisplayStyleChanged(mCurrentDisplayStyle);
- }
-
- @Override
- public void onViewDetachedFromWindow(View v) {
- mIsViewAttached = false;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698