From d3a7ab2368d9527b59f749df4cc292195c23e44c Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 8 Sep 2014 17:49:33 +0300 Subject: [PATCH] Local index activity refactored to be fragment --- OsmAnd/AndroidManifest.xml | 2 +- .../osmand/plus/OsmAndAppCustomization.java | 4 +- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 3 +- .../plus/activities/LocalIndexHelper.java | 2 +- .../audionotes/AudioVideoNotesPlugin.java | 8 +- .../plus/download/DownloadActivity.java | 37 ++++ .../LocalIndexesFragment.java} | 184 +++++++++--------- 7 files changed, 137 insertions(+), 103 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/download/DownloadActivity.java rename OsmAnd/src/net/osmand/plus/{activities/LocalIndexesActivity.java => download/LocalIndexesFragment.java} (88%) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index a6ca9541ad..8aac5d263b 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -220,7 +220,7 @@ - + diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 18972ee086..27ee35bcb3 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -12,12 +12,12 @@ import net.osmand.Location; import net.osmand.data.LocationPoint; import net.osmand.plus.activities.DownloadIndexActivity; import net.osmand.plus.activities.FavouritesActivity; -import net.osmand.plus.activities.LocalIndexesActivity; import net.osmand.plus.activities.MainMenuActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginsActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.search.SearchActivity; +import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.routing.RouteCalculationResult; @@ -87,7 +87,7 @@ public class OsmAndAppCustomization { } public Class getLocalIndexActivity() { - return LocalIndexesActivity.class; + return DownloadActivity.class; } // Download screen diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index e30775ffc6..d87d5fe613 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -10,7 +10,7 @@ import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; import net.osmand.plus.activities.LocalIndexInfo; -import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask; +import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; @@ -19,7 +19,6 @@ import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmo.OsMoPlugin; -import net.osmand.plus.osmodroid.OsMoDroidPlugin; import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routepointsnavigation.RoutePointsPlugin; diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index fdf2812a25..e47d2b468b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -31,7 +31,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; -import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask; +import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask; import net.osmand.plus.voice.MediaCommandPlayerImpl; import net.osmand.plus.voice.TTSCommandPlayerImpl; import net.osmand.util.MapUtils; diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b96e3b440e..10e6123538 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -34,11 +34,11 @@ import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; import net.osmand.plus.activities.LocalIndexInfo; -import net.osmand.plus.activities.LocalIndexesActivity; -import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask; +import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SettingsActivity; +import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -1094,8 +1094,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void contextMenuLocalIndexes(Activity activity, SherlockFragment fragment, Object obj, ContextMenuAdapter adapter) { - if (activity instanceof LocalIndexesActivity) { - final LocalIndexesActivity la = (LocalIndexesActivity) activity; + if (activity instanceof DownloadActivity) { + final DownloadActivity la = (DownloadActivity) activity; LocalIndexInfo info = (LocalIndexInfo) obj; if (info.getType() == LocalIndexType.AV_DATA) { final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java new file mode 100644 index 0000000000..df70cb7d6d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -0,0 +1,37 @@ +package net.osmand.plus.download; + +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.widget.TabHost; +import com.actionbarsherlock.app.SherlockFragmentActivity; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.FavouritesActivity; + +/** + * Created by Denis on 08.09.2014. + */ +public class DownloadActivity extends SherlockFragmentActivity { + + private TabHost tabHost; + private FavouritesActivity.TabsAdapter mTabsAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + ((OsmandApplication) getApplication()).applyTheme(this); + super.onCreate(savedInstanceState); + + + setContentView(R.layout.tab_content); + OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings(); + 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.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator("Local maps"), + LocalIndexesFragment.class, null); + tabHost.setCurrentTab(0); + } + +} diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java similarity index 88% rename from OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java rename to OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 99bd5cc0fd..372ced24c9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -1,4 +1,4 @@ -package net.osmand.plus.activities; +package net.osmand.plus.download; import java.io.File; import java.text.MessageFormat; @@ -10,13 +10,16 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import com.actionbarsherlock.view.*; import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.access.AccessibleToast; import net.osmand.map.OsmandRegions; import net.osmand.plus.*; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; +import net.osmand.plus.activities.*; import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; +import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.util.Algorithms; @@ -48,14 +51,9 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.view.ActionMode; import com.actionbarsherlock.view.ActionMode.Callback; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.SubMenu; -import com.actionbarsherlock.view.Window; -public class LocalIndexesActivity extends OsmandExpandableListActivity { +public class LocalIndexesFragment extends OsmandExpandableListFragment { private LoadLocalIndexTask asyncLoader; private LocalIndexesAdapter listAdapter; @@ -77,20 +75,41 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @SuppressWarnings("unchecked") @Override - protected void onCreate(Bundle savedInstanceState) { - requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + public void onCreate(Bundle savedInstanceState) { + //requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); - setContentView(R.layout.local_index); - getSupportActionBar().setTitle(R.string.local_index_descr_title); - setSupportProgressBarIndeterminateVisibility(false); + //setContentView(R.layout.local_index); + //getSupportActionBar().setTitle(R.string.local_index_descr_title); + //setSupportProgressBarIndeterminateVisibility(false); // getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon); descriptionLoader = new LoadLocalIndexDescriptionTask(); - listAdapter = new LocalIndexesAdapter(this); + listAdapter = new LocalIndexesAdapter(getActivity()); + setAdapter(listAdapter); + updateDescriptionTextWithSize(); + if (asyncLoader == null || asyncLoader.getResult() == null) { + // getLastNonConfigurationInstance method should be in onCreate() method + // (onResume() doesn't work) + Object indexes = getActivity().getLastNonConfigurationInstance(); + asyncLoader = new LoadLocalIndexTask(); + if (indexes instanceof List) { + asyncLoader.setResult((List) indexes); + } + } + } + + @Override + public void onResume() { + super.onResume(); + if (asyncLoader == null || asyncLoader.getResult() == null) { + asyncLoader = new LoadLocalIndexTask(); + asyncLoader.execute(getActivity()); + } + getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { @@ -103,35 +122,14 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } } }); - - setListAdapter(listAdapter); - updateDescriptionTextWithSize(); - if (asyncLoader == null || asyncLoader.getResult() == null) { - // getLastNonConfigurationInstance method should be in onCreate() method - // (onResume() doesn't work) - Object indexes = getLastNonConfigurationInstance(); - asyncLoader = new LoadLocalIndexTask(); - if (indexes instanceof List) { - asyncLoader.setResult((List) indexes); - } - } - } - - @Override - protected void onResume() { - super.onResume(); - if (asyncLoader == null || asyncLoader.getResult() == null) { - asyncLoader = new LoadLocalIndexTask(); - asyncLoader.execute(this); - } } private void showContextMenu(final LocalIndexInfo info) { - Builder builder = new AlertDialog.Builder(this); - final ContextMenuAdapter adapter = new ContextMenuAdapter(this); + Builder builder = new AlertDialog.Builder(getActivity()); + final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity()); basicFileOperation(info, adapter); - OsmandPlugin.onContextMenuActivity(this, null, info, adapter); + OsmandPlugin.onContextMenuActivity(getActivity(), null, info, adapter); String[] values = adapter.getItemNames(); builder.setItems(values, new DialogInterface.OnClickListener() { @@ -157,7 +155,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } else if (resId == R.string.local_index_mi_restore) { new LocalIndexOperationTask(RESTORE_OPERATION).execute(info); } else if (resId == R.string.local_index_mi_delete) { - Builder confirm = new AlertDialog.Builder(LocalIndexesActivity.this); + Builder confirm = new AlertDialog.Builder(getActivity()); confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -186,9 +184,9 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { private void renameFile(LocalIndexInfo info) { final File f = new File(info.getPathToData()); - Builder b = new AlertDialog.Builder(this); + Builder b = new AlertDialog.Builder(getActivity()); if(f.exists()){ - final EditText editText = new EditText(this); + final EditText editText = new EditText(getActivity()); editText.setText(f.getName()); b.setView(editText); b.setPositiveButton(R.string.default_buttons_save, new DialogInterface.OnClickListener() { @@ -198,7 +196,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { String newName = editText.getText().toString(); File dest = new File(f.getParentFile(), newName); if (dest.exists()) { - AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show(); + AccessibleToast.makeText(getMyActivity(), R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show(); } else { if(!f.getParentFile().exists()) { f.getParentFile().mkdirs(); @@ -206,7 +204,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { if(f.renameTo(dest)){ reloadIndexes(); } else { - AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show(); + AccessibleToast.makeText(getMyActivity(), R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show(); } } @@ -233,9 +231,9 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override protected void onPreExecute() { - setSupportProgressBarIndeterminateVisibility(true); + getMyActivity().setSupportProgressBarIndeterminateVisibility(true); } - + @Override protected void onProgressUpdate(LocalIndexInfo... values) { for (LocalIndexInfo v : values) { @@ -243,7 +241,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } listAdapter.notifyDataSetChanged(); } - + public void setResult(List result) { this.result = result; if(result == null){ @@ -260,15 +258,15 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override protected void onPostExecute(List result) { this.result = result; - setSupportProgressBarIndeterminateVisibility(false); + getMyActivity().setSupportProgressBarIndeterminateVisibility(false); } - + public List getResult() { return result; } } - + private File getFileToRestore(LocalIndexInfo i){ if(i.isBackupedData()){ File parent = new File(i.getPathToData()).getParentFile(); @@ -365,13 +363,13 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override protected void onPreExecute() { - setProgressBarIndeterminateVisibility(true); + getMyActivity().setProgressBarIndeterminateVisibility(true); } @Override protected void onPostExecute(String result) { - setProgressBarIndeterminateVisibility(false); - AccessibleToast.makeText(LocalIndexesActivity.this, result, Toast.LENGTH_LONG).show(); + getMyActivity().setProgressBarIndeterminateVisibility(false); + AccessibleToast.makeText(getMyActivity(), result, Toast.LENGTH_LONG).show(); listAdapter.clear(); reloadIndexes(); @@ -430,7 +428,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override - protected void onPause() { + public void onPause() { super.onPause(); if(operationTask != null){ operationTask.cancel(true); @@ -438,23 +436,23 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } @Override - protected void onDestroy() { + public void onDestroy() { super.onDestroy(); asyncLoader.cancel(true); descriptionLoader.cancel(true); } - @Override - public Object onRetainNonConfigurationInstance() { - if(asyncLoader != null){ - return asyncLoader.getResult(); - } - return super.onRetainNonConfigurationInstance(); - } +// @Override +// public Object onRetainNonConfigurationInstance() { +// if(asyncLoader != null){ +// return asyncLoader.getResult(); +// } +// return super.onRetainNonConfigurationInstance(); +// } @Override - public boolean onCreateOptionsMenu(Menu menu) { - optionsMenuAdapter = new ContextMenuAdapter(this); + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + optionsMenuAdapter = new ContextMenuAdapter(getMyActivity()); OnContextMenuClick listener = new OnContextMenuClick() { @Override public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) { @@ -476,7 +474,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { optionsMenuAdapter.item(R.string.local_index_mi_delete) .icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light) .listen(listener).position(4).reg(); - OsmandPlugin.onOptionsMenuActivity(this, null, optionsMenuAdapter); + OsmandPlugin.onOptionsMenuActivity(getMyActivity(), null, optionsMenuAdapter); // doesn't work correctly int max = getResources().getInteger(R.integer.abs__max_action_buttons); SubMenu split = null; @@ -501,18 +499,16 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } } - return true; } - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - if(operationTask == null || operationTask.getStatus() == Status.FINISHED){ - menu.setGroupVisible(0, true); - } else { - menu.setGroupVisible(0, false); - } - return true; - } +// @Override +// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { +// if(operationTask == null || operationTask.getStatus() == Status.FINISHED){ +// menu.setGroupVisible(0, true); +// } else { +// menu.setGroupVisible(0, false); +// } +// } @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -561,14 +557,14 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { final String actionButton = value; if(listAdapter.getGroupCount() == 0){ listAdapter.cancelFilter(); - AccessibleToast.makeText(LocalIndexesActivity.this, getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show(); + AccessibleToast.makeText(getMyActivity(), getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show(); return; } collapseAllGroups(); selectionMode = true; selectedItems.clear(); - actionMode = startActionMode(new Callback() { + actionMode = getMyActivity().startActionMode(new Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { @@ -590,12 +586,12 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (selectedItems.isEmpty()) { - AccessibleToast.makeText(LocalIndexesActivity.this, + AccessibleToast.makeText(getMyActivity(), getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show(); return true; } - Builder builder = new AlertDialog.Builder(LocalIndexesActivity.this); + Builder builder = new AlertDialog.Builder(getMyActivity()); builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size())); builder.setPositiveButton(actionButton, listener); builder.setNegativeButton(R.string.default_buttons_cancel, null); @@ -606,15 +602,15 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override public void onDestroyActionMode(ActionMode mode) { selectionMode = false; - findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE); - updateDescriptionTextWithSize(); + //findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE); + //updateDescriptionTextWithSize(); listAdapter.cancelFilter(); collapseAllGroups(); listAdapter.notifyDataSetChanged(); } }); - findViewById(R.id.DescriptionText).setVisibility(View.GONE); + //findViewById(R.id.DescriptionText).setVisibility(View.GONE); listAdapter.notifyDataSetChanged(); } @@ -625,7 +621,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { StatFs fs = new StatFs(dir.getAbsolutePath()); size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) }); } - TextView ds = (TextView) findViewById(R.id.DescriptionText); + //TextView ds = (TextView) findViewById(R.id.DescriptionText); String text = getString(R.string.download_link_and_local_description, size); int l = text.indexOf('.'); if(l == -1) { @@ -636,7 +632,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override public void onClick(View widget) { asyncLoader.setResult(null); - startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class)); + startActivity(new Intent(getMyActivity(), DownloadIndexActivity.class)); } @Override @@ -645,8 +641,8 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { // ds.setColor(Color.GREEN); } }, 0, l, 0); - ds.setText(content); - ds.setMovementMethod(LinkMovementMethod.getInstance()); + //ds.setText(content); + //ds.setMovementMethod(LinkMovementMethod.getInstance()); } @@ -654,7 +650,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { public void localOptionsMenu(final int itemId) { if (itemId == R.string.local_index_download) { asyncLoader.setResult(null); - startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class)); + startActivity(new Intent(getMyActivity(), DownloadIndexActivity.class)); } else if (itemId == R.string.local_index_mi_reload) { reloadIndexes(); } else if (itemId == R.string.local_index_mi_delete) { @@ -707,7 +703,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { @Override protected void onPostExecute(List warnings) { - setProgressBarIndeterminateVisibility(false); + getMyActivity().setProgressBarIndeterminateVisibility(false); if (!warnings.isEmpty()) { final StringBuilder b = new StringBuilder(); boolean f = true; @@ -719,17 +715,17 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { } b.append(w); } - AccessibleToast.makeText(LocalIndexesActivity.this, b.toString(), Toast.LENGTH_LONG).show(); + AccessibleToast.makeText(getMyActivity(), b.toString(), Toast.LENGTH_LONG).show(); } if(asyncLoader.getStatus() == Status.PENDING) { - asyncLoader.execute(LocalIndexesActivity.this); + asyncLoader.execute(getMyActivity()); } } @Override protected void onPreExecute() { super.onPreExecute(); - setProgressBarIndeterminateVisibility(true); + getMyActivity().setProgressBarIndeterminateVisibility(true); } @Override protected List doInBackground(Void... params) { @@ -877,12 +873,12 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { View v = convertView; final LocalIndexInfo child = (LocalIndexInfo) getChild(groupPosition, childPosition); if (v == null ) { - LayoutInflater inflater = getLayoutInflater(); + LayoutInflater inflater = (LayoutInflater) getMyActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false); } TextView viewName = ((TextView) v.findViewById(R.id.local_index_name)); String mapDescr = getMapDescription(child.getFileName()); - String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getApplication()).getResourceManager().getOsmandRegions(), child.getFileName()); + String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getMyActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName()); if (mapDescr.length() > 0){ viewName.setText(mapDescr + " - " + mapName); @@ -951,10 +947,10 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { View v = convertView; LocalIndexInfo group = getGroup(groupPosition); if (v == null) { - LayoutInflater inflater = getLayoutInflater(); + LayoutInflater inflater = (LayoutInflater) getMyActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); v = inflater.inflate(net.osmand.plus.R.layout.expandable_list_item_category, parent, false); } - StringBuilder t = new StringBuilder(group.getType().getHumanString(LocalIndexesActivity.this)); + StringBuilder t = new StringBuilder(group.getType().getHumanString(getMyActivity())); if(group.getSubfolder() != null) { t.append(" ").append(group.getSubfolder()); } @@ -1035,4 +1031,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity { return ""; } } + + private DownloadActivity getMyActivity(){ return (DownloadActivity)getActivity();} }