Revert DownloadOsmandIndexesHelper changes + fix download regions
This commit is contained in:
parent
8a123271c6
commit
8faa3b0aa8
5 changed files with 14 additions and 25 deletions
|
@ -3,5 +3,5 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<include layout="@layout/free_version_banner"/><include layout="@layout/local_items_fragment"/>
|
<include layout="@layout/free_version_banner"/><include layout="@layout/download_items_list"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
7
OsmAnd/res/layout/download_items_fragment.xml
Normal file
7
OsmAnd/res/layout/download_items_fragment.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<include layout="@layout/download_items_list"/>
|
||||||
|
</LinearLayout>
|
|
@ -106,30 +106,12 @@ public class DownloadOsmandIndexesHelper {
|
||||||
log.debug("Start loading list of index files"); //$NON-NLS-1$
|
log.debug("Start loading list of index files"); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
String strUrl = ctx.getAppCustomization().getIndexesUrl();
|
String strUrl = ctx.getAppCustomization().getIndexesUrl();
|
||||||
|
|
||||||
log.info(strUrl);
|
log.info(strUrl);
|
||||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||||
File tmp = new File(ctx.getAppPath(IndexConstants.BACKUP_INDEX_DIR), "map_indexes.tmp");
|
URLConnection connection = NetworkUtils.getHttpURLConnection(strUrl);
|
||||||
if (!tmp.exists()) {
|
InputStream in = connection.getInputStream();
|
||||||
log.info(strUrl);
|
GZIPInputStream gzin = new GZIPInputStream(in);
|
||||||
|
|
||||||
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));
|
|
||||||
parser.setInput(gzin, "UTF-8"); //$NON-NLS-1$
|
parser.setInput(gzin, "UTF-8"); //$NON-NLS-1$
|
||||||
int next;
|
int next;
|
||||||
while((next = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
while((next = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||||
|
@ -148,7 +130,7 @@ public class DownloadOsmandIndexesHelper {
|
||||||
}
|
}
|
||||||
result.sort();
|
result.sort();
|
||||||
gzin.close();
|
gzin.close();
|
||||||
//in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error while loading indexes from repository", e); //$NON-NLS-1$
|
log.error("Error while loading indexes from repository", e); //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
this.region = region;
|
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);
|
builder = new ItemsListBuilder(getMyApplication(), this.region);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue