aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/test/BottomAwareScrollView.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/test/BottomAwareScrollView.java')
-rw-r--r--tests/src/cgeo/geocaching/test/BottomAwareScrollView.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/test/BottomAwareScrollView.java b/tests/src/cgeo/geocaching/test/BottomAwareScrollView.java
new file mode 100644
index 0000000..5735241
--- /dev/null
+++ b/tests/src/cgeo/geocaching/test/BottomAwareScrollView.java
@@ -0,0 +1,36 @@
+package cgeo.geocaching.test;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ScrollView;
+
+public class BottomAwareScrollView extends ScrollView {
+
+ private boolean isAtBottom = true;
+
+ public BottomAwareScrollView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public BottomAwareScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public BottomAwareScrollView(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+ View lastChildView = getChildAt(getChildCount() - 1);
+ int diff = (lastChildView.getBottom() - (getHeight() + getScrollY()));
+ isAtBottom = diff <= 0;
+ super.onScrollChanged(l, t, oldl, oldt);
+ }
+
+ public boolean isAtBottom() {
+ return isAtBottom;
+ }
+
+}