11package com .blankj .androidutilcode .feature .core .log ;
22
3+ import android .content .ComponentName ;
34import android .content .Context ;
45import android .content .Intent ;
6+ import android .net .Uri ;
57import android .os .Bundle ;
68import android .os .Environment ;
79import android .support .annotation .Nullable ;
810import android .view .View ;
911import android .widget .TextView ;
1012
13+ import com .blankj .androidutilcode .Config ;
1114import com .blankj .androidutilcode .R ;
1215import com .blankj .androidutilcode .UtilsApp ;
1316import com .blankj .androidutilcode .base .BaseBackActivity ;
1417import com .blankj .utilcode .util .LogUtils ;
1518
19+ import java .util .ArrayList ;
20+
1621
1722/**
1823 * <pre>
2429 */
2530public class LogActivity extends BaseBackActivity {
2631
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+ }
2899
29100 private TextView tvAboutLog ;
30101
@@ -41,16 +112,6 @@ public class LogActivity extends BaseBackActivity {
41112 private int consoleFilter = LogUtils .V ;
42113 private int fileFilter = LogUtils .V ;
43114
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 ;
54115
55116 private Runnable mRunnable = new Runnable () {
56117 @ Override
@@ -64,18 +125,6 @@ public void run() {
64125 }
65126 };
66127
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-
79128 public static void start (Context context ) {
80129 Intent starter = new Intent (context , LogActivity .class );
81130 context .startActivity (starter );
@@ -115,6 +164,11 @@ public void initView(Bundle savedInstanceState, View contentView) {
115164 findViewById (R .id .btn_log_file ).setOnClickListener (this );
116165 findViewById (R .id .btn_log_json ).setOnClickListener (this );
117166 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 );
118172 updateConfig (0 );
119173 }
120174
@@ -199,7 +253,7 @@ public void onWidgetClick(View view) {
199253 LogUtils .aTag ("customTag" , "assert0" , "assert1" );
200254 break ;
201255 case R .id .btn_log_long :
202- LogUtils .d (longStr );
256+ LogUtils .d (LONG_STR );
203257 break ;
204258 case R .id .btn_log_file :
205259 for (int i = 0 ; i < 100 ; i ++) {
@@ -208,14 +262,28 @@ public void onWidgetClick(View view) {
208262 }
209263 break ;
210264 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 );
214267 break ;
215268 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 );
219287 break ;
220288 }
221289 }
0 commit comments