@@ -29,19 +29,25 @@ public class LogActivity extends BaseActivity {
29
29
30
30
private LogUtils .Builder mBuilder = new LogUtils .Builder ();
31
31
32
- private String dir = "" ;
33
- private String globalTag = "" ;
34
- private boolean head = true ;
35
- private boolean file = false ;
36
- private boolean border = true ;
37
- private int filter = LogUtils .V ;
38
-
39
- private static final int UPDATE_TAG = 0x01 ;
40
- private static final int UPDATE_HEAD = 0x01 << 1 ;
41
- private static final int UPDATE_FILE = 0x01 << 2 ;
42
- private static final int UPDATE_DIR = 0x01 << 3 ;
43
- private static final int UPDATE_BORDER = 0x01 << 4 ;
44
- private static final int UPDATE_FILTER = 0x01 << 5 ;
32
+ private String dir = "" ;
33
+ private String globalTag = "" ;
34
+ private boolean log = true ;
35
+ private boolean console = true ;
36
+ private boolean head = true ;
37
+ private boolean file = false ;
38
+ private boolean border = true ;
39
+ private int consoleFilter = LogUtils .V ;
40
+ private int fileFilter = LogUtils .V ;
41
+
42
+ private static final int UPDATE_LOG = 0x01 ;
43
+ private static final int UPDATE_CONSOLE = 0x01 << 1 ;
44
+ private static final int UPDATE_TAG = 0x01 << 2 ;
45
+ private static final int UPDATE_HEAD = 0x01 << 3 ;
46
+ private static final int UPDATE_FILE = 0x01 << 4 ;
47
+ private static final int UPDATE_DIR = 0x01 << 5 ;
48
+ private static final int UPDATE_BORDER = 0x01 << 6 ;
49
+ private static final int UPDATE_CONSOLE_FILTER = 0x01 << 7 ;
50
+ private static final int UPDATE_FILE_FILTER = 0x01 << 8 ;
45
51
46
52
private Runnable mRunnable = new Runnable () {
47
53
@ Override
@@ -79,12 +85,15 @@ public int bindLayout() {
79
85
80
86
@ Override
81
87
public void initView (Bundle savedInstanceState , View view ) {
88
+ findViewById (R .id .btn_toggle_log ).setOnClickListener (this );
89
+ findViewById (R .id .btn_toggle_console ).setOnClickListener (this );
82
90
findViewById (R .id .btn_toggle_tag ).setOnClickListener (this );
83
91
findViewById (R .id .btn_toggle_head ).setOnClickListener (this );
84
92
findViewById (R .id .btn_toggle_border ).setOnClickListener (this );
85
93
findViewById (R .id .btn_toggle_file ).setOnClickListener (this );
86
94
findViewById (R .id .btn_toggle_dir ).setOnClickListener (this );
87
- findViewById (R .id .btn_toggle_filter ).setOnClickListener (this );
95
+ findViewById (R .id .btn_toggle_conole_filter ).setOnClickListener (this );
96
+ findViewById (R .id .btn_toggle_file_filter ).setOnClickListener (this );
88
97
findViewById (R .id .btn_log_no_tag ).setOnClickListener (this );
89
98
findViewById (R .id .btn_log_with_tag ).setOnClickListener (this );
90
99
findViewById (R .id .btn_log_in_new_thread ).setOnClickListener (this );
@@ -106,6 +115,12 @@ public void doBusiness(Context context) {
106
115
@ Override
107
116
public void onWidgetClick (View view ) {
108
117
switch (view .getId ()) {
118
+ case R .id .btn_toggle_log :
119
+ updateAbout (UPDATE_LOG );
120
+ break ;
121
+ case R .id .btn_toggle_console :
122
+ updateAbout (UPDATE_CONSOLE );
123
+ break ;
109
124
case R .id .btn_toggle_tag :
110
125
updateAbout (UPDATE_TAG );
111
126
break ;
@@ -121,8 +136,11 @@ public void onWidgetClick(View view) {
121
136
case R .id .btn_toggle_border :
122
137
updateAbout (UPDATE_BORDER );
123
138
break ;
124
- case R .id .btn_toggle_filter :
125
- updateAbout (UPDATE_FILTER );
139
+ case R .id .btn_toggle_conole_filter :
140
+ updateAbout (UPDATE_CONSOLE_FILTER );
141
+ break ;
142
+ case R .id .btn_toggle_file_filter :
143
+ updateAbout (UPDATE_FILE_FILTER );
126
144
break ;
127
145
case R .id .btn_log_no_tag :
128
146
LogUtils .v ("verbose" );
@@ -164,23 +182,32 @@ public void onWidgetClick(View view) {
164
182
LogUtils .d (longStr );
165
183
break ;
166
184
case R .id .btn_log_file :
167
- for (int i = 0 ; i < 1000 ; i ++) {
185
+ for (int i = 0 ; i < 100 ; i ++) {
168
186
LogUtils .file ("test0 log to file" );
187
+ LogUtils .file (LogUtils .I , "test0 log to file" );
169
188
}
170
189
break ;
171
190
case R .id .btn_log_json :
172
191
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\" }]}" ;
173
192
LogUtils .json (json );
193
+ LogUtils .json (LogUtils .I , json );
174
194
break ;
175
195
case R .id .btn_log_xml :
176
196
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>" ;
177
197
LogUtils .xml (xml );
198
+ LogUtils .xml (LogUtils .I , xml );
178
199
break ;
179
200
}
180
201
}
181
202
182
203
private void updateAbout (int args ) {
183
204
switch (args ) {
205
+ case UPDATE_LOG :
206
+ log = !log ;
207
+ break ;
208
+ case UPDATE_CONSOLE :
209
+ console = !console ;
210
+ break ;
184
211
case UPDATE_TAG :
185
212
globalTag = globalTag .equals (TAG ) ? "" : TAG ;
186
213
break ;
@@ -202,16 +229,22 @@ private void updateAbout(int args) {
202
229
case UPDATE_BORDER :
203
230
border = !border ;
204
231
break ;
205
- case UPDATE_FILTER :
206
- filter = filter == LogUtils .V ? LogUtils .W : LogUtils .V ;
232
+ case UPDATE_CONSOLE_FILTER :
233
+ consoleFilter = consoleFilter == LogUtils .V ? LogUtils .W : LogUtils .V ;
234
+ break ;
235
+ case UPDATE_FILE_FILTER :
236
+ fileFilter = fileFilter == LogUtils .V ? LogUtils .I : LogUtils .V ;
207
237
break ;
208
238
}
209
- mBuilder .setGlobalTag (globalTag )
239
+ mBuilder .setLogSwitch (log )
240
+ .setConsoleSwitch (console )
241
+ .setGlobalTag (globalTag )
210
242
.setLogHeadSwitch (head )
211
243
.setLog2FileSwitch (file )
212
244
.setDir (dir )
213
245
.setBorderSwitch (border )
214
- .setLogFilter (filter );
246
+ .setConsoleFilter (consoleFilter )
247
+ .setFileFilter (fileFilter );
215
248
tvAboutLog .setText (mBuilder .toString ());
216
249
}
217
250
0 commit comments