This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update new day/night method and delete some feature
- Loading branch information
谢晨成
authored and
谢晨成
committed
Jul 9, 2016
1 parent
8d04d9b
commit 14cbe6f
Showing
26 changed files
with
280 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/src/main/java/com/xiecc/seeWeather/common/utils/RevealAnimUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.xiecc.seeWeather.common.utils; | ||
|
||
import android.animation.Animator; | ||
import android.animation.AnimatorListenerAdapter; | ||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import android.support.annotation.ColorRes; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.v4.content.ContextCompat; | ||
import android.view.View; | ||
import android.view.ViewAnimationUtils; | ||
import android.view.animation.AccelerateDecelerateInterpolator; | ||
|
||
/** | ||
* Created by HugoXie on 16/7/7. | ||
* | ||
* Email: Hugo3641@gamil.com | ||
* GitHub: https://github.com/xcc3641 | ||
* Info: 焦点在 fab 上的 reveal 动画,切换 activity 使用 | ||
*/ | ||
public class RevealAnimUtil { | ||
|
||
public interface OnRevealAnimationListener { | ||
void onRevealHide(); | ||
|
||
void onRevealShow(); | ||
} | ||
|
||
// 显示 | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public static void animateRevealShow(final Context context, final View view, final FloatingActionButton fab, | ||
final int startRadius, @ColorRes final int color, | ||
final OnRevealAnimationListener listener) { | ||
// 获得开始焦点 fab 中心 | ||
int cx = (fab.getLeft() + fab.getRight()) / 2; | ||
int cy = (fab.getTop() + fab.getBottom()) / 2; | ||
|
||
float finalRadius = (float) Math.hypot(view.getWidth(), view.getHeight()); | ||
|
||
// 设置圆形显示动画 | ||
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, finalRadius); | ||
anim.setDuration(500); | ||
anim.setInterpolator(new AccelerateDecelerateInterpolator()); | ||
anim.addListener(new AnimatorListenerAdapter() { | ||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
super.onAnimationEnd(animation); | ||
view.setVisibility(View.INVISIBLE); | ||
//切换代码在动画开始时执行比较好 | ||
listener.onRevealShow(); | ||
} | ||
|
||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
super.onAnimationStart(animation); | ||
view.setBackgroundColor(ContextCompat.getColor(context, color)); | ||
view.setVisibility(View.VISIBLE); | ||
} | ||
}); | ||
anim.start(); | ||
} | ||
|
||
// 圆圈凝聚效果 | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public static void animateRevealHide( | ||
final Context context, final View view, | ||
final int finalRadius, @ColorRes final int color, | ||
final OnRevealAnimationListener listener | ||
) { | ||
int cx = (view.getLeft() + view.getRight()) / 2; | ||
int cy = (view.getTop() + view.getBottom()) / 2; | ||
int initialRadius = view.getWidth(); | ||
// 与入场动画的区别就是圆圈起始和终止的半径相反 | ||
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, finalRadius); | ||
anim.setDuration(300); | ||
anim.setInterpolator(new AccelerateDecelerateInterpolator()); | ||
anim.addListener(new AnimatorListenerAdapter() { | ||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
super.onAnimationStart(animation); | ||
view.setBackgroundColor(ContextCompat.getColor(context, color)); | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
super.onAnimationEnd(animation); | ||
listener.onRevealHide(); | ||
view.setVisibility(View.INVISIBLE); | ||
} | ||
}); | ||
anim.start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.