Skip to content

Commit

Permalink
fullActivityBuilder() support drawable ~
Browse files Browse the repository at this point in the history
  • Loading branch information
XunMengWinter committed Aug 1, 2018
1 parent 121a3a0 commit 876f743
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
4 changes: 2 additions & 2 deletions circularanim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 27
versionCode 8
versionName "0.3.8"
versionCode 9
versionName "0.4.2"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
Expand Down Expand Up @@ -98,11 +99,19 @@ public VisibleBuilder(View animView, boolean isShow) {
}
}

/**
* set the trigger view.
* if {@link VisibleBuilder#mTriggerPoint} is null,
* then will set the mTriggerView's center as trigger point.
*/
public VisibleBuilder triggerView(View triggerView) {
mTriggerView = triggerView;
return this;
}

/**
* set the trigger point.
*/
public VisibleBuilder triggerPoint(Point triggerPoint) {
mTriggerPoint = triggerPoint;
return this;
Expand Down Expand Up @@ -217,6 +226,7 @@ public static class FullActivityBuilder {
private Point mTriggerPoint;
private float mStartRadius = MINI_RADIUS;
private int mColorOrImageRes = getColorOrImageRes();
private Drawable mDrawable;
private Long mDurationMills;
private OnAnimatorDeployListener mStartAnimatorDeployListener;
private OnAnimatorDeployListener mReturnAnimatorDeployListener;
Expand All @@ -242,11 +252,23 @@ public FullActivityBuilder startRadius(float startRadius) {
return this;
}

/**
* set the ripple background drawableRes.
* this will be override by {@link FullActivityBuilder#drawable(Drawable)}
*/
public FullActivityBuilder colorOrImageRes(int colorOrImageRes) {
mColorOrImageRes = colorOrImageRes;
return this;
}

/**
* set the ripple background drawable.
*/
public FullActivityBuilder drawable(Drawable drawable) {
mDrawable = drawable;
return this;
}

public FullActivityBuilder duration(long durationMills) {
mDurationMills = durationMills;
return this;
Expand All @@ -258,11 +280,17 @@ public FullActivityBuilder overridePendingTransition(int enterAnim, int exitAnim
return this;
}

/**
* set the start animation interceptor
*/
public FullActivityBuilder deployStartAnimator(OnAnimatorDeployListener onAnimatorDeployListener) {
mStartAnimatorDeployListener = onAnimatorDeployListener;
return this;
}

/**
* set the return animation interceptor
*/
public FullActivityBuilder deployReturnAnimator(OnAnimatorDeployListener onAnimatorDeployListener) {
mReturnAnimatorDeployListener = onAnimatorDeployListener;
return this;
Expand All @@ -279,7 +307,11 @@ public void go(OnAnimationEndListener onAnimationEndListener) {

final ImageView view = new ImageView(mActivity);
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
view.setImageResource(mColorOrImageRes);
// 优先使用 mDrawable
if (mDrawable != null)
view.setImageDrawable(mDrawable);
else
view.setImageResource(mColorOrImageRes);
final ViewGroup decorView = (ViewGroup) mActivity.getWindow().getDecorView();
int w = decorView.getWidth();
int h = decorView.getHeight();
Expand Down
14 changes: 14 additions & 0 deletions demo/src/main/java/top/wefor/circularanimdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.animation.Animator;
import android.content.Intent;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -140,7 +141,20 @@ public void onClick(View view) {
});
}

public void fullWithDrawable(View view) {
// 先将图片展出铺满,然后启动新的Activity
CircularAnim.fullActivity(MainActivity.this, view)
.drawable(new ColorDrawable(0xFF996383)) // drawable will override colorOrImageRes
.go(new CircularAnim.OnAnimationEndListener() {
@Override
public void onAnimationEnd() {
startActivity(new Intent(MainActivity.this, ListActivity.class));
}
});
}

public void fragmentDemo(View view) {
startActivity(new Intent(this, FragmentTestActivity.class));
}

}
24 changes: 17 additions & 7 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="top.wefor.circularanimdemo.MainActivity"
android:paddingTop="32dp"
tools:context="top.wefor.circularanimdemo.MainActivity"
>

<LinearLayout
android:layout_margin="16dp"
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="#dfa"
android:orientation="vertical">

Expand All @@ -37,6 +37,16 @@
android:text="Start Activity 颜色"
android:textColor="@android:color/white"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@color/colorPrimary"
android:onClick="fullWithDrawable"
android:padding="16dp"
android:text="Start Activity Drawable"
android:textColor="@android:color/white"/>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -81,21 +91,21 @@
</LinearLayout>

<ImageView
android:alpha="0.5"
android:id="@+id/logoBtn_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginRight="16dp"
android:alpha="0.5"
android:src="@mipmap/ic_launcher"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="16dp"
android:text="fragment demo"
android:onClick="fragmentDemo"
android:layout_gravity="bottom|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:text="fragment demo"/>

</FrameLayout>

0 comments on commit 876f743

Please sign in to comment.