From f48aca7eb2f714b8168b401c7a01e2e0d2504f7d Mon Sep 17 00:00:00 2001 From: wushunlian Date: Thu, 21 Feb 2019 19:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=B0=E7=A7=92=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=A2=9E=E5=8A=A012/24=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=85=A8=E5=B1=8F=E7=B2=BE=E7=AE=80=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 26 +- app/build.gradle | 2 + .../socoolby/com/clock/MainActivity.java | 367 +++++++++++++++-- .../socoolby/com/clock/model/DateModel.java | 34 +- .../com/clock/model/SharePerferenceModel.java | 14 + .../animatorview/animator/ClockAnimator.java | 331 +++++++++++++++ .../animatorview/animator/FireAnimator.java | 182 +++++++++ .../animatorview/animator/FishAnimator.java | 381 ++++++++++++++++++ .../animatorview/animator/RippleAnimator.java | 345 ++++++++++++++++ .../animatorview/animator/WaterAnimator.java | 256 ++++++++++++ .../animator/WindmillAnimator.java | 130 ++++++ .../animatorview/animator/bean/Particle.java | 10 - .../animator/particle/I_PraticleDraw.java | 8 + .../animator/particle/Particle.java | 30 ++ .../particle/drawer/CircleDrawer.java | 18 + .../particle/drawer/FilletSquareDrawer.java | 24 ++ .../particle/drawer/PolygonDrawer.java | 4 + .../particle/drawer/SquareDrawer.java | 20 + .../particle/drawer/TriangleDraw.java | 45 +++ .../widget/textview/AutoScrollTextView.java | 4 +- .../clock/widget/textview/DigitTextView.java | 180 +++++++++ .../library/BaseViewAnimator.java | 158 ++++++++ .../androidanimations/library/Techniques.java | 184 +++++++++ .../androidanimations/library/YoYo.java | 281 +++++++++++++ .../library/attention/BounceAnimator.java | 39 ++ .../library/attention/FlashAnimator.java | 39 ++ .../library/attention/PulseAnimator.java | 40 ++ .../library/attention/RubberBandAnimator.java | 40 ++ .../library/attention/ShakeAnimator.java | 40 ++ .../library/attention/StandUpAnimator.java | 45 +++ .../library/attention/SwingAnimator.java | 39 ++ .../library/attention/TadaAnimator.java | 41 ++ .../library/attention/WaveAnimator.java | 44 ++ .../library/attention/WobbleAnimator.java | 42 ++ .../bouncing_entrances/BounceInAnimator.java | 41 ++ .../BounceInDownAnimator.java | 40 ++ .../BounceInLeftAnimator.java | 41 ++ .../BounceInRightAnimator.java | 40 ++ .../BounceInUpAnimator.java | 41 ++ .../fading_entrances/FadeInAnimator.java | 39 ++ .../fading_entrances/FadeInDownAnimator.java | 40 ++ .../fading_entrances/FadeInLeftAnimator.java | 40 ++ .../fading_entrances/FadeInRightAnimator.java | 40 ++ .../fading_entrances/FadeInUpAnimator.java | 40 ++ .../library/fading_exits/FadeOutAnimator.java | 39 ++ .../fading_exits/FadeOutDownAnimator.java | 40 ++ .../fading_exits/FadeOutLeftAnimator.java | 40 ++ .../fading_exits/FadeOutRightAnimator.java | 40 ++ .../fading_exits/FadeOutUpAnimator.java | 40 ++ .../library/flippers/FlipInXAnimator.java | 40 ++ .../library/flippers/FlipInYAnimator.java | 40 ++ .../library/flippers/FlipOutXAnimator.java | 40 ++ .../library/flippers/FlipOutYAnimator.java | 40 ++ .../rotating_entrances/RotateInAnimator.java | 40 ++ .../RotateInDownLeftAnimator.java | 44 ++ .../RotateInDownRightAnimator.java | 44 ++ .../RotateInUpLeftAnimator.java | 44 ++ .../RotateInUpRightAnimator.java | 44 ++ .../rotating_exits/RotateOutAnimator.java | 40 ++ .../RotateOutDownLeftAnimator.java | 44 ++ .../RotateOutDownRightAnimator.java | 44 ++ .../RotateOutUpLeftAnimator.java | 44 ++ .../RotateOutUpRightAnimator.java | 44 ++ .../library/sliders/SlideInDownAnimator.java | 41 ++ .../library/sliders/SlideInLeftAnimator.java | 43 ++ .../library/sliders/SlideInRightAnimator.java | 43 ++ .../library/sliders/SlideInUpAnimator.java | 43 ++ .../library/sliders/SlideOutDownAnimator.java | 43 ++ .../library/sliders/SlideOutLeftAnimator.java | 40 ++ .../sliders/SlideOutRightAnimator.java | 43 ++ .../library/sliders/SlideOutUpAnimator.java | 40 ++ .../library/specials/HingeAnimator.java | 50 +++ .../library/specials/RollInAnimator.java | 41 ++ .../library/specials/RollOutAnimator.java | 41 ++ .../library/specials/in/DropOutAnimator.java | 19 + .../library/specials/in/LandingAnimator.java | 19 + .../specials/out/TakingOffAnimator.java | 19 + .../zooming_entrances/ZoomInAnimator.java | 41 ++ .../zooming_entrances/ZoomInDownAnimator.java | 42 ++ .../zooming_entrances/ZoomInLeftAnimator.java | 42 ++ .../ZoomInRightAnimator.java | 42 ++ .../zooming_entrances/ZoomInUpAnimator.java | 45 +++ .../zooming_exits/ZoomOutAnimator.java | 41 ++ .../zooming_exits/ZoomOutDownAnimator.java | 45 +++ .../zooming_exits/ZoomOutLeftAnimator.java | 42 ++ .../zooming_exits/ZoomOutRightAnimator.java | 45 +++ .../zooming_exits/ZoomOutUpAnimator.java | 42 ++ .../particlesmasher/ParticleSmasher.java | 139 +++++++ .../fadai/particlesmasher/SmashAnimator.java | 330 +++++++++++++++ .../java/com/fadai/particlesmasher/Utils.java | 30 ++ .../particle/DropParticle.java | 126 ++++++ .../particle/ExplosionParticle.java | 123 ++++++ .../particle/FloatParticle.java | 164 ++++++++ .../particlesmasher/particle/Particle.java | 34 ++ app/src/main/res/drawable/ic_am.xml | 39 ++ app/src/main/res/drawable/ic_pm.xml | 6 + app/src/main/res/layout/activity_main.xml | 31 +- 98 files changed, 6550 insertions(+), 62 deletions(-) create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/ClockAnimator.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireAnimator.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FishAnimator.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java delete mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/bean/Particle.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/I_PraticleDraw.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/Particle.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/CircleDrawer.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/FilletSquareDrawer.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/PolygonDrawer.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/SquareDrawer.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/TriangleDraw.java create mode 100644 app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/BaseViewAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/Techniques.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/YoYo.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/BounceAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/FlashAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/PulseAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/RubberBandAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/ShakeAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/StandUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/SwingAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/TadaAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/WaveAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/attention/WobbleAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInXAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInYAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutXAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutYAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/HingeAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/RollInAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/RollOutAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/in/DropOutAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/in/LandingAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/specials/out/TakingOffAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInUpAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutDownAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutLeftAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutRightAnimator.java create mode 100755 app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutUpAnimator.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/SmashAnimator.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/Utils.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/particle/DropParticle.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/particle/ExplosionParticle.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/particle/FloatParticle.java create mode 100755 app/src/main/java/com/fadai/particlesmasher/particle/Particle.java create mode 100644 app/src/main/res/drawable/ic_am.xml create mode 100644 app/src/main/res/drawable/ic_pm.xml diff --git a/.gitignore b/.gitignore index 61536b2..d42cbd8 100755 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,4 @@ captures app/src/custom_flavor/ app/src/ptest/ app/src/debug -/app/release/app-release.apk +/app/release/ diff --git a/README.md b/README.md index d7b49db..23022f0 100755 --- a/README.md +++ b/README.md @@ -16,20 +16,42 @@ An Android clock 计时器 单击->改变状态,长按-> 设置时间 + 计时显 单击->修改本次计时时间,不保存 长按->隐去自已 + 日期 单击->显示日历 + 星期 单击->切换走秒方式,长按->切换12或24小时制 + 天气 单击->显示近几天天气 下面说明条 单击->随机名言 - 时间 长按-->显示列多功能 + 时间 长按-->显示[更多功能状态](#更多功能) + + 锁 单击->锁定屏幕,长按->进行[全屏精简模式](#全屏精简模式) ### 定时提醒状态 - 倒计时 单击->停止闹铃,返回普通状态 + 倒计时 单击->停止闹铃,返回[普通状态](#普通状态) ### 更多功能 会出现颜色选择,及设置按键 + 实心马 单击->设置背景色 + + 空心马1 单击->改变当明的前景色 长按-->设置1号位的前景色 (注:此为启动时的前景应用色) + + 空心马2 单击->改变当明的前景色 长按-->设置2号位的前景色 (注:此也为背景动画的应用色) + + 设置 单击->进入[更多设置页]() + + 时间 长按-->返回[普通状态](#普通状态) + +### 全屏精简模式 + 锁 单击->退出全屏模式,返回先前的状态 + + 时间 长按-->切换时间显、隐。即进入真全屏,如用图型走钟 + + 计时显 长按->隐去自已 ------ 其它在设置页设置 diff --git a/app/build.gradle b/app/build.gradle index 98de526..5bf5a4a 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,4 +42,6 @@ dependencies { implementation 'com.blankj:utilcode:1.23.4' implementation 'com.larswerkman:HoloColorPicker:1.5' + + implementation 'com.daimajia.easing:library:2.0@aar' } diff --git a/app/src/main/java/clock/socoolby/com/clock/MainActivity.java b/app/src/main/java/clock/socoolby/com/clock/MainActivity.java index 451a2c8..f662544 100755 --- a/app/src/main/java/clock/socoolby/com/clock/MainActivity.java +++ b/app/src/main/java/clock/socoolby/com/clock/MainActivity.java @@ -12,6 +12,9 @@ import android.os.PowerManager; import android.os.Bundle; import android.provider.Settings; import android.support.v4.app.ActivityCompat; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.SpannableStringBuilder; import android.util.Log; import android.view.GestureDetector; import android.view.KeyEvent; @@ -25,8 +28,11 @@ import android.widget.TextView; import android.widget.Toast; import com.blankj.utilcode.util.PermissionUtils; +import com.fadai.particlesmasher.ParticleSmasher; +import com.fadai.particlesmasher.SmashAnimator; import java.text.NumberFormat; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Timer; @@ -43,19 +49,26 @@ import clock.socoolby.com.clock.utils.Player; import clock.socoolby.com.clock.utils.ScreenManager; import clock.socoolby.com.clock.model.SharePerferenceModel; import clock.socoolby.com.clock.pop.TimeSetupPopup; +import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator; import clock.socoolby.com.clock.widget.animatorview.AnimatorView; import clock.socoolby.com.clock.widget.animatorview.I_Animator; import clock.socoolby.com.clock.widget.animatorview.animator.BubbleAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.BubbleCollisionAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.BubbleWhirlPoolAnimator; +import clock.socoolby.com.clock.widget.animatorview.animator.ClockAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.DotsLineAnimator; +import clock.socoolby.com.clock.widget.animatorview.animator.FireAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.FireworkAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.FluorescenceAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.RainAnimator; +import clock.socoolby.com.clock.widget.animatorview.animator.RippleAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.SkyAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.SnowAnimator; import clock.socoolby.com.clock.widget.animatorview.animator.StarFallAnimator; +import clock.socoolby.com.clock.widget.animatorview.animator.WaterAnimator; +import clock.socoolby.com.clock.widget.animatorview.animator.WindmillAnimator; import clock.socoolby.com.clock.widget.textview.AutoScrollTextView; +import clock.socoolby.com.clock.widget.textview.DigitTextView; public class MainActivity extends Activity implements Handler.Callback, View.OnClickListener, android.view.GestureDetector.OnGestureListener { @@ -65,6 +78,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC public final static int MODE_NORMAL = 200; public final static int MODE_SETTING_OTHER = 202; public final static int MODE_HANDUP=203; + public final static int MODE_FULLSCREEN=204; + clock.socoolby.com.clock.widget.animatorview.AnimatorView view; public final static String[] FONT_NAME_ARRAY={ @@ -94,27 +109,27 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC public final static Map FONT_SIZE_MAP=new HashMap<>(); static { - FONT_SIZE_MAP.put("cherif",100); + FONT_SIZE_MAP.put("cherif",80); FONT_SIZE_MAP.put("Cigar Box Guitar",120); - FONT_SIZE_MAP.put("Ciung Wanara Sejati",130); + FONT_SIZE_MAP.put("Ciung Wanara Sejati",110); FONT_SIZE_MAP.put("crystallightning",150); FONT_SIZE_MAP.put("DK Bergelmir",120); FONT_SIZE_MAP.put("ds_digi",140); - FONT_SIZE_MAP.put("Granite Rock St",120); + FONT_SIZE_MAP.put("Granite Rock St",110); FONT_SIZE_MAP.put("GROOT",120); FONT_SIZE_MAP.put("LCD-U",130); - FONT_SIZE_MAP.put("MILKDROP",120); + FONT_SIZE_MAP.put("MILKDROP",110); FONT_SIZE_MAP.put("Pro Display tfb",120); FONT_SIZE_MAP.put("SailingJunco",130); FONT_SIZE_MAP.put("scoreboard",120); - FONT_SIZE_MAP.put("SFWasabi-Bold",120); + FONT_SIZE_MAP.put("SFWasabi-Bold",110); FONT_SIZE_MAP.put("the_vandor_spot",140); FONT_SIZE_MAP.put("WarioLand4CHMC",120); FONT_SIZE_MAP.put("Woodplank",120); - FONT_SIZE_MAP.put("Xtra Power",110); + FONT_SIZE_MAP.put("Xtra Power",100); } private TextView tv_time; @@ -126,6 +141,9 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC private ImageButton tv_handup; private TextView tv_handup_image; + private TextView tv_hand_time; + private boolean hand_time_visable=true; + private Timer timer; private Handler handler; private final static int UPDATE_TIME = 100; @@ -137,6 +155,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC private int currectAnimatorIndex=0; + + private ImageButton tv_hours_system; //颜色相关 private ImageButton tv_background_color; private ImageButton tv_foreground_color; @@ -194,9 +214,26 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC animatorView=findViewById(R.id.tv_background_animatorview); tv_time = findViewById(R.id.tv_time); + //tv_time.setOnClickListener(this); + tv_date = findViewById(R.id.tv_date); - tv_day = findViewById(R.id.tv_day); tv_date.setOnClickListener(this); + + + tv_day = findViewById(R.id.tv_day); + tv_day.setOnClickListener(this); + tv_day.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if(screenLock) + return true; + model.setHourSystem12(!model.isHourSystem12()); + model.save(); + updateHourSystem(); + return true; + } + }); + tv_weather = findViewById(R.id.tv_weather); tv_weather.setOnClickListener(this); tv_descript = findViewById(R.id.tv_descript); @@ -206,10 +243,24 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC tv_handup.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { + if(screenLock) + return true; setupHandUpTime(); return true; } }); + tv_hand_time=findViewById(R.id.tv_hand_time); + tv_hand_time.setOnClickListener(this); + tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + hand_time_visable=false; + tv_hand_time.setVisibility(View.GONE); + return true; + } + }); + + tv_hours_system=findViewById(R.id.tv_hours_system); tv_background_color=findViewById(R.id.tv_background_color); tv_background_color.setOnClickListener(this); @@ -219,12 +270,15 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC tv_foreground_color.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { + if(screenLock) + return true; if (colorPickerDialog == null) colorPickerDialog = new ColorPickerPop(MainActivity.this); colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() { @Override public void onEnsure(int color) { + model.setForegroundColor(color); model.save(); setForegroundColor(color); @@ -245,6 +299,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC tv_foreground_color1.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { + if(screenLock) + return true; if (colorPickerDialog == null) colorPickerDialog = new ColorPickerPop(MainActivity.this); @@ -274,12 +330,20 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC handler = new Handler(this); tv_setting = (ImageButton) findViewById(R.id.tv_setting); tv_setting.setOnClickListener(this); - //tv_time.setOnClickListener(this); + //RelativeLayout rel_main = (RelativeLayout) findViewById(R.id.rel_main); //rel_main.setOnClickListener(this); tv_screen_lock = (ImageButton) findViewById(R.id.tv_screen_lock); tv_screen_lock.setOnClickListener(this); + tv_screen_lock.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + screenLock(true); + switchMode(MODE_FULLSCREEN); + return true; + } + }); if(PermissionUtils.isGranted("android.permission.WAKE_LOCK","android.permission.DEVICE_POWER")) { @@ -359,9 +423,10 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC fontIndex =model.getFontIndex()==null?4:model.getFontIndex(); brightness=getSystemBrightness(); handUpAbla=model.isHandUpAble(); + resetColorFromModel(); upHandStatic(); resetHandUpTime(); - resetColorFromModel(); + updateHourSystem(); } private void resetColorFromModel(){ @@ -372,6 +437,14 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC animatorView.setColor(model.getForegroundColor1()); } + + private void updateHourSystem(){ + if(model.isHourSystem12()) + tv_hours_system.setVisibility(View.VISIBLE); + else + tv_hours_system.setVisibility(View.GONE); + } + //将该Activity上的触碰事件交给GestureDetector处理 @Override public boolean onTouchEvent(MotionEvent me) @@ -425,10 +498,14 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC } protected void setFont(int index){ + String timeString=tv_time.getText().toString(); + tv_time.setText("", TextView.BufferType.NORMAL); + Log.d(TAG,"befor setFont text:"+timeString+"\t witch:"+tv_time.getWidth()+"\t height:"+tv_time.getHeight()); Log.d(TAG,"setFont index:"+index+"/t name:"+FONT_NAME_ARRAY[index]+".ttf/t size:"+FONT_SIZE_MAP.get(FONT_NAME_ARRAY[index])); FontUtils.getInstance().replaceFontFromAsset(tv_time,"fonts/"+FONT_NAME_ARRAY[index]+".ttf"); - tv_time.setTextSize(FONT_SIZE_MAP.get(FONT_NAME_ARRAY[index])); FontUtils.getInstance().replaceFontFromAsset(tv_date,"fonts/"+FONT_NAME_ARRAY[index]+".ttf"); + tv_time.setTextSize(FONT_SIZE_MAP.get(FONT_NAME_ARRAY[index])); + Log.d(TAG,"after setFont text:"+tv_time.getText()+"\t witch:"+tv_time.getWidth()+"\t height:"+tv_time.getHeight()); } protected void setForegroundColor(Integer color){ @@ -446,6 +523,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC tv_screen_lock.setColorFilter(color); tv_setting.setColorFilter(color); tv_background_color.setColorFilter(color); + tv_hand_time.setTextColor(color); + tv_hours_system.setColorFilter(color); } protected void setBackGroundColor(Integer color){ @@ -458,11 +537,13 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC CalendarPopup calendarPopup; WeatherPopup weatherPopup; + ParticleSmasher particleSmasher; @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public void onClick(View view) { - if(screenLock&&view.getId()!=R.id.tv_screen_lock&&view.getId()!=R.id.tv_handup_image) + if(screenLock&&view.getId()!=R.id.tv_screen_lock&&view.getId()!=R.id.tv_handup_image) { return; + } switch (view.getId()) { case R.id.tv_setting: setup(); @@ -478,9 +559,16 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC switchMode(MODE_NORMAL); } break; + case R.id.tv_hand_time: + setupTempHandUpTime(); + break; case R.id.tv_handup_image: switchMode(MODE_NORMAL); break; + case R.id.tv_day: + model.setDisplaySecond(!model.isDisplaySecond()); + model.save(); + break; case R.id.tv_date: if( calendarPopup ==null) calendarPopup =new CalendarPopup(this); @@ -494,9 +582,9 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC weatherPopup.showPopupWindow(); break; case R.id.tv_screen_lock: - screenLock=!screenLock; - tv_screen_lock.setImageResource(screenLock?R.drawable.ic_screen_lock:R.drawable.ic_screen_unlock); - setUpProximityService(); + if(isFullScreen) + fullScreen(false); + screenLock(!screenLock); break; case R.id.tv_descript: setDiscript(SettingActivity.roundAutoQuotes()); @@ -529,16 +617,34 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC } + public void screenLock(boolean locked){ + screenLock=locked; + tv_screen_lock.setImageResource(screenLock?R.drawable.ic_screen_lock:R.drawable.ic_screen_unlock); + setUpProximityService(); + } + + private int prevMode=MODE_NORMAL; + private boolean isArtificialHiddle=false; + private boolean isFullScreen=false; private void switchMode(int mode) { Log.d(TAG,"switch mode to:"+mode); switch (mode) { + case MODE_FULLSCREEN: + fullScreen(true); + break; case MODE_NORMAL: - tv_time.setVisibility(View.VISIBLE); - tv_handup_image.setVisibility(View.GONE); - tv_setting.setVisibility(View.GONE); - tv_background_color.setVisibility(View.GONE); - tv_foreground_color.setVisibility(View.GONE); - tv_foreground_color1.setVisibility(View.GONE); + if(isFullScreen){ + if(!isArtificialHiddle) + tv_time.setVisibility(View.VISIBLE); + tv_handup_image.setVisibility(View.GONE); + }else { + tv_time.setVisibility(View.VISIBLE); + tv_handup_image.setVisibility(View.GONE); + tv_setting.setVisibility(View.GONE); + tv_background_color.setVisibility(View.GONE); + tv_foreground_color.setVisibility(View.GONE); + tv_foreground_color1.setVisibility(View.GONE); + } break; case MODE_SETTING_OTHER: tv_time.setVisibility(View.VISIBLE); @@ -549,17 +655,60 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC tv_foreground_color1.setVisibility(View.VISIBLE); break; case MODE_HANDUP: - tv_time.setVisibility(View.GONE); - tv_handup_image.setVisibility(View.VISIBLE); - tv_setting.setVisibility(View.GONE); - tv_background_color.setVisibility(View.GONE); - tv_foreground_color.setVisibility(View.GONE); - tv_foreground_color1.setVisibility(View.GONE); - setDiscriptForModel(); + if(isFullScreen){ + tv_time.setVisibility(View.GONE); + tv_handup_image.setVisibility(View.VISIBLE); + }else { + tv_time.setVisibility(View.GONE); + tv_handup_image.setVisibility(View.VISIBLE); + tv_setting.setVisibility(View.GONE); + tv_background_color.setVisibility(View.GONE); + tv_foreground_color.setVisibility(View.GONE); + tv_foreground_color1.setVisibility(View.GONE); + setDiscriptForModel(); + } } + prevMode=mMode; mMode = mode; } + private void fullScreen(boolean fullable){ + isFullScreen=fullable; + if(fullable) { + // @tudo 可对其时行位置移动 + //tv_time.setVisibility(View.GONE); + tv_date.setVisibility(View.GONE); + tv_day.setVisibility(View.GONE); + tv_weather.setVisibility(View.GONE); + tv_descript.setVisibility(View.GONE); + tv_handup_image.setVisibility(View.GONE); + + tv_handup.setVisibility(View.GONE); + + tv_setting.setVisibility(View.GONE); + tv_background_color.setVisibility(View.GONE); + //tv_hand_time.setTextColor(color); + + tv_background_color.setVisibility(View.GONE); + tv_foreground_color.setVisibility(View.GONE); + tv_foreground_color1.setVisibility(View.GONE); + }else{ + tv_time.setVisibility(View.VISIBLE); + tv_date.setVisibility(View.VISIBLE); + tv_day.setVisibility(View.VISIBLE); + tv_weather.setVisibility(View.VISIBLE); + tv_descript.setVisibility(View.VISIBLE); + tv_handup_image.setVisibility(View.VISIBLE); + + tv_handup.setVisibility(View.VISIBLE); + + if(prevMode==MODE_HANDUP) + switchMode(MODE_NORMAL); + else + switchMode(prevMode); + } + } + StarFallAnimator starAnimator; SkyAnimator skyAnimator; RainAnimator rainAnimator; @@ -570,6 +719,11 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC BubbleCollisionAnimator bubbleCollisionAnimator; FireworkAnimator fireworkAnimator; DotsLineAnimator dotsLineAnimator; + WaterAnimator waterAnimator; + FireAnimator fireAnimator; + ClockAnimator clockAnimator; + RippleAnimator rippleAnimator; + WindmillAnimator windmillAnimator; public void changeBackGroundAnimator(int index){ switch(index){ case 0: @@ -582,13 +736,13 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC backGroundAnimator.setRandColor(false); break; case 2: - if(skyAnimator==null) { - skyAnimator = new SkyAnimator(); - skyAnimator.init(animatorView.getContext(),animatorView); - skyAnimator.setColor(foregroundColor); + if(clockAnimator ==null) { + clockAnimator = new ClockAnimator(); + clockAnimator.init(animatorView.getContext(),animatorView); + clockAnimator.setColor(foregroundColor); } - backGroundAnimator=skyAnimator; - backGroundAnimator.setRandColor(false); + backGroundAnimator= clockAnimator; + //backGroundAnimator.setRandColor(true); break; case 3: if(rainAnimator==null) { @@ -734,7 +888,7 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC backGroundAnimator= dotsLineAnimator; backGroundAnimator.setRandColor(false); break; - case 1: + case 19: if(dotsLineAnimator ==null) { dotsLineAnimator = new DotsLineAnimator(); dotsLineAnimator.init(animatorView.getContext(),animatorView); @@ -743,6 +897,52 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC backGroundAnimator= dotsLineAnimator; backGroundAnimator.setRandColor(true); break; + case 20: + if(waterAnimator ==null) { + waterAnimator = new WaterAnimator(); + waterAnimator.init(animatorView.getContext(),animatorView); + waterAnimator.setColor(foregroundColor); + } + backGroundAnimator= waterAnimator; + backGroundAnimator.setRandColor(true); + break; + case 21: + if(fireAnimator ==null) { + fireAnimator = new FireAnimator(); + fireAnimator.init(animatorView.getContext(),animatorView); + fireAnimator.setColor(foregroundColor); + } + backGroundAnimator= fireAnimator; + //backGroundAnimator.setRandColor(true); + break; + case 22: + if(skyAnimator==null) { + skyAnimator = new SkyAnimator(); + skyAnimator.init(animatorView.getContext(),animatorView); + skyAnimator.setColor(foregroundColor); + } + backGroundAnimator=skyAnimator; + backGroundAnimator.setRandColor(false); + break; + case 23: + if(rippleAnimator ==null) { + rippleAnimator = new RippleAnimator(); + rippleAnimator.init(animatorView.getContext(),animatorView); + rippleAnimator.setColor(foregroundColor); + } + backGroundAnimator= rippleAnimator; + backGroundAnimator.setRandColor(true); + break; + case 1: + if(windmillAnimator ==null) { + windmillAnimator = new WindmillAnimator(); + windmillAnimator.init(animatorView.getContext(),animatorView); + windmillAnimator.setColor(foregroundColor); + } + backGroundAnimator= windmillAnimator; + backGroundAnimator.setRandColor(true); + break; + default: currectAnimatorIndex=0; backGroundAnimator=null; @@ -752,9 +952,13 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC private void upHandStatic(){ if(handUpAbla) { - this.tv_handup.setColorFilter(0x000); + this.tv_handup.setColorFilter(foregroundColor); + //if(hand_time_visable) + hand_time_visable=true; + this.tv_hand_time.setVisibility(View.VISIBLE); }else{ this.tv_handup.setColorFilter(R.color.colorPrimaryDark); + this.tv_hand_time.setVisibility(View.GONE); } } @@ -795,6 +999,26 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC handUpTimePopup.showPopupWindow(); } + private void setupTempHandUpTime(){ + handUpAbla=false; + int hour=0; + int minute=0; + if(handUpTimePopup==null) { + handUpTimePopup = new TimeSetupPopup(this); + handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() { + @Override + public void onChanged(int hour, int minute) { + handUpTime=hour*60+minute; + } + }); + } + hour=handUpTime/60; + minute=handUpTime-hour*60; + handUpTimePopup.init(hour,minute); + handUpTimePopup.showPopupWindow(); + handUpAbla=true; + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(screenLock) @@ -842,8 +1066,9 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC private int handUPDialy=60; private void checkHandUp(){ - if(!handUpAbla) + if(!handUpAbla) { return; + } //Log.d(TAG,"checkHandUp..\thandUPDialy:"+handUPDialy+" \thandUpTime:"+handUpTime+"\thandUpAble:"+handUpAbla); if(mMode==MODE_HANDUP) { tv_handup_image.setText("hand up:"+handUPDialy); @@ -855,6 +1080,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC return; } handUpTime--; + if(hand_time_visable) + tv_hand_time.setText(DateModel.getTime(handUpTime)); if (handUpTime <= 10&&handUpTime > 0) setDiscript("提醒时间倒计时: " + handUpTime); if (handUpTime == 0) { @@ -864,17 +1091,45 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC } } - @TargetApi(Build.VERSION_CODES.GINGERBREAD) + DigitTextView.DigitSpan digitSpan,digitSpan1; + DigitTextView.DigitSmallSpan digitSpan2; + SpannableString spannable; + DigitTextView.DigitFlagSpan digitFlagSpan; + private void setCurrentTimeToView(String timeString){ + spannable = new SpannableString(timeString); + if(digitSpan==null) { + digitSpan = new DigitTextView.DigitSpan(); + digitSpan1 = new DigitTextView.DigitSpan(); + digitSpan2 = new DigitTextView.DigitSmallSpan(); + digitFlagSpan=new DigitTextView.DigitFlagSpan(); + } + spannable.setSpan(digitSpan,0,2,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + spannable.setSpan(digitFlagSpan,2,3,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + spannable.setSpan(digitSpan1,3,5,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + if(timeString.length()>5) + spannable.setSpan(digitSpan2,5,8,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + //tv_time.setText(spannable, TextView.BufferType.SPANNABLE); + tv_time.setText(spannable, TextView.BufferType.NORMAL); + //tv_time.setText(timeString); + } + + boolean heartbeat=false; private void updateTime() { + heartbeat=!heartbeat; DateModel date = new DateModel(); - String timeString = model.isDisplaySecond() ? date.getTimeString() : date.getShortTimeString(); - //timeString=timeString.replace("1", " 1"); - if(timeString.startsWith(" ")) - timeString=timeString.substring(1,timeString.length()); - tv_time.setText(timeString); - //tv_date.setText(dateString.replace("1", " 1")); + String timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12()); + setCurrentTimeToView(timeString); reportTime(date); updateDay(date); + updateHourSytemStyle(date); + } + + int beforeHourForUpdateSystem=-1; + private void updateHourSytemStyle(DateModel date){ + if(model.isHourSystem12()&&beforeHourForUpdateSystem!=date.getHour()) { + beforeHourForUpdateSystem=date.getHour(); + tv_hours_system.setImageResource(beforeHourForUpdateSystem>12?R.drawable.ic_pm:R.drawable.ic_am); + } } DateModel currentDate=null; @@ -960,6 +1215,7 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC @Override public boolean onDown(MotionEvent motionEvent) { + return false; } @@ -981,6 +1237,31 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC @Override public void onLongPress(MotionEvent motionEvent) { + if(screenLock&&isFullScreen) { + if(tv_time.getVisibility()==View.GONE) { + tv_time.setVisibility(View.VISIBLE); + isArtificialHiddle=false; + return; + } + if(particleSmasher==null) + particleSmasher=new ParticleSmasher(this); + particleSmasher.with(tv_time).setDuration(1000).addAnimatorListener(new SmashAnimator.OnAnimatorListener() { + @Override + public void onAnimatorStart() { + super.onAnimatorStart(); + // 回调,动画开始 + } + + @Override + public void onAnimatorEnd() { + super.onAnimatorEnd(); + // 回调,动画结束 + particleSmasher.reShowView(tv_time); + tv_time.setVisibility(View.GONE); + isArtificialHiddle=true; + } + }).startRandomAnimator(); + } if(screenLock) return; if(!isPowerManagerDisable()) diff --git a/app/src/main/java/clock/socoolby/com/clock/model/DateModel.java b/app/src/main/java/clock/socoolby/com/clock/model/DateModel.java index c1b7751..64f70cb 100755 --- a/app/src/main/java/clock/socoolby/com/clock/model/DateModel.java +++ b/app/src/main/java/clock/socoolby/com/clock/model/DateModel.java @@ -90,8 +90,6 @@ public class DateModel implements Serializable { } else { setDataString(getNowWithTime()); } - - } public String toString() { @@ -102,12 +100,30 @@ public class DateModel implements Serializable { return String.format("%04d-%02d-%02d ", year, month, day); } + public String getShortTimeString() { return String.format("%02d:%02d", hour, minute); } public String getTimeString() { - return String.format("%02d:%02d:%02d", hour, minute, second); + return String.format("%02d:%02d %02d", hour, minute, second); + } + + public String getShortTimeString(boolean heartbeat,boolean isHourSystem12) { + if(heartbeat) + if(isHourSystem12&&hour>12) + return String.format("%02d %02d", hour-12, minute); + else + return String.format("%02d %02d", hour, minute); + if(isHourSystem12&&hour>12) + return String.format("%02d:%02d", hour-12, minute, second); + return String.format("%02d:%02d", hour, minute); + } + + public String getTimeString(boolean isHourSystem12) { + if(isHourSystem12&&hour>12) + return String.format("%02d:%02d %02d", hour-12, minute, second); + return String.format("%02d:%02d %02d", hour, minute, second); } public static String getNowWithTime() { @@ -116,6 +132,18 @@ public class DateModel implements Serializable { return sdf.format(dt); } + + public static String getTime(int second){ + long hours = second / 3600;//转换小时数 + second = second % 3600;//剩余秒数 + long minutes = second / 60;//转换分钟 + second = second % 60;//剩余秒数 + if(minutes>0||hours>0){ + return String.format(" %02d:%02d", hours, minutes, second); + } + return String.format("%02d:%02d:%02d", hours, minutes, second); + } + public int minusTime(DateModel strEnd) { SimpleDateFormat df = new SimpleDateFormat("HH:mm"); Date d1 = null; diff --git a/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java b/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java index 4c0d4ef..e65e218 100755 --- a/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java +++ b/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java @@ -28,6 +28,9 @@ public class SharePerferenceModel implements Serializable { private boolean isTriggerScreen = true; private final static String KEY_IS_TRIGGER_SCREEN = "key_is_trigger_screen"; + private boolean hourSystem12 = false; + private final static String KEY_IS_HOUR_SYSTEM_12 = "key_is_hour_system_12"; + private final static String KEY_CITY = "key_city"; private String mCity; @@ -193,6 +196,7 @@ public class SharePerferenceModel implements Serializable { backgroundColor=jsonObject.optInt(KEY_BACKGROUND_COLOR,Color.rgb(0, 0, 0)); foregroundColor=jsonObject.optInt(KEY_FOREGROUND_COLOR,Color.rgb(255, 255, 255)); foregroundColor1=jsonObject.optInt(KEY_FOREGROUND_COLOR1,Color.rgb(199,21,133)); + hourSystem12=jsonObject.optBoolean(KEY_IS_HOUR_SYSTEM_12,false); } catch (JSONException e) { e.printStackTrace(); } @@ -221,6 +225,7 @@ public class SharePerferenceModel implements Serializable { jsonObject.put(KEY_BACKGROUND_COLOR,backgroundColor); jsonObject.put(KEY_FOREGROUND_COLOR,foregroundColor); jsonObject.put(KEY_FOREGROUND_COLOR1,foregroundColor1); + jsonObject.put(KEY_IS_HOUR_SYSTEM_12,hourSystem12); } catch (JSONException e) { e.printStackTrace(); } @@ -260,6 +265,7 @@ public class SharePerferenceModel implements Serializable { ", backgroundColor="+backgroundColor+ ", foregroundColor="+foregroundColor+ ", foregroundColor1="+foregroundColor1+ + ", hourSystem12="+hourSystem12+ '}'; } @@ -311,4 +317,12 @@ public class SharePerferenceModel implements Serializable { public void setForegroundColor1(Integer foregroundColor1) { this.foregroundColor1 = foregroundColor1; } + + public boolean isHourSystem12() { + return hourSystem12; + } + + public void setHourSystem12(boolean hourSystem12) { + this.hourSystem12 = hourSystem12; + } } diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/ClockAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/ClockAnimator.java new file mode 100644 index 0000000..d5eb4c2 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/ClockAnimator.java @@ -0,0 +1,331 @@ +package clock.socoolby.com.clock.widget.animatorview.animator; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import java.util.Calendar; + +import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator; + +// 参考自:https://github.com/ifadai/ClockDemo +public class ClockAnimator extends AbstractAnimator { + private final String TAG = getClass().getSimpleName(); + + @Override + public boolean run() { + for(Clock clock:list) + clock.getTime(); + return true; + } + + @Override + public void onDraw(Canvas canvas) { + for(Clock clock:list) + clock.onDraw(canvas); + } + + @Override + public void reset() { + super.reset(); + int textColor=color; + if(randColor) + randomColor(); + int minHigh=Math.min(width,height); + int r=rand.nextInt(minHigh); + if(r { + + + @Override + public void reset() { + super.reset(); + addFires(1); + } + + int high=0; + int fireWidth=0; + int particlesCount; + public void addFires(int quantity) { + + for (int i = 0; i < quantity;i++) { + high=rand.nextInt(height); + if(high<=height/3) + high=high+height/2; + fireWidth=rand.nextInt(width/2); + particlesCount=rand.nextInt(300); + particlesCount=particlesCount>150?particlesCount:particlesCount+150; + list.add(new ParticleSystem(width/2,height,high,fireWidth,particlesCount,rand.nextInt(30))); + } + } + + @Override + public boolean run() { + for(ParticleSystem fire:list) + fire.update(WIND.NULL,0); + //fire.update(rand.nextFloat()*0.18f); + return true; + } + + @Override + public void onDraw(Canvas canvas) { + for(ParticleSystem fire:list) + fire.onDraw(canvas); + } + + public class ParticleSystem { + private List particles = new ArrayList<>(); + private int fire_width = 20; + private int particle_width=20; + private Paint paint = new Paint(); + private int x,y,high; + + + public ParticleSystem(int x,int y,int high,int fire_width,int particlesCount,int particle_width) { + this.x=x; + this.y=y; + this.high=high; + this.fire_width =fire_width; + this.particle_width=particle_width; + if(particle_width<10) + this.particle_width=10; + if(randColor) { + randomColor(); + paint.setColor(color); + }else + paint.setColor(Color.RED); + for (int i = 0; i < particlesCount; i++) { + particles.add(newParticle()); + } + } + + public void onDraw(Canvas canvas) { + for (int i = 0; i < particles.size(); i++) { + Particle particle = particles.get(i); + paint.setAlpha(particle.alpha); + canvas.drawRect(particle.getX(), particle.getY(), particle.getX() + particle_width, particle.getY() + particle_width, paint); + } + } + + /** + * 粒子集合更新方法 + * + * @param wind wind是风,volume 是风加速度 0时代表无风,粒子不偏移 + */ + public void update(WIND wind,float volume) { + for (int i = 0; i < particles.size(); i++) { + Particle particle = particles.get(i); + + if (particle.xv > 0) { + //当初始加速度为正,就一直为正 + particle.xv += 0.01f + volume; + } else { + //当初始加速度为负,就一直为正 + particle.xv += -0.01f + volume; + } + particle.yv = particle.yv + 0.1f; + switch (wind){ + case LEFT_TO_RIGHT: + break; + case RIGHT_TO_LEFT: + break; + } + + particle.setX(particle.getX() + particle.xv); + particle.setY(particle.getY() - particle.yv); + //跟据上升高度 计算透明度 + particle.alpha = 255-(int) ((y-particle.y)*255/high); + } + List list = new ArrayList<>(); + list.addAll(particles); + for (Particle particle : list) { + if (particle.getY() < y-high) { + moveToTrashCache(particle); + particles.remove(particle); + } + } + for (int i = 0; i < 5; i++) { + particles.add(newParticle()); + } + } + + + public Particle newParticle(){ + Particle particle =revectForTrashCache(); + if(particle==null) + particle = new Particle(); + if(rand.nextBoolean()) + particle.x=x - rand.nextInt(fire_width /2); + else + particle.x=x + rand.nextInt(fire_width /2); + particle.y=y; + particle.xv = 0.5f - 1 * rand.nextFloat(); + particle.yv=1; + particle.alpha=255; + return particle; + } + } + + //用于两边向中间靠拢 + public enum WIND{ + LEFT_TO_RIGHT,NULL,RIGHT_TO_LEFT, + TORNADO;//龙卷风 + } + + public class Particle { + //火焰粒子坐标 + private float x; + private float y; + public float xv = 1;//x轴加速度 + public float yv = 1;//y轴加速度 + public int alpha; + + public Particle(){ + } + + public Particle(float x, float y) { + this.x = x; + this.y = y; + } + + public float getX() { + return x; + } + + public void setX(float x) { + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + this.y = y; + } + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FishAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FishAnimator.java new file mode 100644 index 0000000..75710c7 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FishAnimator.java @@ -0,0 +1,381 @@ +package clock.socoolby.com.clock.widget.animatorview.animator; + +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.ColorFilter; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PixelFormat; +import android.graphics.PointF; + +//参考自:https://blog.csdn.net/guimianhao9833/article/details/75094010 +public class FishAnimator { + + + private static final String TAG = "Jcs_Fishsss"; + private static final float HEAD_RADIUS = 50; + protected static final float BODY_LENGHT = HEAD_RADIUS * 3.2f; //第一节身体长度 + private static final int BODY_ALPHA = 220; + private static final int OTHER_ALPHA = 160; + private static final int FINS_ALPHA = 100; + private static final int FINS_LEFT = 1;//左鱼鳍 + private static final int FINS_RIGHT = -1; + private static final float FINS_LENGTH = HEAD_RADIUS * 1.3f; + public static final float TOTAL_LENGTH = 6.79f * HEAD_RADIUS; + + public class Fish{ + private Paint mPaint; + //控制区域 + private int currentValue = 0;//全局控制标志 + private float mainAngle = 90;//角度表示的角 + private float waveFrequence = 1; + //鱼头点 + private PointF headPoint; + //转弯更自然的中心点 + private PointF middlePoint; + private float finsAngle = 0; + private Paint bodyPaint; + private Path mPath; + + public Fish() { + init(); + } + + public void run(){ + //currentValue = (int) (animation.getAnimatedValue()); + //invalidateSelf(); + } + + private void init() { + + //路径 + mPath = new Path(); + //画笔 + mPaint = new Paint(); + mPaint.setAntiAlias(true); + mPaint.setStyle(Paint.Style.FILL); + mPaint.setDither(true);//防抖 + mPaint.setColor(Color.argb(OTHER_ALPHA, 244, 92, 71)); + //身体画笔 + bodyPaint = new Paint(); + bodyPaint.setAntiAlias(true); + bodyPaint.setStyle(Paint.Style.FILL); + bodyPaint.setDither(true);//防抖 + bodyPaint.setColor(Color.argb(OTHER_ALPHA + 5, 244, 92, 71)); + middlePoint = new PointF(4.18f * HEAD_RADIUS, 4.18f * HEAD_RADIUS); + + //鱼鳍灵动动画 + //finsAnimator = ObjectAnimator.ofFloat(this, "finsAngle", 0f, 1f, 0f); + //finsAnimator.setRepeatMode(ValueAnimator.REVERSE); + //finsAnimator.setRepeatCount(new Random().nextInt(3)); + + //引擎部分 + //ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 540 * 100); + //valueAnimator.setDuration(180 * 1000); + //valueAnimator.setInterpolator(new LinearInterpolator()); + //valueAnimator.setRepeatCount(ValueAnimator.INFINITE); + //valueAnimator.setRepeatMode(ValueAnimator.REVERSE); + //valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + // @Override + // public void onAnimationUpdate(ValueAnimator animation) { + // currentValue = (int) (animation.getAnimatedValue()); + // invalidateSelf(); + // } + //}); + //valueAnimator.addListener(new AnimatorListenerAdapter() { + // @Override + // public void onAnimationRepeat(Animator animation) { + // super.onAnimationRepeat(animation); + // finsAnimator.start(); + // } + //}); + //valueAnimator.start(); + + } + + public PointF getHeadPoint() { + return headPoint; + } + + /** + * 设置身体主轴线方向角度 + * + * @param mainAngle + */ + public void setMainAngle(float mainAngle) { + this.mainAngle = mainAngle; + } + + /** + * 获取当前角度 + * + * @return + */ + public float getMainAngle() { + return mainAngle; + } + + /** + * 设置头的位置 + * + * @param headPoint + */ + public void setHeadPoint(PointF headPoint) { + this.headPoint = headPoint; + } + + public void setMiddlePoint(PointF middlePoint) { + this.middlePoint = middlePoint; + } + + public PointF getMiddlePoint() { + return middlePoint; + } + + public float getTotalLength() { + return TOTAL_LENGTH; + } + + public void draw(Canvas canvas) { + + //生成一个半透明图层,否则与背景白色形成干扰,尺寸必须与view的大小一致否则鱼显示不全 + canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), 240, Canvas.ALL_SAVE_FLAG); + makeBody(canvas, HEAD_RADIUS); + canvas.restore(); + mPath.reset(); + mPaint.setColor(Color.argb(OTHER_ALPHA, 244, 92, 71)); + } + + //画身子 + + /** + * 主方向是头到尾的方向跟X轴正方向的夹角(顺时针为正) + * 前进方向和主方向相差180度 + * R + 3.2R + * + * @param canvas + * @param headRadius + */ + private void makeBody(Canvas canvas, float headRadius) { + //sin参数为弧度值 + //现有角度=原始角度+ sin(域值[-1,1])*可摆动的角度 sin作用是控制周期摆动 + float angle = mainAngle + (float) Math.sin(Math.toRadians(currentValue * 1.2 * waveFrequence)) * 2;//中心轴线加偏移量和X轴顺时针方向夹角 + headPoint = calculatPoint(middlePoint, BODY_LENGHT / 2,mainAngle); + //画头 + canvas.drawCircle(headPoint.x, headPoint.y, HEAD_RADIUS, mPaint); + //右鳍 起点 + PointF pointFinsRight = calculatPoint(headPoint, headRadius * 0.9f, angle -110); + makeFins(canvas, pointFinsRight, FINS_RIGHT, angle); + //左鳍 起点 + PointF pointFinsLeft = calculatPoint(headPoint, headRadius * 0.9f, angle +110); + makeFins(canvas, pointFinsLeft, FINS_LEFT, angle); + + PointF endPoint = calculatPoint(headPoint, BODY_LENGHT, angle-180); + //躯干2 + PointF mainPoint = new PointF(endPoint.x, endPoint.y); + makeSegments(canvas, mainPoint, headRadius * 0.7f, 0.6f, angle); + PointF point1, point2, point3, point4, contralLeft, contralRight; + //point1和4的初始角度决定发髻线的高低值越大越低 + point1 = calculatPoint(headPoint, headRadius, angle-80); + point2 = calculatPoint(endPoint, headRadius * 0.7f, angle-90); + point3 = calculatPoint(endPoint, headRadius * 0.7f, angle +90); + point4 = calculatPoint(headPoint, headRadius, angle +80); + //决定胖瘦 + contralLeft = calculatPoint(headPoint, BODY_LENGHT * 0.56f, angle -130); + contralRight = calculatPoint(headPoint, BODY_LENGHT * 0.56f, angle +130); + mPath.reset(); + mPath.moveTo(point1.x, point1.y); + mPath.quadTo(contralLeft.x, contralLeft.y, point2.x, point2.y); + mPath.lineTo(point3.x, point3.y); + mPath.quadTo(contralRight.x, contralRight.y, point4.x, point4.y); + mPath.lineTo(point1.x, point1.y); + + mPaint.setColor(Color.argb(BODY_ALPHA, 244, 92, 71)); + //画最大的身子 + canvas.drawPath(mPath, mPaint); + } + + /** + * 第二节节肢 + * 0.7R * 0.6 =1.12R + * + * @param canvas + * @param mainPoint + * @param segmentRadius + * @param MP 梯形上边下边长度比 + */ + private void makeSegments(Canvas canvas, PointF mainPoint, float segmentRadius, float MP, float fatherAngle) { + float angle = fatherAngle + (float) Math.cos(Math.toRadians(currentValue * 1.5 * waveFrequence)) * 15;//中心轴线和X轴顺时针方向夹角 + //身长 + float segementLenght = segmentRadius * (MP + 1); + PointF endPoint = calculatPoint(mainPoint, segementLenght, angle-180); + + PointF point1, point2, point3, point4; + point1 = calculatPoint(mainPoint, segmentRadius, angle-90); + point2 = calculatPoint(endPoint, segmentRadius * MP,angle-90); + point3 = calculatPoint(endPoint, segmentRadius * MP, angle +90); + point4 = calculatPoint(mainPoint, segmentRadius, angle+90); + + canvas.drawCircle(mainPoint.x, mainPoint.y, segmentRadius, mPaint); + canvas.drawCircle(endPoint.x, endPoint.y, segmentRadius * MP, mPaint); + mPath.reset(); + mPath.moveTo(point1.x, point1.y); + mPath.lineTo(point2.x, point2.y); + mPath.lineTo(point3.x, point3.y); + mPath.lineTo(point4.x, point4.y); + canvas.drawPath(mPath, mPaint); + + //躯干2 + PointF mainPoint2 = new PointF(endPoint.x, endPoint.y); + makeSegmentsLong(canvas, mainPoint2, segmentRadius * 0.6f, 0.4f, angle); + } + + /** + * 第三节节肢 + * 0.7R * 0.6 * (0.4 + 2.7) + 0.7R * 0.6 * 0.4=1.302R + 0.168R + * + * @param canvas + * @param mainPoint + * @param segmentRadius + * @param MP 梯形上边下边长度比 + */ + private void makeSegmentsLong(Canvas canvas, PointF mainPoint, float segmentRadius, float MP, float fatherAngle) { + float angle = fatherAngle + (float) Math.sin(Math.toRadians(currentValue * 1.5 * waveFrequence)) * 35;//中心轴线和X轴顺时针方向夹角 + //身长 + float segementLenght = segmentRadius * (MP + 2.7f); + PointF endPoint = calculatPoint(mainPoint, segementLenght, angle-180); + + PointF point1, point2, point3, point4; + point1 = calculatPoint(mainPoint, segmentRadius, angle -90 ); + point2 = calculatPoint(endPoint, segmentRadius * MP,angle -90 ); + point3 = calculatPoint(endPoint, segmentRadius * MP, angle +90); + point4 = calculatPoint(mainPoint, segmentRadius, angle +90); + + makeTail(canvas, mainPoint, segementLenght, segmentRadius, angle); + + + canvas.drawCircle(endPoint.x, endPoint.y, segmentRadius * MP, mPaint); + mPath.reset(); + mPath.moveTo(point1.x, point1.y); + mPath.lineTo(point2.x, point2.y); + mPath.lineTo(point3.x, point3.y); + mPath.lineTo(point4.x, point4.y); + canvas.drawPath(mPath, mPaint); + } + + /** + * 鱼鳍 + * + * @param canvas + * @param startPoint + * @param type + */ + private void makeFins(Canvas canvas, PointF startPoint, int type, float fatherAngle) { + float contralAngle = 115;//鱼鳍三角控制角度 + mPath.reset(); + mPath.moveTo(startPoint.x, startPoint.y); + PointF endPoint = calculatPoint(startPoint, FINS_LENGTH, type == FINS_RIGHT ? fatherAngle - finsAngle-180 : fatherAngle + finsAngle+180); + PointF contralPoint = calculatPoint(startPoint, FINS_LENGTH * 1.8f, type == FINS_RIGHT ? + fatherAngle - contralAngle - finsAngle : fatherAngle + contralAngle + finsAngle); + mPath.quadTo(contralPoint.x, contralPoint.y, endPoint.x, endPoint.y); + mPath.lineTo(startPoint.x, startPoint.y); + mPaint.setColor(Color.argb(FINS_ALPHA, 244, 92, 71)); + canvas.drawPath(mPath, mPaint); + mPaint.setColor(Color.argb(OTHER_ALPHA, 244, 92, 71)); + + } + + /** + * 鱼尾及鱼尾张合 + * + * @param canvas + * @param mainPoint + * @param length + * @param maxWidth + */ + private void makeTail(Canvas canvas, PointF mainPoint, float length, float maxWidth, float angle) { + float newWidth = (float) Math.abs(Math.sin(Math.toRadians(currentValue * 1.7 * waveFrequence)) * maxWidth + HEAD_RADIUS/5*3); + //endPoint为三角形底边中点 + PointF endPoint = calculatPoint(mainPoint, length, angle-180); + PointF endPoint2 = calculatPoint(mainPoint, length - 10, angle-180); + PointF point1, point2, point3, point4; + point1 = calculatPoint(endPoint, newWidth, angle-90); + point2 = calculatPoint(endPoint, newWidth, angle +90); + point3 = calculatPoint(endPoint2, newWidth - 20, angle-90); + point4 = calculatPoint(endPoint2, newWidth - 20, angle +90); + //内 + mPath.reset(); + mPath.moveTo(mainPoint.x, mainPoint.y); + mPath.lineTo(point3.x, point3.y); + mPath.lineTo(point4.x, point4.y); + mPath.lineTo(mainPoint.x, mainPoint.y); + canvas.drawPath(mPath, mPaint); + //外 + mPath.reset(); + mPath.moveTo(mainPoint.x, mainPoint.y); + mPath.lineTo(point1.x, point1.y); + mPath.lineTo(point2.x, point2.y); + mPath.lineTo(mainPoint.x, mainPoint.y); + canvas.drawPath(mPath, mPaint); + + } + + private void setFinsAngle(float currentValue) { + finsAngle = 45 * currentValue; + } + + + public void setWaveFrequence(float waveFrequence) { + this.waveFrequence = waveFrequence; + } + + + + + public void setAlpha(int alpha) { + mPaint.setAlpha(alpha); + } + + + public void setColorFilter(ColorFilter colorFilter) { + mPaint.setColorFilter(colorFilter); + } + + + public int getOpacity() { + return PixelFormat.TRANSLUCENT; + } + + /** + * 高度要容得下两个鱼身长度 + * 8.36计算过程 身长6.79减去头顶到中部位置的长度2.6 再乘以2 + * + * @return + */ + + public int getIntrinsicHeight() { + return (int) (8.38f * HEAD_RADIUS); + } + + + public int getIntrinsicWidth() { + return (int) (8.38f * HEAD_RADIUS); + } + } + + + /** + * 输入起点、长度、旋转角度计算终点 + * @param startPoint 起点 + * @param length 长度 + * @param angle 旋转角度 + * @return 计算结果点 + */ + private static PointF calculatPoint(PointF startPoint, float length, float angle) { + float deltaX = (float) Math.cos(Math.toRadians(angle)) * length; + //符合Android坐标的y轴朝下的标准 + float deltaY = (float) Math.sin(Math.toRadians(angle-180)) * length; + return new PointF(startPoint.x + deltaX, startPoint.y + deltaY); + } + +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java new file mode 100644 index 0000000..c3018d0 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java @@ -0,0 +1,345 @@ +package clock.socoolby.com.clock.widget.animatorview.animator; + + +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; + +import java.util.ArrayList; +import java.util.List; + +import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator; + +//参考自:https://github.com/zhuwentao2150/RippleView +public class RippleAnimator extends AbstractAnimator { + + @Override + public void reset() { + super.reset(); + Style style; + int ran=rand.nextInt(3); + if(ran==2) + style=Style.OUT; + else if(ran==1) + style=Style.BREATH; + else + style=Style.IN; + list.add(new Ripple(width,height,Color.BLUE,style)); + } + + + @Override + public boolean run() { + for(Ripple ripple:list) + ripple.breath(); + return true; + } + + @Override + public void onDraw(Canvas canvas) { + for(Ripple ripple:list) + ripple.onDraw(canvas); + } + + public enum Style{ + IN,OUT,BREATH; + } + + public class Ripple{ + // 画笔对象 + private Paint mPaint; + + // View宽 + private float mWidth; + + // View高 + private float mHeight; + + // 声波的圆圈集合 + private List mRipples; + + private int sqrtNumber; + + // 圆圈扩散的速度 + private int mSpeed; + + // 圆圈之间的密度 + private int mDensity; + + // 圆圈的颜色 + private int mColor; + + // 圆圈是否为填充模式 + private boolean mIsFill; + + // 圆圈是否为渐变模式 + private boolean mIsAlpha; + + Style style; + + + + public Ripple(float mWidth, float mHeight, int mColor,Style style) { + this.mWidth = mWidth; + this.mHeight = mHeight; + this.mColor = mColor; + this.style=style; + + init(); + } + + private void init() { + mSpeed = 1; + mDensity = 10; + mIsFill = true; + mIsAlpha = true; + + // 设置画笔样式 + mPaint = new Paint(); + mPaint.setColor(mColor); + mPaint.setStrokeWidth(Util.dipToPX(context,1)); + if (mIsFill) { + mPaint.setStyle(Paint.Style.FILL); + } else { + mPaint.setStyle(Paint.Style.STROKE); + } + mPaint.setStrokeCap(Paint.Cap.ROUND); + mPaint.setAntiAlias(true); + + // 添加第一个圆圈 + mRipples = new ArrayList<>(); + addNewCircle(); + + mDensity = Util.dipToPX(context, mDensity); + } + + public void onDraw(Canvas canvas) { + switch (style){ + case BREATH: + //呼吸的 + drawBreath(canvas); + break; + case OUT: + // 外切正方形 + drawOutCircle(canvas); + break; + default: + // 内切正方形 + drawInCircle(canvas); + } + + } + + + private void addNewCircle(){ + Circle c = new Circle(0, 255); + if(randColor) { + randomColor(); + c.color=color; + }else + c.color=mColor; + mRipples.add(c); + } + + /** + * 圆到宽度 + * + * @param canvas + */ + private void drawInCircle(Canvas canvas) { + canvas.save(); + + // 处理每个圆的宽度和透明度 + for (int i = 0; i < mRipples.size(); i++) { + Circle c = mRipples.get(i); + mPaint.setAlpha(c.alpha);// (透明)0~255(不透明) + canvas.drawCircle(mWidth / 2, height / 2, c.width - mPaint.getStrokeWidth(), mPaint); + + // 当圆超出View的宽度后删除 + if (c.width > width / 2) { + mRipples.remove(i); + } else { + // 计算不透明的数值,这里有个小知识,就是如果不加上double的话,255除以一个任意比它大的数都将是0 + if (mIsAlpha) { + double alpha = 255 - c.width * (255 / ((double) mWidth / 2)); + c.alpha = (int) alpha; + } + // 修改这个值控制速度 + c.width += mSpeed; + } + } + + + // 里面添加圆 + if (mRipples.size() > 0) { + // 控制第二个圆出来的间距 + if (mRipples.get(mRipples.size() - 1).width > Util.dipToPX(context, mDensity)) { + addNewCircle(); + } + } + canvas.restore(); + } + + + /** + * 圆到对角线 + * + * @param canvas + */ + private void drawOutCircle(Canvas canvas) { + canvas.save(); + + // 使用勾股定律求得一个外切正方形中心点离角的距离 + sqrtNumber = (int) (Math.sqrt(mWidth * mWidth + mHeight * mHeight) / 2); + + // 变大 + for (int i = 0; i < mRipples.size(); i++) { + + // 启动圆圈 + Circle c = mRipples.get(i); + mPaint.setAlpha(c.alpha);// (透明)0~255(不透明) + canvas.drawCircle(mWidth / 2, mHeight / 2, c.width - mPaint.getStrokeWidth(), mPaint); + + // 当圆超出对角线后删掉 + if (c.width > sqrtNumber) { + mRipples.remove(i); + } else { + // 计算不透明的度数 + double degree = 255 - c.width * (255 / (double) sqrtNumber); + c.alpha = (int) degree; + c.width += 1; + } + } + + // 里面添加圆 + if (mRipples.size() > 0) { + // 控制第二个圆出来的间距 + if (mRipples.get(mRipples.size() - 1).width == 50) { + addNewCircle(); + } + } + canvas.restore(); + } + + private float breathDirection = 1;//呼吸方向(+1:变亮,-1:变暗) + private float breathSpeed = 0.02f;//呼吸速度 + private boolean isBreathing = false; + + private int a = 0; + private float breath = 1f;//控制呼吸 + private int waveCount = 5;//波纹的总个数 + + public void drawBreath(Canvas canvas) { + + int alphaSpeed; + float radiusSpeed; + float hw = mWidth/2f; + + /** + * 根据view的宽度计算半径和透明度的变化速度,(为了尽力保证半径和透明度同时达到最值:255是透明度的最大值) + */ + if(hw >255f){ + radiusSpeed = hw/255f; + alphaSpeed = 1; + }else { + alphaSpeed = new Float(255f/hw).intValue(); + radiusSpeed = 1; + } + + /** + * 控制呼吸 + */ + if(isBreathing){ + breath=breath+breathSpeed*breathDirection; + if(breath>1 ){ + breathDirection *= -1;//呼吸反向 + if(beforBreathIsAwave){ + isBreathing = false; + isStarting = true; + breath = 1; + } + + }else if(breath <0.001){ + breathDirection *= -1;//呼吸反向 + if(!beforBreathIsAwave){ + isBreathing = false; + isStarting = false; + breath = 1; + } + } + } + + + /** + * 当达到设定的波距或第一次运行时 添加一个新波 + */ + if (++a>= (hw/waveCount) || mRipples.size()<1){ + a = 0; + addNewCircle(); + } + + for (int i= 0;i< mRipples.size();i++){ + Circle temp = mRipples.get(i); + if(isStarting){ + temp.alpha=temp.alpha-alphaSpeed;//改变波的透明度 + if(temp.alpha <0){ + temp.alpha=0; + } + temp.width=temp.width + new Float(radiusSpeed).intValue();//增加波的半径 + } + mPaint.setColor(temp.color); + int tempAlpha = (int)(temp.alpha*breath);//乘以breath是为了通过改变透明度达到呼吸的效果 + mPaint.setAlpha(tempAlpha<0?0:tempAlpha); + canvas.drawCircle(mWidth / 2, mHeight / 2, temp.width, mPaint);//绘制波 + + + /** + * 当波的半径大于本控件的宽大时删除这个波 + */ + if( temp.width >mWidth || temp.alpha <0){ + mRipples.remove(temp); + } + } + } + + private boolean beforBreathIsAwave = true; + private boolean isStarting = true; + + private int sleep=0; + + /** + * 此方法调用一次波会呼吸一次 + */ + public synchronized void breath(){ + sleep++; + if(sleep<10) + return; + sleep=0; + this.beforBreathIsAwave = isStarting; + if(beforBreathIsAwave){ + breath = 1; + breathDirection =-1; + } + else { + breath = 0.01f; + breathDirection = 1; + } + isBreathing = true; + } + + } + + + class Circle { + Circle(int width, int alpha) { + this.width = width; + this.alpha = alpha; + } + + int width; + + int alpha; + + int color; + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java new file mode 100644 index 0000000..e9266e2 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java @@ -0,0 +1,256 @@ +package clock.socoolby.com.clock.widget.animatorview.animator; + +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; + +import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator; + +public class WaterAnimator extends AbstractAnimator { + + + @Override + public boolean run() { + for(Water water:list) { + water.runWave(); + } + return true; + } + + @Override + public void onDraw(Canvas canvas) { + for(Water water:list) { + water.drawWaterView(canvas); + } + } + + @Override + public void reset() { + super.reset(); + addWater(1); + } + + + Water water; + + public void addWater(int quantity) { + for (int i = 0; i < quantity;i++) { + if(randColor) + randomColor(); + Water water=new Water(color,50); + list.add(water); + } + } + + + public class Water{ + private int mWaterWidth;//水波纹圆形的宽度 + private int mWaterHeight;//水波纹圆形的高度 + private int mWaveCount = 2;//水波纹的个数 + private int mStep = 0;//移步的步长 + private float mWaterRange = 30;//水波纹的高度 + + private int mProgressY;//水波纹的中心的Y轴 + + //private int mRadius;//水波纹圆的半径 + private int mWaveLength;//波纹的宽度 + private Path path; + private int waterColor;//水波纹的颜色 + private Paint waterPaint; + + private int mPercent = 0;//当前进度0-100,决定Y点位置 + + public Water(int waterColor,int mPercent) { + this.waterColor = waterColor; + this.mPercent=mPercent; + initWaveRange(); + } + + /** + * 初始化水波纹的振幅 + */ + public void initWaveRange() { + //mHeight = Math.min(width, height); + mWaterWidth = Math.min(width, height); + mWaterHeight = Math.min(width, height); + + waterPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + waterPaint.setAntiAlias(true); + waterPaint.setColor(waterColor); + waterPaint.setStrokeWidth(3); + waterPaint.setStyle(Paint.Style.FILL_AND_STROKE); + + mStep=rand.nextInt(width);//移动步长 + + mWaterRange = rand.nextInt(200);//高度 + if(mWaterRange<10) + mWaterRange=50; + mWaveCount=1;//波浪数 + path = new Path(); + mWaveLength = mWaterWidth / mWaveCount;//每个波浪数长度 + } + + /** + * 绘制水波纹 + * + * @param canvas + * + */ + public void drawWaterView(Canvas canvas) { + mProgressY = mWaterHeight - (mWaterHeight * mPercent / 100); + + //从左到右 + canvas.drawPath(getPath(), waterPaint); + + //从右到左 + + //确定贝塞尔曲线各个点的位置 + path.reset(); + path.moveTo(0 , mProgressY); + //从左往右绘制 + Point point=null; + //w为什么是mWaveCount*3,那是因为需要在不可见的区域多绘制几个曲线,这样就可以形成 + //波浪的效果,如果只有一个mWaveCount的话,那么就是一个简单的正选曲线 + for (int i = 1; i <= mWaveCount * 3; i++) { + int x1 = mWaveLength * i - mWaveLength / 2 - mStep; + + if (i % 2 != 0) { + path.quadTo(x1, + mProgressY - mWaterRange, + mWaveLength * i - mStep, + mProgressY); + + //point=getControlPointF(new Point(x1,mProgressY - mWaterRange),new Point(mWaveLength * i - mStep,mProgressY),new Point(width / 2, mProgressY + mWaveLength * i - mWaveLength / 2)); + + } else { + path.quadTo( + x1, + mProgressY + mWaterRange, + mWaveLength * i - mStep, + mProgressY); + //point=getControlPointF(new Point(x1,mProgressY + mWaterRange),new Point(mWaveLength * i - mStep,mProgressY),new Point(width / 2, mProgressY + mWaveLength * i - mWaveLength / 2)); + + } + //Paint temp=new Paint(); + //temp.setColor(Color.WHITE); + //canvas.drawCircle(width / 2,point.y-100,30,temp); + } + + path.lineTo(mWaveCount * 2 * mWaveLength,mWaterHeight); + + path.lineTo(0, mWaterHeight); + + path.close(); + canvas.drawPath(path, waterPaint); + + } + + + /** + * 核心代码,计算path + * @return + */ + private Path getPath(){ + int itemWidth = mWaterWidth/2;//半个波长 + Path mPath = new Path(); + mPath.moveTo(-itemWidth * 3, mProgressY);//起始坐标 + //核心的代码就是这里 + for (int i = -3; i < 4; i++) { + int startX = i * itemWidth; + mPath.quadTo( + startX + itemWidth/2 + mStep,//控制点的X,(起始点X + itemWidth/2 + offset) + getWaveHeigh( i ),//控制点的Y + startX + itemWidth + mStep,//结束点的X + mProgressY//结束点的Y + );//只需要处理完半个波长,剩下的有for循环自已就添加了。 + } + //下面这三句话很重要,它是形成了一封闭区间,让曲线以下的面积填充一种颜色,大家可以把这3句话注释了看看效果。 + mPath.lineTo(width,height); + mPath.lineTo(0,height); + mPath.close(); + return mPath; + } + + //奇数峰值是正的,偶数峰值是负数 + private float getWaveHeigh(int num){ + if(num % 2 == 0){ + return mProgressY + mWaterRange; + } + return mProgressY - mWaterRange; + } + + + + /** + * Author: MrGao + * CreateTime: 2018/1/4 16:29 + * MethodName: + * Des:水波纹动画 + * Params: + * Return: + **/ + public void runWave(){ + mStep = mStep+mWaveLength/30 ; + if(mStep>width) + mStep=0; + //mStep=rand.nextInt(20); + } + + } + + /** + * 绘制外层的刻度 + * + * @param canvas + protected void drawOutArc(Canvas canvas) { + canvas.save(); + for (int i = 0; i < 100; i++) { + if (i < mPercent) { + mOutProgressPaint.setColor(mProgressColor); + } else { + mOutProgressPaint.setColor(mOutBaseColor); + } + canvas.rotate(3.6f, width / 2, height / 2); + canvas.drawLine(width / 2, 0, height / 2, mDefaultLineLen, mOutProgressPaint); + + } + canvas.restore(); + } + */ + + /** + * 根据 最高点,获取贝塞尔曲线的 控制点 + * + * @param startPointF 开始点 + * @param endPointF 结束点 + * @param bezierPointF 最高点 + * @return 控制点 + */ + public static Point getControlPointF(Point startPointF, Point endPointF, Point bezierPointF) { + //B(t)=(1-t)^2P0+2t(1-t)P1+t^2P2; + Point controlPointF = new Point(0l, 0l); + float tmp = 0.5F; + float t = 0.5F; + controlPointF.setX((bezierPointF.x - tmp * tmp * startPointF.y - t * t * endPointF.y) / (2 * t * tmp)); + controlPointF.setY((bezierPointF.y- tmp * tmp * startPointF.y - t * t * endPointF.y) / (2 * t * tmp)); + return controlPointF; + } + + public static class Point{ + public float x,y; + public Point(float x,float y){ + this.x=x; + this.y=y; + } + + public void setX(float x){ + this.x=x; + } + + public void setY(float y){ + this.y=y; + } + } + +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java new file mode 100644 index 0000000..adf0123 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java @@ -0,0 +1,130 @@ +package clock.socoolby.com.clock.widget.animatorview.animator; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.util.Log; + +import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator; + +//参考:https://blog.csdn.net/u014112893/article/details/78556098 +public class WindmillAnimator extends AbstractAnimator { + + + @Override + public boolean run() { + for(Windmill windmill:list) + windmill.run(); + return true; + } + + @Override + public void onDraw(Canvas canvas) { + for(Windmill windmill:list) + windmill.onDraw(canvas); + } + + @Override + public void reset() { + super.reset(); + addWindmill(3); + } + + private void addWindmill(int quantity){ + //用于个个之间保证有足够的间距,不会都在一起 + int step=width/quantity; + + for(int i=0;iheight) + y=height-h-30; + int w=h*3/4; + if(x+w>width) + x=width-w-30; + if(randColor) + randomColor(); + list.add(new Windmill(x,y,h,w,color)); + } + } + + public class Windmill{ + private Paint mPaint; + private Path mPath; + private int width, height; + private int x,y; + int color; + + private int lineWidth = 5; + private int windmillLeng; // 扇叶长度 + private float lengthOfSide; // 扇叶小三角形的斜边长 + private float angle = 0F; + + private int delay=0;//使个个转动都不同 + + public Windmill(int x,int y,int width, int height,int color) { + this.width = width; + this.height = height; + this.x=x; + this.y=y; + this.color=color; + delay=rand.nextInt(5); + initPaint(); + } + + private void initPaint() { + mPaint = new Paint(); + mPath = new Path(); + mPaint.setColor(color); + mPaint.setStrokeWidth(lineWidth); + mPaint.setAntiAlias(true); + windmillLeng = Math.min(width, height) / 2 - 20; + lengthOfSide = (float) (windmillLeng / 10 / Math.cos(45)); + } + + int step=0; + public void run(){ + step++; + if(step= 360) angle = 0; + angle += 5; + } + + protected void onDraw(Canvas canvas) { + drawLines(canvas); + drawWindMills(canvas); + } + + + // 每个扇叶由2个三角形组成,小三角形是由2个等边直角三角形组成,变成是扇叶长度的十分之一 + private void drawWindMills(Canvas canvas) { + for (int i = 0; i < 3; i++) { + //Log.i("drawWindMills", height + " / " + windmillLeng); + mPath.moveTo(x+width / 2, y+ windmillLeng); + mPath.lineTo(x+width / 2 + lengthOfSide * (float) Math.sin(Math.PI / 180 * (-45 + angle + 120 * i)), + y+ windmillLeng - lengthOfSide * (float) Math.cos(Math.PI / 180 * (-45 + angle + 120 * i))); + mPath.lineTo(x+width / 2 + windmillLeng * (float) Math.sin(Math.PI / 180 * (120 * i + angle)), + y+ windmillLeng - windmillLeng * (float) Math.cos(Math.PI / 180 * (120 * i + angle))); + mPath.lineTo(x+width / 2 + lengthOfSide * (float) Math.sin(Math.PI / 180 * (45 + angle + 120 * i)), + y+ windmillLeng - lengthOfSide * (float) Math.cos(Math.PI / 180 * (45 + angle + 120 * i))); + mPath.lineTo(x+width / 2, y+ windmillLeng); + mPath.close(); + canvas.drawPath(mPath, mPaint); + } + mPath.reset(); + } + + // 绘制风车支架 + private void drawLines(Canvas canvas) { + canvas.drawLine(x+width / 3, y+height, x+width / 2, y+ windmillLeng, mPaint); + canvas.drawLine(x+width / 2, y+ windmillLeng, x+2 * width / 3, y+height, mPaint); + canvas.drawPath(mPath, mPaint); + } + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/bean/Particle.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/bean/Particle.java deleted file mode 100644 index 9bada0b..0000000 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/bean/Particle.java +++ /dev/null @@ -1,10 +0,0 @@ -package clock.socoolby.com.clock.widget.animatorview.animator.bean; - -public class Particle { - public int color; - public Double direction; - public float speed; - public float x = 0; - public float y = 0; - public float r=10; -} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/I_PraticleDraw.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/I_PraticleDraw.java new file mode 100644 index 0000000..3b245a1 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/I_PraticleDraw.java @@ -0,0 +1,8 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle; + +import android.graphics.Canvas; +import android.graphics.Paint; + +public interface I_PraticleDraw { + void draw(Canvas canvas, Particle particle, Paint paint); +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/Particle.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/Particle.java new file mode 100644 index 0000000..bb2de0c --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/Particle.java @@ -0,0 +1,30 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle; + +public class Particle { + //运动相关 + public float aX;//加速度 + public float aY;//加速度Y + public float vX;//速度X + public float vY;//速度Y + public long born;//诞生时间 + + //绘制相关 + public float x;//点位X,统一为中心点X + public float y;//点位Y,统一为中心点Y + public int color;//颜色 + public float r;//半径,主要用于计算所占面积,不只用于圆 + public int alpha;//透明度 + public I_PraticleDraw style; + + + + public Particle clone() { + Particle clone = null; + try { + clone = (Particle) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return clone; + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/CircleDrawer.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/CircleDrawer.java new file mode 100644 index 0000000..b8a0cb0 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/CircleDrawer.java @@ -0,0 +1,18 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle.drawer; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import clock.socoolby.com.clock.widget.animatorview.animator.particle.I_PraticleDraw; +import clock.socoolby.com.clock.widget.animatorview.animator.particle.Particle; + +public class CircleDrawer implements I_PraticleDraw { + public static final CircleDrawer INSTANCE=new CircleDrawer(); + + @Override + public void draw(Canvas canvas, Particle particle, Paint paint) { + paint.setAlpha(particle.alpha); + paint.setColor(particle.color); + canvas.drawCircle(particle.x,particle.y,particle.r,paint); + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/FilletSquareDrawer.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/FilletSquareDrawer.java new file mode 100644 index 0000000..fad2f1c --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/FilletSquareDrawer.java @@ -0,0 +1,24 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle.drawer; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Build; + +import clock.socoolby.com.clock.widget.animatorview.animator.particle.I_PraticleDraw; +import clock.socoolby.com.clock.widget.animatorview.animator.particle.Particle; + +public class FilletSquareDrawer implements I_PraticleDraw { + public static FilletSquareDrawer getInstance() { + return new FilletSquareDrawer(); + } + + @Override + public void draw(Canvas canvas, Particle particle, Paint paint) { + paint.setAlpha(particle.alpha); + paint.setColor(particle.color); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + canvas.drawRoundRect(particle.x - particle.r, particle.y - particle.r, particle.x + particle.r, particle.y + particle.r, particle.r / 2, particle.r / 2, paint); + }else + canvas.drawRect(particle.x-particle.r,particle.y-particle.r,particle.x+particle.r,particle.y+particle.r,paint); + } +} \ No newline at end of file diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/PolygonDrawer.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/PolygonDrawer.java new file mode 100644 index 0000000..f08320e --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/PolygonDrawer.java @@ -0,0 +1,4 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle.drawer; + +public class PolygonDrawer { +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/SquareDrawer.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/SquareDrawer.java new file mode 100644 index 0000000..ccab430 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/SquareDrawer.java @@ -0,0 +1,20 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle.drawer; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import clock.socoolby.com.clock.widget.animatorview.animator.particle.I_PraticleDraw; +import clock.socoolby.com.clock.widget.animatorview.animator.particle.Particle; + +public class SquareDrawer implements I_PraticleDraw { + public static SquareDrawer getInstance(){ + return new SquareDrawer(); + } + + @Override + public void draw(Canvas canvas, Particle particle, Paint paint) { + paint.setAlpha(particle.alpha); + paint.setColor(particle.color); + canvas.drawRect(particle.x-particle.r,particle.y-particle.r,particle.x+particle.r,particle.y+particle.r,paint); + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/TriangleDraw.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/TriangleDraw.java new file mode 100644 index 0000000..7e43a12 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/particle/drawer/TriangleDraw.java @@ -0,0 +1,45 @@ +package clock.socoolby.com.clock.widget.animatorview.animator.particle.drawer; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import clock.socoolby.com.clock.widget.animatorview.animator.particle.I_PraticleDraw; +import clock.socoolby.com.clock.widget.animatorview.animator.particle.Particle; + +public class TriangleDraw implements I_PraticleDraw { + public static TriangleDraw getInstance(){ + return new TriangleDraw(); + } + + Direction direction; + + public TriangleDraw() { + this(Direction.UP); + } + + public TriangleDraw(Direction direction) { + this.direction = direction; + } + + @Override + public void draw(Canvas canvas, Particle particle, Paint paint) { + canvas.save(); + paint.setAlpha(particle.alpha); + paint.setColor(particle.color); + canvas.rotate(direction.degree,particle.x,particle.y); + canvas.drawLine(particle.x, particle.y-particle.r, particle.x-particle.r,particle.y+particle.r, paint); + canvas.drawLine(particle.x, particle.y-particle.r, particle.x+particle.r,particle.y+particle.r, paint); + canvas.drawLine(particle.x-particle.r, particle.y+particle.r, particle.x+particle.r,particle.y+particle.r, paint); + canvas.restore(); + } + + + public enum Direction{ + LEFT(-270),RIGHT(-90),UP(0),DOWN(-180); + public float degree; + + Direction(float degree) { + this.degree = degree; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/AutoScrollTextView.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/AutoScrollTextView.java index 012e9ce..c8e93e0 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/textview/AutoScrollTextView.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/AutoScrollTextView.java @@ -56,12 +56,12 @@ public class AutoScrollTextView extends android.support.v7.widget.AppCompatTextV textLength = paint.measureText(text); viewWidth = getWidth(); - Log.e("zmm","--->"+textLength+"--->"+viewWidth+"-->"+getTextSize()); + Log.e(TAG,"--->"+textLength+"--->"+viewWidth+"-->"+getTextSize()); if(viewWidth == 0) { viewWidth = 600;//获取屏幕的宽度 } - Log.e("zmm","屏幕的宽度-->"+ 600); + Log.e(TAG,"屏幕的宽度-->"+ 600); step = textLength;//文字真实的长度 temp_view_plus_text_length = viewWidth/2 + textLength; temp_view_plus_two_text_length = viewWidth + textLength * 2;//文字移动的距离应该是控件的长度+左边一个文字的长度+右边一个文字的长度 diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java new file mode 100644 index 0000000..f712ccf --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java @@ -0,0 +1,180 @@ +package clock.socoolby.com.clock.widget.textview; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Build; +import android.text.TextPaint; +import android.text.style.ReplacementSpan; +import android.util.AttributeSet; +import android.util.Log; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; + +@SuppressLint("AppCompatCustomView") +public class DigitTextView extends TextView { + public DigitTextView(Context context) { + super(context); + } + + public DigitTextView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public DigitTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public DigitTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + /** + * 使TextView中不同大小字体垂直居中 + */ + public static class DigitSpan extends ReplacementSpan { + private int fontSizeSp; //字体大小sp + + public DigitSpan(){ + } + + @Override + public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) { + + String text1 = text.subSequence(start, end).toString(); + //Log.d("DigitSpan","getSize text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1); + //Paint p = getCustomTextPaint(paint); + return (int) getCharWidth("8",paint)*text1.length(); + } + + @Override + public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { + String text1 = text.subSequence(start, end).toString(); + //Log.d("DigitSpan","draw text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1); + Paint p = getCustomTextPaint(paint); + Paint.FontMetricsInt fm = p.getFontMetricsInt(); + int baseCharWitch= getCharWidth("8",paint); + int currentCharWidth,moveWidthX; + for(int i=0;i callbacks; + private View target; + + private YoYo(AnimationComposer animationComposer) { + animator = animationComposer.animator; + duration = animationComposer.duration; + delay = animationComposer.delay; + repeat = animationComposer.repeat; + repeatTimes = animationComposer.repeatTimes; + repeatMode = animationComposer.repeatMode; + interpolator = animationComposer.interpolator; + pivotX = animationComposer.pivotX; + pivotY = animationComposer.pivotY; + callbacks = animationComposer.callbacks; + target = animationComposer.target; + } + + public static AnimationComposer with(Techniques techniques) { + return new AnimationComposer(techniques); + } + + public static AnimationComposer with(BaseViewAnimator animator) { + return new AnimationComposer(animator); + } + + public interface AnimatorCallback { + public void call(Animator animator); + } + + private static class EmptyAnimatorListener implements Animator.AnimatorListener { + @Override + public void onAnimationStart(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + } + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } + + public static final class AnimationComposer { + + private List callbacks = new ArrayList<>(); + + private BaseViewAnimator animator; + private long duration = DURATION; + + private long delay = NO_DELAY; + private boolean repeat = false; + private int repeatTimes = 0; + private int repeatMode = ValueAnimator.RESTART; + private float pivotX = YoYo.CENTER_PIVOT, pivotY = YoYo.CENTER_PIVOT; + private Interpolator interpolator; + private View target; + + private AnimationComposer(Techniques techniques) { + this.animator = techniques.getAnimator(); + } + + private AnimationComposer(BaseViewAnimator animator) { + this.animator = animator; + } + + public AnimationComposer duration(long duration) { + this.duration = duration; + return this; + } + + public AnimationComposer delay(long delay) { + this.delay = delay; + return this; + } + + public AnimationComposer interpolate(Interpolator interpolator) { + this.interpolator = interpolator; + return this; + } + + public AnimationComposer pivot(float pivotX, float pivotY) { + this.pivotX = pivotX; + this.pivotY = pivotY; + return this; + } + + public AnimationComposer pivotX(float pivotX) { + this.pivotX = pivotX; + return this; + } + + public AnimationComposer pivotY(float pivotY) { + this.pivotY = pivotY; + return this; + } + + public AnimationComposer repeat(int times) { + if (times < INFINITE) { + throw new RuntimeException("Can not be less than -1, -1 is infinite loop"); + } + repeat = times != 0; + repeatTimes = times; + return this; + } + + public AnimationComposer repeatMode(int mode) { + repeatMode = mode; + return this; + } + + public AnimationComposer withListener(Animator.AnimatorListener listener) { + callbacks.add(listener); + return this; + } + + public AnimationComposer onStart(final AnimatorCallback callback) { + callbacks.add(new EmptyAnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + callback.call(animation); + } + }); + return this; + } + + public AnimationComposer onEnd(final AnimatorCallback callback) { + callbacks.add(new EmptyAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + callback.call(animation); + } + }); + return this; + } + + public AnimationComposer onCancel(final AnimatorCallback callback) { + callbacks.add(new EmptyAnimatorListener() { + @Override + public void onAnimationCancel(Animator animation) { + callback.call(animation); + } + }); + return this; + } + + public AnimationComposer onRepeat(final AnimatorCallback callback) { + callbacks.add(new EmptyAnimatorListener() { + @Override + public void onAnimationRepeat(Animator animation) { + callback.call(animation); + } + }); + return this; + } + + public YoYoString playOn(View target) { + this.target = target; + return new YoYoString(new YoYo(this).play(), this.target); + } + + } + + /** + * YoYo string, you can use this string to control your YoYo. + */ + public static final class YoYoString { + + private BaseViewAnimator animator; + private View target; + + private YoYoString(BaseViewAnimator animator, View target) { + this.target = target; + this.animator = animator; + } + + public boolean isStarted() { + return animator.isStarted(); + } + + public boolean isRunning() { + return animator.isRunning(); + } + + public void stop() { + stop(true); + } + + public void stop(boolean reset) { + animator.cancel(); + + if (reset) + animator.reset(target); + } + } + + private BaseViewAnimator play() { + animator.setTarget(target); + + if (pivotX == YoYo.CENTER_PIVOT) { + ViewCompat.setPivotX(target, target.getMeasuredWidth() / 2.0f); + } else { + target.setPivotX(pivotX); + } + if (pivotY == YoYo.CENTER_PIVOT) { + ViewCompat.setPivotY(target, target.getMeasuredHeight() / 2.0f); + } else { + target.setPivotY(pivotY); + } + + animator.setDuration(duration) + .setRepeatTimes(repeatTimes) + .setRepeatMode(repeatMode) + .setInterpolator(interpolator) + .setStartDelay(delay); + + if (callbacks.size() > 0) { + for (Animator.AnimatorListener callback : callbacks) { + animator.addAnimatorListener(callback); + } + } + animator.animate(); + return animator; + } + +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/BounceAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/BounceAnimator.java new file mode 100755 index 0000000..8beb599 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/BounceAnimator.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationY", 0, 0, -30, 0, -15, 0, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/FlashAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/FlashAnimator.java new file mode 100755 index 0000000..1aa3265 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/FlashAnimator.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FlashAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0, 1, 0, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/PulseAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/PulseAnimator.java new file mode 100755 index 0000000..f8131b8 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/PulseAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class PulseAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleY", 1, 1.1f, 1), + ObjectAnimator.ofFloat(target, "scaleX", 1, 1.1f, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/RubberBandAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/RubberBandAnimator.java new file mode 100755 index 0000000..d443ea1 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/RubberBandAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RubberBandAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 1, 1.25f, 0.75f, 1.15f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.75f, 1.25f, 0.85f, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/ShakeAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/ShakeAnimator.java new file mode 100755 index 0000000..af88fde --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/ShakeAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ShakeAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationX", 0, 25, -25, 25, -25, 15, -15, 6, -6, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/StandUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/StandUpAnimator.java new file mode 100755 index 0000000..e012992 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/StandUpAnimator.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + + +public class StandUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2 + + target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y), + ObjectAnimator.ofFloat(target, "rotationX", 55, -30, 15, -15, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/SwingAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/SwingAnimator.java new file mode 100755 index 0000000..8c772cb --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/SwingAnimator.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SwingAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", 0, 10, -10, 6, -6, 3, -3, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/TadaAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/TadaAnimator.java new file mode 100755 index 0000000..3263251 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/TadaAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class TadaAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.9f, 0.9f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.9f, 0.9f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1), + ObjectAnimator.ofFloat(target, "rotation", 0, -3, -3, 3, -3, 3, -3, 3, -3, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/WaveAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/WaveAnimator.java new file mode 100755 index 0000000..f95e993 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/WaveAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class WaveAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2 + + target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", 12, -12, 3, -3, 0), + ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/attention/WobbleAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/attention/WobbleAnimator.java new file mode 100755 index 0000000..383e7ca --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/attention/WobbleAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.attention; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class WobbleAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float width = target.getWidth(); + float one = (float) (width / 100.0); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationX", 0 * one, -25 * one, 20 * one, -15 * one, 10 * one, -5 * one, 0 * one, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, -5, 3, -3, 2, -1, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInAnimator.java new file mode 100755 index 0000000..b86b840 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.bouncing_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceInAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1), + ObjectAnimator.ofFloat(target, "scaleX", 0.3f, 1.05f, 0.9f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.3f, 1.05f, 0.9f, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInDownAnimator.java new file mode 100755 index 0000000..19e92d7 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInDownAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.bouncing_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceInDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1), + ObjectAnimator.ofFloat(target, "translationY", -target.getHeight(), 30, -10, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInLeftAnimator.java new file mode 100755 index 0000000..61e6b50 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInLeftAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.bouncing_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceInLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationX", -target.getWidth(), 30, -10, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1) + ); + } +} + diff --git a/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInRightAnimator.java new file mode 100755 index 0000000..28addc2 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInRightAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.bouncing_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceInRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationX", target.getMeasuredWidth() + target.getWidth(), -30, 10, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInUpAnimator.java new file mode 100755 index 0000000..6ab17cf --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/bouncing_entrances/BounceInUpAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.bouncing_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class BounceInUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "translationY", target.getMeasuredHeight(), -30, 10, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1) + ); + } + +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInAnimator.java new file mode 100755 index 0000000..8ececcb --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInAnimator.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeInAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInDownAnimator.java new file mode 100755 index 0000000..f72ae53 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInDownAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeInDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationY", -target.getHeight() / 4, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInLeftAnimator.java new file mode 100755 index 0000000..faaa0e9 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInLeftAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeInLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationX", -target.getWidth() / 4, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInRightAnimator.java new file mode 100755 index 0000000..a3d97f7 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInRightAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeInRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationX", target.getWidth() / 4, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInUpAnimator.java new file mode 100755 index 0000000..e3e0d97 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_entrances/FadeInUpAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeInUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationY", target.getHeight() / 4, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutAnimator.java new file mode 100755 index 0000000..5407978 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutAnimator.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeOutAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutDownAnimator.java new file mode 100755 index 0000000..f38f89c --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutDownAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeOutDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationY", 0, target.getHeight() / 4) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutLeftAnimator.java new file mode 100755 index 0000000..a583f7b --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutLeftAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeOutLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationX", 0, -target.getWidth() / 4) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutRightAnimator.java new file mode 100755 index 0000000..01c313d --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutRightAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeOutRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationX", 0, target.getWidth() / 4) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutUpAnimator.java new file mode 100755 index 0000000..70928a4 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/fading_exits/FadeOutUpAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.fading_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FadeOutUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationY", 0, -target.getHeight() / 4) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInXAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInXAnimator.java new file mode 100755 index 0000000..2f66bba --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInXAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.flippers; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FlipInXAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotationX", 90, -15, 15, 0), + ObjectAnimator.ofFloat(target, "alpha", 0.25f, 0.5f, 0.75f, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInYAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInYAnimator.java new file mode 100755 index 0000000..78bbcf6 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipInYAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.flippers; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FlipInYAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotationY", 90, -15, 15, 0), + ObjectAnimator.ofFloat(target, "alpha", 0.25f, 0.5f, 0.75f, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutXAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutXAnimator.java new file mode 100755 index 0000000..1780efe --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutXAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.flippers; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FlipOutXAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotationX", 0, 90), + ObjectAnimator.ofFloat(target, "alpha", 1, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutYAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutYAnimator.java new file mode 100755 index 0000000..cd67c30 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/flippers/FlipOutYAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.flippers; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class FlipOutYAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotationY", 0, 90), + ObjectAnimator.ofFloat(target, "alpha", 1, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInAnimator.java new file mode 100755 index 0000000..b787acb --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateInAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", -200, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownLeftAnimator.java new file mode 100755 index 0000000..9f9bdad --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownLeftAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateInDownLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", -90, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownRightAnimator.java new file mode 100755 index 0000000..f9d1b1f --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInDownRightAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateInDownRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getWidth() - target.getPaddingRight(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", 90, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpLeftAnimator.java new file mode 100755 index 0000000..ea112ef --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpLeftAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateInUpLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", 90, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpRightAnimator.java new file mode 100755 index 0000000..b96982a --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_entrances/RotateInUpRightAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateInUpRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getWidth() - target.getPaddingRight(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "rotation", -90, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutAnimator.java new file mode 100755 index 0000000..5fbfe9b --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateOutAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, 200) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownLeftAnimator.java new file mode 100755 index 0000000..efbec35 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownLeftAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateOutDownLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, 90), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownRightAnimator.java new file mode 100755 index 0000000..5871ef1 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutDownRightAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateOutDownRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getWidth() - target.getPaddingRight(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, -90), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpLeftAnimator.java new file mode 100755 index 0000000..98a0d36 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpLeftAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateOutUpLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getPaddingLeft(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, -90), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpRightAnimator.java new file mode 100755 index 0000000..275c092 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/rotating_exits/RotateOutUpRightAnimator.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.rotating_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RotateOutUpRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getWidth() - target.getPaddingRight(); + float y = target.getHeight() - target.getPaddingBottom(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "rotation", 0, 90), + ObjectAnimator.ofFloat(target, "pivotX", x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInDownAnimator.java new file mode 100755 index 0000000..bc46644 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInDownAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideInDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + int distance = target.getTop() + target.getHeight(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationY", -distance, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInLeftAnimator.java new file mode 100755 index 0000000..4dfebd4 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInLeftAnimator.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideInLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getWidth() - target.getLeft(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationX", -distance, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInRightAnimator.java new file mode 100755 index 0000000..f006fac --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInRightAnimator.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideInRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getWidth() - target.getLeft(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationX", distance, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInUpAnimator.java new file mode 100755 index 0000000..111b1a8 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideInUpAnimator.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideInUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getHeight() - target.getTop(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationY", distance, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutDownAnimator.java new file mode 100755 index 0000000..7e8abbc --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutDownAnimator.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideOutDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getHeight() - target.getTop(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationY", 0, distance) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutLeftAnimator.java new file mode 100755 index 0000000..2f8b4e7 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutLeftAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideOutLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationX", 0, -target.getRight()) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutRightAnimator.java new file mode 100755 index 0000000..6eb7dac --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutRightAnimator.java @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideOutRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getWidth() - target.getLeft(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationX", 0, distance) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutUpAnimator.java new file mode 100755 index 0000000..2b836b2 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/sliders/SlideOutUpAnimator.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.sliders; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class SlideOutUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationY", 0, -target.getBottom()) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/HingeAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/HingeAnimator.java new file mode 100755 index 0000000..b1ba027 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/HingeAnimator.java @@ -0,0 +1,50 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.specials; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; +import com.daimajia.easing.Glider; +import com.daimajia.easing.Skill; + +public class HingeAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + float x = target.getPaddingLeft(); + float y = target.getPaddingTop(); + getAnimatorAgent().playTogether( + Glider.glide(Skill.SineEaseInOut, 1300, ObjectAnimator.ofFloat(target, "rotation", 0, 80, 60, 80, 60, 60)), + ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), + ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), + ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), + ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y) + ); + + setDuration(1300); + } +} + diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/RollInAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/RollInAnimator.java new file mode 100755 index 0000000..d55c26f --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/RollInAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.specials; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RollInAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + ObjectAnimator.ofFloat(target, "translationX", -(target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()), 0), + ObjectAnimator.ofFloat(target, "rotation", -120, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/RollOutAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/RollOutAnimator.java new file mode 100755 index 0000000..baf2f25 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/RollOutAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.specials; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class RollOutAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0), + ObjectAnimator.ofFloat(target, "translationX", 0, target.getWidth()), + ObjectAnimator.ofFloat(target, "rotation", 0, 120) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/in/DropOutAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/in/DropOutAnimator.java new file mode 100755 index 0000000..b1b3237 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/in/DropOutAnimator.java @@ -0,0 +1,19 @@ +package com.daimajia.androidanimations.library.specials.in; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; +import com.daimajia.easing.Glider; +import com.daimajia.easing.Skill; + +public class DropOutAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + int distance = target.getTop() + target.getHeight(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1), + Glider.glide(Skill.BounceEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "translationY", -distance, 0)) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/in/LandingAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/in/LandingAnimator.java new file mode 100755 index 0000000..7e7869e --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/in/LandingAnimator.java @@ -0,0 +1,19 @@ +package com.daimajia.androidanimations.library.specials.in; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; +import com.daimajia.easing.Glider; +import com.daimajia.easing.Skill; + +public class LandingAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + getAnimatorAgent().playTogether( + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "scaleX", 1.5f, 1f)), + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "scaleY", 1.5f, 1f)), + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "alpha", 0, 1f)) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/specials/out/TakingOffAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/specials/out/TakingOffAnimator.java new file mode 100755 index 0000000..9d4e4c1 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/specials/out/TakingOffAnimator.java @@ -0,0 +1,19 @@ +package com.daimajia.androidanimations.library.specials.out; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; +import com.daimajia.easing.Glider; +import com.daimajia.easing.Skill; + +public class TakingOffAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + getAnimatorAgent().playTogether( + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "scaleX", 1f, 1.5f)), + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "scaleY", 1f, 1.5f)), + Glider.glide(Skill.QuintEaseOut, getDuration(), ObjectAnimator.ofFloat(target, "alpha", 1, 0)) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInAnimator.java new file mode 100755 index 0000000..35b79fb --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomInAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 0.45f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.45f, 1), + ObjectAnimator.ofFloat(target, "alpha", 0, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInDownAnimator.java new file mode 100755 index 0000000..748b631 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInDownAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomInDownAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "translationY", -target.getBottom(), 60, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInLeftAnimator.java new file mode 100755 index 0000000..ebe5234 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInLeftAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomInLeftAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "translationX", -target.getRight(), 48, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInRightAnimator.java new file mode 100755 index 0000000..82322ef --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInRightAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomInRightAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "translationX", target.getWidth() + target.getPaddingRight(), -48, 0), + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInUpAnimator.java new file mode 100755 index 0000000..dea04d7 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_entrances/ZoomInUpAnimator.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_entrances; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomInUpAnimator extends BaseViewAnimator { + @Override + public void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getHeight() - target.getTop(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1), + ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1), + ObjectAnimator.ofFloat(target, "translationY", distance, -60, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutAnimator.java new file mode 100755 index 0000000..0f4fef8 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutAnimator.java @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomOutAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 0, 0), + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.3f, 0), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.3f, 0) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutDownAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutDownAnimator.java new file mode 100755 index 0000000..d5d4f31 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutDownAnimator.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_exits; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomOutDownAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getHeight() - target.getTop(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0), + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "translationY", 0, -60, distance) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutLeftAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutLeftAnimator.java new file mode 100755 index 0000000..ac80be2 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutLeftAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomOutLeftAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0), + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "translationX", 0, 42, -target.getRight()) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutRightAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutRightAnimator.java new file mode 100755 index 0000000..7bc3fb0 --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutRightAnimator.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_exits; + +import android.animation.ObjectAnimator; +import android.view.View; +import android.view.ViewGroup; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomOutRightAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + ViewGroup parent = (ViewGroup) target.getParent(); + int distance = parent.getWidth() - parent.getLeft(); + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0), + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "translationX", 0, -42, distance) + ); + } +} diff --git a/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutUpAnimator.java b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutUpAnimator.java new file mode 100755 index 0000000..4958dcd --- /dev/null +++ b/app/src/main/java/com/daimajia/androidanimations/library/zooming_exits/ZoomOutUpAnimator.java @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 daimajia + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.daimajia.androidanimations.library.zooming_exits; + +import android.animation.ObjectAnimator; +import android.view.View; + +import com.daimajia.androidanimations.library.BaseViewAnimator; + +public class ZoomOutUpAnimator extends BaseViewAnimator { + @Override + protected void prepare(View target) { + getAnimatorAgent().playTogether( + ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0), + ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f), + ObjectAnimator.ofFloat(target, "translationY", 0, 60, -target.getBottom()) + ); + } +} diff --git a/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java b/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java new file mode 100755 index 0000000..4ff08b2 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java @@ -0,0 +1,139 @@ +package com.fadai.particlesmasher; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; + +import java.util.ArrayList; +import java.util.List; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/14
+ *     desc   : xxxx描述
+ *     version: 1.0
+ * 
+ */ + +public class ParticleSmasher extends View { + + private List mAnimators = new ArrayList<>(); + private Canvas mCanvas; + private Activity mActivity; + + public ParticleSmasher(Activity activity) { + super((Context) activity); + this.mActivity = activity; + addView2Window(activity); + init(); + } + + /** + * 添加View到当前界面 + */ + private void addView2Window(Activity activity) { + ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); + // 需要足够的空间展现动画,因此这里使用的是充满父布局 + ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + rootView.addView(this, layoutParams); + } + + private void init() { + mCanvas = new Canvas(); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + for (SmashAnimator animator : mAnimators) { + animator.draw(canvas); + } + } + + public SmashAnimator with(View view) { + // 每次都新建一个单独的SmashAnimator对象 + SmashAnimator animator = new SmashAnimator(this, view); + mAnimators.add(animator); + return animator; + } + + + /** + * 获取View的Rect,并去掉状态栏、toolbar高度 + * @param view 来源View + * @return 获取到的Rect + */ + public Rect getViewRect(View view) { + Rect rect = new Rect(); + view.getGlobalVisibleRect(rect); + + int[] location = new int[2]; + getLocationOnScreen(location); + + rect.offset(-location[0], -location[1]); + return rect; + } + + /** + * 获取View的Bitmap + * @param view 来源View + * @return 获取到的图片 + */ + public Bitmap createBitmapFromView(View view) { + + view.clearFocus(); + Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + if (bitmap != null) { + synchronized (mCanvas) { + Canvas canvas = mCanvas; + canvas.setBitmap(bitmap); + view.draw(canvas); + canvas.setBitmap(null); + } + } + return bitmap; + } + + /** + * 移除动画 + * @param animator 需要移除的动画 + */ + public void removeAnimator(SmashAnimator animator) { + if (mAnimators.contains(animator)) { + mAnimators.remove(animator); + } + } + + /** + * 清除所有动画 + */ + public void clear() { + mAnimators.clear(); + invalidate(); + } + + /** + * 让View重新显示 + * @param view 已经隐藏的View + */ + public void reShowView(View view) { + view.animate().setDuration(100).setStartDelay(0).scaleX(1).scaleY(1).translationX(0).translationY(0).alpha(1).start(); + } + + /** + * 让View重新显示 + * @param view 已经隐藏的View + */ + public void resetView(View view) { + view.animate().setDuration(100).setStartDelay(0).scaleX(1).scaleY(1).translationX(0).translationY(0).alpha(1).start(); + } + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/SmashAnimator.java b/app/src/main/java/com/fadai/particlesmasher/SmashAnimator.java new file mode 100755 index 0000000..1e4d2a6 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/SmashAnimator.java @@ -0,0 +1,330 @@ +package com.fadai.particlesmasher; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Point; +import android.graphics.Rect; +import android.view.View; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.Interpolator; + +import com.fadai.particlesmasher.particle.DropParticle; +import com.fadai.particlesmasher.particle.ExplosionParticle; +import com.fadai.particlesmasher.particle.FloatParticle; +import com.fadai.particlesmasher.particle.Particle; + +import java.util.Random; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/14
+ *     desc   : xxxx描述
+ *     version: 1.0
+ * 
+ */ + +public class SmashAnimator { + + public static final int STYLE_EXPLOSION=1, // 爆炸 + STYLE_DROP=2, // 下落 + STYLE_FLOAT_LEFT=3, // 飘落——>自左往右,逐列飘落 + STYLE_FLOAT_RIGHT=4, // 飘落——>自右往左,逐列飘落 + STYLE_FLOAT_TOP=5, // 飘落——>自上往下,逐行飘落 + STYLE_FLOAT_BOTTOM=6; // 飘落——>自下往上,逐行飘落 + + private int mStyle=STYLE_EXPLOSION; // 动画样式 + + private ValueAnimator mValueAnimator; + + private ParticleSmasher mContainer; // 绘制动画效果的View + private View mAnimatorView; // 要进行爆炸动画的View + + private Bitmap mBitmap; + private Rect mRect; // 要进行动画的View在坐标系中的矩形 + + private Paint mPaint; // 绘制粒子的画笔 + private Particle[][] mParticles; // 粒子数组 + + private float mEndValue = 1.5f; + + private long mDuration = 1000L; + private long mStartDelay = 150L; + private float mHorizontalMultiple = 3; // 粒子水平变化幅度 + private float mVerticalMultiple = 4; // 粒子垂直变化幅度 + private int mRadius=Utils.dp2Px(2); // 粒子基础半径 + + + // 加速度插值器 + private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f); + private OnAnimatorListener mOnAnimatorLIstener; + + public SmashAnimator(ParticleSmasher view, View animatorView) { + this.mContainer = view; + init(animatorView); + } + + private void init(View animatorView) { + this.mAnimatorView = animatorView; + mBitmap = mContainer.createBitmapFromView(animatorView); + mRect = mContainer.getViewRect(animatorView); + initValueAnimator(); + initPaint(); + } + + private void initValueAnimator() { + mValueAnimator = new ValueAnimator(); + mValueAnimator.setFloatValues(0F, mEndValue); + mValueAnimator.setInterpolator(DEFAULT_INTERPOLATOR); + } + + private void initPaint() { + mPaint = new Paint(); + mPaint.setAntiAlias(true); + } + + + /** + * 爆炸动画回调事件 + */ + public static abstract class OnAnimatorListener { + + /** + * 动画开始时回调 + */ + public void onAnimatorStart() { + } + + /** + * 动画结束后回调 + */ + public void onAnimatorEnd() { + } + + } + + /** + * 设置动画样式 + * @param style {@link #STYLE_EXPLOSION},{@link #STYLE_DROP},{@link #STYLE_FLOAT_TOP},{@link #STYLE_FLOAT_BOTTOM},{@link #STYLE_FLOAT_LEFT},{@link #STYLE_FLOAT_RIGHT}; + * + * @return 链式调用,因此返回本身 + */ + public SmashAnimator setStyle(int style){ + this.mStyle=style; + return this; + } + + /** + * 设置爆炸动画时间 + * @param duration 时间,单位为毫秒 + * @return 链式调用,因此返回本身 + */ + public SmashAnimator setDuration(long duration) { + this.mDuration = duration; + return this; + } + + /** + * 设置爆炸动画前延时 + * @param startDelay 动画开始前的延时,单位为毫秒 + * @return 链式调用,因此返回本身 + * + */ + public SmashAnimator setStartDelay(long startDelay) { + mStartDelay = startDelay; + return this; + } + + /** + * 设置水平变化参数 + * @param horizontalMultiple 水平变化幅度,默认为3。为0则不产生变化。 + * @return 链式调用,因此返回本身 + */ + public SmashAnimator setHorizontalMultiple(float horizontalMultiple) { + this.mHorizontalMultiple = horizontalMultiple; + return this; + } + + /** + * 设置垂直变化参数 + * @param verticalMultiple 垂直变化参数,默认为4,为0则不产生变化 + * @return 链式调用,因此返回本身 + * + */ + public SmashAnimator setVerticalMultiple(float verticalMultiple) { + this.mVerticalMultiple = verticalMultiple; + return this; + } + + /** + * 设置粒子基础半径 + * @param radius 半径,单位为px + * @return 链式调用,因此返回本身 + */ + public SmashAnimator setParticleRadius(int radius){ + this.mRadius=radius; + return this; + } + + /** + * 添加回调 + * @param listener 回调事件,包含开始回调、结束回调。 + * @return 链式调用,因此返回本身 + */ + public SmashAnimator addAnimatorListener(final OnAnimatorListener listener) { + this.mOnAnimatorLIstener = listener; + return this; + } + + /** + * 开始动画 + */ + public void start() { + setValueAnimator(); + calculateParticles(mBitmap); + hideView(mAnimatorView, mStartDelay); + mValueAnimator.start(); + mContainer.invalidate(); + } + + public void startRandomAnimator(){ + Random random=new Random(); + mStyle=random.nextInt(6); + if(mStyle<=0) + mStyle=1; + setValueAnimator(); + calculateParticles(mBitmap); + hideView(mAnimatorView, mStartDelay); + mValueAnimator.start(); + mContainer.invalidate(); + } + + /** + * 设置动画参数 + */ + private void setValueAnimator() { + mValueAnimator.setDuration(mDuration); + mValueAnimator.setStartDelay(mStartDelay); + mValueAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (mOnAnimatorLIstener != null) { + mOnAnimatorLIstener.onAnimatorEnd(); + } + mContainer.removeAnimator(SmashAnimator.this); + } + + @Override + public void onAnimationStart(Animator animation) { + if (mOnAnimatorLIstener != null) { + mOnAnimatorLIstener.onAnimatorStart(); + } + + } + }); + } + + /** + * 根据图片计算粒子 + * @param bitmap 需要计算的图片 + */ + private void calculateParticles(Bitmap bitmap) { + + int col = bitmap.getWidth() /(mRadius*2); + int row = bitmap.getHeight() / (mRadius*2); + + Random random = new Random(System.currentTimeMillis()); + mParticles = new Particle[row][col]; + + for (int i = 0; i < row; i++) { + for (int j = 0; j < col; j++) { + int x=j * mRadius*2 + mRadius; + int y=i * mRadius*2 + mRadius; + int color = bitmap.getPixel(x, y); + Point point=new Point(mRect.left+x,mRect.top+y); + + switch (mStyle){ + case STYLE_EXPLOSION: + mParticles[i][j] = new ExplosionParticle(color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + case STYLE_DROP: + mParticles[i][j] = new DropParticle(point,color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + case STYLE_FLOAT_LEFT: + mParticles[i][j] = new FloatParticle(FloatParticle.ORIENTATION_LEFT,point,color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + case STYLE_FLOAT_RIGHT: + mParticles[i][j] = new FloatParticle(FloatParticle.ORIENTATION_RIGHT,point,color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + case STYLE_FLOAT_TOP: + mParticles[i][j] = new FloatParticle(FloatParticle.ORIENTATION_TOP,point,color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + case STYLE_FLOAT_BOTTOM: + mParticles[i][j] = new FloatParticle(FloatParticle.ORIENTATION_BOTTOM,point,color, mRadius, mRect, mEndValue, random, mHorizontalMultiple, mVerticalMultiple); + break; + } + + } + } + mBitmap.recycle(); + mBitmap = null; + } + + + /** + * View执行颤抖动画,之后再执行和透明动画,达到隐藏View的效果 + * @param view 执行效果的View + * @param startDelay 爆炸动画的开始前延时时间 + */ + public void hideView(final View view, long startDelay) { + ValueAnimator valueAnimator = new ValueAnimator(); + valueAnimator.setDuration(startDelay + 50).setFloatValues(0f, 1f); + // 使View颤抖 + valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + + Random random = new Random(); + + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + view.setTranslationX((random.nextFloat() - 0.5F) * view.getWidth() * 0.05F); + view.setTranslationY((random.nextFloat() - 0.5f) * view.getHeight() * 0.05f); + } + }); + valueAnimator.start(); + // 将View 缩放至0、透明至0 + view.animate().setDuration(260).setStartDelay(startDelay).scaleX(0).scaleY(0).alpha(0).start(); + } + + + /** + * 开始逐个绘制粒子 + * @param canvas 绘制的画板 + * @return 是否成功 + */ + public boolean draw(Canvas canvas) { + if (!mValueAnimator.isStarted()) { + return false; + } + for (Particle[] particle : mParticles) { + for (Particle p : particle) { + // 根据动画进程,修改粒子的参数 + p.advance((float) (mValueAnimator.getAnimatedValue()), mEndValue); + if (p.alpha > 0) { + mPaint.setColor(p.color); + mPaint.setAlpha((int) (Color.alpha(p.color) * p.alpha)); + canvas.drawCircle(p.cx, p.cy, p.radius, mPaint); + } + } + } + mContainer.invalidate(); + return true; + } + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/Utils.java b/app/src/main/java/com/fadai/particlesmasher/Utils.java new file mode 100755 index 0000000..67bdd74 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/Utils.java @@ -0,0 +1,30 @@ +package com.fadai.particlesmasher; + +import android.content.res.Resources; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/04
+ *     desc   : xxxx描述
+ *     version: 1.0
+ * 
+ */ + +public class Utils { + + private static final float DENSITY = Resources.getSystem().getDisplayMetrics().density; + + /** + * dp转换px + * @param dp dp值 + * @return 转换后的px值 + */ + public static int dp2Px(int dp) { + return Math.round(dp * DENSITY); + } + + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/particle/DropParticle.java b/app/src/main/java/com/fadai/particlesmasher/particle/DropParticle.java new file mode 100755 index 0000000..9ff1b13 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/particle/DropParticle.java @@ -0,0 +1,126 @@ +package com.fadai.particlesmasher.particle; + +import android.graphics.Point; +import android.graphics.Rect; + +import java.util.Random; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/20
+ *     desc   : 下落粒子的实体类
+ *     version: 1.0
+ * 
+ */ + +public class DropParticle extends Particle { + + /** + * 生成粒子 + * @param point 粒子在图片中原始位置 + * @param color 粒子颜色 + * @param radius 粒子的半径 + * @param rect View区域的矩形 + * @param endValue 动画的结束值 + * @param random 随机数 + * @param horizontalMultiple 水平变化幅度 + * @param verticalMultiple 垂直变化幅度 + */ + public DropParticle(Point point, int color, int radius, Rect rect, float endValue, Random random, float horizontalMultiple, float verticalMultiple){ + + this.color = color; + alpha = 1; + + // 参与横向变化参数和竖直变化参数计算,规则:横向参数相对值越大,竖直参数越小 + float nextFloat = random.nextFloat(); + + baseRadius = getBaseRadius(radius, random, nextFloat); + this.radius = baseRadius; + + horizontalElement = getHorizontalElement(rect, random, nextFloat, horizontalMultiple); + verticalElement = getVerticalElement(rect, random, nextFloat, verticalMultiple); + + baseCx = point.x; + baseCy = point.y; + cx = baseCx; + cy = baseCy; + + + font = endValue / 10 * random.nextFloat(); + later = 0.4f * random.nextFloat(); + } + + private static float getBaseRadius(float radius, Random random, float nextFloat) { + // 下落和飘落的粒子,其半径很大概率大于初始设定的半径 + + float r = radius + radius * (random.nextFloat() - 0.5f) * 0.5f; + r = nextFloat < 0.6f ? r : + nextFloat < 0.8f ? r * 1.4f : r * 1.6f; + return r; + } + + private static float getHorizontalElement(Rect rect, Random random, float nextFloat, float horizontalMultiple) { + + // 第一次随机运算:h=width*±(0.01~0.49) + float horizontal = rect.width() * (random.nextFloat() - 0.5f); + + // 第二次随机运行: h= 1/5概率:h;3/5概率:h*0.6; 1/5概率:h*0.3; nextFloat越大,h越小。 + horizontal = nextFloat < 0.2f ? horizontal : + nextFloat < 0.8f ? horizontal * 0.6f : horizontal * 0.3f; + + // 上面的计算是为了让横向变化参数有随机性,下面的计算是修改横向变化的幅度。 + return horizontal * horizontalMultiple; + } + + private static float getVerticalElement(Rect rect, Random random, float nextFloat, float verticalMultiple) { + + // 第一次随机运算: v=height*(0.5~1) + float vertical = rect.height() * (random.nextFloat() * 0.5f + 0.5f); + + // 第二次随机运行: v= 1/5概率:v;3/5概率:v*1.2; 1/5概率:v*1.4; nextFloat越大,h越大。 + vertical = nextFloat < 0.2f ? vertical : + nextFloat < 0.8f ? vertical * 1.2f : vertical * 1.4f; + + // 上面的计算是为了让变化参数有随机性,下面的计算是变化的幅度。 + return vertical * verticalMultiple; + } + + + public void advance(float factor, float endValue) { + + // 动画进行到了几分之几 + float normalization = factor / endValue; + + if (normalization < font ) { + alpha = 1; + return; + } + if ( normalization > 1f - later) { + alpha = 0; + return; + } + alpha = 1; + + // 粒子可显示的状态中,动画实际进行到了几分之几 + normalization = (normalization - font) / (1f - font - later); + // 动画超过7/10,则开始逐渐变透明 + if (normalization >= 0.7f) { + alpha = 1f - (normalization - 0.7f) / 0.3f; + } + + float realValue = normalization * endValue; + + // y=j+k*x,j、k都是常数,x为 0~1.4 + cx = baseCx + horizontalElement * realValue; + + // 下落粒子,y轴持续增大 + cy = baseCy + verticalElement * realValue; + + radius = baseRadius + baseRadius / 6 * realValue; + + } + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/particle/ExplosionParticle.java b/app/src/main/java/com/fadai/particlesmasher/particle/ExplosionParticle.java new file mode 100755 index 0000000..3cbbc61 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/particle/ExplosionParticle.java @@ -0,0 +1,123 @@ +package com.fadai.particlesmasher.particle; + +import android.graphics.Rect; + +import java.util.Random; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/14
+ *     desc   : 爆炸粒子
+ *     version: 1.0
+ * 
+ */ + +public class ExplosionParticle extends Particle{ + + /** + * 生成粒子 + * + * @param color 粒子颜色 + * @param radius 粒子的半径 + * @param rect View区域的矩形 + * @param endValue 动画的结束值 + * @param random 随机数 + * @param horizontalMultiple 水平变化幅度 + * @param verticalMultiple 垂直变化幅度 + */ + public ExplosionParticle( int color, int radius, Rect rect, float endValue, Random random, float horizontalMultiple, float verticalMultiple){ + + this.color = color; + alpha = 1; + + // 参与横向变化参数和竖直变化参数计算,规则:横向参数相对值越大,竖直参数越小 + float nextFloat = random.nextFloat(); + + baseRadius = getBaseRadius(radius, random, nextFloat); + this.radius = baseRadius; + + horizontalElement = getHorizontalElement(rect, random, nextFloat, horizontalMultiple); + verticalElement = getVerticalElement(rect, random, nextFloat, verticalMultiple); + + int offsetX = rect.width() / 4; + int offsetY = rect.height() / 4; + + // baseCx,baseCy在中心点四周的offset/2的范围内。 + baseCx = rect.centerX() + offsetX * (random.nextFloat() - 0.5f); + baseCy = rect.centerY() + offsetY * (random.nextFloat() - 0.5f); + cx = baseCx; + cy = baseCy; + + + font = endValue / 10 * random.nextFloat(); + later = 0.4f * random.nextFloat(); + } + + private static float getBaseRadius(float radius, Random random, float nextFloat) { + float r = radius + radius * (random.nextFloat() - 0.5f) * 0.5f; + r = nextFloat < 0.6f ? r : + nextFloat < 0.8f ? r * 1.4f : r * 0.8f; + return r; + } + + private static float getHorizontalElement(Rect rect, Random random, float nextFloat,float horizontalMultiple) { + + // 第一次随机运算:h=width*±(0.01~0.49) + float horizontal = rect.width() * (random.nextFloat() - 0.5f); + + // 第二次随机运行: h= 1/5概率:h;3/5概率:h*0.6; 1/5概率:h*0.3; nextFloat越大,h越小。 + horizontal = nextFloat < 0.2f ? horizontal : + nextFloat < 0.8f ? horizontal * 0.6f : horizontal * 0.3f; + + // 上面的计算是为了让横向变化参数有随机性,下面的计算是修改横向变化的幅度。 + return horizontal * horizontalMultiple; + } + + private static float getVerticalElement(Rect rect, Random random, float nextFloat,float verticalMultiple) { + + // 第一次随机运算: v=height*(0.5~1) + float vertical = rect.height() * (random.nextFloat() * 0.5f + 0.5f); + + // 第二次随机运行: v= 1/5概率:v;3/5概率:v*1.2; 1/5概率:v*1.4; nextFloat越大,h越大。 + vertical = nextFloat < 0.2f ? vertical : + nextFloat < 0.8f ? vertical * 1.2f : vertical * 1.4f; + + // 上面的计算是为了让变化参数有随机性,下面的计算是变化的幅度。 + return vertical * verticalMultiple; + } + + + public void advance(float factor, float endValue) { + + // 动画进行到了几分之几 + float normalization = factor / endValue; + + if (normalization < font || normalization > 1f - later) { + alpha = 0; + return; + } + alpha = 1; + + // 粒子可显示的状态中,动画实际进行到了几分之几 + normalization = (normalization - font) / (1f - font - later); + // 动画超过7/10,则开始逐渐变透明 + if (normalization >= 0.7f) { + alpha = 1f - (normalization - 0.7f) / 0.3f; + } + + float realValue = normalization * endValue; + + // y=j+k*x,j、k都是常数,x为 0~1.4 + cx = baseCx + horizontalElement * realValue; + + // y=j+k*(x*(x-1),j、k都是常数,x为 0~1.4 + cy = baseCy + verticalElement * (realValue * (realValue - 1)); + + radius = baseRadius + baseRadius / 4 * realValue; + + } + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/particle/FloatParticle.java b/app/src/main/java/com/fadai/particlesmasher/particle/FloatParticle.java new file mode 100755 index 0000000..b2ef015 --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/particle/FloatParticle.java @@ -0,0 +1,164 @@ +package com.fadai.particlesmasher.particle; + +import android.graphics.Point; +import android.graphics.Rect; + +import java.util.Random; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/20
+ *     desc   : 飘落粒子
+ *     version: 1.0
+ * 
+ */ + +public class FloatParticle extends Particle { + + private float top; + private float left; + public static final int ORIENTATION_LEFT=1,ORIENTATION_RIGHT=2,ORIENTATION_TOP=3,ORIENTATION_BOTTOM=4; + // 方向 + private int orientation=ORIENTATION_TOP; + + /** + * 生成粒子 + * @param orientation 方向 + * @param point 粒子在图片中的位置 + * @param color 粒子颜色 + * @param radius 粒子的半径 + * @param rect View区域的矩形 + * @param endValue 动画的结束值 + * @param random 随机数 + * @param horizontalMultiple 水平变化幅度 + * @param verticalMultiple 垂直变化幅度 + */ + public FloatParticle(int orientation,Point point, int color, int radius, Rect rect, float endValue, Random random, float horizontalMultiple, float verticalMultiple){ + + this.color = color; + alpha = 1; + + // 参与横向变化参数和竖直变化参数计算,规则:横向参数相对值越大,竖直参数越小 + float nextFloat = random.nextFloat(); + + baseRadius = getBaseRadius(radius, random, nextFloat); + this.radius = baseRadius; + + horizontalElement = getHorizontalElement(rect, random, nextFloat, horizontalMultiple); + verticalElement = getVerticalElement(rect, random, nextFloat, verticalMultiple); + + baseCx = point.x; + baseCy = point.y; + cx = baseCx; + cy = baseCy; + + + font = endValue / 10 * random.nextFloat(); + later = 0.4f * random.nextFloat(); + + left=(baseCx-rect.left)/rect.width(); + top=(baseCy-rect.top)/rect.height(); + this.orientation=orientation; + } + + private static float getBaseRadius(float radius, Random random, float nextFloat) { + // 下落和飘落的粒子,其半径很大概率大于初始设定的半径 + + float r = radius + radius * (random.nextFloat() - 0.5f) * 0.5f; + r = nextFloat < 0.6f ? r : + nextFloat < 0.8f ? r * 1.4f : r * 1.6f; + return r; + } + + private static float getHorizontalElement(Rect rect, Random random, float nextFloat, float horizontalMultiple) { + + // 第一次随机运算:h=width*±(0.01~0.49) + float horizontal = rect.width() * (random.nextFloat() - 0.5f); + + // 第二次随机运行: h= 1/5概率:h;3/5概率:h*0.6; 1/5概率:h*0.3; nextFloat越大,h越小。 + horizontal = nextFloat < 0.2f ? horizontal : + nextFloat < 0.8f ? horizontal * 0.6f : horizontal * 0.3f; + + // 上面的计算是为了让横向变化参数有随机性,下面的计算是修改横向变化的幅度。 + return horizontal * horizontalMultiple; + } + + private static float getVerticalElement(Rect rect, Random random, float nextFloat, float verticalMultiple) { + + // 第一次随机运算: v=height*(0.5~1) + float vertical = rect.height() * (random.nextFloat() * 0.5f + 0.5f); + + // 第二次随机运行: v= 1/5概率:v;3/5概率:v*1.2; 1/5概率:v*1.4; nextFloat越大,h越大。 + vertical = nextFloat < 0.2f ? vertical : + nextFloat < 0.8f ? vertical * 1.2f : vertical * 1.4f; + + // 上面的计算是为了让变化参数有随机性,下面的计算是变化的幅度。 + return vertical * verticalMultiple; + } + + + public void advance(float factor, float endValue) { + + // 动画进行到了几分之几 + float normalization = factor / endValue; + + if (normalization < font ) { + alpha = 1; + return; + } + + if ( normalization > 1f - later) { + alpha = 0; + return; + } + alpha = 1; + + // 粒子可显示的状态中,动画实际进行到了几分之几 + normalization = (normalization - font) / (1f - font - later); + // 动画超过7/10,则开始逐渐变透明 + if (normalization >= 0.7f) { + alpha = 1f - (normalization - 0.7f) / 0.3f; + } + + float realValue = normalization * endValue; + + // 重点:这里使用了realValue(0~1),而不是normalization(0~1.4)。如果使用nor的话,在最后面开始飘落的粒子就会全透明看不到了。 + switch (orientation){ + case ORIENTATION_LEFT: + if(realValue>left){ + cy=baseCy+verticalElement*(realValue-left); + cx = baseCx + horizontalElement * (realValue-left); + } + break; + case ORIENTATION_RIGHT: + if(realValue>(1-left)){ + cy=baseCy+verticalElement*(realValue-(1-left)); + cx = baseCx + horizontalElement * (realValue-(1-left)); + } + break; + case ORIENTATION_TOP: + if(realValue>top){ + cy=baseCy+verticalElement*(realValue-top); + cx = baseCx + horizontalElement * (realValue-top); + } + break; + case ORIENTATION_BOTTOM: + if(realValue>(1-top)){ + cy=baseCy+verticalElement*(realValue-(1-top)); + cx = baseCx + horizontalElement * (realValue-(1-top)); + } + break; + + } + + + radius = baseRadius + baseRadius / 6 * realValue; + + } + + + + +} diff --git a/app/src/main/java/com/fadai/particlesmasher/particle/Particle.java b/app/src/main/java/com/fadai/particlesmasher/particle/Particle.java new file mode 100755 index 0000000..3f6990b --- /dev/null +++ b/app/src/main/java/com/fadai/particlesmasher/particle/Particle.java @@ -0,0 +1,34 @@ +package com.fadai.particlesmasher.particle; + +/** + *
+ *     author : FaDai
+ *     e-mail : i_fadai@163.com
+ *     time   : 2017/12/20
+ *     desc   : xxxx描述
+ *     version: 1.0
+ * 
+ */ + +public abstract class Particle { + + public int color; // 颜色 + public float radius; // 半径 + public float alpha; // 透明度(0~1) + public float cx; // 圆心 x + public float cy; // 圆心 y + + + public float horizontalElement; // 水平变化参数 + public float verticalElement; // 垂直变化参数 + + public float baseRadius; // 初始半径,同时负责半径大小变化 + public float baseCx; // 初始圆心 x + public float baseCy; // 初始圆心 y + + public float font; // 决定了粒子在动画开始多久之后,开始显示 + public float later; // 决定了粒子动画结束前多少时间开始隐藏 + + public void advance(float factor, float endValue) { + } +} diff --git a/app/src/main/res/drawable/ic_am.xml b/app/src/main/res/drawable/ic_am.xml new file mode 100644 index 0000000..1788edd --- /dev/null +++ b/app/src/main/res/drawable/ic_am.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_pm.xml b/app/src/main/res/drawable/ic_pm.xml new file mode 100644 index 0000000..0c6516a --- /dev/null +++ b/app/src/main/res/drawable/ic_pm.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e001dba..6c06365 100755 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -47,12 +47,26 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" + android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" android:background="#00FFFFFF" android:textColor="#fff" android:textSize="32sp" /> + + + + + +