From 3d8547104c633d623f2c60a71753799e42ac6378 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 13 Aug 2014 19:05:19 +0200 Subject: [PATCH 1/2] Small updates --- .../net/osmand/plus/activities/DownloadIndexActivity.java | 2 +- OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index d7ffea8939..4f00b88922 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -273,7 +273,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity { } if(count > 0){ Builder builder = new AlertDialog.Builder(this); - builder.setMessage(MessageFormat.format(getString(R.string.download_additional_maps), s, sz)); + builder.setMessage(getString(R.string.download_additional_maps, s, sz)); builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java index 9a1d60caf1..79237920d8 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java @@ -65,6 +65,7 @@ public class TourViewActivity extends SherlockFragmentActivity { private ListView mDrawerList; private ArrayAdapter drawerAdapter; private WeakHashMap fragments = new WeakHashMap(); + private boolean restartAfterDownload; private static Object selectedItem; @Override @@ -219,6 +220,10 @@ public class TourViewActivity extends SherlockFragmentActivity { @Override protected void onResume() { super.onResume(); + if(restartAfterDownload){ + restartAfterDownload = false; + selectMenu(selectedItem == null ? R.string.sherpafy_tours : selectedItem); + } } public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType, @@ -373,6 +378,7 @@ public class TourViewActivity extends SherlockFragmentActivity { final Intent download = new Intent(this, DownloadIndexActivity.class); download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(download); + restartAfterDownload = true; } public void goToMap(LatLon location) { From defbdad46fec7d7fa670b6b6ef1a6016b0313bcd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 13 Aug 2014 19:11:48 +0200 Subject: [PATCH 2/2] Small updates --- .../osmand/plus/activities/DownloadIndexActivity.java | 3 ++- .../osmand/plus/sherpafy/SherpafyCustomization.java | 7 ++++--- .../plus/sherpafy/SherpafySelectToursFragment.java | 7 +++++-- .../net/osmand/plus/sherpafy/TourViewActivity.java | 11 ++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index 4f00b88922..72daedc066 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FilenameFilter; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -251,7 +252,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity { getMyApplication().setDownloadActivity(null); } - public void showDialogToDownloadMaps(List maps) { + public void showDialogToDownloadMaps(Collection maps) { int count = 0; int sz = 0; String s = ""; diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java index 9476df0198..74ff03ff98 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.TreeSet; @@ -149,7 +150,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization { ArrayList tourPresent = new ArrayList(); List warns = new ArrayList(); selectedTour = null; - final List suggestToDownloadMap = new ArrayList(); + final HashSet suggestToDownloadMap = new HashSet(); if(toursFolder.exists()) { File[] availableTours = toursFolder.listFiles(); if(availableTours != null) { @@ -197,7 +198,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization { da.showDialogToDownloadMaps(suggestToDownloadMap); } - }, 2000); + }); } } return warns; @@ -360,6 +361,6 @@ public class SherpafyCustomization extends OsmAndAppCustomization { @Override public boolean showDownloadExtraActions() { - return super.showDownloadExtraActions(); + return false; } } diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafySelectToursFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafySelectToursFragment.java index 3270ddeeb6..563650549d 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafySelectToursFragment.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafySelectToursFragment.java @@ -46,9 +46,12 @@ public class SherpafySelectToursFragment extends SherlockListFragment { super.onAttach(activity); app = (OsmandApplication) getSherlockActivity().getApplication(); custom = (SherpafyCustomization) app.getAppCustomization(); - TourAdapter tourAdapter = new TourAdapter(custom.getTourInformations()); - setListAdapter(tourAdapter); setHasOptionsMenu(true); + refreshAdapter(); + } + + public void refreshAdapter() { + setListAdapter(new TourAdapter(custom.getTourInformations())); } diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java index 79237920d8..590b88c4a3 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/TourViewActivity.java @@ -21,7 +21,6 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.graphics.Point; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.app.Fragment; @@ -65,7 +64,7 @@ public class TourViewActivity extends SherlockFragmentActivity { private ListView mDrawerList; private ArrayAdapter drawerAdapter; private WeakHashMap fragments = new WeakHashMap(); - private boolean restartAfterDownload; + private boolean refreshListAfterDownload; private static Object selectedItem; @Override @@ -220,8 +219,8 @@ public class TourViewActivity extends SherlockFragmentActivity { @Override protected void onResume() { super.onResume(); - if(restartAfterDownload){ - restartAfterDownload = false; + if(refreshListAfterDownload){ + refreshListAfterDownload = false; selectMenu(selectedItem == null ? R.string.sherpafy_tours : selectedItem); } } @@ -262,6 +261,8 @@ public class TourViewActivity extends SherlockFragmentActivity { if (fragment == null) { fragment = new SherpafySelectToursFragment(); fragments.put(item, fragment); + } else { + ((SherpafySelectToursFragment) fragment).refreshAdapter(); } state = STATE_SELECT_TOUR; setDrawerIndicatorVisible(true); @@ -377,8 +378,8 @@ public class TourViewActivity extends SherlockFragmentActivity { public void startDownloadActivity() { final Intent download = new Intent(this, DownloadIndexActivity.class); download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + refreshListAfterDownload = true; startActivity(download); - restartAfterDownload = true; } public void goToMap(LatLon location) {