├── .gitignore
├── EdgeEffectOverride
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── uk
│ │ └── co
│ │ └── androidalliance
│ │ └── edgeeffectoverride
│ │ ├── ContextWrapperEdgeEffect.java
│ │ ├── ExpandableListView.java
│ │ ├── GridView.java
│ │ ├── HorizontalScrollView.java
│ │ ├── ListView.java
│ │ ├── MulticastOnScrollListener.java
│ │ ├── ScrollView.java
│ │ ├── Spinner.java
│ │ ├── ViewPager.java
│ │ └── WebView.java
│ └── res
│ ├── drawable-hdpi-v19
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-hdpi
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-mdpi-v19
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-mdpi
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-xhdpi-v19
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-xhdpi
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── drawable-xxhdpi-v19
│ ├── overscroll_edge.png
│ └── overscroll_glow.png
│ ├── values-v19
│ └── defaults.xml
│ └── values
│ ├── attrs.xml
│ └── defaults.xml
├── EdgeEffectOverrideSample
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ └── uk
│ │ └── co
│ │ └── androidalliance
│ │ └── edgeeffectoverride
│ │ └── sample
│ │ ├── ExpandableListViewActivity.java
│ │ ├── GridViewActivity.java
│ │ ├── ListViewActivity.java
│ │ ├── MainActivity.java
│ │ ├── ScrollViewActivity.java
│ │ ├── ViewPagerActivity.java
│ │ └── WebViewActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable-xxxhdpi
│ └── ic_launcher.png
│ ├── layout
│ ├── activity_main.xml
│ ├── expandablelistview_layout.xml
│ ├── gridview_layout.xml
│ ├── listview_layout.xml
│ ├── scrollview_layout.xml
│ ├── viewpager_layout.xml
│ └── webview_layout.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── maven_push.gradle
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Eclipse
2 | .project
3 | .classpath
4 | .settings
5 | .checkstyle
6 |
7 | # IntelliJ IDEA
8 | .idea
9 | *.iml
10 | *.ipr
11 | *.iws
12 | classes
13 | gen-external-apklibs
14 |
15 | # Gradle
16 | .gradle
17 | build
18 |
19 | # Maven
20 | target
21 | release.properties
22 | pom.xml.*
23 |
24 | # Ant
25 | bin
26 | gen
27 | build.xml
28 | ant.properties
29 | local.properties
30 | proguard.cfg
31 | proguard-project.txt
32 |
33 | # Other
34 | .DS_Store
35 | tmp
--------------------------------------------------------------------------------
/EdgeEffectOverride/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | repositories {
4 | mavenCentral()
5 | }
6 |
7 | android {
8 | compileSdkVersion 21
9 | buildToolsVersion '21.0.2'
10 |
11 | defaultConfig {
12 | minSdkVersion 10
13 | targetSdkVersion 16
14 |
15 | versionName project.VERSION_NAME
16 | versionCode Integer.parseInt(project.VERSION_CODE)
17 | }
18 | }
19 |
20 | dependencies {
21 | compile 'com.android.support:support-v4:18.0.+'
22 | }
23 |
24 | // directions for mvn-push: https://github.com/chrisbanes/gradle-mvn-push
25 | //apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
--------------------------------------------------------------------------------
/EdgeEffectOverride/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=Edge Effect Override - Library
2 | POM_ARTIFACT_ID=edgeeffectoverride
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/ContextWrapperEdgeEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.ContextWrapper;
20 | import android.content.res.AssetManager;
21 | import android.content.res.Configuration;
22 | import android.content.res.Resources;
23 | import android.graphics.PorterDuff;
24 | import android.graphics.drawable.Drawable;
25 | import android.util.DisplayMetrics;
26 | import android.util.Log;
27 |
28 | public class ContextWrapperEdgeEffect extends ContextWrapper {
29 |
30 | private ResourcesEdgeEffect mResourcesEdgeEffect;
31 | private int mColor;
32 | private Drawable mEdgeDrawable;
33 | private Drawable mGlowDrawable;
34 |
35 | public ContextWrapperEdgeEffect(Context context) {
36 | this(context, 0);
37 | }
38 |
39 | public ContextWrapperEdgeEffect(Context context, int color) {
40 | super(context);
41 | mColor = color;
42 | Resources resources = context.getResources();
43 | mResourcesEdgeEffect = new ResourcesEdgeEffect(resources.getAssets(), resources.getDisplayMetrics(), resources.getConfiguration());
44 | }
45 |
46 | public void setEdgeEffectColor(int color) {
47 | mColor = color;
48 | if (mEdgeDrawable != null) mEdgeDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
49 | if (mGlowDrawable != null) mGlowDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
50 | }
51 |
52 | @Override
53 | public Resources getResources() {
54 | return mResourcesEdgeEffect;
55 | }
56 |
57 | private class ResourcesEdgeEffect extends Resources {
58 | private int overscroll_edge = getPlatformDrawableId("overscroll_edge");
59 | private int overscroll_glow = getPlatformDrawableId("overscroll_glow");
60 |
61 | public ResourcesEdgeEffect(AssetManager assets, DisplayMetrics metrics, Configuration config) {
62 | //super(metrics, localConfiguration);
63 | super(assets, metrics, config);
64 | }
65 |
66 | private int getPlatformDrawableId(String name) {
67 | try {
68 | int i = ((Integer) Class.forName("com.android.internal.R$drawable").getField(name).get(null)).intValue();
69 | return i;
70 | } catch (ClassNotFoundException e) {
71 | Log.e("[ContextWrapperEdgeEffect].getPlatformDrawableId()", "Cannot find internal resource class");
72 | return 0;
73 | } catch (NoSuchFieldException e1) {
74 | Log.e("[ContextWrapperEdgeEffect].getPlatformDrawableId()", "Internal resource id does not exist: " + name);
75 | return 0;
76 | } catch (IllegalArgumentException e2) {
77 | Log.e("[ContextWrapperEdgeEffect].getPlatformDrawableId()", "Cannot access internal resource id: " + name);
78 | return 0;
79 | } catch (IllegalAccessException e3) {
80 | Log.e("[ContextWrapperEdgeEffect].getPlatformDrawableId()", "Cannot access internal resource id: " + name);
81 | }
82 | return 0;
83 | }
84 |
85 | @Override
86 | public Drawable getDrawable(int resId) throws Resources.NotFoundException {
87 | Drawable ret = null;
88 | if (resId == this.overscroll_edge) {
89 | mEdgeDrawable = ContextWrapperEdgeEffect.this.getBaseContext().getResources().getDrawable(R.drawable.overscroll_edge);
90 | ret = mEdgeDrawable;
91 | } else if (resId == this.overscroll_glow) {
92 | mGlowDrawable = ContextWrapperEdgeEffect.this.getBaseContext().getResources().getDrawable(R.drawable.overscroll_glow);
93 | ret = mGlowDrawable;
94 | } else return super.getDrawable(resId);
95 |
96 | if (ret != null) {
97 | ret.setColorFilter(mColor, PorterDuff.Mode.MULTIPLY);
98 | }
99 |
100 | return ret;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/ExpandableListView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class ExpandableListView extends android.widget.ExpandableListView {
23 |
24 | public ExpandableListView(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public ExpandableListView(Context context, AttributeSet attrs) {
29 | this(context, attrs, android.R.attr.expandableListViewStyle);
30 | }
31 |
32 | public ExpandableListView(Context context, AttributeSet attrs, int defStyle) {
33 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
34 | init(context, attrs, defStyle);
35 | }
36 |
37 | private void init(Context context, AttributeSet attrs, int defStyle){
38 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
39 |
40 | if (attrs != null) {
41 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
42 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
43 | a.recycle();
44 | }
45 | setEdgeEffectColor(color);
46 | }
47 |
48 | public void setEdgeEffectColor(int edgeEffectColor){
49 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/GridView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class GridView extends android.widget.GridView {
23 |
24 | private OnScrollListener mLegacyOnScrollListener;
25 | private final MulticastOnScrollListener mMulticastOnScrollListener = new MulticastOnScrollListener();
26 |
27 | public GridView(Context context) {
28 | this(context, null);
29 | }
30 |
31 | public GridView(Context context, AttributeSet attrs) {
32 | this(context, attrs, android.R.attr.gridViewStyle);
33 | }
34 |
35 | public GridView(Context context, AttributeSet attrs, int defStyle) {
36 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
37 | init(context, attrs, defStyle);
38 | }
39 |
40 | private void init(Context context, AttributeSet attrs, int defStyle) {
41 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
42 |
43 | if (attrs != null) {
44 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
45 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
46 | a.recycle();
47 | }
48 | setEdgeEffectColor(color);
49 | }
50 |
51 | public void setOnScrollListener(OnScrollListener listener) {
52 | if (listener != null) {
53 | checkPrecondition(mLegacyOnScrollListener == null);
54 | mLegacyOnScrollListener = listener;
55 | addOnScrollListener(mLegacyOnScrollListener);
56 | } else if (mLegacyOnScrollListener != null) {
57 | removeOnScrollListener(mLegacyOnScrollListener);
58 | mLegacyOnScrollListener = null;
59 | }
60 | }
61 |
62 | public void setEdgeEffectColor(int edgeEffectColor) {
63 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
64 | }
65 |
66 | public void addOnScrollListener(OnScrollListener listener) {
67 | mMulticastOnScrollListener.add(listener);
68 | }
69 |
70 | public void clearOnScrollListeners() {
71 | mMulticastOnScrollListener.clear();
72 | }
73 |
74 | public void removeOnScrollListener(OnScrollListener listener) {
75 | mMulticastOnScrollListener.remove(listener);
76 | }
77 |
78 | void checkPrecondition(boolean state) {
79 | if (!state) {
80 | throw new IllegalStateException();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/HorizontalScrollView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.annotation.TargetApi;
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.os.Build;
22 | import android.util.AttributeSet;
23 |
24 | public class HorizontalScrollView extends android.widget.HorizontalScrollView {
25 |
26 | public static final int SCROLL_RIGHT = 1;
27 | public static final int SCROLL_LEFT = 2;
28 | private OnScrollChangedListener mOnScrollChangedListener;
29 |
30 | public HorizontalScrollView(Context context) {
31 | this(context, null);
32 | }
33 |
34 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
35 | public HorizontalScrollView(Context context, AttributeSet attrs) {
36 | super(new ContextWrapperEdgeEffect(context), attrs);
37 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
38 | init(context, attrs, android.R.attr.horizontalScrollViewStyle);
39 | } else {
40 | init(context, attrs, 0);
41 | }
42 | }
43 |
44 | public HorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
45 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
46 | init(context, attrs, defStyle);
47 | }
48 |
49 | private void init(Context context, AttributeSet attrs, int defStyle) {
50 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
51 |
52 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
53 |
54 | setEdgeEffectColor(color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color));
55 |
56 | a.recycle();
57 | }
58 |
59 | public void setEdgeEffectColor(int edgeEffectColor) {
60 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
61 | }
62 |
63 | @Override
64 | protected void onScrollChanged(int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
65 | super.onScrollChanged(scrollX, scrollY, oldScrollX, oldScrollY);
66 | if (mOnScrollChangedListener != null) {
67 | int scrollDirection;
68 | if (scrollX > oldScrollX) {
69 | scrollDirection = SCROLL_RIGHT;
70 | } else {
71 | scrollDirection = SCROLL_LEFT;
72 | }
73 | mOnScrollChangedListener.onScrollChanged(this, scrollDirection, scrollX, scrollY, oldScrollX, oldScrollY);
74 | }
75 | }
76 |
77 | public void setOnScrollChangedListener(OnScrollChangedListener listener) {
78 | mOnScrollChangedListener = listener;
79 | }
80 |
81 | public interface OnScrollChangedListener {
82 | void onScrollChanged(HorizontalScrollView scrollView, int scrollDirection, int scrollX, int scrollY, int oldScrollX, int oldScrollY);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/ListView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class ListView extends android.widget.ListView {
23 |
24 | private OnScrollListener mLegacyOnScrollListener;
25 | private final MulticastOnScrollListener mMulticastOnScrollListener = new MulticastOnScrollListener();
26 |
27 | public ListView(Context context) {
28 | this(context, null);
29 | }
30 |
31 | public ListView(Context context, AttributeSet attrs) {
32 | this(context, attrs, android.R.attr.listViewStyle);
33 | }
34 |
35 | public ListView(Context context, AttributeSet attrs, int defStyle) {
36 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
37 | init(context, attrs, defStyle);
38 | }
39 |
40 | private void init(Context context, AttributeSet attrs, int defStyle) {
41 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
42 |
43 | if (attrs != null) {
44 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
45 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
46 | a.recycle();
47 | }
48 | setEdgeEffectColor(color);
49 | }
50 |
51 | public void setOnScrollListener(OnScrollListener listener) {
52 | if (listener != null) {
53 | checkPrecondition(mLegacyOnScrollListener == null);
54 | mLegacyOnScrollListener = listener;
55 | addOnScrollListener(mLegacyOnScrollListener);
56 | } else if (mLegacyOnScrollListener != null) {
57 | removeOnScrollListener(mLegacyOnScrollListener);
58 | mLegacyOnScrollListener = null;
59 | }
60 | }
61 |
62 | public void setEdgeEffectColor(int edgeEffectColor) {
63 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
64 | }
65 |
66 | public void addOnScrollListener(OnScrollListener listener) {
67 | mMulticastOnScrollListener.add(listener);
68 | }
69 |
70 | public void clearOnScrollListeners() {
71 | mMulticastOnScrollListener.clear();
72 | }
73 |
74 | public void removeOnScrollListener(OnScrollListener listener) {
75 | mMulticastOnScrollListener.remove(listener);
76 | }
77 |
78 | void checkPrecondition(boolean state) {
79 | if (!state) {
80 | throw new IllegalStateException();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/MulticastOnScrollListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.widget.AbsListView;
19 |
20 | import java.util.HashSet;
21 | import java.util.Iterator;
22 | import java.util.Set;
23 |
24 | public class MulticastOnScrollListener implements AbsListView.OnScrollListener {
25 |
26 | private Set mListeners = new HashSet();
27 |
28 | public MulticastOnScrollListener add(AbsListView.OnScrollListener scrollListener) {
29 | mListeners.add(scrollListener);
30 | return this;
31 | }
32 |
33 | public MulticastOnScrollListener clear() {
34 | mListeners.clear();
35 | return this;
36 | }
37 |
38 | @Override
39 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
40 | Iterator iterator = this.mListeners.iterator();
41 | while (iterator.hasNext()) {
42 | ((AbsListView.OnScrollListener) iterator.next()).onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
43 | }
44 | }
45 |
46 | @Override
47 | public void onScrollStateChanged(AbsListView view, int scrollState) {
48 | Iterator iterator = mListeners.iterator();
49 | while (iterator.hasNext()) {
50 | ((AbsListView.OnScrollListener) iterator.next()).onScrollStateChanged(view, scrollState);
51 | }
52 | }
53 |
54 | public MulticastOnScrollListener remove(AbsListView.OnScrollListener scrollListener) {
55 | mListeners.remove(scrollListener);
56 | return this;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/ScrollView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class ScrollView extends android.widget.ScrollView {
23 |
24 | public static final int SCROLL_UP = 1;
25 | public static final int SCROLL_DOWN = 2;
26 | private OnScrollChangedListener mOnScrollChangedListener;
27 |
28 |
29 | public ScrollView(Context context) {
30 | this(context, null);
31 | }
32 |
33 | public ScrollView(Context context, AttributeSet attrs) {
34 | this(context, attrs, android.R.attr.scrollViewStyle);
35 | }
36 |
37 | public ScrollView(Context context, AttributeSet attrs, int defStyle) {
38 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
39 | init(context, attrs, defStyle);
40 | }
41 |
42 | private void init(Context context, AttributeSet attrs, int defStyle) {
43 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
44 |
45 | if (attrs != null) {
46 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
47 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
48 | a.recycle();
49 | }
50 | setEdgeEffectColor(color);
51 | }
52 |
53 | public void setEdgeEffectColor(int edgeEffectColor) {
54 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
55 | }
56 |
57 | @Override
58 | protected void onScrollChanged(int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
59 | super.onScrollChanged(scrollX, scrollY, oldScrollX, oldScrollY);
60 | if (mOnScrollChangedListener != null) {
61 | int scrollDirection;
62 | if (scrollY > oldScrollY) {
63 | scrollDirection = SCROLL_UP;
64 | } else {
65 | scrollDirection = SCROLL_DOWN;
66 | }
67 | mOnScrollChangedListener.onScrollChanged(this, scrollDirection, scrollX, scrollY, oldScrollX, oldScrollY);
68 | }
69 | }
70 |
71 | public void setOnScrollChangedListener(OnScrollChangedListener listener) {
72 | mOnScrollChangedListener = listener;
73 | }
74 |
75 | public interface OnScrollChangedListener {
76 | void onScrollChanged(ScrollView scrollView, int scrollDirection, int scrollX, int scrollY, int oldScrollX, int oldScrollY);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/Spinner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class Spinner extends android.widget.Spinner {
23 |
24 | public Spinner(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public Spinner(Context context, AttributeSet attrs) {
29 | this(context, attrs, android.R.attr.dropDownSpinnerStyle);
30 | }
31 |
32 | public Spinner(Context context, AttributeSet attrs, int defStyle) {
33 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
34 | init(context, attrs, defStyle);
35 | }
36 |
37 | private void init(Context context, AttributeSet attrs, int defStyle) {
38 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
39 |
40 | if (attrs != null) {
41 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
42 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
43 | a.recycle();
44 | }
45 | setEdgeEffectColor(color);
46 | }
47 |
48 | public void setEdgeEffectColor(int edgeEffectColor) {
49 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/ViewPager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 |
22 | public class ViewPager extends android.support.v4.view.ViewPager {
23 |
24 | public ViewPager(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public ViewPager(Context context, AttributeSet attrs) {
29 | super(new ContextWrapperEdgeEffect(context), attrs);
30 | init(context, attrs, 0);
31 | }
32 |
33 | private void init(Context context, AttributeSet attrs, int defStyle) {
34 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
35 |
36 | if (attrs != null) {
37 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
38 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
39 | a.recycle();
40 | }
41 | setEdgeEffectColor(color);
42 | }
43 |
44 | public void setEdgeEffectColor(int edgeEffectColor) {
45 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/java/uk/co/androidalliance/edgeeffectoverride/WebView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Android Alliance, LTD
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.androidalliance.edgeeffectoverride;
17 |
18 | import android.annotation.TargetApi;
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.util.AttributeSet;
22 |
23 | public class WebView extends android.webkit.WebView {
24 |
25 | public WebView(Context context) {
26 | this(context, null);
27 | }
28 |
29 | public WebView(Context context, AttributeSet attrs) {
30 | this(context, attrs, android.R.attr.webViewStyle);
31 | }
32 |
33 | public WebView(Context context, AttributeSet attrs, int defStyle) {
34 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle);
35 | init(context, attrs, defStyle);
36 | }
37 |
38 | @Deprecated
39 | @TargetApi(11)
40 | public WebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
41 | super(new ContextWrapperEdgeEffect(context), attrs, defStyle, privateBrowsing);
42 | init(context, attrs, defStyle);
43 | }
44 |
45 | private void init(Context context, AttributeSet attrs, int defStyle) {
46 | int color = context.getResources().getColor(R.color.default_edgeeffect_color);
47 |
48 | if (attrs != null) {
49 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EdgeEffectView, defStyle, 0);
50 | color = a.getColor(R.styleable.EdgeEffectView_edgeeffect_color, color);
51 | a.recycle();
52 | }
53 | setEdgeEffectColor(color);
54 | }
55 |
56 | public void setEdgeEffectColor(int edgeEffectColor) {
57 | ((ContextWrapperEdgeEffect) getContext()).setEdgeEffectColor(edgeEffectColor);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-hdpi-v19/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-hdpi-v19/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-hdpi-v19/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-hdpi-v19/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-hdpi/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-hdpi/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-hdpi/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-hdpi/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-mdpi-v19/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-mdpi-v19/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-mdpi-v19/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-mdpi-v19/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-mdpi/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-mdpi/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-mdpi/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-mdpi/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xhdpi-v19/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xhdpi-v19/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xhdpi-v19/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xhdpi-v19/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xhdpi/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xhdpi/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xhdpi/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xhdpi/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xxhdpi-v19/overscroll_edge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xxhdpi-v19/overscroll_edge.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/drawable-xxhdpi-v19/overscroll_glow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverride/src/main/res/drawable-xxhdpi-v19/overscroll_glow.png
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/values-v19/defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF717171
4 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/EdgeEffectOverride/src/main/res/values/defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF33B5E5
4 |
--------------------------------------------------------------------------------
/EdgeEffectOverrideSample/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | ____ _
3 | / ___| __ _ _ __ ___ _ __ | | ___
4 | \___ \ / _` | '_ ` _ \| '_ \| |/ _ \
5 | ___) | (_| | | | | | | |_) | | __/
6 | |____/ \__,_|_| |_| |_| .__/|_|\___|
7 | |_|
8 | */
9 | apply plugin: 'com.android.application'
10 |
11 | repositories {
12 | mavenCentral()
13 | }
14 |
15 | android {
16 | compileSdkVersion 21
17 | buildToolsVersion '21.0.2'
18 |
19 | defaultConfig {
20 | minSdkVersion 11
21 | targetSdkVersion 16
22 | }
23 | }
24 |
25 | dependencies {
26 | compile 'com.android.support:support-v4:18.0.+'
27 | compile project(':EdgeEffectOverride')
28 | }
29 |
--------------------------------------------------------------------------------
/EdgeEffectOverrideSample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
33 |
34 |
37 |
38 |
41 |
42 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/EdgeEffectOverrideSample/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AndroidAlliance/EdgeEffectOverride/0c41dc3c867d7bf662f550acf028a635f04a83ba/EdgeEffectOverrideSample/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/EdgeEffectOverrideSample/src/main/java/uk/co/androidalliance/edgeeffectoverride/sample/ExpandableListViewActivity.java:
--------------------------------------------------------------------------------
1 | package uk.co.androidalliance.edgeeffectoverride.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.widget.SimpleExpandableListAdapter;
6 |
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | import uk.co.androidalliance.edgeeffectoverride.ExpandableListView;
13 |
14 | public class ExpandableListViewActivity extends Activity {
15 |
16 | private static final String NAME = "NAME";
17 | private static final String IS_EVEN = "IS_EVEN";
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.expandablelistview_layout);
23 |
24 | //this comes from android samples
25 | List