Skip to content

Commit 8e42e60

Browse files
committed
[commit] 增加测试程序
1 parent 6e39361 commit 8e42e60

File tree

18 files changed

+867
-66
lines changed

18 files changed

+867
-66
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 使用方式
22
* 这个library还在功能迭代中,功能不尽完善...
33
```gradle
4-
compile 'com.code19.library:library:0.0.4'
4+
compile 'com.code19.library:library:0.0.5'
55
```
66
# 常用工具类
77
- 每一个Android开发者在日常开发中都会积累一些自己的代码片段
@@ -81,7 +81,7 @@ compile 'com.code19.library:library:0.0.4'
8181
* getSerial 获取设备序列号
8282
* getSIMSerial 获取SIM序列号
8383
* getPhoneNumber 获取手机号码(未获取成功)
84-
* getMNC 获取网络运营商 46000,46002,46007 中国移动46001 中国联通46003 中国电信
84+
* getMNC 获取网络运营商 46000,46002,46007 中国移动,46001 中国联通,46003 中国电信
8585
* getCarrier 获取网络运营商:中国电信,中国移动,中国联通
8686
* getModel 获取硬件型号
8787
* getBuildBrand 获取编译厂商
@@ -194,12 +194,12 @@ compile 'com.code19.library:library:0.0.4'
194194
- VerificationUtils.java 验证工具类
195195
* matcherRealName 判断姓名格式
196196
```
197-
真实姓名可以是汉字也可以是字母但是不能两者都有也不能包含任何符号和数字
197+
真实姓名可以是汉字,也可以是字母,但是不能两者都有,也不能包含任何符号和数字
198198
1.如果是英文名,可以允许英文名字中出现空格
199-
2.英文名的空格可以是多个但是不能连续出现多个
199+
2.英文名的空格可以是多个,但是不能连续出现多个
200200
3.汉字不能出现空格
201201
```
202-
* matcherPhoneNum 判断手机号格式 (匹配11数字并且13-19开头)
202+
* matcherPhoneNum 判断手机号格式 (匹配11数字,并且13-19开头)
203203
* matcherAccount 判断账号格式 (4-20位字符)
204204
* matcherPassword 判断密码格式 (6-12位字母或数字)
205205
* matcherPassword2 判断密码格式 (6-12位字母或数字,必须同时包含字母和数字)
@@ -228,24 +228,25 @@ compile 'com.code19.library:library:0.0.4'
228228
/**
229229
* 身份证校验
230230
* <p>
231-
* 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。
231+
* 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。
232+
* 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。
232233
* 地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。
233-
* 出生日期码表示编码对象出生的年、月、日其中年份用四位数字表示年、月、日之间不用分隔符。
234-
* 顺序码表示同一地址码所标识的区域范围内对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性偶数分给女性。
235-
* 校验码是根据前面十七位数字码按照ISO 7064:1983.MOD 11-2校验码计算出来的检验码。
234+
* 出生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。
235+
* 顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。
236+
* 校验码是根据前面十七位数字码,按照ISO 7064:1983.MOD 11-2校验码计算出来的检验码。
236237
* 出生日期计算方法。
237-
* 15位的身份证编码首先把出生年扩展为4位简单的就是增加一个19或18,这样就包含了所有1800-1999年出生的人;
238-
* 2000年后出生的肯定都是18位的了没有这个烦恼至于1800年前出生的,那啥那时应该还没身份证号这个东东⊙﹏⊙b汗...
238+
* 15位的身份证编码首先把出生年扩展为4位,简单的就是增加一个19或18,这样就包含了所有1800-1999年出生的人;
239+
* 2000年后出生的肯定都是18位的了没有这个烦恼,至于1800年前出生的,那啥那时应该还没身份证号这个东东,⊙﹏⊙b汗...
239240
* 下面是正则表达式:
240241
* 出生日期1800-2099 /(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])/
241242
* 身份证正则表达式 /^[1-9]\d{5}((1[89]|20)\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dx]$/i
242243
* 15位校验规则 6位地址编码+6位出生日期+3位顺序号
243244
* 18位校验规则 6位地址编码+8位出生日期+3位顺序号+1位校验位
244245
* 校验位规则 公式:∑(ai×Wi)(mod 11)……………………………………(1)
245246
* 公式(1)中:
246-
* i----表示号码字符从由至左包括校验码在内的位置序号
247+
* i----表示号码字符从由至左包括校验码在内的位置序号;
247248
* ai----表示第i位置上的号码字符值;
248-
* Wi----示第i位置上的加权因子其数值依据公式Wi=2^(n-1)(mod 11)计算得出。
249+
* Wi----示第i位置上的加权因子,其数值依据公式Wi=2^(n-1)(mod 11)计算得出。
249250
* i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
250251
* Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
251252
* </P>

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ dependencies {
2424
testCompile 'junit:junit:4.12'
2525
compile 'com.android.support:appcompat-v7:23.3.0'
2626
compile project(':library')
27+
compile 'com.android.support:recyclerview-v7:23.3.0'
28+
compile 'com.android.support:cardview-v7:23.3.0'
2729
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
16-
-->
17-
16+
-->
1817
<manifest package="com.code19.androidcommon"
1918
xmlns:android="http://schemas.android.com/apk/res/android">
2019

@@ -39,6 +38,8 @@
3938
<category android:name="android.intent.category.LAUNCHER"/>
4039
</intent-filter>
4140
</activity>
41+
<activity android:name=".AppManager">
42+
</activity>
4243
</application>
4344

4445
</manifest>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright (C) 2016 android@19code.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.code19.androidcommon;
18+
19+
import android.app.ProgressDialog;
20+
import android.os.Bundle;
21+
import android.support.v7.app.AppCompatActivity;
22+
import android.support.v7.widget.DefaultItemAnimator;
23+
import android.support.v7.widget.GridLayoutManager;
24+
import android.support.v7.widget.RecyclerView;
25+
import android.util.Log;
26+
27+
import com.code19.androidcommon.model.AppBean;
28+
import com.code19.androidcommon.presenter.AppPresenter;
29+
import com.code19.androidcommon.ui.adapter.AppRecyAdapter;
30+
import com.code19.androidcommon.view.IAppView;
31+
32+
import java.util.List;
33+
34+
public class AppManager extends AppCompatActivity implements IAppView {
35+
private static final String TAG = "ghost";
36+
37+
private AppPresenter mPresenter;
38+
private ProgressDialog mDialog;
39+
private RecyclerView mRecyapp;
40+
41+
@Override
42+
protected void onCreate(Bundle savedInstanceState) {
43+
super.onCreate(savedInstanceState);
44+
setContentView(R.layout.activity_app_manager);
45+
mRecyapp = (RecyclerView) findViewById(R.id.recy_app);
46+
mRecyapp.setLayoutManager(new GridLayoutManager(this, 4));
47+
mRecyapp.setItemAnimator(new DefaultItemAnimator());
48+
initProgress();
49+
mPresenter = new AppPresenter(this, this);
50+
new Thread(new Runnable() {
51+
@Override
52+
public void run() {
53+
mPresenter.getData();
54+
}
55+
}).start();
56+
}
57+
58+
private void initProgress() {
59+
mDialog = new ProgressDialog(this);
60+
mDialog.setMessage(getString(R.string.loading));
61+
mDialog.setCancelable(true);
62+
mDialog.setCanceledOnTouchOutside(false);
63+
mDialog.show();
64+
}
65+
66+
@Override
67+
public void showLoading() {
68+
mDialog.show();
69+
}
70+
71+
@Override
72+
public void hideLoading() {
73+
mDialog.cancel();
74+
}
75+
76+
@Override
77+
public void referData(List<AppBean> list) {
78+
for (AppBean bean : list) {
79+
Log.i(TAG, "app: " + bean.toString());
80+
}
81+
mRecyapp.setAdapter(new AppRecyAdapter(this, list));
82+
}
83+
}

app/src/main/java/com/code19/androidcommon/MainActivity.java

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,62 @@
1717
package com.code19.androidcommon;
1818

1919
import android.content.Context;
20+
import android.content.Intent;
2021
import android.os.Bundle;
2122
import android.support.v7.app.AppCompatActivity;
2223
import android.view.View;
2324
import android.widget.Button;
2425

25-
public class MainActivity extends AppCompatActivity {
26+
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
2627
private static final String TAG = "ghost";
2728
private Context c = this;
2829

2930
@Override
3031
protected void onCreate(Bundle savedInstanceState) {
3132
super.onCreate(savedInstanceState);
3233
setContentView(R.layout.activity_main);
33-
Button fire = (Button) findViewById(R.id.fire);
34-
Button dial = (Button) findViewById(R.id.dial);
35-
36-
if (fire != null) {
37-
fire.setOnClickListener(new View.OnClickListener() {
38-
@Override
39-
public void onClick(View v) {
40-
share();
41-
}
42-
});
43-
}
44-
if (dial != null) {
45-
dial.setOnClickListener(new View.OnClickListener() {
46-
@Override
47-
public void onClick(View v) {
48-
}
49-
});
50-
}
34+
Button systemutils = (Button) findViewById(R.id.systemutils);
35+
Button netutils = (Button) findViewById(R.id.netutils);
36+
Button jsonutils = (Button) findViewById(R.id.jsonutils);
37+
Button fileutils = (Button) findViewById(R.id.fileutils);
38+
Button dateutils = (Button) findViewById(R.id.dateutils);
39+
Button densityutils = (Button) findViewById(R.id.densityutils);
40+
Button bitmaputils = (Button) findViewById(R.id.bitmaputils);
41+
Button cacheutils = (Button) findViewById(R.id.cacheutils);
42+
Button apputils = (Button) findViewById(R.id.apputils);
43+
systemutils.setOnClickListener(this);
44+
netutils.setOnClickListener(this);
45+
jsonutils.setOnClickListener(this);
46+
fileutils.setOnClickListener(this);
47+
dateutils.setOnClickListener(this);
48+
densityutils.setOnClickListener(this);
49+
bitmaputils.setOnClickListener(this);
50+
cacheutils.setOnClickListener(this);
51+
apputils.setOnClickListener(this);
5152
}
5253

53-
public void share() {
54-
55-
54+
@Override
55+
public void onClick(View v) {
56+
switch (v.getId()) {
57+
case R.id.apputils:
58+
startActivity(new Intent(MainActivity.this, AppManager.class));
59+
break;
60+
case R.id.cacheutils:
61+
break;
62+
case R.id.bitmaputils:
63+
break;
64+
case R.id.densityutils:
65+
break;
66+
case R.id.dateutils:
67+
break;
68+
case R.id.fileutils:
69+
break;
70+
case R.id.jsonutils:
71+
break;
72+
case R.id.netutils:
73+
break;
74+
case R.id.systemutils:
75+
break;
76+
}
5677
}
5778
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright (C) 2016 android@19code.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.code19.androidcommon.model;
18+
19+
import android.graphics.drawable.Drawable;
20+
21+
/**
22+
* Create by h4de5ing 2016/5/24 024
23+
*/
24+
public class AppBean {
25+
private String appName;
26+
private Drawable appIcon;
27+
private long appDate;
28+
private long appSize;
29+
private String appAPk;
30+
private String appVerName;
31+
private int appVerCode;
32+
private String appInstaller;
33+
private boolean isSystemApp;
34+
35+
public String getAppName() {
36+
return appName;
37+
}
38+
39+
public void setAppName(String appName) {
40+
this.appName = appName;
41+
}
42+
43+
public Drawable getAppIcon() {
44+
return appIcon;
45+
}
46+
47+
public void setAppIcon(Drawable appIcon) {
48+
this.appIcon = appIcon;
49+
}
50+
51+
public long getAppDate() {
52+
return appDate;
53+
}
54+
55+
public void setAppDate(long appDate) {
56+
this.appDate = appDate;
57+
}
58+
59+
public long getAppSize() {
60+
return appSize;
61+
}
62+
63+
public void setAppSize(long appSize) {
64+
this.appSize = appSize;
65+
}
66+
67+
public String getAppAPk() {
68+
return appAPk;
69+
}
70+
71+
public void setAppAPk(String appAPk) {
72+
this.appAPk = appAPk;
73+
}
74+
75+
public String getAppVerName() {
76+
return appVerName;
77+
}
78+
79+
public void setAppVerName(String appVerName) {
80+
this.appVerName = appVerName;
81+
}
82+
83+
public int getAppVerCode() {
84+
return appVerCode;
85+
}
86+
87+
public void setAppVerCode(int appVerCode) {
88+
this.appVerCode = appVerCode;
89+
}
90+
91+
public String getAppInstaller() {
92+
return appInstaller;
93+
}
94+
95+
public void setAppInstaller(String appInstaller) {
96+
this.appInstaller = appInstaller;
97+
}
98+
99+
public boolean isSystemApp() {
100+
return isSystemApp;
101+
}
102+
103+
public void setSystemApp(boolean systemApp) {
104+
isSystemApp = systemApp;
105+
}
106+
107+
@Override
108+
public String toString() {
109+
return "AppBean{" +
110+
"appName='" + appName + '\'' +
111+
", appDate=" + appDate +
112+
", appSize=" + appSize +
113+
", appAPk='" + appAPk + '\'' +
114+
", appVerName='" + appVerName + '\'' +
115+
", appVerCode=" + appVerCode +
116+
", appInstaller='" + appInstaller + '\'' +
117+
", isSystemApp=" + isSystemApp +
118+
'}';
119+
}
120+
}

0 commit comments

Comments
 (0)