Skip to content

Commit

Permalink
发布1.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
junixapp committed Feb 18, 2019
1 parent 95f1d92 commit 7790356
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -397,7 +397,7 @@ implementation 'com.lxj:xpopup:最新的版本号'

默认情况下,XPopup的主色为灰色,主色作用于Button文字,EditText边框和光标,Check文字的颜色上。因为XPopup是单例,所以主色调只需要设置一次即可,可以放在Application中设置。
```java
XPopup.get(this).setPrimaryColor(getResources().getColor(R.color.colorPrimary));
XPopup.setPrimaryColor(getResources().getColor(R.color.colorPrimary));
```

- 常用设置
Expand All @@ -406,6 +406,7 @@ implementation 'com.lxj:xpopup:最新的版本号'
.hasShadowBg(true) // 是否有半透明的背景,默认为true
.dismissOnBackPressed(true) // 按返回键是否关闭弹窗,默认为true
.dismissOnTouchOutside(true) // 点击外部是否关闭弹窗,默认为true
.autoDismiss(false) // 操作完毕后是否自动关闭弹窗,默认为true;比如点击ConfirmPopup的确认按钮,默认自动关闭;如果为false,则不会关闭
.popupAnimation(PopupAnimation.ScaleAlphaFromCenter) // 设置内置的动画
.customAnimator(null) // 设置自定义的动画器
.setPopupCallback(new XPopupCallback() { //设置显示和隐藏的回调
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 3 additions & 1 deletion app/src/main/java/com/lxj/xpopupdemo/MainActivity.java
@@ -1,5 +1,6 @@
package com.lxj.xpopupdemo;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
Expand Down Expand Up @@ -62,7 +63,8 @@ public void run() {
}
},300);

XPopup.get(this).setPrimaryColor(getResources().getColor(R.color.colorPrimary));
XPopup.setPrimaryColor(getResources().getColor(R.color.colorPrimary));
// XPopup.setPrimaryColor(Color.RED);

}

Expand Down
Expand Up @@ -75,6 +75,7 @@ public void onConfirm() {
})
// .dismissOnTouchOutside(false)
// 设置弹窗显示和隐藏的回调监听
.autoDismiss(false)
.setPopupCallback(new XPopupCallback() {
@Override
public void onShow() {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Expand Up @@ -33,7 +33,7 @@ publish {
userOrg = 'li-xiaojun'
groupId = 'com.lxj'
artifactId = 'xpopup'
publishVersion = '1.3.5'
publishVersion = '1.3.6'
repoName = 'jrepo'
desc = '功能强大,UI简洁,交互优雅的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!'
website = 'https://github.com/li-xiaojun/XPopup'
Expand Down
20 changes: 16 additions & 4 deletions library/src/main/java/com/lxj/xpopup/XPopup.java
Expand Up @@ -46,7 +46,7 @@ public class XPopup {
private static WeakReference<Context> contextRef;
private PopupInfo tempInfo = null;
private BasePopupView tempView;
private int primaryColor = Color.parseColor("#121212");
private static int primaryColor = Color.parseColor("#121212");
private static ArrayList<BasePopupView> popupViews = new ArrayList<>();

private XPopup() {
Expand Down Expand Up @@ -206,11 +206,11 @@ private void release() {
*
* @param color
*/
public void setPrimaryColor(int color) {
this.primaryColor = color;
public static void setPrimaryColor(int color) {
primaryColor = color;
}

public int getPrimaryColor() {
public static int getPrimaryColor() {
return primaryColor;
}

Expand Down Expand Up @@ -274,6 +274,18 @@ public XPopup dismissOnTouchOutside(boolean isDismissOnTouchOutside) {
return this;
}

/**
* 操作完毕后是否自动关闭弹窗,默认为true。
* 比如:点击确认对话框的确认和取消按钮后默认会关闭弹窗,如果设置为false则不会自动关闭
* @param isAutoDismiss
* @return
*/
public XPopup autoDismiss(boolean isAutoDismiss) {
checkPopupInfo();
tempInfo.autoDismiss = isAutoDismiss;
return this;
}

public XPopup atView(View view) {
checkPopupInfo();
tempInfo.setAtView(view);
Expand Down
1 change: 1 addition & 0 deletions library/src/main/java/com/lxj/xpopup/core/PopupInfo.java
Expand Up @@ -17,6 +17,7 @@ public class PopupInfo {
public PopupType popupType = null; //窗体的类型
public Boolean isDismissOnBackPressed = true; //按返回键是否消失
public Boolean isDismissOnTouchOutside = true; //点击外部消失
public Boolean autoDismiss = true; //操作完毕后是否自动关闭
public Boolean hasShadowBg = true; // 是否有半透明的背景
private View atView = null; // 依附于那个View显示
// 动画执行器,如果不指定,则会根据窗体类型popupType字段生成默认合适的动画执行器
Expand Down
Expand Up @@ -53,7 +53,7 @@ public void onItemClick(View view, RecyclerView.ViewHolder holder, int position)
if (selectListener != null) {
selectListener.onSelect(position, adapter.getDatas().get(position));
}
dismiss();
if(popupInfo.autoDismiss)dismiss();
}
});
recyclerView.setAdapter(adapter);
Expand Down
Expand Up @@ -61,9 +61,9 @@ protected void convert(@NonNull ViewHolder holder, @NonNull String s, int positi
// 对勾View
if (checkedPosition != -1) {
holder.setVisible(R.id.check_view, position == checkedPosition);
holder.<CheckView>getView(R.id.check_view).setColor(XPopup.get(getContext()).getPrimaryColor());
holder.<CheckView>getView(R.id.check_view).setColor(XPopup.getPrimaryColor());
holder.setTextColor(R.id.tv_text, position==checkedPosition ?
XPopup.get(getContext()).getPrimaryColor() : getResources().getColor(R.color._xpopup_title_color));
XPopup.getPrimaryColor() : getResources().getColor(R.color._xpopup_title_color));
}
}
};
Expand All @@ -80,7 +80,7 @@ public void onItemClick(View view, RecyclerView.ViewHolder holder, int position)
postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
if(popupInfo.autoDismiss)dismiss();
}
},100);
}
Expand Down
Expand Up @@ -61,9 +61,9 @@ protected void convert(@NonNull ViewHolder holder, @NonNull String s, int positi
// 对勾View
if (checkedPosition != -1) {
holder.setVisible(R.id.check_view, position == checkedPosition);
holder.<CheckView>getView(R.id.check_view).setColor(XPopup.get(getContext()).getPrimaryColor());
holder.<CheckView>getView(R.id.check_view).setColor(XPopup.getPrimaryColor());
holder.setTextColor(R.id.tv_text, position==checkedPosition ?
XPopup.get(getContext()).getPrimaryColor() : getResources().getColor(R.color._xpopup_title_color));
XPopup.getPrimaryColor() : getResources().getColor(R.color._xpopup_title_color));
}
}
};
Expand All @@ -77,7 +77,7 @@ public void onItemClick(View view, RecyclerView.ViewHolder holder, int position)
checkedPosition = position;
adapter.notifyDataSetChanged();
}
dismiss();
if(popupInfo.autoDismiss)dismiss();
}
});
recyclerView.setAdapter(adapter);
Expand Down
Expand Up @@ -50,8 +50,8 @@ protected void initPopupContent() {
}

protected void applyPrimaryColor(){
tv_cancel.setTextColor(XPopup.get(getContext()).getPrimaryColor());
tv_confirm.setTextColor(XPopup.get(getContext()).getPrimaryColor());
tv_cancel.setTextColor(XPopup.getPrimaryColor());
tv_confirm.setTextColor(XPopup.getPrimaryColor());
}

OnCancelListener cancelListener;
Expand All @@ -73,6 +73,6 @@ public void onClick(View v) {
}else if(v==tv_confirm){
if(confirmListener!=null)confirmListener.onConfirm();
}
dismiss();
if(popupInfo.autoDismiss)dismiss();
}
}
Expand Up @@ -39,12 +39,12 @@ protected void initPopupContent() {

protected void applyPrimaryColor(){
super.applyPrimaryColor();
XPopupUtils.setCursorDrawableColor(tv_input, XPopup.get(getContext()).getPrimaryColor());
XPopupUtils.setCursorDrawableColor(tv_input, XPopup.getPrimaryColor());
tv_input.post(new Runnable() {
@Override
public void run() {
BitmapDrawable defaultDrawable = XPopupUtils.createBitmapDrawable(getResources(), tv_input.getMeasuredWidth(), Color.parseColor("#888888"));
BitmapDrawable focusDrawable = XPopupUtils.createBitmapDrawable(getResources(), tv_input.getMeasuredWidth(), XPopup.get(getContext()).getPrimaryColor());
BitmapDrawable focusDrawable = XPopupUtils.createBitmapDrawable(getResources(), tv_input.getMeasuredWidth(), XPopup.getPrimaryColor());
tv_input.setBackgroundDrawable(XPopupUtils.createSelector(defaultDrawable, focusDrawable));
}
});
Expand All @@ -62,10 +62,9 @@ public void setListener( OnInputConfirmListener inputConfirmListener,OnCancelLis
public void onClick(View v) {
if(v==tv_cancel){
if(cancelListener!=null)cancelListener.onCancel();
dismiss();
}else if(v==tv_confirm){
if(inputConfirmListener!=null)inputConfirmListener.onConfirm(tv_input.getText().toString().trim());
dismiss();
}
if(popupInfo.autoDismiss)dismiss();
}
}

0 comments on commit 7790356

Please sign in to comment.