package com.lxj.xpopup;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PointF;
import android.os.Build;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.RequiresApi;
import androidx.lifecycle.Lifecycle;
import com.lxj.xpopup.animator.PopupAnimator;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.ImageViewerPopupView;
import com.lxj.xpopup.core.PopupInfo;
import com.lxj.xpopup.enums.PopupAnimation;
import com.lxj.xpopup.enums.PopupPosition;
import com.lxj.xpopup.impl.AttachListPopupView;
import com.lxj.xpopup.impl.BottomListPopupView;
import com.lxj.xpopup.impl.CenterListPopupView;
import com.lxj.xpopup.impl.ConfirmPopupView;
import com.lxj.xpopup.impl.InputConfirmPopupView;
import com.lxj.xpopup.impl.LoadingPopupView;
import com.lxj.xpopup.interfaces.OnCancelListener;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.lxj.xpopup.interfaces.OnImageViewerLongPressListener;
import com.lxj.xpopup.interfaces.OnInputConfirmListener;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.lxj.xpopup.interfaces.OnSrcViewUpdateListener;
import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lxj.xpopup.interfaces.XPopupImageLoader;
import com.lxj.xpopup.util.XPermission;
import com.lxj.xpopup.util.XPopupUtils;
import java.util.ArrayList;
import java.util.List;
public class XPopup {
private XPopup() { }
/**
* 全局弹窗的设置
**/
private static int primaryColor = Color.parseColor("#121212");
private static int animationDuration = 300;
private static int statusBarBgColor = Color.parseColor("#55000000");
private static int navigationBarColor = 0;
private static int shadowBgColor = Color.parseColor("#7F000000");
public static int isLightStatusBar = 0; //大于0为true,小于0为false
public static int isLightNavigationBar = 0; //大于0为true,小于0为false
/**
* 设置全局的背景阴影颜色
* @param color
*/
public static void setShadowBgColor(int color) {
shadowBgColor = color;
}
public static int getShadowBgColor() {
return shadowBgColor;
}
/**
* 设置全局的状态栏背景颜色
*
* @param color
*/
public static void setStatusBarBgColor(int color) {
statusBarBgColor = color;
}
public static int getStatusBarBgColor() {
return statusBarBgColor;
}
/**
* 设置全局的导航栏栏背景颜色
*
* @param color
*/
public static void setNavigationBarColor(int color) {
navigationBarColor = color;
}
public static int getNavigationBarColor() {
return navigationBarColor;
}
/**
* 设置主色调
*
* @param color
*/
public static void setPrimaryColor(int color) {
primaryColor = color;
}
public static int getPrimaryColor() {
return primaryColor;
}
/**
* 统一设置是否是亮色状态栏
* @param isLight
*/
public static void setIsLightStatusBar(boolean isLight) {
isLightStatusBar = isLight ? 1 : -1;
}
/**
* 统一设置是否是亮色导航栏
* @param isLight
*/
public static void setIsLightNavigationBar(boolean isLight) {
isLightNavigationBar = isLight ? 1 : -1;
}
/**
* 设置全局动画时长
* @param duration
*/
public static void setAnimationDuration(int duration) {
if (duration >= 0) {
animationDuration = duration;
}
}
public static int getAnimationDuration() {
return animationDuration;
}
/**
* 在长按弹出弹窗后,能保证下层View不能滑动
* @param v
*/
public static PointF longClickPoint = null;
public static void fixLongClick(View v){
v.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN){
longClickPoint = new PointF(event.getRawX(), event.getRawY());
}
if("xpopup".equals(v.getTag()) && event.getAction()==MotionEvent.ACTION_MOVE){
//长按发送,阻断父View拦截
v.getParent().requestDisallowInterceptTouchEvent(true);
}
if(event.getAction()==MotionEvent.ACTION_UP){
//长按结束,恢复阻断
v.getParent().requestDisallowInterceptTouchEvent(false);
v.setTag(null);
}
return false;
}
});
v.setTag("xpopup");
}
public static class Builder {
private final PopupInfo popupInfo = new PopupInfo();
private Context context;
public Builder(Context context) {
this.context = context;
}
/**
* 设置按下返回键是否关闭弹窗,默认为true
*
* @param isDismissOnBackPressed
* @return
*/
public Builder dismissOnBackPressed(Boolean isDismissOnBackPressed) {
this.popupInfo.isDismissOnBackPressed = isDismissOnBackPressed;
return this;
}
/**
* 设置点击弹窗外面是否关闭弹窗,默认为true
*
* @param isDismissOnTouchOutside
* @return
*/
public Builder dismissOnTouchOutside(Boolean isDismissOnTouchOutside) {
this.popupInfo.isDismissOnTouchOutside = isDismissOnTouchOutside;
return this;
}
/**
* 设置当操作完毕后是否自动关闭弹窗,默认为true。比如:点击Confirm弹窗的确认按钮默认是关闭弹窗,如果为false,则不关闭
*
* @param autoDismiss
* @return
*/
public Builder autoDismiss(Boolean autoDismiss) {
this.popupInfo.autoDismiss = autoDismiss;
return this;
}
/**
* 弹窗是否有半透明背景遮罩,默认是true
*
* @param hasShadowBg
* @return
*/
public Builder hasShadowBg(Boolean hasShadowBg) {
this.popupInfo.hasShadowBg = hasShadowBg;
return this;
}
/**
* 是否设置背景为高斯模糊背景。默认为false
*
* @param hasBlurBg
* @return
*/
public Builder hasBlurBg(boolean hasBlurBg) {
this.popupInfo.hasBlurBg = hasBlurBg;
return this;
}
/**
* 设置弹窗依附的View,Attach弹窗必须设置这个
*
* @param atView
* @return
*/
public Builder atView(View atView) {
popupInfo.atView = atView;
return this;
}
/**
* 设置弹窗依附的点,Attach弹窗必须设置这个
* @param point
* @return
*/
public Builder atPoint(PointF point) {
popupInfo.touchPoint = point;
return this;
}
/**
* 设置弹窗监视的View
*
* @param watchView
* @return
*/
public Builder watchView(View watchView) {
watchView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
popupInfo.touchPoint = new PointF(event.getRawX(), event.getRawY());
}
return false;
}
});
return this;
}
/**
* 为弹窗设置内置的动画器
没有合适的资源?快使用搜索试试~ 我知道了~
真正可以免费使用的公众号和小程序微商城
共237个文件
java:113个
xml:75个
gif:21个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 109 浏览量
2023-05-24
12:22:02
上传
评论 1
收藏 23.6MB ZIP 举报
温馨提示
XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义。真正可以免费使用的公众号和小程序微商城。支持卖任意商品和视频教程;支持优惠券,积分抵现,分销功能,客户回访提醒等;支持在线客服功能
资源推荐
资源详情
资源评论
收起资源包目录
真正可以免费使用的公众号和小程序微商城 (237个子文件)
gradlew.bat 2KB
imageviewer2.gif 4.1MB
imageviewer3.gif 2.85MB
imageviewer1.gif 2.79MB
imageviewer4.gif 2.08MB
animators.gif 1.31MB
bottom1.gif 1.21MB
drawer.gif 1.11MB
inset1.gif 950KB
bottom2.gif 931KB
attach1.gif 727KB
custom.gif 726KB
search.gif 720KB
partshadow1.gif 664KB
inset2.gif 616KB
full.gif 576KB
background.gif 502KB
input.gif 498KB
partshadow2.gif 449KB
position.gif 379KB
attach2.gif 301KB
bubble.gif 232KB
.gitignore 109B
.gitignore 7B
.gitignore 7B
build.gradle 2KB
build.gradle 922B
build.gradle 787B
settings.gradle 27B
gradlew 5KB
gradle-wrapper.jar 52KB
XPopup.java 41KB
BasePopupView.java 36KB
XPopupUtils.java 33KB
PhotoViewAttacher.java 32KB
QuickStartDemo.java 31KB
BubbleLayout.java 24KB
ImageViewerPopupView.java 21KB
XPermission.java 16KB
AttachPopupView.java 15KB
ImageViewerDemo.java 15KB
BubbleAttachPopupView.java 14KB
FuckRomUtils.java 14KB
PopupDrawerLayout.java 13KB
SmartGlideImageLoader.java 12KB
SmartDragLayout.java 10KB
BottomListPopupView.java 8KB
FullScreenDialog.java 8KB
CustomGestureDetector.java 7KB
PhotoView.java 7KB
CenterListPopupView.java 7KB
DrawerPopupView.java 7KB
PartShadowDemo.java 7KB
PhotoViewContainer.java 7KB
ScrollScaleAnimator.java 6KB
BottomPopupView.java 6KB
HorizontalAttachPopupView.java 6KB
PositionPopupContainer.java 6KB
BubbleHorizontalAttachPopupView.java 6KB
KeyboardUtils.java 6KB
SmartDivider.java 6KB
ConfirmPopupView.java 6KB
PartShadowPopupView.java 5KB
AttachListPopupView.java 5KB
DemoActivity.java 5KB
ZhihuCommentPopup.java 5KB
CustomPopupDemo.java 4KB
MainActivity.java 4KB
PopupInfo.java 4KB
TranslateAnimator.java 4KB
FullScreenPopupView.java 4KB
PartShadowContainer.java 4KB
PositionPopupView.java 3KB
ImageDownloadTarget.java 3KB
LoadingView.java 3KB
LoadingPopupView.java 3KB
CustomDrawerPopupView.java 3KB
CenterPopupView.java 3KB
InputConfirmPopupView.java 3KB
ListDrawerPopupView.java 3KB
ScaleAlphaAnimator.java 3KB
BlurAnimator.java 3KB
TranslateAlphaAnimator.java 2KB
ShadowBgAnimator.java 2KB
PopupAnimator.java 2KB
PagerBottomPopup.java 2KB
CustomEditTextBottomPopup.java 2KB
CustomAnimatorDemo.java 2KB
XPopupCallback.java 2KB
SSIVListener.java 2KB
AllAnimatorDemo.java 2KB
BaseFragment.java 2KB
LoginPopup.java 2KB
PagerDrawerPopup.java 2KB
CustomBubbleAttachPopup.java 2KB
CustomImageViewerPopup.java 2KB
CustomHorizontalBubbleAttachPopup.java 2KB
BlankView.java 2KB
CheckView.java 2KB
CustomPartShadowPopupView.java 1KB
共 237 条
- 1
- 2
- 3
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6651
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功