Downdload map design in progress. Voice now has no aggreagation. Icons. Back is now working.
This commit is contained in:
parent
3114e2187a
commit
80798e4f8e
7 changed files with 166 additions and 77 deletions
|
@ -1,6 +1,8 @@
|
||||||
package net.osmand.plus.download;
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -24,34 +26,53 @@ import java.util.Map;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||||
|
|
||||||
public class DownloadActivityType {
|
public class DownloadActivityType implements Parcelable {
|
||||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
private static Map<String, DownloadActivityType> byTag = new HashMap<String, DownloadActivityType>();
|
private static Map<String, DownloadActivityType> byTag = new HashMap<>();
|
||||||
|
|
||||||
public static final DownloadActivityType NORMAL_FILE = new DownloadActivityType(R.string.download_regular_maps, "map");
|
public static final DownloadActivityType NORMAL_FILE = new DownloadActivityType(R.string.download_regular_maps, "map");
|
||||||
public static final DownloadActivityType VOICE_FILE = new DownloadActivityType(R.string.voices, "voice");
|
public static final DownloadActivityType VOICE_FILE =
|
||||||
|
new DownloadActivityType(R.string.voices, R.drawable.ic_action_volume_up, "voice");
|
||||||
public static final DownloadActivityType ROADS_FILE = new DownloadActivityType(R.string.download_roads_only_maps, "road_map");
|
public static final DownloadActivityType ROADS_FILE = new DownloadActivityType(R.string.download_roads_only_maps, "road_map");
|
||||||
public static final DownloadActivityType SRTM_COUNTRY_FILE = new DownloadActivityType(R.string.download_srtm_maps, "srtm_map");
|
public static final DownloadActivityType SRTM_COUNTRY_FILE =
|
||||||
public static final DownloadActivityType HILLSHADE_FILE = new DownloadActivityType(R.string.download_hillshade_maps, "hillshade");
|
new DownloadActivityType(R.string.download_srtm_maps,
|
||||||
public static final DownloadActivityType WIKIPEDIA_FILE = new DownloadActivityType(R.string.download_wikipedia_maps, "wikimap");
|
R.drawable.ic_plugin_srtm, "srtm_map");
|
||||||
|
public static final DownloadActivityType HILLSHADE_FILE =
|
||||||
|
new DownloadActivityType(R.string.download_hillshade_maps,
|
||||||
|
R.drawable.ic_action_hillshade_dark, "hillshade");
|
||||||
|
public static final DownloadActivityType WIKIPEDIA_FILE =
|
||||||
|
new DownloadActivityType(R.string.download_wikipedia_maps,
|
||||||
|
R.drawable.ic_world_globe_dark, "wikimap");
|
||||||
public static final DownloadActivityType LIVE_UPDATES_FILE = new DownloadActivityType(R.string.download_live_updates, "live_updates");
|
public static final DownloadActivityType LIVE_UPDATES_FILE = new DownloadActivityType(R.string.download_live_updates, "live_updates");
|
||||||
private int resource;
|
private final int stringResource;
|
||||||
private String[] tags;
|
private final int iconResource;
|
||||||
|
|
||||||
public DownloadActivityType(int resource, String... tags) {
|
private String tag;
|
||||||
this.resource = resource;
|
|
||||||
this.tags = tags;
|
public DownloadActivityType(int stringResource, int iconResource, String tag) {
|
||||||
for(String st : tags) {
|
this.stringResource = stringResource;
|
||||||
byTag.put(st, this);
|
this.tag = tag;
|
||||||
}
|
byTag.put(tag, this);
|
||||||
|
this.iconResource = iconResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResource(){
|
public DownloadActivityType(int stringResource, String tag) {
|
||||||
return resource;
|
this.stringResource = stringResource;
|
||||||
|
this.tag = tag;
|
||||||
|
byTag.put(tag, this);
|
||||||
|
iconResource = R.drawable.ic_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStringResource(){
|
||||||
|
return stringResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIconResource() {
|
||||||
|
return iconResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return tags[0];
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +87,7 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(Context c) {
|
public String getString(Context c) {
|
||||||
return c.getString(resource);
|
return c.getString(stringResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadActivityType getIndexType(String tagName) {
|
public static DownloadActivityType getIndexType(String tagName) {
|
||||||
|
@ -271,8 +292,7 @@ public class DownloadActivityType {
|
||||||
if (l == -1) {
|
if (l == -1) {
|
||||||
l = fileName.length();
|
l = fileName.length();
|
||||||
}
|
}
|
||||||
String s = fileName.substring(0, l);
|
return fileName.substring(0, l);
|
||||||
return s;
|
|
||||||
} else if (this == HILLSHADE_FILE) {
|
} else if (this == HILLSHADE_FILE) {
|
||||||
return fileName.replace('_', ' ');
|
return fileName.replace('_', ' ');
|
||||||
} else if (this == LIVE_UPDATES_FILE) {
|
} else if (this == LIVE_UPDATES_FILE) {
|
||||||
|
@ -322,8 +342,7 @@ public class DownloadActivityType {
|
||||||
if (l == -1) {
|
if (l == -1) {
|
||||||
l = fileName.length();
|
l = fileName.length();
|
||||||
}
|
}
|
||||||
String s = fileName.substring(0, l);
|
return fileName.substring(0, l);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
if (this == LIVE_UPDATES_FILE) {
|
if (this == LIVE_UPDATES_FILE) {
|
||||||
if(fileName.indexOf('.') > 0){
|
if(fileName.indexOf('.') > 0){
|
||||||
|
@ -341,5 +360,32 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeInt(this.stringResource);
|
||||||
|
dest.writeInt(this.iconResource);
|
||||||
|
dest.writeString(this.tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DownloadActivityType(Parcel in) {
|
||||||
|
this.stringResource = in.readInt();
|
||||||
|
this.iconResource = in.readInt();
|
||||||
|
this.tag = in.readString();
|
||||||
|
byTag.put(tag, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<DownloadActivityType> CREATOR = new Parcelable.Creator<DownloadActivityType>() {
|
||||||
|
public DownloadActivityType createFromParcel(Parcel source) {
|
||||||
|
return new DownloadActivityType(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadActivityType[] newArray(int size) {
|
||||||
|
return new DownloadActivityType[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package net.osmand.plus.download;
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -18,7 +20,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class IndexItem implements Comparable<IndexItem>, HasName {
|
public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
|
||||||
private static final Log log = PlatformUtil.getLog(IndexItem.class);
|
private static final Log log = PlatformUtil.getLog(IndexItem.class);
|
||||||
|
|
||||||
String description;
|
String description;
|
||||||
|
@ -114,9 +116,9 @@ public class IndexItem implements Comparable<IndexItem>, HasName {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NonNull IndexItem another) {
|
public int compareTo(@NonNull IndexItem another) {
|
||||||
if(another == null) {
|
// if(another == null) {
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
return getFileName().compareTo(another.getFileName());
|
return getFileName().compareTo(another.getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ public class IndexItem implements Comparable<IndexItem>, HasName {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return initializedName;
|
return initializedName + " must be fixed";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String initializedName) {
|
public void setName(String initializedName) {
|
||||||
|
@ -166,4 +168,44 @@ public class IndexItem implements Comparable<IndexItem>, HasName {
|
||||||
", extra=" + extra +
|
", extra=" + extra +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(this.description);
|
||||||
|
dest.writeString(this.fileName);
|
||||||
|
dest.writeString(this.size);
|
||||||
|
dest.writeLong(this.timestamp);
|
||||||
|
dest.writeLong(this.contentSize);
|
||||||
|
dest.writeLong(this.containerSize);
|
||||||
|
dest.writeParcelable(this.type, flags);
|
||||||
|
dest.writeByte(extra ? (byte) 1 : (byte) 0);
|
||||||
|
dest.writeString(this.initializedName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IndexItem(Parcel in) {
|
||||||
|
this.description = in.readString();
|
||||||
|
this.fileName = in.readString();
|
||||||
|
this.size = in.readString();
|
||||||
|
this.timestamp = in.readLong();
|
||||||
|
this.contentSize = in.readLong();
|
||||||
|
this.containerSize = in.readLong();
|
||||||
|
this.type = in.readParcelable(DownloadActivityType.class.getClassLoader());
|
||||||
|
this.extra = in.readByte() != 0;
|
||||||
|
this.initializedName = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<IndexItem> CREATOR = new Parcelable.Creator<IndexItem>() {
|
||||||
|
public IndexItem createFromParcel(Parcel source) {
|
||||||
|
return new IndexItem(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexItem[] newArray(int size) {
|
||||||
|
return new IndexItem[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
private OsmandRegions osmandRegions;
|
private OsmandRegions osmandRegions;
|
||||||
private java.text.DateFormat format;
|
private java.text.DateFormat format;
|
||||||
private UpdateIndexAdapter listAdapter;
|
private UpdateIndexAdapter listAdapter;
|
||||||
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
List<IndexItem> indexItems = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -233,7 +233,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
private void filterExisting() {
|
private void filterExisting() {
|
||||||
final Map<String, String> listAlreadyDownloaded = DownloadActivity.downloadListIndexThread.getDownloadedIndexFileNames();
|
final Map<String, String> listAlreadyDownloaded = DownloadActivity.downloadListIndexThread.getDownloadedIndexFileNames();
|
||||||
|
|
||||||
final List<IndexItem> filtered = new ArrayList<IndexItem>();
|
final List<IndexItem> filtered = new ArrayList<>();
|
||||||
for (IndexItem fileItem : listAdapter.getIndexFiles()) {
|
for (IndexItem fileItem : listAdapter.getIndexFiles()) {
|
||||||
if (fileItem.isAlreadyDownloaded(listAlreadyDownloaded)) {
|
if (fileItem.isAlreadyDownloaded(listAlreadyDownloaded)) {
|
||||||
filtered.add(fileItem);
|
filtered.add(fileItem);
|
||||||
|
@ -329,7 +329,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMapDescription(IndexItem item){
|
private String getMapDescription(IndexItem item){
|
||||||
String typeName = getTypeName(item, item.getType().getResource());
|
String typeName = getTypeName(item, item.getType().getStringResource());
|
||||||
String date = item.getDate(format);
|
String date = item.getDate(format);
|
||||||
String size = item.getSizeDescription(getActivity());
|
String size = item.getSizeDescription(getActivity());
|
||||||
return typeName + " " + date + " " + size;
|
return typeName + " " + date + " " + size;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import net.osmand.OsmAndCollator;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.map.OsmandRegions;
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
@ -133,30 +132,32 @@ public class IndexItemCategoryWithSubcat implements Comparable<IndexItemCategory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexItemCategoryWithSubcat region;
|
if (i.getType() == DownloadActivityType.VOICE_FILE){
|
||||||
region = cats.get(i.getBasename());
|
// TODO remove
|
||||||
final String visibleName = i.getVisibleName(ctx, ctx.getRegions());
|
final String visibleName = i.getVisibleName(ctx, ctx.getRegions());
|
||||||
i.setName(visibleName);
|
i.setName(visibleName);
|
||||||
if (region == null) {
|
category.items.add(i);
|
||||||
final CategoryStaticData regionStaticData = new CategoryStaticData(0, 0);
|
} else {
|
||||||
regionStaticData.setName(visibleName);
|
IndexItemCategoryWithSubcat region;
|
||||||
region = new IndexItemCategoryWithSubcat(regionStaticData);
|
region = cats.get(i.getBasename());
|
||||||
cats.put(i.getBasename(), region);
|
// TODO remove
|
||||||
category.subcats.add(region);
|
final String visibleName = i.getVisibleName(ctx, ctx.getRegions());
|
||||||
|
i.setName(visibleName);
|
||||||
|
if (region == null) {
|
||||||
|
final CategoryStaticData regionStaticData = new CategoryStaticData(0, 0);
|
||||||
|
regionStaticData.setName(visibleName);
|
||||||
|
region = new IndexItemCategoryWithSubcat(regionStaticData);
|
||||||
|
cats.put(i.getBasename(), region);
|
||||||
|
category.subcats.add(region);
|
||||||
|
}
|
||||||
|
region.items.add(i);
|
||||||
|
if (i.getType() == DownloadActivityType.NORMAL_FILE
|
||||||
|
|| i.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||||
|
|| i.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
|
||||||
|
|| i.getType() == DownloadActivityType.HILLSHADE_FILE) {
|
||||||
|
region.types.add(i.getType().getStringResource());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
region.items.add(i);
|
|
||||||
|
|
||||||
if (i.getType() == DownloadActivityType.NORMAL_FILE) {
|
|
||||||
region.types.add(R.string.shared_string_map);
|
|
||||||
}
|
|
||||||
if (i.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
|
|
||||||
region.types.add(R.string.shared_string_wikipedia);
|
|
||||||
}
|
|
||||||
if (i.getType() == DownloadActivityType.ROADS_FILE) {
|
|
||||||
region.types.add(R.string.roads);
|
|
||||||
}
|
|
||||||
|
|
||||||
final CategoryStaticData parent = category.categoryStaticData.getParent();
|
|
||||||
}
|
}
|
||||||
final Collator collator = OsmAndCollator.primaryCollator();
|
final Collator collator = OsmAndCollator.primaryCollator();
|
||||||
for (IndexItemCategoryWithSubcat ct : mainList) {
|
for (IndexItemCategoryWithSubcat ct : mainList) {
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class MapsInCategoryFragment extends DialogFragment {
|
||||||
|
|
||||||
public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
|
public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
|
||||||
LOG.debug("onCategorySelected()");
|
LOG.debug("onCategorySelected()");
|
||||||
getChildFragmentManager().beginTransaction().replace(R.id.fragmentContainer,
|
createInstance(category).show(getChildFragmentManager(), TAG);
|
||||||
SubcategoriesFragment.createInstance(category)).addToBackStack(null).commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIndexItemSelected(@NonNull IndexItem indexItem) {
|
public void onIndexItemSelected(@NonNull IndexItem indexItem) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
@ -55,13 +54,6 @@ public class NewLocalIndexesFragment extends OsmAndListFragment {
|
||||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
mAdapter = new CategoriesAdapter(getActivity(), getMyApplication());
|
mAdapter = new CategoriesAdapter(getActivity(), getMyApplication());
|
||||||
listView.setAdapter(mAdapter);
|
listView.setAdapter(mAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
LOG.debug("onItemClick()");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
View header = inflater.inflate(R.layout.local_index_fragment_header, listView, false);
|
View header = inflater.inflate(R.layout.local_index_fragment_header, listView, false);
|
||||||
initMemoryConsumedCard(header);
|
initMemoryConsumedCard(header);
|
||||||
|
@ -116,7 +108,6 @@ public class NewLocalIndexesFragment extends OsmAndListFragment {
|
||||||
fragmentTransaction.addToBackStack(null);
|
fragmentTransaction.addToBackStack(null);
|
||||||
MapsInCategoryFragment.createInstance(mAdapter.getItem(position-1))
|
MapsInCategoryFragment.createInstance(mAdapter.getItem(position-1))
|
||||||
.show(fragmentTransaction, MapsInCategoryFragment.TAG);
|
.show(fragmentTransaction, MapsInCategoryFragment.TAG);
|
||||||
LOG.debug("onListItemClick()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DownloadActivity getDownloadActivity() {
|
private DownloadActivity getDownloadActivity() {
|
||||||
|
@ -124,7 +115,6 @@ public class NewLocalIndexesFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCategorizationFinished(List<IndexItem> filtered, List<IndexItemCategoryWithSubcat> cats) {
|
public void onCategorizationFinished(List<IndexItem> filtered, List<IndexItemCategoryWithSubcat> cats) {
|
||||||
LOG.debug("cats=" + cats);
|
|
||||||
mAdapter.clear();
|
mAdapter.clear();
|
||||||
mAdapter.addAll(cats);
|
mAdapter.addAll(cats);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.helpers.HasName;
|
import net.osmand.plus.helpers.HasName;
|
||||||
|
|
||||||
|
@ -38,8 +39,9 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
assert category != null;
|
assert category != null;
|
||||||
|
|
||||||
ListView listView = new ListView(getActivity());
|
ListView listView = new ListView(getActivity());
|
||||||
|
final OsmandApplication application = (OsmandApplication) getActivity().getApplication();
|
||||||
final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
|
final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
|
||||||
((OsmandApplication) getActivity().getApplication()).getIconsCache());
|
application.getIconsCache(), application);
|
||||||
listView.setAdapter(mAdapter);
|
listView.setAdapter(mAdapter);
|
||||||
mAdapter.addAll(category.items);
|
mAdapter.addAll(category.items);
|
||||||
mAdapter.addAll(category.subcats);
|
mAdapter.addAll(category.subcats);
|
||||||
|
@ -51,8 +53,7 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
View freeVersionBanner = inflater.inflate(R.layout.free_version_banner, listView, false);
|
View freeVersionBanner = inflater.inflate(R.layout.free_version_banner, listView, false);
|
||||||
final OsmandSettings settings =
|
final OsmandSettings settings = application.getSettings();
|
||||||
((OsmandApplication) getActivity().getApplication()).getSettings();
|
|
||||||
DownloadsUiInitHelper.initFreeVersionBanner(freeVersionBanner, settings, getResources());
|
DownloadsUiInitHelper.initFreeVersionBanner(freeVersionBanner, settings, getResources());
|
||||||
listView.addHeaderView(freeVersionBanner);
|
listView.addHeaderView(freeVersionBanner);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@ -85,10 +86,12 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
private static class MapFilesAdapter extends ArrayAdapter<HasName> {
|
private static class MapFilesAdapter extends ArrayAdapter<HasName> {
|
||||||
|
|
||||||
private final IconsCache iconsCache;
|
private final IconsCache iconsCache;
|
||||||
|
private final OsmandApplication application;
|
||||||
|
|
||||||
public MapFilesAdapter(Context context, IconsCache iconsCache) {
|
public MapFilesAdapter(Context context, IconsCache iconsCache, OsmandApplication application) {
|
||||||
super(context, R.layout.two_line_with_images_list_item);
|
super(context, R.layout.two_line_with_images_list_item);
|
||||||
this.iconsCache = iconsCache;
|
this.iconsCache = iconsCache;
|
||||||
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,20 +120,28 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
stringBuilder.append(resources.getString(mapType));
|
stringBuilder.append(resources.getString(mapType));
|
||||||
stringBuilder.append(", ");
|
stringBuilder.append(", ");
|
||||||
}
|
}
|
||||||
LOG.debug("stringBuilder=" + stringBuilder);
|
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.capacity());
|
||||||
stringBuilder.delete(stringBuilder.capacity() - 3, stringBuilder.capacity());
|
|
||||||
viewHolder.descrTextView.setText(stringBuilder.toString());
|
viewHolder.descrTextView.setText(stringBuilder.toString());
|
||||||
} else {
|
} else {
|
||||||
// TODO replace with string constant
|
// TODO replace with string constant
|
||||||
viewHolder.descrTextView.setText("Others");
|
viewHolder.descrTextView.setText("Others");
|
||||||
}
|
}
|
||||||
|
viewHolder.leftImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_map));
|
||||||
LOG.debug("category.types=" + category.types);
|
LOG.debug("category.types=" + category.types);
|
||||||
|
} else if (item instanceof IndexItem) {
|
||||||
|
IndexItem indexItem = (IndexItem) item;
|
||||||
|
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
|
||||||
|
viewHolder.nameTextView.setText(indexItem.getVisibleName(getContext(),
|
||||||
|
application.getRegions()));
|
||||||
|
} else {
|
||||||
|
viewHolder.nameTextView.setText(indexItem.getType().getString(getContext()));
|
||||||
|
}
|
||||||
|
viewHolder.descrTextView.setText(indexItem.getSizeDescription(getContext()));
|
||||||
|
viewHolder.leftImageView.setImageResource(indexItem.getType().getIconResource());
|
||||||
} else {
|
} else {
|
||||||
viewHolder.nameTextView.setText(item.getName());
|
throw new IllegalArgumentException("Item must be of type IndexItem or " +
|
||||||
// TODO replace with real values
|
"IndexItemCategory but is of type:" + item.getClass());
|
||||||
viewHolder.descrTextView.setText("Temp values");
|
|
||||||
}
|
}
|
||||||
viewHolder.leftImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_map));
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue