Skip to content

Commit 4ae804b

Browse files
committed
更新弹性动画是否覆盖全屏幕
1 parent 2458375 commit 4ae804b

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

adlibrary/src/main/java/com/uuch/adlibrary/AdManager.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public class AdManager {
6565
private double speed = AdConstant.SPEED;
6666
// viewPager滑动动画效果
6767
private ViewPager.PageTransformer pageTransformer = null;
68+
// 是否覆盖全屏幕
69+
private boolean isOverScreen = true;
6870

6971
private OnImageClickListener onImageClickListener = null;
7072

@@ -112,6 +114,7 @@ public void showAdDialog(final int animType) {
112114
.setDialogCloseable(isDialogCloseable)
113115
.setDialogBackViewColor(backViewColor)
114116
.setOnCloseClickListener(onCloseClickListener)
117+
.setOverScreen(isOverScreen)
115118
.initView(contentView);
116119
setRootContainerHeight();
117120

@@ -194,7 +197,6 @@ public void onFinalImageSet(
194197
if (imageInfo == null) {
195198
return;
196199
}
197-
Log.i("##########", "onFinalImageSet()");
198200
errorView.setVisibility(View.GONE);
199201
loadingView.setVisibility(View.GONE);
200202
simpleDraweeView.setVisibility(View.VISIBLE);
@@ -207,7 +209,6 @@ public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
207209

208210
@Override
209211
public void onFailure(String id, Throwable throwable) {
210-
Log.i("#############", "onFilure()");
211212
errorView.setVisibility(View.VISIBLE);
212213
loadingView.setVisibility(View.GONE);
213214
simpleDraweeView.setVisibility(View.GONE);
@@ -349,4 +350,15 @@ public AdManager setPageTransformer(ViewPager.PageTransformer pageTransformer) {
349350

350351
return this;
351352
}
353+
354+
/**
355+
* 设置弹窗背景是否覆盖全屏幕
356+
* @param overScreen
357+
* @return
358+
*/
359+
public AdManager setOverScreen(boolean overScreen) {
360+
isOverScreen = overScreen;
361+
362+
return this;
363+
}
352364
}

adlibrary/src/main/java/com/uuch/adlibrary/AnimDialogUtils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class AnimDialogUtils {
3535
private View.OnClickListener onCloseClickListener = null;
3636
// 设置弹窗背景颜色
3737
private int backViewColor = Color.parseColor("#bf000000");
38+
// 弹窗背景是否覆盖全屏幕
39+
private boolean isOverScreen = true;
3840

3941
private AnimDialogUtils(Activity context) {
4042
this.context = context;
@@ -51,7 +53,11 @@ public static AnimDialogUtils getInstance(Activity context) {
5153
* @return
5254
*/
5355
public AnimDialogUtils initView(final View customView) {
54-
androidContentView = (ViewGroup) context.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
56+
if (isOverScreen) {
57+
androidContentView = (ViewGroup) context.getWindow().getDecorView();
58+
} else {
59+
androidContentView = (ViewGroup) context.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
60+
}
5561
rootView = LayoutInflater.from(context).inflate(R.layout.anim_dialog_layout, null);
5662
rootView.setTag(ANIM_DIALOG_TAG);
5763

@@ -148,6 +154,16 @@ public AnimDialogUtils setAnimBackViewTransparent(boolean animBackViewTransparen
148154
return this;
149155
}
150156

157+
/**
158+
* 设置弹窗背景是否覆盖全屏幕
159+
* @param overScreen
160+
*/
161+
public AnimDialogUtils setOverScreen(boolean overScreen) {
162+
isOverScreen = overScreen;
163+
164+
return this;
165+
}
166+
151167
// ################### get方法 ####################
152168

153169
public RelativeLayout getAnimContainer() {

adlibrary/src/main/res/layout/ad_dialog_content_layout.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
xmlns:fpi="http://schemas.android.com/apk/res-auto"
44
android:id="@+id/ad_root_content"
55
android:layout_width="match_parent"
6-
android:layout_height="wrap_content">
6+
android:layout_height="wrap_content"
7+
>
78

89
<android.support.v4.view.ViewPager
910
android:id="@+id/viewPager"

adlibrary/src/main/res/layout/anim_dialog_layout.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
android:layout_centerInParent="true"
1515
android:layout_marginLeft="44dp"
1616
android:layout_marginRight="44dp"
17+
android:paddingTop="48dp"
1718
>
1819

1920
<FrameLayout

app/src/main/java/com/uuch/android_addialog/MainActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.uuch.adlibrary.AdConstant;
1515
import com.uuch.adlibrary.bean.AdInfo;
1616
import com.uuch.adlibrary.AdManager;
17+
import com.uuch.adlibrary.transformer.DepthPageTransformer;
1718
import com.uuch.adlibrary.transformer.ZoomOutPageTransformer;
1819

1920
import java.util.ArrayList;
@@ -188,7 +189,7 @@ public void onImageClick(View view, AdInfo advInfo) {
188189
}
189190
})
190191
.setPadding(100)
191-
.setWidthPerHeight(1f)
192+
.setWidthPerHeight(0.5f)
192193
.showAdDialog(AdConstant.ANIM_UP_TO_DOWN);
193194
}
194195
});
@@ -223,6 +224,7 @@ public void onImageClick(View view, AdInfo advInfo) {
223224
})
224225
.setBounciness(15)
225226
.setDialogCloseable(true)
227+
.setOverScreen(false)
226228
.showAdDialog(AdConstant.ANIM_UP_TO_DOWN);
227229
}
228230
});
@@ -238,7 +240,7 @@ public void onImageClick(View view, AdInfo advInfo) {
238240
Toast.makeText(MainActivity.this, "您点击了ViewPagerItem...", Toast.LENGTH_SHORT).show();
239241
}
240242
})
241-
.setPageTransformer(new ZoomOutPageTransformer())
243+
.setPageTransformer(new DepthPageTransformer())
242244
.showAdDialog(AdConstant.ANIM_UP_TO_DOWN);
243245
}
244246
});

0 commit comments

Comments
 (0)