@@ -50,135 +50,147 @@ protected void onCreate(Bundle savedInstanceState) {
5050 setupActionBar ();
5151
5252 try {
53- initHarLog (getIntent ().getIntExtra ("pos" ,-1 ));
54- }catch (Exception e ){
53+ initHarLog (getIntent ().getIntExtra ("pos" , -1 ));
54+ } catch (Exception e ) {
5555 e .printStackTrace ();
5656 finish ();
5757 }
5858 }
5959
60- public void initHarLog (int pos ){
61- HarLog harLog = ((SysApplication )getApplication ()).proxy .getHar ().getLog ();
60+ public void initHarLog (int pos ) {
61+ HarLog harLog = ((SysApplication ) getApplication ()).proxy .getHar ().getLog ();
6262 HarEntry harEntry = harLog .getEntries ().get (pos );
6363
6464 HarRequest harRequest = harEntry .getRequest ();
6565 HarResponse harResponse = harEntry .getResponse ();
6666
6767 addItem ("Overview" );
68- addItem ("URL" ,harRequest .getUrl ());
68+ addItem ("URL" , harRequest .getUrl ());
6969
70- addItem ("Method" ,harRequest .getMethod ());
71- addItem ("Code" ,harResponse .getStatus ()+ "" );
72- addItem ("TotalTime" ,harEntry .getTime ()+ "ms" );
73- addItem ("Size" ,harResponse .getBodySize ()+ "Bytes" );
70+ addItem ("Method" , harRequest .getMethod ());
71+ addItem ("Code" , harResponse .getStatus () + "" );
72+ addItem ("TotalTime" , harEntry .getTime () + "ms" );
73+ addItem ("Size" , harResponse .getBodySize () + "Bytes" );
7474
75- if (harRequest .getQueryString ().size ()> 0 ) {
75+ if (harRequest .getQueryString ().size () > 0 ) {
7676 addItem ("Request Query" );
77- for (HarNameValuePair pair : harRequest .getQueryString ()) {
77+ for (HarNameValuePair pair : harRequest .getQueryString ()) {
7878 addItem (pair .getName (), pair .getDecodeValue ());
7979 }
8080 }
8181
8282 addItem ("Request Header" );
83- for (HarNameValuePair pair : harRequest .getHeaders ()) {
84- if (pair .getName ().equals ("Cookie" )){
83+ for (HarNameValuePair pair : harRequest .getHeaders ()) {
84+ if (pair .getName ().equals ("Cookie" )) {
8585 break ;
8686 }
87- addItem (pair .getName (),pair .getDecodeValue ());
87+ addItem (pair .getName (), pair .getDecodeValue ());
8888 }
8989
90- if (harRequest .getCookies ().size ()> 0 ) {
90+ if (harRequest .getCookies ().size () > 0 ) {
9191 addItem ("Request Cookies" );
9292 for (HarCookie cookie : harRequest .getCookies ()) {
9393 addItem (cookie .getName (), cookie .getDecodeValue ());
9494 }
9595 }
9696
97- if (harRequest .getPostData ()!= null ) {
97+ if (harRequest .getPostData () != null ) {
9898 addItem ("Request Content" );
9999 addItem ("PostData" , harRequest .getPostData ().getText ());
100100 }
101101
102102 addItem ("Response Header" );
103- for (HarNameValuePair pair : harResponse .getHeaders ()) {
104- if (pair .getName ().equals ("Cookie" )){
103+ for (HarNameValuePair pair : harResponse .getHeaders ()) {
104+ if (pair .getName ().equals ("Cookie" )) {
105105 break ;
106106 }
107- addItem (pair .getName (),pair .getDecodeValue ());
107+ addItem (pair .getName (), pair .getDecodeValue ());
108108 }
109109
110- if (harResponse .getCookies ().size ()> 0 ) {
110+ if (harResponse .getCookies ().size () > 0 ) {
111111 addItem ("Response Cookies" );
112- for (HarCookie cookie : harResponse .getCookies ()) {
113- addItem (cookie .getName (),cookie .getDecodeValue ());
112+ for (HarCookie cookie : harResponse .getCookies ()) {
113+ addItem (cookie .getName (), cookie .getDecodeValue ());
114114 }
115115 }
116116
117- if ((harResponse .getRedirectURL () != null && harResponse .getRedirectURL ().length ()> 0 ) ||
118- (harResponse .getContent ().getText () != null && harResponse .getContent ().getText ().length ()> 0 ) ) {
117+ if ((harResponse .getRedirectURL () != null && harResponse .getRedirectURL ().length () > 0 ) ||
118+ (harResponse .getContent ().getText () != null && harResponse .getContent ().getText ().length () > 0 ) ) {
119119 addItem ("Response Content" );
120120 }
121- if (harResponse .getRedirectURL () != null && harResponse .getRedirectURL ().length ()> 0 ) {
121+ if (harResponse .getRedirectURL () != null && harResponse .getRedirectURL ().length () > 0 ) {
122122 addItem ("RedirectURL" , harResponse .getRedirectURL ());
123123 }
124- if (harResponse .getContent ().getText () != null && harResponse .getContent ().getText ().length ()> 0 ) {
125- addItem ("Content" ,harResponse .getContent ().getText ());
124+ if (harResponse .getContent ().getText () != null && harResponse .getContent ().getText ().length () > 0 ) {
125+ addItem ("Content" , harResponse .getContent ().getText (), pos );
126126 }
127127
128128 }
129129
130- public void addItem (String title , final String value ) {
130+ public void addItem (String title , final String value , final int pos ) {
131131 View view = LayoutInflater .from (this ).inflate (R .layout .item_detail , null );
132132
133133 TextView textView = (TextView ) view .findViewById (R .id .tv_title );
134134 textView .setText (title );
135135
136136 TextView valueTextView = (TextView ) view .findViewById (R .id .tv_value );
137- valueTextView .setText (value .substring (0 ,value .length ()> 50 ? 50 : value .length ()));
137+ valueTextView .setText (value .substring (0 , value .length () > 50 ? 50 : value .length ()));
138138
139- if (title .equals ("Content" )){
139+ if (title .equals ("Content" )) {
140140 view .setOnClickListener (new View .OnClickListener () {
141141 @ Override
142142 public void onClick (View view ) {
143143 if (value != null && value .length () > 10 ) {
144- Intent intent = new Intent (HarDetailActivity .this ,JsonPreviewActivity .class );
145- intent .putExtra ("content" , value );
144+ Intent intent = new Intent (HarDetailActivity .this , JsonPreviewActivity .class );
145+ intent .putExtra ("pos" , pos );
146146 HarDetailActivity .this .startActivity (intent );
147147 }
148148 }
149149 });
150- }else {
151- view .setOnClickListener (new View .OnClickListener () {
152- @ Override
153- public void onClick (View view ) {
154- if (value != null && value .length () > 10 ) {
155- View textEntryView = LayoutInflater .from (HarDetailActivity .this ).inflate (R .layout .alert_textview , null );
156- TextView edtInput = (TextView ) textEntryView .findViewById (R .id .tv_content );
157- edtInput .setText (value );
158-
159- AlertDialog .Builder builder = new AlertDialog .Builder (HarDetailActivity .this );
160- builder .setCancelable (true );
161- builder .setView (textEntryView );
162- builder .setPositiveButton ("确认" , null );
163- builder .show ();
164- }
165- }
166- });
167150 }
151+ linearLayout .addView (view );
152+ }
153+
154+ public void addItem (String title , final String value ) {
155+ View view = LayoutInflater .from (this ).inflate (R .layout .item_detail , null );
156+
157+ TextView textView = (TextView ) view .findViewById (R .id .tv_title );
158+ textView .setText (title );
159+
160+ TextView valueTextView = (TextView ) view .findViewById (R .id .tv_value );
161+ valueTextView .setText (value .substring (0 , value .length () > 50 ? 50 : value .length ()));
162+
163+ view .setOnClickListener (new View .OnClickListener () {
164+ @ Override
165+ public void onClick (View view ) {
166+ if (value != null && value .length () > 10 ) {
167+ View textEntryView = LayoutInflater .from (HarDetailActivity .this ).inflate (R .layout .alert_textview , null );
168+ TextView edtInput = (TextView ) textEntryView .findViewById (R .id .tv_content );
169+ edtInput .setText (value );
170+
171+ AlertDialog .Builder builder = new AlertDialog .Builder (HarDetailActivity .this );
172+ builder .setCancelable (true );
173+ builder .setView (textEntryView );
174+ builder .setPositiveButton ("确认" , null );
175+ builder .show ();
176+ }
177+ }
178+ });
179+
168180
169181 linearLayout .addView (view );
170182 }
171183
172- public void addItem (String cateName ){
184+ public void addItem (String cateName ) {
173185 View view = LayoutInflater .from (this ).inflate (R .layout .item_cate , null );
174186 TextView textView = (TextView ) view .findViewById (R .id .tv_catetitle );
175187 textView .setText (cateName );
176188 linearLayout .addView (view );
177189 }
178190
179191 /**
180- * Set up the {@link android.app.ActionBar}, if the API is available.
181- */
192+ * Set up the {@link android.app.ActionBar}, if the API is available.
193+ */
182194 private void setupActionBar () {
183195 setTitle ("数据详情" );
184196 ActionBar actionBar = getSupportActionBar ();
0 commit comments