-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update RxTextUtils update RxPopupView
- Loading branch information
秋逸
committed
Mar 15, 2017
1 parent
ee54a63
commit 19b1885
Showing
7 changed files
with
626 additions
and
4 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
100 changes: 100 additions & 0 deletions
100
RxTools-library/src/main/java/com/vondear/rxtools/RxAnimationUtils.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,100 @@ | ||
package com.vondear.rxtools; | ||
|
||
import android.animation.Animator; | ||
import android.animation.ArgbEvaluator; | ||
import android.animation.ObjectAnimator; | ||
import android.animation.ValueAnimator; | ||
import android.view.View; | ||
import android.view.animation.AccelerateInterpolator; | ||
import android.view.animation.DecelerateInterpolator; | ||
import android.view.animation.Interpolator; | ||
|
||
import com.vondear.rxtools.interfaces.onUpdateListener; | ||
|
||
import static com.vondear.rxtools.RxImageUtils.invisToVis; | ||
import static com.vondear.rxtools.RxImageUtils.visToInvis; | ||
|
||
/** | ||
* Created by Administrator on 2017/3/15. | ||
*/ | ||
|
||
public class RxAnimationUtils { | ||
|
||
/** | ||
* 颜色渐变动画 | ||
* @param beforeColor 变化之前的颜色 | ||
* @param afterColor 变化之后的颜色 | ||
* @param listener 变化事件 | ||
*/ | ||
public static void animationColorGradient(int beforeColor, int afterColor, final onUpdateListener listener) { | ||
ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), beforeColor, afterColor).setDuration(3000); | ||
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | ||
@Override | ||
public void onAnimationUpdate(ValueAnimator animation) { | ||
// textView.setTextColor((Integer) animation.getAnimatedValue()); | ||
listener.onUpdate((Integer) animation.getAnimatedValue()); | ||
} | ||
}); | ||
valueAnimator.start(); | ||
} | ||
|
||
/** | ||
* 卡片翻转动画 | ||
* @param beforeView | ||
* @param AfterView | ||
*/ | ||
public static void FilpAnimation(final View beforeView, final View AfterView) { | ||
Interpolator accelerator = new AccelerateInterpolator(); | ||
Interpolator decelerator = new DecelerateInterpolator(); | ||
if (beforeView.getVisibility() == View.GONE) { | ||
// 局部layout可达到字体翻转 背景不翻转 | ||
invisToVis = ObjectAnimator.ofFloat(beforeView, | ||
"rotationY", -90f, 0f); | ||
visToInvis = ObjectAnimator.ofFloat(AfterView, | ||
"rotationY", 0f, 90f); | ||
} else if (AfterView.getVisibility() == View.GONE) { | ||
invisToVis = ObjectAnimator.ofFloat(AfterView, | ||
"rotationY", -90f, 0f); | ||
visToInvis = ObjectAnimator.ofFloat(beforeView, | ||
"rotationY", 0f, 90f); | ||
} | ||
|
||
visToInvis.setDuration(250);// 翻转速度 | ||
visToInvis.setInterpolator(accelerator);// 在动画开始的地方速率改变比较慢,然后开始加速 | ||
invisToVis.setDuration(250); | ||
invisToVis.setInterpolator(decelerator); | ||
visToInvis.addListener(new Animator.AnimatorListener() { | ||
|
||
@Override | ||
public void onAnimationEnd(Animator arg0) { | ||
if (beforeView.getVisibility() == View.GONE) { | ||
AfterView.setVisibility(View.GONE); | ||
invisToVis.start(); | ||
beforeView.setVisibility(View.VISIBLE); | ||
} else { | ||
AfterView.setVisibility(View.GONE); | ||
visToInvis.start(); | ||
beforeView.setVisibility(View.VISIBLE); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator arg0) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator arg0) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationStart(Animator arg0) { | ||
|
||
} | ||
}); | ||
visToInvis.start(); | ||
} | ||
|
||
|
||
} |
40 changes: 40 additions & 0 deletions
40
RxTools-library/src/main/java/com/vondear/rxtools/RxBroadcastUtils.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,40 @@ | ||
package com.vondear.rxtools; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.net.ConnectivityManager; | ||
|
||
/** | ||
* Created by Administrator on 2017/3/15. | ||
*/ | ||
|
||
public class RxBroadcastUtils { | ||
|
||
|
||
/** | ||
* 网络状态改变广播 | ||
*/ | ||
public class BroadcastReceiverNetWork extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
RxNetUtils.getNetWorkType(context); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* 注册监听网络状态的广播 | ||
* @param context | ||
* @return | ||
*/ | ||
private BroadcastReceiverNetWork initRegisterReceiverNetWork(Context context) { | ||
// 注册监听网络状态的服务 | ||
BroadcastReceiverNetWork mReceiverNetWork = new BroadcastReceiverNetWork(); | ||
IntentFilter mFilter = new IntentFilter(); | ||
mFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); | ||
context.registerReceiver(mReceiverNetWork, mFilter); | ||
return mReceiverNetWork; | ||
} | ||
} |
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
213 changes: 213 additions & 0 deletions
213
RxTools-library/src/main/java/com/vondear/rxtools/RxRegUtils.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,213 @@ | ||
package com.vondear.rxtools; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import static com.vondear.rxtools.RxConstUtils.REGEX_CHZ; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_DATE; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_EMAIL; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_IDCARD; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_IDCARD15; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_IDCARD18; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_IP; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_MOBILE_EXACT; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_MOBILE_SIMPLE; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_TEL; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_URL; | ||
import static com.vondear.rxtools.RxConstUtils.REGEX_USERNAME; | ||
import static com.vondear.rxtools.RxDataUtils.isNullString; | ||
|
||
/** | ||
* Created by Administrator on 2017/3/15. | ||
*/ | ||
|
||
public class RxRegUtils { | ||
//--------------------------------------------正则表达式----------------------------------------- | ||
/** | ||
* 原文链接:http://caibaojian.com/regexp-example.html | ||
* 提取信息中的网络链接:(h|H)(r|R)(e|E)(f|F) *= *('|")?(\w|\\|\/|\.)+('|"| *|>)? | ||
* 提取信息中的邮件地址:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* | ||
* 提取信息中的图片链接:(s|S)(r|R)(c|C) *= *('|")?(\w|\\|\/|\.)+('|"| *|>)? | ||
* 提取信息中的IP地址:(\d+)\.(\d+)\.(\d+)\.(\d+) | ||
* 提取信息中的中国电话号码(包括移动和固定电话):(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14} | ||
* 提取信息中的中国邮政编码:[1-9]{1}(\d+){5} | ||
* 提取信息中的中国身份证号码:\d{18}|\d{15} | ||
* 提取信息中的整数:\d+ | ||
* 提取信息中的浮点数(即小数):(-?\d*)\.?\d+ | ||
* 提取信息中的任何数字 :(-?\d*)(\.\d+)? | ||
* 提取信息中的中文字符串:[\u4e00-\u9fa5]* | ||
* 提取信息中的双字节字符串 (汉字):[^\x00-\xff]* | ||
*/ | ||
|
||
|
||
/** | ||
* 判断是否为真实手机号 | ||
* | ||
* @param mobiles | ||
* @return | ||
*/ | ||
public static boolean isMobile(String mobiles) { | ||
Pattern p = Pattern.compile("^1(3[0-9]|5[012356789]|8[0256789]|7[0678])\\d{8}$"); | ||
Matcher m = p.matcher(mobiles); | ||
return m.matches(); | ||
} | ||
|
||
/** | ||
* 验证银卡卡号 | ||
* | ||
* @param cardNo | ||
* @return | ||
*/ | ||
public static boolean isBankCard(String cardNo) { | ||
Pattern p = Pattern.compile("^\\d{16,19}$|^\\d{6}[- ]\\d{10,13}$|^\\d{4}[- ]\\d{4}[- ]\\d{4}[- ]\\d{4,7}$"); | ||
Matcher m = p.matcher(cardNo); | ||
return m.matches(); | ||
} | ||
|
||
/** | ||
* 15位和18位身份证号码的正则表达式 身份证验证 | ||
* | ||
* @param idCard | ||
* @return | ||
*/ | ||
public static boolean validateIdCard(String idCard) { | ||
// 15位和18位身份证号码的正则表达式 | ||
String regIdCard = "^(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$)|(^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}[Xx])$)$"; | ||
Pattern p = Pattern.compile(regIdCard); | ||
return p.matcher(idCard).matches(); | ||
} | ||
//=========================================正则表达式============================================= | ||
|
||
/** | ||
* 验证手机号(简单) | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isMobileSimple(String string) { | ||
return isMatch(REGEX_MOBILE_SIMPLE, string); | ||
} | ||
|
||
/** | ||
* 验证手机号(精确) | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isMobileExact(String string) { | ||
return isMatch(REGEX_MOBILE_EXACT, string); | ||
} | ||
|
||
/** | ||
* 验证电话号码 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isTel(String string) { | ||
return isMatch(REGEX_TEL, string); | ||
} | ||
|
||
/** | ||
* 验证身份证号码15位 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isIDCard15(String string) { | ||
return isMatch(REGEX_IDCARD15, string); | ||
} | ||
|
||
/** | ||
* 验证身份证号码18位 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isIDCard18(String string) { | ||
return isMatch(REGEX_IDCARD18, string); | ||
} | ||
|
||
/** | ||
* 验证身份证号码15或18位 包含以x结尾 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isIDCard(String string) { | ||
return isMatch(REGEX_IDCARD, string); | ||
} | ||
|
||
|
||
/** | ||
* 验证邮箱 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isEmail(String string) { | ||
return isMatch(REGEX_EMAIL, string); | ||
} | ||
|
||
/** | ||
* 验证URL | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isURL(String string) { | ||
return isMatch(REGEX_URL, string); | ||
} | ||
|
||
/** | ||
* 验证汉字 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isChz(String string) { | ||
return isMatch(REGEX_CHZ, string); | ||
} | ||
|
||
/** | ||
* 验证用户名 | ||
* <p>取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位</p> | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isUsername(String string) { | ||
return isMatch(REGEX_USERNAME, string); | ||
} | ||
|
||
/** | ||
* 验证yyyy-MM-dd格式的日期校验,已考虑平闰年 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isDate(String string) { | ||
return isMatch(REGEX_DATE, string); | ||
} | ||
|
||
/** | ||
* 验证IP地址 | ||
* | ||
* @param string 待验证文本 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isIP(String string) { | ||
return isMatch(REGEX_IP, string); | ||
} | ||
|
||
/** | ||
* string是否匹配regex正则表达式字符串 | ||
* | ||
* @param regex 正则表达式字符串 | ||
* @param string 要匹配的字符串 | ||
* @return {@code true}: 匹配<br>{@code false}: 不匹配 | ||
*/ | ||
public static boolean isMatch(String regex, String string) { | ||
return !isNullString(string) && Pattern.matches(regex, string); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
RxTools-library/src/main/java/com/vondear/rxtools/interfaces/onUpdateListener.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,9 @@ | ||
package com.vondear.rxtools.interfaces; | ||
|
||
/** | ||
* Created by Administrator on 2017/3/10. | ||
*/ | ||
|
||
public interface onUpdateListener { | ||
void onUpdate(int intValue); | ||
} |
Oops, something went wrong.