diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a5527f2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,8 @@ +# These are supported funding model platforms + +github: [UFreedom] +patreon: UFreedom +open_collective: Replace with a single Open Collective username +ko_fi: UFreedom +tidelift: UFreedom +custom: https://qr.alipay.com/paipai/personal.htm diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java index 2e5d019..ade15ec 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/Floating.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview; import android.app.Activity; @@ -62,7 +79,6 @@ public Floating(Activity activity){ public void startFloating(FloatingElement floatingElement) { - View anchorView = floatingElement.anchorView; View targetView = floatingElement.targetView; diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java index 644d911..d84fd8d 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingBuilder.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview; import android.support.annotation.LayoutRes; @@ -16,59 +33,59 @@ */ public class FloatingBuilder { - private FloatingElement floatingElement; + private FloatingElement mFloatingElement; public FloatingBuilder() { - floatingElement = new FloatingElement(); - floatingElement.targetViewLayoutResId = -1; + mFloatingElement = new FloatingElement(); + mFloatingElement.targetViewLayoutResId = -1; } public FloatingBuilder offsetX(int offsetX) { - floatingElement.offsetX = offsetX; + mFloatingElement.offsetX = offsetX; return this; } public FloatingBuilder offsetY(int offsetY) { - floatingElement.offsetY = offsetY; + mFloatingElement.offsetY = offsetY; return this; } public FloatingBuilder floatingTransition(FloatingTransition floatingTransition) { - floatingElement.floatingTransition = floatingTransition; + mFloatingElement.floatingTransition = floatingTransition; return this; } public FloatingBuilder anchorView(View view){ - floatingElement.anchorView = view; + mFloatingElement.anchorView = view; return this; } public FloatingBuilder targetView(View view) { - floatingElement.targetView = view; + mFloatingElement.targetView = view; return this; } public FloatingBuilder targetView(@LayoutRes int layResId) { - floatingElement.targetViewLayoutResId = layResId; + mFloatingElement.targetViewLayoutResId = layResId; return this; } public FloatingElement build() { - if (floatingElement.targetView == null && floatingElement.targetViewLayoutResId == -1) { + if (mFloatingElement.targetView == null && mFloatingElement.targetViewLayoutResId == -1) { throw new NullPointerException("TargetView should not be null"); } - if (floatingElement.anchorView == null){ + if (mFloatingElement.anchorView == null){ throw new NullPointerException("AnchorView should not be null"); } - if (floatingElement.floatingTransition == null) { - floatingElement.floatingTransition = new ScaleFloatingTransition(); + if (mFloatingElement.floatingTransition == null) { + mFloatingElement.floatingTransition = new ScaleFloatingTransition(); } - return floatingElement; + return mFloatingElement; } } diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java index a0a8daf..542fb0c 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/FloatingElement.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview; import android.view.View; diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java index 1670d50..218cafe 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/CurveFloatingPathTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.effect; import android.animation.Animator; @@ -20,25 +37,25 @@ public class CurveFloatingPathTransition extends BaseFloatingPathTransition { - private Path path; + private Path mPath; public CurveFloatingPathTransition() { } public CurveFloatingPathTransition(Path path) { - this.path = path; + this.mPath = path; } @Override public FloatingPath getFloatingPath() { - if (path == null){ - path = new Path(); - path.moveTo(0, 0); - path.quadTo(-100, -200, 0, -300); - path.quadTo(200, -400, 0, -500); + if (mPath == null){ + mPath = new Path(); + mPath.moveTo(0, 0); + mPath.quadTo(-100, -200, 0, -300); + mPath.quadTo(200, -400, 0, -500); } - return FloatingPath.create(path, false); + return FloatingPath.create(mPath, false); } @Override diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java index bd5a070..1ad5259 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/ScaleFloatingTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.effect; import android.animation.ObjectAnimator; @@ -16,33 +33,33 @@ public class ScaleFloatingTransition implements FloatingTransition { - private long duration; - private double bounciness; - private double speed; + private long mDuration; + private double mBounciness; + private double mSpeed; public ScaleFloatingTransition() { - duration = 1000; - bounciness = 10; - speed = 15; + mDuration = 1000; + mBounciness = 10; + mSpeed = 15; } public ScaleFloatingTransition(long duration) { - this.duration = duration; - bounciness = 10; - speed = 15; + this.mDuration = duration; + mBounciness = 10; + mSpeed = 15; } public ScaleFloatingTransition(long duration, double bounciness, double speed) { - this.duration = duration; - this.bounciness = bounciness; - this.speed = speed; + this.mDuration = duration; + this.mBounciness = bounciness; + this.mSpeed = speed; } @Override public void applyFloating(final YumFloating yumFloating) { ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f); - alphaAnimator.setDuration(duration); + alphaAnimator.setDuration(mDuration); alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { @@ -51,7 +68,7 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) { }); alphaAnimator.start(); - SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f,bounciness, speed) + SpringHelper.createWithBouncinessAndSpeed(0.0f, 1.0f, mBounciness, mSpeed) .reboundListener(new SimpleReboundListener(){ @Override public void onReboundUpdate(double currentValue) { diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/TranslateFloatingTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/TranslateFloatingTransition.java index 910259d..5b299a5 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/TranslateFloatingTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/effect/TranslateFloatingTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.effect; import android.animation.Animator; @@ -18,25 +35,25 @@ public class TranslateFloatingTransition implements FloatingTransition { - private float translateY; - private long duration; + private float mTranslateY; + private long mDuration; public TranslateFloatingTransition() { - translateY = -200f; - duration = 1500; + mTranslateY = -200f; + mDuration = 1500; } public TranslateFloatingTransition(float translateY, long duration) { - this.translateY = translateY; - this.duration = duration; + this.mTranslateY = translateY; + this.mDuration = duration; } @Override public void applyFloating(final YumFloating yumFloating) { - ValueAnimator translateAnimator = ObjectAnimator.ofFloat(0, translateY); - translateAnimator.setDuration(duration); + ValueAnimator translateAnimator = ObjectAnimator.ofFloat(0, mTranslateY); + translateAnimator.setDuration(mDuration); translateAnimator.setStartDelay(50); translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override @@ -55,7 +72,7 @@ public void onAnimationEnd(Animator animation) { }); ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f); - alphaAnimator.setDuration(duration); + alphaAnimator.setDuration(mDuration); alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/ReboundListener.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/ReboundListener.java index 81b4ce1..52a76ff 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/ReboundListener.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/ReboundListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.spring; /** diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SimpleReboundListener.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SimpleReboundListener.java index f49a73f..7a39b0b 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SimpleReboundListener.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SimpleReboundListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.spring; /** diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java index 785527c..d89b3d9 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/spring/SpringHelper.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.spring; import com.facebook.rebound.SimpleSpringListener; @@ -18,17 +35,17 @@ public class SpringHelper { - private float startValue; - private float endValue; - private double configValueOne; - private double configValueTwo; - private int config = -1; - private ReboundListener reboundListener; - private SpringListener springListener; + private float mStartValue; + private float mEndValue; + private double mConfigValueOne; + private double mConfigValueTwo; + private int mConfig = -1; + private ReboundListener mReboundListener; + private SpringListener mSpringListener; private SpringHelper(float startValue, float endValue) { - this.startValue = startValue; - this.endValue = endValue; + this.mStartValue = startValue; + this.mEndValue = endValue; } public static SpringHelper create(float startValue, float endValue){ @@ -47,36 +64,36 @@ public static SpringHelper createWithTensionAndFriction(float startValue, float public SpringHelper configBouncinessAndSpeed(double bounciness, double speed){ - configValueOne = bounciness; - configValueTwo = speed; - config = 0; + mConfigValueOne = bounciness; + mConfigValueTwo = speed; + mConfig = 0; return this; } public SpringHelper configTensionAndFriction(double tension, double friction){ - configValueOne = tension; - configValueTwo = friction; - config = 1; + mConfigValueOne = tension; + mConfigValueTwo = friction; + mConfig = 1; return this; } public SpringHelper reboundListener(ReboundListener reboundListener){ - this.reboundListener = reboundListener; + this.mReboundListener = reboundListener; return this; } public SpringHelper springListener(SpringListener springListener){ - this.springListener = springListener; + this.mSpringListener = springListener; return this; } public void start(){ SpringSystem springSystem = SpringSystem.create(); Spring spring = springSystem.createSpring(); - if (config == 0){ - spring.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(configValueOne, configValueTwo)); - }else if (config == 1){ - spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(configValueOne,configValueTwo)); + if (mConfig == 0){ + spring.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(mConfigValueOne, mConfigValueTwo)); + }else if (mConfig == 1){ + spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mConfigValueOne, mConfigValueTwo)); } start(spring); } @@ -84,23 +101,23 @@ public void start(){ private void start(Spring spring){ if (spring != null){ - if (springListener != null){ - spring.addListener(springListener); + if (mSpringListener != null){ + spring.addListener(mSpringListener); } spring.addListener(new SimpleSpringListener(){ @Override public void onSpringUpdate(Spring spring) { if (spring.getCurrentValue() == spring.getEndValue()){ - if (reboundListener != null){ - reboundListener.onReboundEnd(); + if (mReboundListener != null){ + mReboundListener.onReboundEnd(); } } - if (reboundListener != null){ - reboundListener.onReboundUpdate(transition(spring.getCurrentValue(),startValue,endValue)); + if (mReboundListener != null){ + mReboundListener.onReboundUpdate(transition(spring.getCurrentValue(), mStartValue, mEndValue)); } } - }).setEndValue(endValue); + }).setEndValue(mEndValue); }else { throw new NullPointerException("Spring should not be null"); } @@ -108,15 +125,15 @@ public void onSpringUpdate(Spring spring) { public void start(final YumFloating yumFloating){ - if (config == -1){ - throw new IllegalStateException("Hi , You must call one of the method configBouncinessAndSpeed and configTensionAndFriction to make config"); + if (mConfig == -1){ + throw new IllegalStateException("Hi , You must call one of the method configBouncinessAndSpeed and configTensionAndFriction to make mConfig"); } Spring spring = null; - if (config == 0){ - spring = yumFloating.createSpringByBouncinessAndSpeed(configValueOne,configValueTwo); - }else if (config == 1){ - spring = yumFloating.createSpringByTensionAndFriction(configValueOne,configValueTwo); + if (mConfig == 0){ + spring = yumFloating.createSpringByBouncinessAndSpeed(mConfigValueOne, mConfigValueTwo); + }else if (mConfig == 1){ + spring = yumFloating.createSpringByTensionAndFriction(mConfigValueOne, mConfigValueTwo); } start(spring); } diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java index d915ad9..831df8a 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/BaseFloatingPathTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; /** @@ -7,8 +24,8 @@ public abstract class BaseFloatingPathTransition implements FloatingPathTransition { - private PathPosition pathPosition; - private float [] pathPositionGetter; + private PathPosition mPathPosition; + private float [] mPathPositionGetter; public float getStartPathPosition(){ return 0; @@ -22,18 +39,18 @@ public float getEndPathPosition(){ } public PathPosition getFloatingPosition(float progress) { - if (pathPosition == null){ - pathPosition = new PathPosition(); + if (mPathPosition == null){ + mPathPosition = new PathPosition(); } - if (pathPositionGetter == null){ - pathPositionGetter = new float[2]; + if (mPathPositionGetter == null){ + mPathPositionGetter = new float[2]; } if (getFloatingPath() != null){ - getFloatingPath() .getPathMeasure().getPosTan(progress, pathPositionGetter, null); - pathPosition.x = pathPositionGetter[0]; - pathPosition.y = pathPositionGetter[1]; + getFloatingPath() .getPathMeasure().getPosTan(progress, mPathPositionGetter, null); + mPathPosition.x = mPathPositionGetter[0]; + mPathPosition.y = mPathPositionGetter[1]; } - return pathPosition; + return mPathPosition; } diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPath.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPath.java index 30493e1..ad03502 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPath.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPath.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; import android.graphics.Path; diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPathTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPathTransition.java index f659f32..4f95a06 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPathTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingPathTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; /** @@ -9,5 +26,4 @@ public interface FloatingPathTransition extends FloatingTransition { public FloatingPath getFloatingPath(); - } diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java index 34c03ad..6815904 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/FloatingTransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/ITransition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/ITransition.java index 5d33bd9..75290fc 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/ITransition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/ITransition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; /** @@ -6,36 +23,29 @@ */ public interface ITransition { - - + public void setAlpha(float alpha); - - + public void setRotation(float rotation); public void setRotationX(float rotationX); public void setRotationY(float rotationY); - - + public void setScaleX(float scaleX); public void setScaleY(float scaleY); - public void setScrollX(int scrollX); public void setScrollY(int scrollY); - public void setTranslationX(float translationX); public void setTranslationY(float translationY); - public void setX(float x); public void setY(float y); - - + } diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/PathPosition.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/PathPosition.java index 6cb6880..390623e 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/PathPosition.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/PathPosition.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; /** diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/Rebound.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/Rebound.java index da2e0f4..3f54d43 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/Rebound.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/Rebound.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; import com.facebook.rebound.Spring; diff --git a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java index 4ed6452..955a2c6 100644 --- a/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java +++ b/FloatingViewLib/src/main/java/com/ufreedom/floatingview/transition/YumFloating.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2015 UFreedom + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package com.ufreedom.floatingview.transition; import android.view.View; @@ -18,28 +35,28 @@ public class YumFloating implements ITransition, Rebound { - private SpringSystem springSystem; - private WeakReference targetViewWeakReference; + private SpringSystem mSpringSystem; + private WeakReference mTargetViewWeakReference; public YumFloating(View targetView, SpringSystem springSystem) { - targetViewWeakReference = new WeakReference(targetView); - this.springSystem = springSystem; + mTargetViewWeakReference = new WeakReference(targetView); + this.mSpringSystem = springSystem; } public YumFloating(View targetView) { - targetViewWeakReference = new WeakReference(targetView); + mTargetViewWeakReference = new WeakReference(targetView); } public View getTargetView() { - return targetViewWeakReference.get(); + return mTargetViewWeakReference.get(); } @Override public void setAlpha(float alpha) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setAlpha(alpha); } } @@ -47,7 +64,7 @@ public void setAlpha(float alpha) { @Override public void setRotation(float rotation) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setRotation(rotation); } } @@ -55,7 +72,7 @@ public void setRotation(float rotation) { @Override public void setRotationX(float rotationX) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setRotationX(rotationX); } } @@ -63,7 +80,7 @@ public void setRotationX(float rotationX) { @Override public void setRotationY(float rotationY) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setRotationY(rotationY); } } @@ -71,7 +88,7 @@ public void setRotationY(float rotationY) { @Override public void setScaleX(float scaleX) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setScaleX(scaleX); } } @@ -79,7 +96,7 @@ public void setScaleX(float scaleX) { @Override public void setScaleY(float scaleY) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setScaleY(scaleY); } } @@ -87,7 +104,7 @@ public void setScaleY(float scaleY) { @Override public void setScrollX(int scrollX) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setScaleX(scrollX); } } @@ -95,7 +112,7 @@ public void setScrollX(int scrollX) { @Override public void setScrollY(int scrollY) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setScaleY(scrollY); } @@ -104,7 +121,7 @@ public void setScrollY(int scrollY) { @Override public void setTranslationX(float translationX) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setTranslationX(translationX); } } @@ -112,7 +129,7 @@ public void setTranslationX(float translationX) { @Override public void setTranslationY(float translationY) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setTranslationY(translationY); } } @@ -120,7 +137,7 @@ public void setTranslationY(float translationY) { @Override public void setX(float x) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setX(x); } } @@ -128,7 +145,7 @@ public void setX(float x) { @Override public void setY(float y) { View targetView; - if ((targetView = getTargetView()) !=null){ + if ((targetView = getTargetView()) != null){ targetView.setY(y); } } @@ -136,13 +153,13 @@ public void setY(float y) { @Override public Spring createSpringByBouncinessAndSpeed(double bounciness, double speed) { - return springSystem.createSpring() + return mSpringSystem.createSpring() .setSpringConfig(SpringConfig.fromBouncinessAndSpeed(bounciness, speed)); } @Override public Spring createSpringByTensionAndFriction(double tension, double friction) { - return springSystem.createSpring() + return mSpringSystem.createSpring() .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(tension, friction)); } @@ -159,7 +176,7 @@ public void clear(){ if (viewParent instanceof ViewGroup){ ViewGroup parent = (ViewGroup) viewParent; parent.removeView(view); - targetViewWeakReference.clear(); + mTargetViewWeakReference.clear(); } } } diff --git a/demo/src/main/java/com/ufreedom/demo/MainActivity.java b/demo/src/main/java/com/ufreedom/demo/MainActivity.java index 986fde3..5ee400a 100644 --- a/demo/src/main/java/com/ufreedom/demo/MainActivity.java +++ b/demo/src/main/java/com/ufreedom/demo/MainActivity.java @@ -31,33 +31,33 @@ public class MainActivity extends AppCompatActivity { - private Floating floating; - private View icPlaneView; - private View icPaperAirPlaneView; - private int screenWidth; - private int screenHeight; + private Floating mFloating; + private View mIcPlaneView; + private View mIcPaperAirPlaneView; + private int mScreenWidth; + private int mScreenHeight; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - floating = new Floating(this); + mFloating = new Floating(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); } - screenWidth = UIUtils.getScreenWidth(this); - screenHeight = UIUtils.getScreenWidth(this); + mScreenWidth = UIUtils.getScreenWidth(this); + mScreenHeight = UIUtils.getScreenWidth(this); initLayout(); } private void initLayout() { int margin = UIUtils.dip2px(this,15); - int w = screenWidth - margin * 2; + int w = mScreenWidth - margin * 2; int h = (int) (w * 0.53f); RelativeLayout bikeRootView = (RelativeLayout) findViewById(R.id.itemBikeContainerView); @@ -70,13 +70,13 @@ private void initLayout() { clockRootViewLayoutParams.width = w; clockRootViewLayoutParams.height = h; - icPlaneView = findViewById(R.id.icPlane); - icPlaneView.setOnClickListener(new View.OnClickListener() { + mIcPlaneView = findViewById(R.id.icPlane); + mIcPlaneView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ImageView imageView = new ImageView(MainActivity.this); - imageView.setLayoutParams(new ViewGroup.LayoutParams(icPlaneView.getMeasuredWidth(), icPlaneView.getMeasuredHeight())); + imageView.setLayoutParams(new ViewGroup.LayoutParams(mIcPlaneView.getMeasuredWidth(), mIcPlaneView.getMeasuredHeight())); imageView.setImageResource(R.drawable.floating_plane); FloatingElement floatingElement = new FloatingBuilder() @@ -84,16 +84,16 @@ public void onClick(View v) { .targetView(imageView) .floatingTransition(new PlaneFloating()) .build(); - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }); - icPaperAirPlaneView = findViewById(R.id.icPaperAirPlane); - icPaperAirPlaneView.setOnClickListener(new View.OnClickListener() { + mIcPaperAirPlaneView = findViewById(R.id.icPaperAirPlane); + mIcPaperAirPlaneView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ImageView imageView = new ImageView(MainActivity.this); - imageView.setLayoutParams(new ViewGroup.LayoutParams(icPaperAirPlaneView.getMeasuredWidth(), icPaperAirPlaneView.getMeasuredHeight())); + imageView.setLayoutParams(new ViewGroup.LayoutParams(mIcPaperAirPlaneView.getMeasuredWidth(), mIcPaperAirPlaneView.getMeasuredHeight())); imageView.setImageResource(R.drawable.paper_airplane); FloatingElement floatingElement = new FloatingBuilder() @@ -101,7 +101,7 @@ public void onClick(View v) { .targetView(imageView) .floatingTransition(new TranslateFloatingTransition()) .build(); - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }); @@ -118,7 +118,7 @@ public void onClick(View v) { .offsetY(-v.getMeasuredHeight()) .floatingTransition(new ScaleFloatingTransition()) .build(); - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }); @@ -131,7 +131,7 @@ public void onClick(View v) { .targetView(R.layout.ic_like) .floatingTransition(new TranslateFloatingTransition()) .build(); - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }); @@ -161,7 +161,7 @@ public void onReboundUpdate(double currentValue) { @Override public void onReboundEnd() { - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }).start(); @@ -184,7 +184,7 @@ public void onClick(View v) { .targetView(imageView) .floatingTransition(new BeerFloating()) .build(); - floating.startFloating(floatingElement); + mFloating.startFloating(floatingElement); } }); } @@ -196,7 +196,7 @@ public FloatingPath getFloatingPath() { Path path = new Path(); path.moveTo(0, 0); path.quadTo(100, -300, 0, -600); - path.rLineTo(0, -screenHeight - 300); + path.rLineTo(0, -mScreenHeight - 300); return FloatingPath.create(path, false); }