diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index c8e290e32c..71f7e52941 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -83,7 +83,7 @@ public class FavouritesActivity extends SherlockFragmentActivity { OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings(); Integer tab = settings.FAVORITES_TAB.get(); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); - mTabsAdapter = new TabsAdapter(this, tabHost, mViewPager, settings); + mTabsAdapter = new TabsAdapter(this, tabHost, mViewPager, settings, true); mTabsAdapter.addTab(tabHost.newTabSpec(FAVOURITES_INFO).setIndicator(getString(R.string.my_favorites)), FavouritesTreeFragment.class, null); mTabsAdapter.addTab(tabHost.newTabSpec(TRACKS).setIndicator(getString(R.string.my_tracks)), @@ -170,6 +170,7 @@ public class FavouritesActivity extends SherlockFragmentActivity { private final ViewPager mViewPager; private final ArrayList mTabs = new ArrayList(); private OsmandSettings osmSettings; + private boolean favorites; static final class TabInfo { private final String tag; @@ -199,8 +200,9 @@ public class FavouritesActivity extends SherlockFragmentActivity { } } - public TabsAdapter(FragmentActivity activity, TabHost tabHost,ViewPager pager, OsmandSettings settings) { + public TabsAdapter(FragmentActivity activity, TabHost tabHost,ViewPager pager, OsmandSettings settings, boolean favorites) { super(activity.getSupportFragmentManager()); + this.favorites = favorites; mContext = activity; mTabHost = tabHost; mViewPager = pager; @@ -236,7 +238,9 @@ public class FavouritesActivity extends SherlockFragmentActivity { @Override public void onTabChanged(String tabId) { int position = mTabHost.getCurrentTab(); - osmSettings.FAVORITES_TAB.set(position); + if (favorites){ + osmSettings.FAVORITES_TAB.set(position); + } mViewPager.setCurrentItem(position); } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 0cf6e1ca08..d997bc4c47 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -19,6 +19,7 @@ import net.osmand.IndexConstants; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.plus.*; import net.osmand.plus.activities.FavouritesActivity; +import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.SettingsGeneralActivity; import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.base.SuggestExternalDirectoryDialog; @@ -51,6 +52,7 @@ public class DownloadActivity extends SherlockFragmentActivity { private TextView progressPercent; private ImageView cancel; private UpdatesIndexFragment updatesIndexFragment; + private List localIndexInfos = new ArrayList(); public static final String FILTER_KEY = "filter"; @@ -69,7 +71,7 @@ public class DownloadActivity extends SherlockFragmentActivity { tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); - mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings); + mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false); mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator("Local"), LocalIndexesFragment.class, null); mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator("Downloads"), @@ -207,6 +209,13 @@ public class DownloadActivity extends SherlockFragmentActivity { return false; } + public void setLocalIndexInfos(List list){ + this.localIndexInfos = list; + } + + public List getLocalIndexInfos(){ + return localIndexInfos; + } public DownloadActivityType getType() { return type;} diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 9befb659b1..c4713e031a 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -268,6 +268,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { protected void onPostExecute(List result) { this.result = result; getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false); + getDownloadActivity().setLocalIndexInfos(result); } public List getResult() { @@ -462,7 +463,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { //fixes issue when local files not shown after switching tabs - reloadIndexes(); + if (listAdapter.getGroupCount() == 0 && getDownloadActivity().getLocalIndexInfos().size() > 0){ + for(LocalIndexInfo info : getDownloadActivity().getLocalIndexInfos()){ + listAdapter.addLocalIndexInfo(info); + } + listAdapter.notifyDataSetChanged(); + } ActionBar actionBar = getDownloadActivity().getSupportActionBar(); //hide action bar from downloadindexfragment actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);