Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed default child item(circle image) in design #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions app/src/main/java/saulmm/myapplication/AvatarImageBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@SuppressWarnings("unused")
public class AvatarImageBehavior extends CoordinatorLayout.Behavior<CircleImageView> {

private final static float MIN_AVATAR_PERCENTAGE_SIZE = 0.3f;
private final static int EXTRA_FINAL_AVATAR_PADDING = 80;
private final static float MIN_AVATAR_PERCENTAGE_SIZE = 0.3f;
private final static int EXTRA_FINAL_AVATAR_PADDING = 80;

private final static String TAG = "behavior";
private final Context mContext;
Expand All @@ -22,13 +22,18 @@ public class AvatarImageBehavior extends CoordinatorLayout.Behavior<CircleImageV
private float mStartPosition;
private int mStartXPosition;
private float mStartToolbarPosition;
private int mStartYPosition;
private int mFinalYPosition;
private int finalHeight;
private int mStartHeight;
private int mFinalXPosition;

public AvatarImageBehavior(Context context, AttributeSet attrs) {
mContext = context;
init();

mFinalLeftAvatarPadding = context.getResources().getDimension(
R.dimen.spacing_normal);
R.dimen.spacing_normal);
}

private void init() {
Expand All @@ -39,12 +44,6 @@ private void bindDimensions() {
mAvatarMaxSize = mContext.getResources().getDimension(R.dimen.image_width);
}

private int mStartYPosition;

private int mFinalYPosition;
private int finalHeight;
private int mStartHeight;
private int mFinalXPosition;
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, CircleImageView child, View dependency) {
return dependency instanceof Toolbar;
Expand All @@ -58,10 +57,10 @@ public boolean onDependentViewChanged(CoordinatorLayout parent, CircleImageView
float expandedPercentageFactor = dependency.getY() / maxScrollDistance;

float distanceYToSubtract = ((mStartYPosition - mFinalYPosition)
* (1f - expandedPercentageFactor)) + (child.getHeight()/2);
* (1f - expandedPercentageFactor)) + (child.getHeight() / 2);

float distanceXToSubtract = ((mStartXPosition - mFinalXPosition)
* (1f - expandedPercentageFactor)) + (child.getWidth()/2);
* (1f - expandedPercentageFactor)) + (child.getWidth() / 2);

float heightToSubtract = ((mStartHeight - finalHeight) * (1f - expandedPercentageFactor));

Expand All @@ -79,10 +78,11 @@ public boolean onDependentViewChanged(CoordinatorLayout parent, CircleImageView

private void shouldInitProperties(CircleImageView child, View dependency) {
if (mStartYPosition == 0)
mStartYPosition = (int) (child.getY() + (child.getHeight() / 2));
//mStartYPosition = (int) (child.getY() + (child.getHeight() / 2));
mStartYPosition = (int) child.getY();

if (mFinalYPosition == 0)
mFinalYPosition = (dependency.getHeight() /2);
mFinalYPosition = (dependency.getHeight() / 2);

if (mStartHeight == 0)
mStartHeight = child.getHeight();
Expand All @@ -97,7 +97,7 @@ private void shouldInitProperties(CircleImageView child, View dependency) {
mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + (finalHeight / 2);

if (mStartToolbarPosition == 0)
mStartToolbarPosition = dependency.getY() + (dependency.getHeight()/2);
mStartToolbarPosition = dependency.getY() + (dependency.getHeight() / 2);
}

public int getStatusBarHeight() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.1.3'


}
Expand Down
19 changes: 10 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# 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
# org.gradle.parallel=true
#Fri Sep 16 10:05:41 EEST 2016
systemProp.https.proxyPort=3128
systemProp.http.proxyHost=10.0.0.78
systemProp.https.proxyHost=10.0.0.78
systemProp.http.proxyPort=3128