Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-01 20:46:31 +02:00
commit dc11724955
11 changed files with 948 additions and 161 deletions

View file

@ -15,13 +15,14 @@
android:orientation="vertical">
<TextView
android:id="@+id/list_world_regions_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="World Regions"
android:textSize="@dimen/default_list_text_size"/>
android:textSize="@dimen/default_desc_text_size"/>
<ListView
android:id="@+id/list_world_regions"
@ -32,16 +33,17 @@
android:scrollbars="none"/>
<TextView
android:id="@+id/list_world_maps_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="World Map"
android:textSize="@dimen/default_list_text_size"/>
android:text="World Maps"
android:textSize="@dimen/default_desc_text_size"/>
<ListView
android:id="@+id/list_world_map"
android:id="@+id/list_world_maps"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:groupIndicator="@android:color/transparent"
@ -49,13 +51,14 @@
android:scrollbars="none"/>
<TextView
android:id="@+id/list_voice_promts_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="Voice Promts"
android:textSize="@dimen/default_list_text_size"/>
android:textSize="@dimen/default_desc_text_size"/>
<ListView
android:id="@+id/list_voice_promts"

View file

@ -7,6 +7,7 @@ import net.osmand.data.LatLon;
import net.osmand.map.OsmandRegions;
import net.osmand.plus.download.DownloadActivityType;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@ -14,7 +15,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class WorldRegion {
public class WorldRegion implements Serializable {
public static final String AFRICA_REGION_ID = "africa";
public static final String ASIA_REGION_ID = "asia";
@ -127,14 +128,14 @@ public class WorldRegion {
this.regionId = regionId;
String downloadName = osmandRegions.getDownloadName(regionId);
if (downloadName != null) {
downloadsIdPrefix = downloadName + ".";
downloadsIdPrefix = downloadName.toLowerCase() + ".";
if (name != null) {
this.name = name;
} else {
this.name = osmandRegions.getLocaleName(downloadName);
}
} else {
this.downloadsIdPrefix = regionId + ".";
this.downloadsIdPrefix = regionId.toLowerCase() + ".";
this.name = name;
}
return this;
@ -144,10 +145,10 @@ public class WorldRegion {
this.regionId = regionId;
String downloadName = osmandRegions.getDownloadName(regionId);
if (downloadName != null) {
downloadsIdPrefix = downloadName + ".";
this.name = osmandRegions.getLocaleName(regionId);
downloadsIdPrefix = downloadName.toLowerCase() + ".";
this.name = osmandRegions.getLocaleName(downloadName);
} else {
this.downloadsIdPrefix = regionId + ".";
this.downloadsIdPrefix = regionId.toLowerCase() + ".";
this.name = regionId;
}
return this;
@ -155,7 +156,7 @@ public class WorldRegion {
private WorldRegion init(String regionId, String name) {
this.regionId = regionId;
this.downloadsIdPrefix = regionId + ".";
this.downloadsIdPrefix = regionId.toLowerCase() + ".";
this.name = name;
return this;
}

View file

@ -32,7 +32,7 @@ import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListFragment;
import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.items.DownloadItemsFragment;
import net.osmand.plus.download.items.WorldItemsFragment;
import net.osmand.plus.download.newimplementation.IndexItemCategoryWithSubcat;
import net.osmand.plus.download.newimplementation.NewLocalIndexesFragment;
import net.osmand.plus.srtmplugin.SRTMPlugin;
@ -123,7 +123,7 @@ public class DownloadActivity extends BaseDownloadActivity {
// mTabs.add(new TabActivity.TabItem(R.string.download_tab_local,
// getString(R.string.download_tab_local), NewLocalIndexesFragment.class));
mTabs.add(new TabActivity.TabItem(R.string.download_tab_local,
getString(R.string.download_tab_local), DownloadItemsFragment.class));
getString(R.string.download_tab_local), WorldItemsFragment.class));
viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs));
mSlidingTabLayout.setViewPager(viewPager);
@ -343,9 +343,9 @@ public class DownloadActivity extends BaseDownloadActivity {
public void onCategorizationFinished() {
for (WeakReference<Fragment> ref : fragSet) {
Fragment f = ref.get();
if (f instanceof DownloadItemsFragment) {
if (f instanceof WorldItemsFragment) {
if (f.isAdded()) {
((DownloadItemsFragment) f).onCategorizationFinished();
((WorldItemsFragment) f).onCategorizationFinished();
}
}
}

View file

@ -413,16 +413,14 @@ public class DownloadIndexesThread {
@Override
protected IndexFileList doInBackground(Void... params) {
IndexFileList indexFileList = DownloadOsmandIndexesHelper.getIndexesList(ctx);
indexFiles = indexFileList;
if (indexFileList != null) {
ItemsListBuilder builder = new ItemsListBuilder(app, app.getWorldRegion());
builder.invalidate();
builder.build();
ItemsListBuilder.prepareData(app, indexFileList.getIndexFiles());
}
return indexFileList;
}
protected void onPostExecute(IndexFileList result) {
indexFiles = result;
if (indexFiles != null && uiActivity != null) {
prepareFilesToUpdate();
boolean basemapExists = uiActivity.getMyApplication().getResourceManager().containsBasemap();

View file

@ -25,6 +25,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
String description;
String fileName;
String simplifiedFileName;
String size;
long timestamp;
long contentSize;
@ -37,6 +38,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
public IndexItem(String fileName, String description, long timestamp, String size, long contentSize,
long containerSize, DownloadActivityType tp) {
this.fileName = fileName;
this.simplifiedFileName = fileName.toLowerCase().replace("_2.", ".");
this.description = description;
this.timestamp = timestamp;
this.size = size;
@ -53,6 +55,10 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
return fileName;
}
public String getSimplifiedFileName() {
return simplifiedFileName;
}
public String getDescription() {
return description;
}
@ -160,6 +166,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
return "IndexItem{" +
"description='" + description + '\'' +
", fileName='" + fileName + '\'' +
", simplifiedFileName='" + simplifiedFileName + '\'' +
", size='" + size + '\'' +
", timestamp=" + timestamp +
", contentSize=" + contentSize +
@ -185,6 +192,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
dest.writeParcelable(this.type, flags);
dest.writeByte(extra ? (byte) 1 : (byte) 0);
dest.writeString(this.initializedName);
dest.writeString(this.simplifiedFileName);
}
protected IndexItem(Parcel in) {
@ -197,6 +205,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
this.type = in.readParcelable(DownloadActivityType.class.getClassLoader());
this.extra = in.readByte() != 0;
this.initializedName = in.readString();
this.simplifiedFileName = in.readString();
}
public static final Parcelable.Creator<IndexItem> CREATOR = new Parcelable.Creator<IndexItem>() {

View file

@ -0,0 +1,88 @@
package net.osmand.plus.download.items;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.WorldRegion;
import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
public class ItemViewHolder {
private final TextView nameTextView;
private final TextView descrTextView;
private final ImageView leftImageView;
private final ImageView rightImageButton;
private final ProgressBar progressBar;
public ItemViewHolder(View convertView) {
nameTextView = (TextView) convertView.findViewById(R.id.name);
descrTextView = (TextView) convertView.findViewById(R.id.description);
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
}
public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context, boolean showTypeInTitle, boolean showTypeInDesc) {
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
nameTextView.setText(indexItem.getVisibleName(context,
context.getMyApplication().getRegions()));
} else {
if (showTypeInTitle) {
nameTextView.setText(indexItem.getType().getString(context));
} else {
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions()));
}
}
if (showTypeInDesc) {
descrTextView.setText(indexItem.getType().getString(context) + "" + indexItem.getSizeDescription(context));
} else {
descrTextView.setText(indexItem.getSizeDescription(context));
}
leftImageView.setImageDrawable(getContextIcon(context,
indexItem.getType().getIconResource()));
rightImageButton.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(getContextIcon(context,
R.drawable.ic_action_import));
rightImageButton.setTag(R.id.index_item, indexItem);
rightImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((BaseDownloadActivity) v.getContext())
.startDownload((IndexItem) v.getTag(R.id.index_item));
progressBar.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(getContextIcon(context,
R.drawable.ic_action_remove_dark));
}
});
progressBar.setVisibility(View.GONE);
}
public void bindRegion(WorldRegion region, DownloadActivity context) {
nameTextView.setText(region.getName());
if (region.getResourceTypes().size() > 0) {
StringBuilder stringBuilder = new StringBuilder();
for (DownloadActivityType activityType : region.getResourceTypes()) {
if (stringBuilder.length() > 0) {
stringBuilder.append(", ");
}
stringBuilder.append(activityType.getString(context));
}
descrTextView.setText(stringBuilder.toString());
} else {
descrTextView.setText(R.string.shared_string_others);
}
leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
rightImageButton.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
}
private Drawable getContextIcon(DownloadActivity context, int resourceId) {
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
}
}

View file

@ -9,6 +9,7 @@ import net.osmand.plus.WorldRegion;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
import net.osmand.util.Algorithms;
import java.util.Collections;
@ -17,6 +18,8 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class ItemsListBuilder {
@ -92,16 +95,16 @@ public class ItemsListBuilder {
String str2;
if (obj1 instanceof WorldRegion) {
str1 = ((WorldRegion)obj1).getName();
str1 = ((WorldRegion) obj1).getName();
} else {
ResourceItem item = (ResourceItem)obj1;
ResourceItem item = (ResourceItem) obj1;
str1 = item.title + item.getIndexItem().getType().getTag();
}
if (obj2 instanceof WorldRegion) {
str2 = ((WorldRegion)obj2).getName();
str2 = ((WorldRegion) obj2).getName();
} else {
ResourceItem item = (ResourceItem)obj2;
ResourceItem item = (ResourceItem) obj2;
str2 = item.title + item.getIndexItem().getType().getTag();
}
@ -114,6 +117,8 @@ public class ItemsListBuilder {
private static Map<WorldRegion, Map<String, IndexItem>> resourcesByRegions =
new HashMap<>();
private static List<WorldRegion> searchableWorldwideRegionItems = new LinkedList<>();
private static final Lock lock = new ReentrantLock();
private List<ResourceItem> regionMapItems;
private List allResourceItems;
@ -122,7 +127,6 @@ public class ItemsListBuilder {
private OsmandApplication app;
private WorldRegion region;
private boolean invalidated;
private boolean srtmDisabled;
private boolean hasSrtm;
@ -138,7 +142,7 @@ public class ItemsListBuilder {
List<WorldRegion> list = new LinkedList<>();
for (Object obj : allResourceItems) {
if (obj instanceof WorldRegion) {
list.add((WorldRegion)obj);
list.add((WorldRegion) obj);
}
}
return list;
@ -157,19 +161,21 @@ public class ItemsListBuilder {
}
public boolean build() {
if (lock.tryLock()) {
try {
return obtainDataAndItems();
} finally {
lock.unlock();
}
} else {
return false;
}
}
private boolean obtainDataAndItems() {
if (invalidated) {
resourcesByRegions.clear();
}
if (resourcesByRegions.isEmpty()) {
if (!prepareData()) {
if (resourcesByRegions.isEmpty() || region == null) {
return false;
}
}
collectSubregionsDataAndItems();
collectResourcesDataAndItems();
@ -182,25 +188,26 @@ public class ItemsListBuilder {
LOG.warn("getAllResourceItems >>>");
for (Object obj : getAllResourceItems()) {
if (obj instanceof WorldRegion) {
WorldRegion item = (WorldRegion)obj;
WorldRegion item = (WorldRegion) obj;
LOG.warn("W resId=" + item.getRegionId() + " title=" + item.getName());
} else if (obj instanceof ResourceItem) {
ResourceItem resourceItem = (ResourceItem)obj;
ResourceItem resourceItem = (ResourceItem) obj;
LOG.warn("R resId=" + resourceItem.getIndexItem().getFileName() + " title=" + resourceItem.getTitle());
}
}
invalidated = false;
return true;
}
public void invalidate() {
invalidated = true;
public static boolean prepareData(OsmandApplication app, List<IndexItem> resources) {
lock.lock();
try {
List<IndexItem> resourcesInRepository;
if (resources != null) {
resourcesInRepository = resources;
} else {
resourcesInRepository = DownloadActivity.downloadListIndexThread.getCachedIndexFiles();
}
private boolean prepareData() {
List<IndexItem> resourcesInRepository = DownloadActivity.downloadListIndexThread.getCachedIndexFiles();
if (resourcesInRepository == null) {
return false;
}
@ -214,29 +221,28 @@ public class ItemsListBuilder {
List<WorldRegion> mergedRegions = app.getWorldRegion().getFlattenedSubregions();
mergedRegions.add(app.getWorldRegion());
for(WorldRegion region : mergedRegions)
{
for (WorldRegion region : mergedRegions) {
if (initSearchableRegions) {
searchableWorldwideRegionItems.add(region);
}
String downloadsIdPrefix = region.getDownloadsIdPrefix().toLowerCase();
String downloadsIdPrefix = region.getDownloadsIdPrefix();
Map<String, IndexItem> regionResources = new HashMap<>();
if (!doInit)
{
if (!doInit) {
regionResources.putAll(resourcesByRegions.get(region));
}
if (doInit)
{
if (doInit) {
List<DownloadActivityType> typesArray = new LinkedList<>();
boolean hasSrtm = false;
for (IndexItem resource : resourcesInRepository)
{
if (!resource.getFileName().startsWith(downloadsIdPrefix))
for (IndexItem resource : resourcesInRepository) {
if (!resource.getSimplifiedFileName().startsWith(downloadsIdPrefix)) {
continue;
}
if (resource.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
hasSrtm = true;
@ -244,13 +250,11 @@ public class ItemsListBuilder {
typesArray.add(resource.getType());
regionResources.put(resource.getFileName(), resource);
regionResources.put(resource.getSimplifiedFileName(), resource);
}
if (region.getSuperregion() != null && hasSrtm && region.getSuperregion().getSuperregion() != app.getWorldRegion())
{
if (!region.getSuperregion().getResourceTypes().contains(DownloadActivityType.SRTM_COUNTRY_FILE))
{
if (region.getSuperregion() != null && hasSrtm && region.getSuperregion().getSuperregion() != app.getWorldRegion()) {
if (!region.getSuperregion().getResourceTypes().contains(DownloadActivityType.SRTM_COUNTRY_FILE)) {
region.getSuperregion().getResourceTypes().add(DownloadActivityType.SRTM_COUNTRY_FILE);
Collections.sort(region.getSuperregion().getResourceTypes(), new Comparator<DownloadActivityType>() {
@Override
@ -273,6 +277,10 @@ public class ItemsListBuilder {
resourcesByRegions.put(region, regionResources);
}
return true;
} finally {
lock.unlock();
}
}
private void collectSubregionsDataAndItems() {
@ -286,10 +294,8 @@ public class ItemsListBuilder {
allSubregionItems.clear();
regionMapItems.clear();
for (WorldRegion subregion : region.getFlattenedSubregions())
{
if (subregion.getSuperregion() == region)
{
for (WorldRegion subregion : region.getFlattenedSubregions()) {
if (subregion.getSuperregion() == region) {
if (subregion.getFlattenedSubregions().size() > 0) {
allSubregionItems.add(subregion);
} else {
@ -316,18 +322,16 @@ public class ItemsListBuilder {
}
ResourceItem resItem = new ResourceItem(indexItem, region);
resItem.setResourceId(indexItem.getFileName());
resItem.setResourceId(indexItem.getSimplifiedFileName());
resItem.setTitle(name);
resItem.setContentSize(indexItem.getContentSize());
resItem.setContainerSize(indexItem.getSize());
if (region != this.region && srtmDisabled)
{
if (region != this.region && srtmDisabled) {
if (hasSrtm && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE)
continue;
if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE)
{
if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
resItem.setTitle("srtm_disabled"); // todo: constant
resItem.setContentSize(0);
resItem.setContainerSize(0);

View file

@ -0,0 +1,93 @@
package net.osmand.plus.download.items;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.WorldRegion;
import org.apache.commons.logging.Log;
public class LocalDialogFragment extends DialogFragment {
private static final Log LOG = PlatformUtil.getLog(LocalDialogFragment.class);
public static final String TAG = "LocalDialogFragment";
private static final String REGION_DLG_KEY = "world_region_dialog_key";
private WorldRegion region;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean isLightTheme = ((OsmandApplication) getActivity().getApplication())
.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
WorldRegion region = null;
if (savedInstanceState != null) {
Object regionObj = savedInstanceState.getSerializable(REGION_DLG_KEY);
if (regionObj != null) {
region = (WorldRegion)regionObj;
}
}
if (region == null) {
Object regionObj = getArguments().getSerializable(REGION_DLG_KEY);
if (regionObj != null) {
region = (WorldRegion)regionObj;
}
}
this.region = region;
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
if (this.region != null) {
getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer,
LocalItemsFragment.createInstance(region)).commit();
toolbar.setTitle(this.region.getName());
}
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putSerializable(REGION_DLG_KEY, region);
super.onSaveInstanceState(outState);
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public void onRegionSelected(WorldRegion region) {
createInstance(region).show(getChildFragmentManager(), TAG);
}
public static LocalDialogFragment createInstance(WorldRegion region) {
Bundle bundle = new Bundle();
bundle.putSerializable(REGION_DLG_KEY, region);
LocalDialogFragment fragment = new LocalDialogFragment();
fragment.setArguments(bundle);
return fragment;
}
}

View file

@ -0,0 +1,281 @@
package net.osmand.plus.download.items;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.WorldRegion;
import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
import org.apache.commons.logging.Log;
import java.text.MessageFormat;
import java.util.Locale;
public class LocalItemsFragment extends Fragment {
public static final String TAG = "LocalItemsFragment";
private static final Log LOG = PlatformUtil.getLog(LocalItemsFragment.class);
private static final MessageFormat formatGb = new MessageFormat("{0, number,<b>#.##</b>} GB", Locale.US);
private ItemsListBuilder builder;
private RegionsAdapter regionsAdapter;
private MapsAdapter mapsAdapter;
private VoicePromtsAdapter voicePromtsAdapter;
private TextView mapsTextView;
private ListView mapsListView;
private TextView regionsTextView;
private ListView regionsListView;
private TextView voicePromtsTextView;
private ListView voicePromtsListView;
private static final String REGION_KEY = "world_region_key";
private WorldRegion region;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
WorldRegion region = null;
if (savedInstanceState != null) {
Object regionObj = savedInstanceState.getSerializable(REGION_KEY);
if (regionObj != null) {
region = (WorldRegion)regionObj;
}
}
if (region == null) {
Object regionObj = getArguments().getSerializable(REGION_KEY);
if (regionObj != null) {
region = (WorldRegion)regionObj;
}
}
this.region = region;
View view = inflater.inflate(R.layout.download_index_fragment, container, false);
builder = new ItemsListBuilder(getMyApplication(), this.region);
mapsTextView = (TextView) view.findViewById(R.id.list_world_regions_title);
mapsTextView.setText("Region maps".toUpperCase());
mapsListView = (ListView) view.findViewById(R.id.list_world_regions);
mapsAdapter = new MapsAdapter(getActivity());
mapsListView.setAdapter(mapsAdapter);
regionsTextView = (TextView) view.findViewById(R.id.list_world_maps_title);
regionsTextView.setText("Additional maps".toUpperCase());
regionsListView = (ListView) view.findViewById(R.id.list_world_maps);
regionsAdapter = new RegionsAdapter(getActivity());
regionsListView.setAdapter(regionsAdapter);
regionsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Object obj = regionsAdapter.getItem(position);
if (obj instanceof WorldRegion) {
WorldRegion region = (WorldRegion) obj;
((LocalDialogFragment) getParentFragment())
.onRegionSelected(region);
}
}
});
voicePromtsTextView = (TextView) view.findViewById(R.id.list_voice_promts_title);
voicePromtsTextView.setText("Voice promts".toUpperCase());
voicePromtsListView = (ListView) view.findViewById(R.id.list_voice_promts);
voicePromtsAdapter = new VoicePromtsAdapter(getActivity(), getMyApplication());
voicePromtsListView.setAdapter(voicePromtsAdapter);
if (builder.build()) {
fillMapsAdapter();
fillRegionsAdapter();
fillVoicePromtsAdapter();
}
return view;
}
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putSerializable(REGION_KEY, region);
super.onSaveInstanceState(outState);
}
public OsmandApplication getMyApplication() {
return (OsmandApplication)getActivity().getApplication();
}
private void fillRegionsAdapter() {
if (regionsAdapter != null) {
regionsAdapter.clear();
regionsAdapter.addAll(builder.getAllResourceItems());
updateVisibility(regionsAdapter, regionsTextView, regionsListView);
}
}
private void fillMapsAdapter() {
if (mapsAdapter != null) {
mapsAdapter.clear();
mapsAdapter.addAll(builder.getRegionMapItems());
updateVisibility(mapsAdapter, mapsTextView, mapsListView);
}
}
private void fillVoicePromtsAdapter() {
if (voicePromtsAdapter != null) {
voicePromtsAdapter.clear();
//voicePromtsAdapter.addAll(cats);
updateVisibility(voicePromtsAdapter, voicePromtsTextView, voicePromtsListView);
}
}
private void updateVisibility(ArrayAdapter adapter, TextView textView, ListView listView) {
if (adapter.isEmpty()) {
textView.setVisibility(View.GONE);
listView.setVisibility(View.GONE);
} else {
textView.setVisibility(View.VISIBLE);
listView.setVisibility(View.VISIBLE);
setListViewHeightBasedOnChildren(listView);
}
}
private DownloadActivity getDownloadActivity() {
return (DownloadActivity) getActivity();
}
public static LocalItemsFragment createInstance(WorldRegion region) {
Bundle bundle = new Bundle();
bundle.putSerializable(REGION_KEY, region);
LocalItemsFragment fragment = new LocalItemsFragment();
fragment.setArguments(bundle);
return fragment;
}
private static class MapsAdapter extends ArrayAdapter<ItemsListBuilder.ResourceItem> {
public MapsAdapter(Context context) {
super(context, R.layout.simple_list_menu_item);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ItemViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ItemViewHolder) convertView.getTag();
}
ItemsListBuilder.ResourceItem item = getItem(position);
viewHolder.bindIndexItem(item.getIndexItem(), (DownloadActivity) getContext(), true, false);
return convertView;
}
}
private static class RegionsAdapter extends ArrayAdapter {
public RegionsAdapter(Context context) {
super(context, R.layout.two_line_with_images_list_item);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ItemViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ItemViewHolder) convertView.getTag();
}
Object item = getItem(position);
if (item instanceof WorldRegion) {
viewHolder.bindRegion((WorldRegion) item, (DownloadActivity) getContext());
} else if (item instanceof ItemsListBuilder.ResourceItem) {
viewHolder.bindIndexItem(((ItemsListBuilder.ResourceItem) item).getIndexItem(),
(DownloadActivity) getContext(), false, true);
} else {
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
"IndexItem but is of type:" + item.getClass());
}
return convertView;
}
}
private static class VoicePromtsAdapter extends ArrayAdapter {
private final OsmandApplication osmandApplication;
public VoicePromtsAdapter(Context context, OsmandApplication osmandApplication) {
super(context, R.layout.simple_list_menu_item);
this.osmandApplication = osmandApplication;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RegionItemViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new RegionItemViewHolder();
viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (RegionItemViewHolder) convertView.getTag();
}
Drawable iconLeft = osmandApplication.getIconsCache()
.getContentIcon(R.drawable.ic_world_globe_dark);
viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
viewHolder.textView.setText(getItem(position).toString());
return convertView;
}
}
private static class RegionItemViewHolder {
TextView textView;
}
}

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.view.LayoutInflater;
import android.view.Menu;
@ -11,6 +12,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
@ -21,26 +23,34 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.WorldRegion;
import net.osmand.plus.download.DownloadActivity;
<<<<<<< HEAD:OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java
import net.osmand.plus.download.newimplementation.MapsInCategoryFragment;
=======
import net.osmand.plus.download.newimplementation.DownloadsUiInitHelper;
>>>>>>> 380dcbe6d79e0f54421d0b67ce3688dfe910e78e:OsmAnd/src/net/osmand/plus/download/items/DownloadItemsFragment.java
import org.apache.commons.logging.Log;
import java.text.MessageFormat;
import java.util.Locale;
public class DownloadItemsFragment extends Fragment {
private static final Log LOG = PlatformUtil.getLog(DownloadItemsFragment.class);
public class WorldItemsFragment extends Fragment {
public static final String TAG = "WorldItemsFragment";
private static final Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
private static final MessageFormat formatGb = new MessageFormat("{0, number,<b>#.##</b>} GB", Locale.US);
public static final int RELOAD_ID = 0;
private ItemsListBuilder builder;
private WorldRegionsAdapter worldRegionsAdapter;
private WorldMapAdapter worldMapAdapter;
private WorldMapsAdapter worldMapsAdapter;
private VoicePromtsAdapter voicePromtsAdapter;
private TextView worldRegionsTextView;
private ListView worldRegionsListView;
private ListView worldMapListView;
private TextView worldMapsTextView;
private ListView worldMapsListView;
private TextView voicePromtsTextView;
private ListView voicePromtsListView;
@Override
@ -54,28 +64,37 @@ public class DownloadItemsFragment extends Fragment {
View view = inflater.inflate(R.layout.download_index_fragment, container, false);
builder = new ItemsListBuilder(getMyApplication(), getMyApplication().getWorldRegion());
boolean hasBuilt = builder.build();
worldRegionsTextView = (TextView) view.findViewById(R.id.list_world_regions_title);
worldRegionsTextView.setText("World regions".toUpperCase());
worldRegionsListView = (ListView) view.findViewById(R.id.list_world_regions);
worldRegionsAdapter = new WorldRegionsAdapter(getActivity(), getMyApplication());
worldRegionsListView.setAdapter(worldRegionsAdapter);
if (hasBuilt) {
fillWorldRegionsAdapter();
}
worldRegionsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
WorldRegion region = worldRegionsAdapter.getItem(position);
worldMapListView = (ListView) view.findViewById(R.id.list_world_map);
worldMapAdapter = new WorldMapAdapter(getActivity(), getMyApplication());
worldMapListView.setAdapter(worldMapAdapter);
if (hasBuilt) {
fillWorldMapAdapter();
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.addToBackStack(null);
LocalDialogFragment.createInstance(region)
.show(fragmentTransaction, MapsInCategoryFragment.TAG);
}
});
worldMapsTextView = (TextView) view.findViewById(R.id.list_world_maps_title);
worldMapsTextView.setText("World maps".toUpperCase());
worldMapsListView = (ListView) view.findViewById(R.id.list_world_maps);
worldMapsAdapter = new WorldMapsAdapter(getActivity());
worldMapsListView.setAdapter(worldMapsAdapter);
voicePromtsTextView = (TextView) view.findViewById(R.id.list_voice_promts_title);
voicePromtsTextView.setText("Voice promts".toUpperCase());
voicePromtsListView = (ListView) view.findViewById(R.id.list_voice_promts);
voicePromtsAdapter = new VoicePromtsAdapter(getActivity(), getMyApplication());
voicePromtsListView.setAdapter(voicePromtsAdapter);
if (hasBuilt) {
fillVoicePromtsAdapter();
}
onCategorizationFinished();
DownloadsUiInitHelper.initFreeVersionBanner(view,
getMyApplication().getSettings(), getResources());
@ -111,15 +130,15 @@ public class DownloadItemsFragment extends Fragment {
if (worldRegionsAdapter != null) {
worldRegionsAdapter.clear();
worldRegionsAdapter.addAll(builder.getRegionsFromAllItems());
setListViewHeightBasedOnChildren(worldRegionsListView);
updateVisibility(worldRegionsAdapter, worldRegionsTextView, worldRegionsListView);
}
}
private void fillWorldMapAdapter() {
if (worldMapAdapter != null) {
worldMapAdapter.clear();
worldMapAdapter.addAll(builder.getRegionMapItems());
setListViewHeightBasedOnChildren(worldMapListView);
private void fillWorldMapsAdapter() {
if (worldMapsAdapter != null) {
worldMapsAdapter.clear();
worldMapsAdapter.addAll(builder.getRegionMapItems());
updateVisibility(worldMapsAdapter, worldMapsTextView, worldMapsListView);
}
}
@ -127,6 +146,18 @@ public class DownloadItemsFragment extends Fragment {
if (voicePromtsAdapter != null) {
voicePromtsAdapter.clear();
//voicePromtsAdapter.addAll(cats);
updateVisibility(voicePromtsAdapter, voicePromtsTextView, voicePromtsListView);
}
}
private void updateVisibility(ArrayAdapter adapter, TextView textView, ListView listView) {
if (adapter.isEmpty()) {
textView.setVisibility(View.GONE);
listView.setVisibility(View.GONE);
} else {
textView.setVisibility(View.VISIBLE);
listView.setVisibility(View.VISIBLE);
setListViewHeightBasedOnChildren(listView);
}
}
@ -154,7 +185,7 @@ public class DownloadItemsFragment extends Fragment {
public void onCategorizationFinished() {
if (builder.build()) {
fillWorldRegionsAdapter();
fillWorldMapAdapter();
fillWorldMapsAdapter();
fillVoicePromtsAdapter();
}
}
@ -191,30 +222,25 @@ public class DownloadItemsFragment extends Fragment {
}
}
private static class WorldMapAdapter extends ArrayAdapter<ItemsListBuilder.ResourceItem> {
private final OsmandApplication osmandApplication;
private static class WorldMapsAdapter extends ArrayAdapter<ItemsListBuilder.ResourceItem> {
public WorldMapAdapter(Context context, OsmandApplication osmandApplication) {
public WorldMapsAdapter(Context context) {
super(context, R.layout.simple_list_menu_item);
this.osmandApplication = osmandApplication;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
ItemViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ItemViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
viewHolder = (ItemViewHolder) convertView.getTag();
}
Drawable iconLeft = osmandApplication.getIconsCache()
.getContentIcon(R.drawable.ic_world_globe_dark);
viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
viewHolder.textView.setText(getItem(position).getTitle());
ItemsListBuilder.ResourceItem item = getItem(position);
viewHolder.bindIndexItem(item.getIndexItem(), (DownloadActivity) getContext(), false, false);
return convertView;
}

View file

@ -0,0 +1,284 @@
package net.osmand.plus.download.items;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.WorldRegion;
import net.osmand.plus.download.DownloadActivity;
<<<<<<< HEAD:OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java
import net.osmand.plus.download.newimplementation.MapsInCategoryFragment;
=======
import net.osmand.plus.download.newimplementation.DownloadsUiInitHelper;
>>>>>>> 380dcbe6d79e0f54421d0b67ce3688dfe910e78e:OsmAnd/src/net/osmand/plus/download/items/DownloadItemsFragment.java
import org.apache.commons.logging.Log;
import java.text.MessageFormat;
import java.util.Locale;
public class WorldItemsFragment extends Fragment {
public static final String TAG = "WorldItemsFragment";
private static final Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
private static final MessageFormat formatGb = new MessageFormat("{0, number,<b>#.##</b>} GB", Locale.US);
public static final int RELOAD_ID = 0;
private ItemsListBuilder builder;
private WorldRegionsAdapter worldRegionsAdapter;
private WorldMapsAdapter worldMapsAdapter;
private VoicePromtsAdapter voicePromtsAdapter;
private TextView worldRegionsTextView;
private ListView worldRegionsListView;
private TextView worldMapsTextView;
private ListView worldMapsListView;
private TextView voicePromtsTextView;
private ListView voicePromtsListView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.download_index_fragment, container, false);
builder = new ItemsListBuilder(getMyApplication(), getMyApplication().getWorldRegion());
worldRegionsTextView = (TextView) view.findViewById(R.id.list_world_regions_title);
worldRegionsTextView.setText("World regions".toUpperCase());
worldRegionsListView = (ListView) view.findViewById(R.id.list_world_regions);
worldRegionsAdapter = new WorldRegionsAdapter(getActivity(), getMyApplication());
worldRegionsListView.setAdapter(worldRegionsAdapter);
worldRegionsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
WorldRegion region = worldRegionsAdapter.getItem(position);
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.addToBackStack(null);
LocalDialogFragment.createInstance(region)
.show(fragmentTransaction, MapsInCategoryFragment.TAG);
}
});
worldMapsTextView = (TextView) view.findViewById(R.id.list_world_maps_title);
worldMapsTextView.setText("World maps".toUpperCase());
worldMapsListView = (ListView) view.findViewById(R.id.list_world_maps);
worldMapsAdapter = new WorldMapsAdapter(getActivity());
worldMapsListView.setAdapter(worldMapsAdapter);
voicePromtsTextView = (TextView) view.findViewById(R.id.list_voice_promts_title);
voicePromtsTextView.setText("Voice promts".toUpperCase());
voicePromtsListView = (ListView) view.findViewById(R.id.list_voice_promts);
voicePromtsAdapter = new VoicePromtsAdapter(getActivity(), getMyApplication());
voicePromtsListView.setAdapter(voicePromtsAdapter);
onCategorizationFinished();
DownloadsUiInitHelper.initFreeVersionBanner(view,
getMyApplication().getSettings(), getResources());
return view;
}
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
public OsmandApplication getMyApplication() {
return (OsmandApplication)getActivity().getApplication();
}
private void fillWorldRegionsAdapter() {
if (worldRegionsAdapter != null) {
worldRegionsAdapter.clear();
worldRegionsAdapter.addAll(builder.getRegionsFromAllItems());
updateVisibility(worldRegionsAdapter, worldRegionsTextView, worldRegionsListView);
}
}
private void fillWorldMapsAdapter() {
if (worldMapsAdapter != null) {
worldMapsAdapter.clear();
worldMapsAdapter.addAll(builder.getRegionMapItems());
updateVisibility(worldMapsAdapter, worldMapsTextView, worldMapsListView);
}
}
private void fillVoicePromtsAdapter() {
if (voicePromtsAdapter != null) {
voicePromtsAdapter.clear();
//voicePromtsAdapter.addAll(cats);
updateVisibility(voicePromtsAdapter, voicePromtsTextView, voicePromtsListView);
}
}
private void updateVisibility(ArrayAdapter adapter, TextView textView, ListView listView) {
if (adapter.isEmpty()) {
textView.setVisibility(View.GONE);
listView.setVisibility(View.GONE);
} else {
textView.setVisibility(View.VISIBLE);
listView.setVisibility(View.VISIBLE);
setListViewHeightBasedOnChildren(listView);
}
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
item.setIcon(R.drawable.ic_action_refresh_dark);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == RELOAD_ID) {
// re-create the thread
DownloadActivity.downloadListIndexThread.runReloadIndexFiles();
return true;
}
return super.onOptionsItemSelected(item);
}
private DownloadActivity getDownloadActivity() {
return (DownloadActivity) getActivity();
}
public void onCategorizationFinished() {
if (builder.build()) {
fillWorldRegionsAdapter();
fillWorldMapsAdapter();
fillVoicePromtsAdapter();
}
}
private static class WorldRegionsAdapter extends ArrayAdapter<WorldRegion> {
private final OsmandApplication osmandApplication;
public WorldRegionsAdapter(Context context, OsmandApplication osmandApplication) {
super(context, R.layout.simple_list_menu_item);
this.osmandApplication = osmandApplication;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Drawable iconLeft = osmandApplication.getIconsCache()
.getContentIcon(R.drawable.ic_world_globe_dark);
viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
viewHolder.textView.setText(getItem(position).getName());
return convertView;
}
private static class ViewHolder {
TextView textView;
}
}
private static class WorldMapsAdapter extends ArrayAdapter<ItemsListBuilder.ResourceItem> {
public WorldMapsAdapter(Context context) {
super(context, R.layout.simple_list_menu_item);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ItemViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ItemViewHolder) convertView.getTag();
}
ItemsListBuilder.ResourceItem item = getItem(position);
viewHolder.bindIndexItem(item.getIndexItem(), (DownloadActivity) getContext(), false, false);
return convertView;
}
private static class ViewHolder {
TextView textView;
}
}
private static class VoicePromtsAdapter extends ArrayAdapter {
private final OsmandApplication osmandApplication;
public VoicePromtsAdapter(Context context, OsmandApplication osmandApplication) {
super(context, R.layout.simple_list_menu_item);
this.osmandApplication = osmandApplication;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Drawable iconLeft = osmandApplication.getIconsCache()
.getContentIcon(R.drawable.ic_world_globe_dark);
viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
viewHolder.textView.setText(getItem(position).toString());
return convertView;
}
private static class ViewHolder {
TextView textView;
}
}
}