[Android]_[初级]_[sdk docs reference api 文档打开慢的解决办法]

来源:互联网 发布:国服lol2017有mac版 编辑:程序博客网 时间:2024/06/10 07:43


场景:

1. 下载sdk时下载了docs/reference文档,文档是html形式的,因为里面带有google的相关网址,浏览器打开时会去访问这些被墙的网址,所以显示巨慢。

2. 解决办法就是遍历子目录删除google相关网址,由于是android开发,就用Java实现吧.

3.以下运行用时9分钟,i5双核,4G内存,开了其他东西,最新的sdk docs,android 5L.

4.即使删除了这些, firefox打开一个package链接还是得5秒左右.

5.有一种打开急速方式,打开firefox, 选中菜单 File->Work Offline,之后打开api文档都是秒开了,缺点就是不能访问在线的网址. 默认菜单是隐藏的,可以移动到Tab页空白处右键Menu bar.


文件.Cleaner.java

import java.io.*;public class Cleaner{public static void main(String[] args) {System.out.println("begin to clean google.com;googleapis.com;google-analytics.com");String currentDir = args[0];Cleaner c = new Cleaner();c.work(currentDir);System.out.println("end to clean google.com;googleapis.com;google-analytics.com");}public Cleaner(){}public void work(String currentDir){File file = new File(currentDir);deleteReference(file);}public void deleteReference(File file){String[] files = file.list();String path = file.getPath();for (String one : files) {String filePath = path+File.separatorChar+one;// System.out.println(filePath);File fileTemp = new File(filePath);if(fileTemp.isDirectory()){deleteReference(fileTemp);}else{// delete google referenceif(filePath.endsWith(".html")){try{BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileTemp),"UTF-8"));filePath = filePath+".tmp";File newFile = new File(filePath);BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile),"UTF-8"));String line = null;while((line = br.readLine())!= null){String newLine = line.replaceAll("google\\.com|googleapis\\.com|google-analytics\\.com","");bw.write(newLine);bw.newLine();}br.close();bw.close();fileTemp.delete();newFile.renameTo(fileTemp);}catch(Exception e){e.printStackTrace();}}}}}}

编译执行:

C:\Users\Admin\Desktop>javac Cleaner.java & java Cleaner E:\software\adt\sdk\docs\referencebegin to clean google.com;googleapis.com;google-analytics.comend to clean google.com;googleapis.com;google-analytics.com

补充一点会快点,但是firefox还是得要5秒,有时间再分析加载过程吧,凑合用着:

删除 sdk/docs/assets/js/docs.js里的 https://apis.google.com/js/plusone.js


1 0
原创粉丝点击