1
1
package com .blankj .androidutilcode .feature .core .log ;
2
2
3
+ import android .content .ComponentName ;
3
4
import android .content .Context ;
4
5
import android .content .Intent ;
6
+ import android .net .Uri ;
5
7
import android .os .Bundle ;
6
8
import android .os .Environment ;
7
9
import android .support .annotation .Nullable ;
8
10
import android .view .View ;
9
11
import android .widget .TextView ;
10
12
13
+ import com .blankj .androidutilcode .Config ;
11
14
import com .blankj .androidutilcode .R ;
12
15
import com .blankj .androidutilcode .UtilsApp ;
13
16
import com .blankj .androidutilcode .base .BaseBackActivity ;
14
17
import com .blankj .utilcode .util .LogUtils ;
15
18
19
+ import java .util .ArrayList ;
20
+
16
21
17
22
/**
18
23
* <pre>
24
29
*/
25
30
public class LogActivity extends BaseBackActivity {
26
31
27
- private static final String TAG = "CMJ" ;
32
+ private static final String TAG = "CMJ" ;
33
+ private static final int UPDATE_LOG = 0x01 ;
34
+ private static final int UPDATE_CONSOLE = 0x01 << 1 ;
35
+ private static final int UPDATE_TAG = 0x01 << 2 ;
36
+ private static final int UPDATE_HEAD = 0x01 << 3 ;
37
+ private static final int UPDATE_FILE = 0x01 << 4 ;
38
+ private static final int UPDATE_DIR = 0x01 << 5 ;
39
+ private static final int UPDATE_BORDER = 0x01 << 6 ;
40
+ private static final int UPDATE_SINGLE = 0x01 << 7 ;
41
+ private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8 ;
42
+ private static final int UPDATE_FILE_FILTER = 0x01 << 9 ;
43
+
44
+ private static final String JSON = "{\" tools\" : [{ \" name\" :\" css format\" , \" site\" :\" http://tools.w3cschool.cn/code/css\" },{ \" name\" :\" JSON format\" , \" site\" :\" http://tools.w3cschool.cn/code/JSON\" },{ \" name\" :\" pwd check\" , \" site\" :\" http://tools.w3cschool.cn/password/my_password_safe\" }]}" ;
45
+ private static final String XML = "<books><book><author>Jack Herrington</author><title>PHP Hacks</title><publisher>O'Reilly</publisher></book><book><author>Jack Herrington</author><title>Podcasting Hacks</title><publisher>O'Reilly</publisher></book></books>" ;
46
+ private static final int [] ONE_D_ARRAY = new int []{1 , 2 , 3 };
47
+ private static final int [][] TWO_D_ARRAY = new int [][]{{1 , 2 , 3 }, {4 , 5 , 6 }, {7 , 8 , 9 }};
48
+ private static final Throwable THROWABLE = new NullPointerException ();
49
+ private static final Bundle BUNDLE = new Bundle ();
50
+ private static final Intent INTENT = new Intent ();
51
+ private static final ArrayList <String > LIST = new ArrayList <>();
52
+
53
+ private static final String LONG_STR ;
54
+
55
+ static {
56
+ StringBuilder sb = new StringBuilder ();
57
+ sb .append ("len = 10400\n content = \" " );
58
+ for (int i = 0 ; i < 800 ; ++i ) {
59
+ sb .append ("Hello world. " );
60
+ }
61
+ sb .append ("\" " );
62
+ LONG_STR = sb .toString ();
63
+
64
+ BUNDLE .putByte ("byte" , (byte ) -1 );
65
+ BUNDLE .putChar ("char" , 'c' );
66
+ BUNDLE .putCharArray ("charArray" , new char []{'c' , 'h' , 'a' , 'r' , 'A' , 'r' , 'r' , 'a' , 'y' });
67
+ BUNDLE .putCharSequence ("charSequence" , "charSequence" );
68
+ BUNDLE .putCharSequenceArray ("charSequenceArray" , new CharSequence []{"char" , "Sequence" , "Array" });
69
+ BUNDLE .putBundle ("bundle" , BUNDLE );
70
+ BUNDLE .putBoolean ("boolean" , true );
71
+ BUNDLE .putInt ("int" , 1 );
72
+ BUNDLE .putFloat ("float" , 1.f );
73
+ BUNDLE .putLong ("long" , 1L );
74
+ BUNDLE .putShort ("short" , (short ) 1 );
75
+
76
+ INTENT .setAction ("LogUtils action" );
77
+ INTENT .addCategory ("LogUtils category" );
78
+ INTENT .setData (Uri .parse (Config .BLOG ));
79
+ INTENT .setType (Intent .ACTION_DIAL );
80
+ INTENT .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
81
+ INTENT .setPackage (Config .PKG );
82
+ INTENT .setComponent (new ComponentName (Config .PKG , LogActivity .class .toString ()));
83
+ INTENT .putExtra ("int" , 1 );
84
+ INTENT .putExtra ("float" , 1f );
85
+ INTENT .putExtra ("char" , 'c' );
86
+ INTENT .putExtra ("string" , "string" );
87
+ INTENT .putExtra ("intArray" , ONE_D_ARRAY );
88
+ ArrayList <String > list = new ArrayList <>();
89
+ list .add ("ArrayList" );
90
+ list .add ("is" );
91
+ list .add ("serializable" );
92
+ INTENT .putExtra ("serializable" , list );
93
+ INTENT .putExtra ("bundle" , BUNDLE );
94
+
95
+ LIST .add ("hello" );
96
+ LIST .add ("log" );
97
+ LIST .add ("utils" );
98
+ }
28
99
29
100
private TextView tvAboutLog ;
30
101
@@ -41,16 +112,6 @@ public class LogActivity extends BaseBackActivity {
41
112
private int consoleFilter = LogUtils .V ;
42
113
private int fileFilter = LogUtils .V ;
43
114
44
- private static final int UPDATE_LOG = 0x01 ;
45
- private static final int UPDATE_CONSOLE = 0x01 << 1 ;
46
- private static final int UPDATE_TAG = 0x01 << 2 ;
47
- private static final int UPDATE_HEAD = 0x01 << 3 ;
48
- private static final int UPDATE_FILE = 0x01 << 4 ;
49
- private static final int UPDATE_DIR = 0x01 << 5 ;
50
- private static final int UPDATE_BORDER = 0x01 << 6 ;
51
- private static final int UPDATE_SINGLE = 0x01 << 7 ;
52
- private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8 ;
53
- private static final int UPDATE_FILE_FILTER = 0x01 << 9 ;
54
115
55
116
private Runnable mRunnable = new Runnable () {
56
117
@ Override
@@ -64,18 +125,6 @@ public void run() {
64
125
}
65
126
};
66
127
67
- private static final String longStr ;
68
-
69
- static {
70
- StringBuilder sb = new StringBuilder ();
71
- sb .append ("len = 10400\n content = \" " );
72
- for (int i = 0 ; i < 800 ; ++i ) {
73
- sb .append ("Hello world. " );
74
- }
75
- sb .append ("\" " );
76
- longStr = sb .toString ();
77
- }
78
-
79
128
public static void start (Context context ) {
80
129
Intent starter = new Intent (context , LogActivity .class );
81
130
context .startActivity (starter );
@@ -115,6 +164,11 @@ public void initView(Bundle savedInstanceState, View contentView) {
115
164
findViewById (R .id .btn_log_file ).setOnClickListener (this );
116
165
findViewById (R .id .btn_log_json ).setOnClickListener (this );
117
166
findViewById (R .id .btn_log_xml ).setOnClickListener (this );
167
+ findViewById (R .id .btn_log_array ).setOnClickListener (this );
168
+ findViewById (R .id .btn_log_throwable ).setOnClickListener (this );
169
+ findViewById (R .id .btn_log_bundle ).setOnClickListener (this );
170
+ findViewById (R .id .btn_log_intent ).setOnClickListener (this );
171
+ findViewById (R .id .btn_log_array_list ).setOnClickListener (this );
118
172
updateConfig (0 );
119
173
}
120
174
@@ -199,7 +253,7 @@ public void onWidgetClick(View view) {
199
253
LogUtils .aTag ("customTag" , "assert0" , "assert1" );
200
254
break ;
201
255
case R .id .btn_log_long :
202
- LogUtils .d (longStr );
256
+ LogUtils .d (LONG_STR );
203
257
break ;
204
258
case R .id .btn_log_file :
205
259
for (int i = 0 ; i < 100 ; i ++) {
@@ -208,14 +262,28 @@ public void onWidgetClick(View view) {
208
262
}
209
263
break ;
210
264
case R .id .btn_log_json :
211
- String json = "{\" tools\" : [{ \" name\" :\" css format\" , \" site\" :\" http://tools.w3cschool.cn/code/css\" },{ \" name\" :\" json format\" , \" site\" :\" http://tools.w3cschool.cn/code/json\" },{ \" name\" :\" pwd check\" , \" site\" :\" http://tools.w3cschool.cn/password/my_password_safe\" }]}" ;
212
- LogUtils .json (json );
213
- LogUtils .json (LogUtils .I , json );
265
+ LogUtils .json (JSON );
266
+ LogUtils .json (LogUtils .I , JSON );
214
267
break ;
215
268
case R .id .btn_log_xml :
216
- String xml = "<books><book><author>Jack Herrington</author><title>PHP Hacks</title><publisher>O'Reilly</publisher></book><book><author>Jack Herrington</author><title>Podcasting Hacks</title><publisher>O'Reilly</publisher></book></books>" ;
217
- LogUtils .xml (xml );
218
- LogUtils .xml (LogUtils .I , xml );
269
+ LogUtils .xml (XML );
270
+ LogUtils .xml (LogUtils .I , XML );
271
+ break ;
272
+ case R .id .btn_log_array :
273
+ LogUtils .e ((Object ) ONE_D_ARRAY );
274
+ LogUtils .e ((Object ) TWO_D_ARRAY );
275
+ break ;
276
+ case R .id .btn_log_throwable :
277
+ LogUtils .e (THROWABLE );
278
+ break ;
279
+ case R .id .btn_log_bundle :
280
+ LogUtils .e (BUNDLE );
281
+ break ;
282
+ case R .id .btn_log_intent :
283
+ LogUtils .e (INTENT );
284
+ break ;
285
+ case R .id .btn_log_array_list :
286
+ LogUtils .e (LIST );
219
287
break ;
220
288
}
221
289
}
0 commit comments