From 8faa3b0aa87f0ef93b072502cd65493016ade554 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 2 Oct 2015 21:18:27 +0300 Subject: [PATCH] Revert DownloadOsmandIndexesHelper changes + fix download regions --- OsmAnd/res/layout/download_index_fragment.xml | 2 +- OsmAnd/res/layout/download_items_fragment.xml | 7 +++++ ...s_fragment.xml => download_items_list.xml} | 0 .../download/DownloadOsmandIndexesHelper.java | 28 ++++--------------- .../download/items/RegionItemsFragment.java | 2 +- 5 files changed, 14 insertions(+), 25 deletions(-) create mode 100644 OsmAnd/res/layout/download_items_fragment.xml rename OsmAnd/res/layout/{local_items_fragment.xml => download_items_list.xml} (100%) diff --git a/OsmAnd/res/layout/download_index_fragment.xml b/OsmAnd/res/layout/download_index_fragment.xml index cdc4dc71ba..fcb9145f8e 100644 --- a/OsmAnd/res/layout/download_index_fragment.xml +++ b/OsmAnd/res/layout/download_index_fragment.xml @@ -3,5 +3,5 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> - + \ No newline at end of file diff --git a/OsmAnd/res/layout/download_items_fragment.xml b/OsmAnd/res/layout/download_items_fragment.xml new file mode 100644 index 0000000000..8d4ca8e92c --- /dev/null +++ b/OsmAnd/res/layout/download_items_fragment.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/local_items_fragment.xml b/OsmAnd/res/layout/download_items_list.xml similarity index 100% rename from OsmAnd/res/layout/local_items_fragment.xml rename to OsmAnd/res/layout/download_items_list.xml diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java index 4838854220..be3f168e5d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java @@ -106,30 +106,12 @@ public class DownloadOsmandIndexesHelper { log.debug("Start loading list of index files"); //$NON-NLS-1$ try { String strUrl = ctx.getAppCustomization().getIndexesUrl(); - + log.info(strUrl); XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); - File tmp = new File(ctx.getAppPath(IndexConstants.BACKUP_INDEX_DIR), "map_indexes.tmp"); - if (!tmp.exists()) { - log.info(strUrl); - - log.warn("111 - NO FILE"); - - URLConnection connection = NetworkUtils.getHttpURLConnection(strUrl); - InputStream in = connection.getInputStream(); - - FileOutputStream out = new FileOutputStream(tmp); - int read; - byte[] buffer = new byte[32256]; - while ((read = in.read(buffer)) != -1) { - out.write(buffer, 0, read); - } - out.close(); - } else { - log.warn("111 - READ BACKUP"); - } - - GZIPInputStream gzin = new GZIPInputStream(new FileInputStream(tmp)); + URLConnection connection = NetworkUtils.getHttpURLConnection(strUrl); + InputStream in = connection.getInputStream(); + GZIPInputStream gzin = new GZIPInputStream(in); parser.setInput(gzin, "UTF-8"); //$NON-NLS-1$ int next; while((next = parser.next()) != XmlPullParser.END_DOCUMENT) { @@ -148,7 +130,7 @@ public class DownloadOsmandIndexesHelper { } result.sort(); gzin.close(); - //in.close(); + in.close(); } catch (IOException e) { log.error("Error while loading indexes from repository", e); //$NON-NLS-1$ return null; diff --git a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java index 83ff161119..544f3016f6 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java @@ -65,7 +65,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment { this.region = region; - View view = inflater.inflate(R.layout.local_items_fragment, container, false); + View view = inflater.inflate(R.layout.download_items_fragment, container, false); builder = new ItemsListBuilder(getMyApplication(), this.region);