@@ -29,19 +29,25 @@ public class LogActivity extends BaseActivity {
2929
3030 private LogUtils .Builder mBuilder = new LogUtils .Builder ();
3131
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 ;
4551
4652 private Runnable mRunnable = new Runnable () {
4753 @ Override
@@ -79,12 +85,15 @@ public int bindLayout() {
7985
8086 @ Override
8187 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 );
8290 findViewById (R .id .btn_toggle_tag ).setOnClickListener (this );
8391 findViewById (R .id .btn_toggle_head ).setOnClickListener (this );
8492 findViewById (R .id .btn_toggle_border ).setOnClickListener (this );
8593 findViewById (R .id .btn_toggle_file ).setOnClickListener (this );
8694 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 );
8897 findViewById (R .id .btn_log_no_tag ).setOnClickListener (this );
8998 findViewById (R .id .btn_log_with_tag ).setOnClickListener (this );
9099 findViewById (R .id .btn_log_in_new_thread ).setOnClickListener (this );
@@ -106,6 +115,12 @@ public void doBusiness(Context context) {
106115 @ Override
107116 public void onWidgetClick (View view ) {
108117 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 ;
109124 case R .id .btn_toggle_tag :
110125 updateAbout (UPDATE_TAG );
111126 break ;
@@ -121,8 +136,11 @@ public void onWidgetClick(View view) {
121136 case R .id .btn_toggle_border :
122137 updateAbout (UPDATE_BORDER );
123138 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 );
126144 break ;
127145 case R .id .btn_log_no_tag :
128146 LogUtils .v ("verbose" );
@@ -164,23 +182,32 @@ public void onWidgetClick(View view) {
164182 LogUtils .d (longStr );
165183 break ;
166184 case R .id .btn_log_file :
167- for (int i = 0 ; i < 1000 ; i ++) {
185+ for (int i = 0 ; i < 100 ; i ++) {
168186 LogUtils .file ("test0 log to file" );
187+ LogUtils .file (LogUtils .I , "test0 log to file" );
169188 }
170189 break ;
171190 case R .id .btn_log_json :
172191 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\" }]}" ;
173192 LogUtils .json (json );
193+ LogUtils .json (LogUtils .I , json );
174194 break ;
175195 case R .id .btn_log_xml :
176196 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>" ;
177197 LogUtils .xml (xml );
198+ LogUtils .xml (LogUtils .I , xml );
178199 break ;
179200 }
180201 }
181202
182203 private void updateAbout (int args ) {
183204 switch (args ) {
205+ case UPDATE_LOG :
206+ log = !log ;
207+ break ;
208+ case UPDATE_CONSOLE :
209+ console = !console ;
210+ break ;
184211 case UPDATE_TAG :
185212 globalTag = globalTag .equals (TAG ) ? "" : TAG ;
186213 break ;
@@ -202,16 +229,22 @@ private void updateAbout(int args) {
202229 case UPDATE_BORDER :
203230 border = !border ;
204231 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 ;
207237 break ;
208238 }
209- mBuilder .setGlobalTag (globalTag )
239+ mBuilder .setLogSwitch (log )
240+ .setConsoleSwitch (console )
241+ .setGlobalTag (globalTag )
210242 .setLogHeadSwitch (head )
211243 .setLog2FileSwitch (file )
212244 .setDir (dir )
213245 .setBorderSwitch (border )
214- .setLogFilter (filter );
246+ .setConsoleFilter (consoleFilter )
247+ .setFileFilter (fileFilter );
215248 tvAboutLog .setText (mBuilder .toString ());
216249 }
217250
0 commit comments