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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDetailScrollView.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDetailScrollView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDetailScrollView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDetailScrollView.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ecd9ef14cadebe1de3032ff8aebceb8b25be78a
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDetailScrollView.java
@@ -0,0 +1,73 @@
+// Copyright 2015 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.enhancedbookmarks;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ScrollView;
+
+import com.google.android.apps.chrome.R;
+
+/**
+ * Customized ScrollView used in EnhancedBookmarkDetailDialog. This ScrollView broadcasts scroll
+ * change events and computes height compensation value used in detail dialog.
+ */
+public class EnhancedBookmarkDetailScrollView extends ScrollView {
+
+ /**
+ * Listener for scroll change event of the scrollView.
+ */
+ public interface OnScrollListener {
+ void onScrollChanged(int y, int oldY);
+ }
+
+ private int mHeightCompensation;
+ // Maximum scroll amount by pixels in Y direction (height).
+ private int mMaximumScrollY;
+ private OnScrollListener mScrollListener;
+
+ public EnhancedBookmarkDetailScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mHeightCompensation =
+ getResources().getDimensionPixelSize(R.dimen.enhanced_bookmark_detail_image_height)
+ - getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow);
+ }
+
+ /**
+ * Sets scroll listener that is called whenever scrollY changes.
+ */
+ public void setOnScrollListener(OnScrollListener listener) {
+ mScrollListener = listener;
+ }
+
+ /**
+ * Gets height compensation, a fixed length that scroll view uses to extend its length if
+ * content is not long enough.
+ */
+ public int getHeightCompensation() {
+ return mHeightCompensation;
+ }
+
+ /**
+ * Gets the maximum value scrollY can be. MaximumScrollY should never be less than
+ * HeightCompensation.
+ */
+ public int getMaximumScrollY() {
+ return mMaximumScrollY;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int childHeight = getChildAt(0).getMeasuredHeight();
+ mMaximumScrollY = childHeight > getMeasuredHeight() ? childHeight - getMeasuredHeight() : 0;
+ }
+
+ @Override
+ protected void onScrollChanged(int x, int y, int oldx, int oldy) {
+ if (mScrollListener == null) return;
+ mScrollListener.onScrollChanged(y, oldy);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698