library
Disclaimer: There may be a method you share here, thank you here. If possible, please contact me with original author information.
Whenever we start to write an Android project, it will be a headache to build various tedious tool classes. Therefore, under this background, the Android tool class library was born. We are committed to building a powerful Android tool class library. The purpose of It allows you to refer to or directly import when writing a project.
Then, since the author is an Android novice, there will inevitably be various bugs, but the author will continue to update, please pay more attention.
Tool class list
class name | illustrate |
---|---|
AppManager | Activity management tool class |
CallBackWenyiFeng | callback interface |
FontImgWenyiFeng | Font picture tools |
ProgressDialogWenyiFeng | Progress dialog tool class |
RegularUtilWenyiFeng | Regular expression tool class |
UtilWebServiceWenyiFeng | Request WebService interface tool class |
UtilWenyiFeng | Common tools |
introduce
Step 1. Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency (because the update is very fast, please pay special attention to the version number)
dependencies {
compile 'com.github.fengwenyi:library:170908.10'
}
API
1. AppManager class
method name | parameter | return | illustrate |
---|---|---|---|
getInstance() | AppManager | single instance | |
addActivity() | Activity | Add the Activity to the stack | |
getCurrentActvity() | Activity | Get the current Activity | |
finishCurrentActivity() | close the current activity | ||
finishActivity() | Activity | Close the specified Activity | |
finishAllActivity() | close all activities | ||
AppExit() | Context | Exit the app (obsolete, replaced by appExit()) | |
appExit() | Context | Exit the app |
It is worth noting that: the closing APP method requires the following permissions:
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
2. CallBackWenyiFeng interface
method name | parameter | return | illustrate |
---|---|---|---|
onSuccess() | T | success, custom data type | |
onFail() | String | failed, error message |
3. FontImgWenyiFeng class
method name | parameter | return | illustrate |
---|---|---|---|
injectFont() | View | static, display font image | |
injectFont() | View, Typeface | static, display font image |
Example of calling:
//字体图片
FontHelper.injectFont(findViewById(R.id.fun_top_back));
In addition, we have provided you with a set of font pictures, please click the picture corresponding code
4. ProgressDialogWenyiFeng class
method name | parameter | return | illustrate |
---|---|---|---|
show() | Context, String, int, boolean, boolean | static, parameter description (context, prompt text, style, whether clicking the margin can be canceled, whether clicking the Home button can be canceled) | |
isShoing() | boolean | static, state, true to show, false to hide | |
dismiss() | static, undisplay |
Example of calling:
ProgressDialogWenyiFeng.show(context, context.getResources().getString(R.string.progress_dialog_loading),
3, false, true);
5、RegularUtilWenyiFeng类
method name | parameter | return | illustrate |
---|---|---|---|
isUsername () | String | boolean | static, regular authentication username, parameter (username), return (whether it is legal or not) |
isPassword | String | boolean | static, regular verification password, parameter (password), return (whether it is legal or not) |
isMobile () | String | boolean | static, regular verification mobile phone number, parameter (mobile phone number), return (whether it is legal) |
isEmail () | String | boolean | static, regular verification E-mail, parameter (E-mail), return (whether it is legal) |
isChinese() | String | boolean | static, Regularly verify whether there is Chinese in the string, parameter (string to be detected), return (whether it contains Chinese) |
isIDCard() | String | boolean | static, regular verification ID number, parameter (ID number), return (whether it is legal or not) |
isUrl () | String | boolean | static, regular verification URL, parameter (url), return (whether it is legal or not) |
isIPAddr () | String | boolean | static, regular verification IP address, parameter (ip), return (whether it is legal) |
isNumber() | String | boolean | static, regular verification whether it is a number, parameter (character to be tested), return (whether it is a number) |
RegularUtilWenyiFeng() | String | custom regular rules | |
customVerify() | String | boolean | Custom validation, parameters (string to be tested), return (whether the conditions are met) |
Custom validation example:
String sQQ = "[1-9][0-9]{3,10}";
RegularUtilWenyiFeng regularUtilWenyiFeng = new RegularUtilWenyiFeng(sQQ);
String testQQ = "3232445924";
boolean isCQQ = regularUtilWenyiFeng.customVerify(testQQ);
System.out.print(isCQQ);
6. UtilWebServiceWenyiFeng class
method name | parameter | return | illustrate |
---|---|---|---|
call() | wsdl地址,命名空间,方法名称,参数集合,数据回调接口 | static, 请求WebService接口数据,参数类型及调用示例见下 | |
setThreadSize() | int | static, 设置线程池大小 | |
setIsDotNet() | boolean | static, 设置是否由 dotNet开发 |
参数类型说明:
wsdl地址:String
命名空间:String
方法名称:String
参数集合:SimpleArrayMap<String, String>
回调接口:CallBackWenyiFeng<SoapObject>
调用示例:
public void testWebService(String url, String namespace, String method, SimpleArrayMap<String, String> params) {
UtilWebServiceWenyiFeng.call(url, namespace, method, params, new CallBackWenyiFeng<SoapObject>() {
@Override
public void onSuccess(SoapObject soapObject) {
}
@Override
public void onFail(String msg) {
}
});
}
7、UtilWenyiFeng类
方法名 | 参数 | 返回 | 说明 |
---|---|---|---|
toast() | Context, String | static, 文字提示弹窗,参数(上下文,提示文字) | |
isNetworkAvailable() | Context | static, 检测当前网络是否可用,参数(上下文) |
值得说明的是:关闭APP方法需要以下权限:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
猛击查看:源码
About me
WenyiFeng(xfsy2014@gmail.com)
Copyright © 2017 fengwenyi.com. All Rights Reserved.