Skip to content

Commit 54fec9e

Browse files
committed
[commit]日志工具
1 parent 9fea09a commit 54fec9e

File tree

7 files changed

+363
-6
lines changed

7 files changed

+363
-6
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,18 @@ compile 'com.code19.library:library:0.0.6'
173173
* object2Json Object对象转换为JSONArray
174174
* string2JSONObject json字符串生成JSONObject对象
175175

176+
- L.java 日志工具
177+
* init 初始化日志开关和TAG(默认日志为开,TAG为"ghost")
178+
* v VERBOSE
179+
* d DEBUG
180+
* i INFO
181+
* w WARN
182+
* e ERROR
183+
* a ASSERT
184+
* json 输出json
185+
* xml 输出xml
186+
187+
176188
- NetUtils.java 网络工具
177189
* getNetworkType 获取网络类型
178190
* getNetworkTypeName 获取网络名称

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.code19.androidcommon.ui.activity.AppManagerActivity;
2727
import com.code19.androidcommon.ui.activity.DeviceActivity;
2828
import com.code19.androidcommon.ui.activity.VerificationActivity;
29+
import com.code19.library.L;
2930

3031
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
3132
private static final String TAG = "ghost";
@@ -40,12 +41,12 @@ protected void onCreate(Bundle savedInstanceState) {
4041
Button systemutils = (Button) findViewById(R.id.systemutils);
4142
Button netutils = (Button) findViewById(R.id.netutils);
4243
Button fileutils = (Button) findViewById(R.id.fileutils);
43-
Button densityutils = (Button) findViewById(R.id.densityutils);
44+
Button logutils = (Button) findViewById(R.id.logutils);
4445
Button apputils = (Button) findViewById(R.id.apputils);
4546
systemutils.setOnClickListener(this);
4647
netutils.setOnClickListener(this);
4748
fileutils.setOnClickListener(this);
48-
densityutils.setOnClickListener(this);
49+
logutils.setOnClickListener(this);
4950
apputils.setOnClickListener(this);
5051
deviceutils.setOnClickListener(this);
5152
virification.setOnClickListener(this);
@@ -60,7 +61,8 @@ public void onClick(View v) {
6061
case R.id.deviceutils:
6162
startActivity(new Intent(MainActivity.this, DeviceActivity.class));
6263
break;
63-
case R.id.densityutils:
64+
case R.id.logutils:
65+
testLog();
6466
break;
6567
case R.id.fileutils:
6668
break;
@@ -73,4 +75,19 @@ public void onClick(View v) {
7375
break;
7476
}
7577
}
78+
79+
private String xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><!-- Copyright w3school.com.cn --><note><to>George</to><from>John</from><heading>Reminder</heading><body>Don't forget the meeting!</body></note>";
80+
private String json = "{'type1': {'0': {'age': 12,'name': 'zhangsdan'},'1': {'age': 13,'name': 'lisi'},'num': '123'},'type3': {'0': {'age': 14,'name': 'wangwu'},'1': {'age': 15,'name': 'maliu'},'num': '456',}}";
81+
82+
private void testLog() {
83+
L.init(true, "admin");
84+
L.v("Verbose...");
85+
L.d("Debug...");
86+
L.i("info。。。");
87+
L.w("Warn...");
88+
L.e("Error...");
89+
L.a("ASSERT...");
90+
L.json(json);
91+
L.xml(xml);
92+
}
7693
}

app/src/main/java/com/code19/androidcommon/ui/activity/AppManagerActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
4444
super.onCreate(savedInstanceState);
4545
setContentView(R.layout.activity_app_manager);
4646
mRecyapp = (RecyclerView) findViewById(R.id.recy_app);
47+
mRecyapp.setHasFixedSize(true);
4748
mRecyapp.setLayoutManager(new GridLayoutManager(this, 4));
4849
mRecyapp.setItemAnimator(new DefaultItemAnimator());
4950
initProgress();

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
android:text="@string/deviceutils"/>
4141

4242
<Button
43-
android:id="@+id/densityutils"
43+
android:id="@+id/logutils"
4444
android:layout_width="match_parent"
4545
android:layout_height="wrap_content"
4646
android:background="?android:attr/selectableItemBackground"
47-
android:text="@string/densityutils"/>
47+
android:text="@string/logutils"/>
4848

4949
<Button
5050
android:id="@+id/fileutils"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<string name="bitmaputils">Bitmap工具</string>
2323
<string name="cipherutils">加密工具</string>
2424
<string name="dateutils">日期时间工具</string>
25-
<string name="densityutils">屏幕工具</string>
25+
<string name="logutils">日志工具</string>
2626
<string name="deviceutils">设备工具</string>
2727
<string name="fileutils">文件工具</string>
2828
<string name="jsonutils">Json工具</string>

0 commit comments

Comments
 (0)