About Android Help Docs open slow

Source: Internet
Author: User

Open Slow reason is: The doc directory in the HTML file contains access to Google js file
<link rel= "stylesheet"
href= "Http://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold" title= "Roboto ">
And
<script src= "Http://www.google.com/jsapi" type= "Text/javascript" ></script>
So you can access Google online when you open a document, so it will be slow to open!

Workaround:

1. Delete js in file

But almost every file contains this section of JS, so you want to open a change, simply turtle speed. So this approach is often pass

2, modify the Hosts file (equivalent to the local DNS, the file specific role of Baidu, I will not say more)

The file location: C:\Windows\System32\drivers\etc\Hosts file

Add below: 127.0.0.1 fonts.googleapis.com
127.0.0.1 www.google.com
127.0.0.1www.google.com/jsapi
127.0.0.1www.google-analytics.com
127.0.0.1apis.google.com/js/

Note Be sure to add a single line!! Otherwise, you may get an error, so when you configure your computer, you will find your own computer when you see Google's website.

3. Write Java program Batch Comment

Traverse all files in the doc directory, delete the top two lines of each file, refer to
/*
* Remove JavaScript code that requires networking in Android documents
*/
Import Java.io.BufferedReader;
Import Java.io.BufferedWriter;
Import Java.io.File;
Import java.io.FileNotFoundException;
Import Java.io.FileReader;
Import Java.io.FileWriter;
Import java.io.IOException;

public class Formatdoc {
public static int j=1;
/**
* @param args
*/
public static void Main (string[] args) {

File File = new file ("d:/android/android-sdk-windows/docs/");
Searchdirectory (file, 0);
System.out.println ("over");
}

public static void Searchdirectory (File f, int depth) {
if (!f.isdirectory ()) {
String fileName = F.getname ();
if (Filename.matches (". *.{ 1}html ")) {
String src= "< (link rel) [=]\" (stylesheet) \ "\ n (href) [=]\" (HTTP)://(FONTS.GOOGLEAPIS.COM/CSS) [?] (family) [=] (Roboto) [:] (Regular,medium,thin,italic,mediumitalic,bold) \ "(title) [=]\" roboto\ ">";
String src1 = "<script src=\" http://www.google.com/jsapi\ "type=\" text/javascript\ "></script>";
String DST = "";
If it is an HTML file, comment out the specific JavaScript code
Annotation (f, SRC, DST);
Annotation (f, src1, DST);
}
} else {
file[] fs = F.listfiles ();
depth++;
for (int i = 0; i < fs.length; ++i) {
File file = Fs[i];
Searchdirectory (file, depth);
}
}
}

/*
* F files that will be modified for specific content
* SRC will be replaced by the content
* DST will be replaced with the content of the layer
*/
public static void annotation (File f, string src, string dst) {
String content = Formatdoc.read (f);
Content = Content.replacefirst (src, DST);
int Ll=content.lastindexof (SRC);
System.out.println (LL);
Formatdoc.write (content, f);
System.out.println (j + +);
Return

}

public static String read (File src) {
StringBuffer res = new StringBuffer ();
String line = null;
try {
BufferedReader reader = new BufferedReader (new FileReader (SRC));
int i=0;
while (line = Reader.readline ()) = null) {
if (i!=0) {
Res.append (' \ n ');
}
Res.append (line);
i++;
}
Reader.close ();
} catch (FileNotFoundException e) {
E.printstacktrace ();
} catch (IOException e) {
E.printstacktrace ();
}
return res.tostring ();
}

public static Boolean write (String cont, File Dist) {
try {
BufferedWriter writer = new BufferedWriter (new FileWriter (Dist));
Writer.write (cont);
Writer.flush ();
Writer.close ();
return true;
} catch (IOException e) {
E.printstacktrace ();
return false;
}
}
}

4. The browser works offline

Open the file, the browser work offline is OK, this method is the simplest, but each time to set. I use the Firefox, offline working location in the file---offline work, other browsers temporarily did not study.

5. Execute script

Through the shell to delete the line JS code, very simple and convenient, than the above Java convenient 100 times times, but can not delete the first section of JS code.
Find. -name "*.html" |xargs grep-l "Jsapi" |xargs sed-i '/jsapi/d '

This method has not been tried yet.

About Android Help Docs open slow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.