File GGCNimages_update1XMLFile = FileUtil.isExistXmlFile("http://www.baidu.com/sitemap.xml", getContext());
if (GGCNimages_update1XMLFile != null) {
Log.d("debug", "从本地缓存文件中加载轮播图片");
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(GGCNimages_update1XMLFile);
Element element = document.getDocumentElement();
NodeList nodeList = element.getElementsByTagName("image");
List<BannerViewItem> bannerViewItemList1 = new ArrayList<BannerViewItem>();
for (int i = 0; i < nodeList.getLength(); i ++) {
Element areaElement = (Element) nodeList.item(i);
String imageurl = areaElement.getElementsByTagName("imageurl").item(0).getTextContent();
String h5url = areaElement.getElementsByTagName("h5url").item(0).getTextContent();
BannerViewItem bannerViewItem = new BannerViewItem();
bannerViewItem.setImageUrl(imageurl);
bannerViewItem.setH5Url(h5url);
bannerViewItemList1.add(bannerViewItem);
}
initBannerView(bannerViewItemList1);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//------------------------------------------------------------------------------------------------------------------------------
String filePath = getContext().getDir("xml", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + "sitemap.xml";
File GGCNimages_update1XMLFile = new File(filePath);
if (GGCNimages_update1XMLFile.exists()) {
boolean resultOfDelete = GGCNimages_update1XMLFile.delete();
Log.d("debug", "InternationalRepPageFragment中删除轮播图文件返回的结果->" + resultOfDelete);
}
InputStream inputStream = new ByteArrayInputStream(callBackStr.getBytes());
try {
OutputStream outputStream = new FileOutputStream(GGCNimages_update1XMLFile);
int ascii = inputStream.read();
while(ascii != -1) {
outputStream.write(ascii);
ascii = inputStream.read();
}
outputStream.flush();
outputStream.close();
inputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}