Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c732e4
commit 70ede0d
Showing
11 changed files
with
673 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Settings specified in this file will override any Gradle settings | ||
# configured through the IDE. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx10248m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
VERSION_NAME=0.0.2 | ||
VERSION_CODE=2 | ||
GROUP=com.github.flavienlaurent.discrollview | ||
|
||
POM_DESCRIPTION=Android library to import the discrollver pattern on Android | ||
POM_URL=https://github.com/flavienlaurent/discrollview | ||
POM_SCM_URL=https://github.com/flavienlaurent/discrollview | ||
POM_SCM_CONNECTION=scm:git@github.com:flavienlaurent/discrollview.git | ||
POM_SCM_DEV_CONNECTION=scm:git@github.com:flavienlaurent/discrollview.git | ||
POM_LICENCE_NAME=Apache License, Version 2.0 | ||
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0 | ||
POM_LICENCE_DIST=repo | ||
POM_DEVELOPER_ID=flavienlaurent | ||
POM_DEVELOPER_NAME=Flavien Laurent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,4 @@ android { | |
} | ||
} | ||
|
||
dependencies { | ||
} | ||
apply from: '../maven_push.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_NAME=Discrollview Library | ||
POM_ARTIFACT_ID=library | ||
POM_PACKAGING=aar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
lib/src/main/java/com/flavienlaurent/discrollview/lib/DiscrollViewContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.flavienlaurent.discrollview.lib; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
|
||
/** | ||
* | ||
*/ | ||
public class DiscrollViewContent extends LinearLayout { | ||
|
||
public DiscrollViewContent(Context context) { | ||
super(context); | ||
setOrientation(VERTICAL); | ||
} | ||
|
||
public DiscrollViewContent(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
setOrientation(VERTICAL); | ||
} | ||
|
||
public DiscrollViewContent(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
setOrientation(VERTICAL); | ||
} | ||
|
||
@Override | ||
public void addView(View child, int index, ViewGroup.LayoutParams params) { | ||
super.addView(asDiscrollvable(child, (LayoutParams) params), index, params); | ||
} | ||
|
||
private View asDiscrollvable(View child, LayoutParams lp) { | ||
if(! isDiscrollvable(lp)) { | ||
return child; | ||
} | ||
DiscrollvableView discrollvableChild = new DiscrollvableView(getContext()); | ||
discrollvableChild.setDiscrollveAlpha(lp.mDiscrollveAlpha); | ||
discrollvableChild.setDiscrollveTranslation(lp.mDiscrollveTranslation); | ||
discrollvableChild.setDiscrollveScaleX(lp.mDiscrollveScaleX); | ||
discrollvableChild.setDiscrollveScaleY(lp.mDiscrollveScaleY); | ||
discrollvableChild.setDiscrollveThreshold(lp.mDiscrollveThreshold); | ||
discrollvableChild.setDiscrollveFromBgColor(lp.mDiscrollveFromBgColor); | ||
discrollvableChild.setDiscrollveToBgColor(lp.mDiscrollveToBgColor); | ||
discrollvableChild.addView(child); | ||
return discrollvableChild; | ||
} | ||
|
||
private boolean isDiscrollvable(LayoutParams lp) { | ||
return lp.mDiscrollveAlpha || | ||
lp.mDiscrollveTranslation != -1 || | ||
lp.mDiscrollveScaleX || | ||
lp.mDiscrollveScaleY || | ||
(lp.mDiscrollveFromBgColor != -1 && lp.mDiscrollveToBgColor != -1); | ||
} | ||
|
||
@Override | ||
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { | ||
return p instanceof LayoutParams; | ||
} | ||
|
||
@Override | ||
protected LinearLayout.LayoutParams generateDefaultLayoutParams() { | ||
return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); | ||
} | ||
|
||
@Override | ||
public LinearLayout.LayoutParams generateLayoutParams(AttributeSet attrs) { | ||
return new LayoutParams(getContext(), attrs); | ||
} | ||
|
||
@Override | ||
protected LinearLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { | ||
return new LayoutParams(p.width, p.height); | ||
} | ||
|
||
public static class LayoutParams extends LinearLayout.LayoutParams { | ||
|
||
private int mDiscrollveFromBgColor; | ||
private int mDiscrollveToBgColor; | ||
private float mDiscrollveThreshold; | ||
public boolean mDiscrollveAlpha; | ||
public boolean mDiscrollveScaleX; | ||
public boolean mDiscrollveScaleY; | ||
private int mDiscrollveTranslation; | ||
|
||
public LayoutParams(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscrollView_LayoutParams); | ||
try { | ||
mDiscrollveAlpha = a.getBoolean(R.styleable.DiscrollView_LayoutParams_discrollve_alpha, false); | ||
mDiscrollveScaleX = a.getBoolean(R.styleable.DiscrollView_LayoutParams_discrollve_scaleX, false); | ||
mDiscrollveScaleY = a.getBoolean(R.styleable.DiscrollView_LayoutParams_discrollve_scaleY, false); | ||
mDiscrollveTranslation = a.getInt(R.styleable.DiscrollView_LayoutParams_discrollve_translation, -1); | ||
mDiscrollveThreshold = a.getFloat(R.styleable.DiscrollView_LayoutParams_discrollve_threshold, 0.0f); | ||
mDiscrollveFromBgColor = a.getColor(R.styleable.DiscrollView_LayoutParams_discrollve_fromBgColor, -1); | ||
mDiscrollveToBgColor = a.getColor(R.styleable.DiscrollView_LayoutParams_discrollve_toBgColor, -1); | ||
} finally { | ||
a.recycle(); | ||
} | ||
} | ||
|
||
public LayoutParams(int w, int h) { | ||
super(w, h); | ||
} | ||
} | ||
} |
Oops, something went wrong.