Confirm dialog if user trying to download roadmaps after downloading full map. ActiveDownloadsDialogFragment: Strings moved to resources, country name as list item title. Fixed bug with buttons appearing on wrong list items. RegionItemsFragment: refactoring. UpdatesIndexFragment: fixing downloading updates in progress.
This commit is contained in:
parent
851a66aa6d
commit
4c3048a616
7 changed files with 198 additions and 181 deletions
|
@ -2015,4 +2015,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="later">Later</string>
|
||||
<string name="get_full_version">Get full version</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="confirm_download_roadmaps">Are you sure you want to download map of roads, even though you have full map?</string>
|
||||
<string name="value_downloaded_from_max">%1$.1f from %2$.1f MB</string>
|
||||
<string name="file_size_in_mb">%.1f MB</string>
|
||||
</resources>
|
||||
|
|
|
@ -653,7 +653,6 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
|
|||
laterButton.setVisibility(View.GONE);
|
||||
}
|
||||
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
||||
// TODO review logic
|
||||
freeVersionBanner.setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout, freeVersionBannerTitle));
|
||||
}
|
||||
|
|
|
@ -12,8 +12,11 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -36,9 +39,7 @@ import java.util.Map;
|
|||
* on 09.09.2014.
|
||||
*/
|
||||
public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||
|
||||
private OsmandRegions osmandRegions;
|
||||
private java.text.DateFormat format;
|
||||
private UpdateIndexAdapter listAdapter;
|
||||
List<IndexItem> indexItems = new ArrayList<>();
|
||||
|
||||
|
@ -46,19 +47,6 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.update_index, container, false);
|
||||
final CheckBox selectAll = (CheckBox) view.findViewById(R.id.select_all);
|
||||
selectAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (selectAll.isChecked()) {
|
||||
selectAll();
|
||||
} else {
|
||||
deselectAll();
|
||||
|
||||
}
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -69,7 +57,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
}
|
||||
CheckBox selectAll = (CheckBox) view.findViewById(R.id.select_all);
|
||||
for (IndexItem item : indexItems) {
|
||||
if (!getDownloadActivity().getEntriesToDownload().containsKey(item)){
|
||||
if (!getMyActivity().getEntriesToDownload().containsKey(item)){
|
||||
selectAll.setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
@ -77,23 +65,9 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
selectAll.setChecked(true);
|
||||
}
|
||||
|
||||
private void setSelectAllVisibility(boolean visible) {
|
||||
View view = getView();
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
if (visible) {
|
||||
view.findViewById(R.id.header_layout).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.findViewById(R.id.header_layout).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
format = getMyApplication().getResourceManager().getDateFormat();
|
||||
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
||||
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
||||
indexItems = new ArrayList<IndexItem>(DownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
||||
}
|
||||
|
@ -110,7 +84,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
indexItems.add(new IndexItem(getString(R.string.no_index_file_to_download), "", 0, "", 0, 0, null));
|
||||
}
|
||||
}
|
||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
||||
listAdapter = new UpdateIndexAdapter(getMyActivity(), R.layout.download_index_list_item, indexItems);
|
||||
listAdapter.sort(new Comparator<IndexItem>() {
|
||||
@Override
|
||||
public int compare(IndexItem indexItem, IndexItem indexItem2) {
|
||||
|
@ -153,27 +127,27 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
|
||||
if (ch.isChecked()) {
|
||||
ch.setChecked(!ch.isChecked());
|
||||
getDownloadActivity().getEntriesToDownload().remove(e);
|
||||
getDownloadActivity().updateFragments();
|
||||
getMyActivity().getEntriesToDownload().remove(e);
|
||||
getMyActivity().updateFragments();
|
||||
} else {
|
||||
List<DownloadEntry> download = e.createDownloadEntry(getMyApplication(), e.getType(), new ArrayList<DownloadEntry>());
|
||||
if (download.size() > 0) {
|
||||
getDownloadActivity().getEntriesToDownload().put(e, download);
|
||||
getDownloadActivity().updateFragments();
|
||||
getMyActivity().getEntriesToDownload().put(e, download);
|
||||
getMyActivity().updateFragments();
|
||||
ch.setChecked(!ch.isChecked());
|
||||
}
|
||||
}
|
||||
refreshSelectAll();
|
||||
}
|
||||
|
||||
public DownloadActivity getDownloadActivity() {
|
||||
public DownloadActivity getMyActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
updateHeader();
|
||||
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
||||
ActionBar actionBar = getMyActivity().getSupportActionBar();
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
|
||||
if (getMyApplication().getAppCustomization().showDownloadExtraActions()) {
|
||||
|
@ -184,7 +158,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
public OsmandApplication getMyApplication() {
|
||||
return getDownloadActivity().getMyApplication();
|
||||
return getMyActivity().getMyApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -210,24 +184,24 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
int selected = 0;
|
||||
for (int i = 0; i < listAdapter.getCount(); i++) {
|
||||
IndexItem es = listAdapter.getItem(i);
|
||||
if (!getDownloadActivity().getEntriesToDownload().containsKey(es)) {
|
||||
if (!getMyActivity().getEntriesToDownload().containsKey(es)) {
|
||||
selected++;
|
||||
getDownloadActivity().getEntriesToDownload().put(es, es.createDownloadEntry(getMyApplication(),
|
||||
getDownloadActivity().getDownloadType(), new ArrayList<DownloadEntry>(1)));
|
||||
getMyActivity().getEntriesToDownload().put(es, es.createDownloadEntry(getMyApplication(),
|
||||
getMyActivity().getDownloadType(), new ArrayList<DownloadEntry>(1)));
|
||||
|
||||
}
|
||||
}
|
||||
AccessibleToast.makeText(getDownloadActivity(), MessageFormat.format(getString(R.string.items_were_selected), selected), Toast.LENGTH_SHORT).show();
|
||||
AccessibleToast.makeText(getMyActivity(), MessageFormat.format(getString(R.string.items_were_selected), selected), Toast.LENGTH_SHORT).show();
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
if (selected > 0) {
|
||||
getDownloadActivity().updateFragments();
|
||||
getMyActivity().updateFragments();
|
||||
}
|
||||
}
|
||||
|
||||
public void deselectAll() {
|
||||
DownloadActivity.downloadListIndexThread.getEntriesToDownload().clear();
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
getDownloadActivity().updateFragments();
|
||||
getMyActivity().updateFragments();
|
||||
}
|
||||
|
||||
private void filterExisting() {
|
||||
|
@ -256,61 +230,15 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
View v = convertView;
|
||||
|
||||
if (v == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
v = inflater.inflate(R.layout.update_index_list_item, null);
|
||||
LayoutInflater inflater = LayoutInflater.from(getMyActivity());
|
||||
v = inflater.inflate(R.layout.two_line_with_images_list_item, null);
|
||||
v.setTag(new UpdateViewHolder(v, getMyActivity()));
|
||||
}
|
||||
|
||||
TextView name = (TextView) v.findViewById(R.id.download_item);
|
||||
TextView description = (TextView) v.findViewById(R.id.download_descr);
|
||||
TextView updateDescr = (TextView) v.findViewById(R.id.update_descr);
|
||||
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
||||
IndexItem e = items.get(position);
|
||||
if (e.getFileName().equals(getString(R.string.everything_up_to_date)) ||
|
||||
e.getFileName().equals(getString(R.string.no_index_file_to_download))) {
|
||||
name.setText(e.getFileName());
|
||||
description.setText("");
|
||||
ch.setVisibility(View.INVISIBLE);
|
||||
setSelectAllVisibility(false);
|
||||
v.setOnClickListener(null);
|
||||
return v;
|
||||
} else {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
String eName = e.getVisibleName(getMyApplication(), osmandRegions);
|
||||
|
||||
name.setText(eName.trim().replace('\n', ' ').replace("TTS","")); //$NON-NLS-1$
|
||||
String d = getMapDescription(e);
|
||||
description.setText(d);
|
||||
|
||||
String sfName = e.getTargetFileName();
|
||||
Map<String, String> indexActivatedFileNames = getMyApplication().getResourceManager().getIndexFileNames();
|
||||
String dt = indexActivatedFileNames.get(sfName);
|
||||
updateDescr.setText("");
|
||||
if (dt != null) {
|
||||
try {
|
||||
Date tm = format.parse(dt);
|
||||
long days = Math.max(1, (e.getTimestamp() - tm.getTime()) / (24 * 60 * 60 * 1000) + 1);
|
||||
updateDescr.setText(days + " " + getString(R.string.days_behind));
|
||||
} catch (ParseException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ch.setChecked(getDownloadActivity().getEntriesToDownload().containsKey(e));
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ch.setChecked(!ch.isChecked());
|
||||
onItemSelected(ch, position);
|
||||
}
|
||||
});
|
||||
|
||||
UpdateViewHolder holder = (UpdateViewHolder) v.getTag();
|
||||
holder.bindUpdatesIndexItem(items.get(position));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -328,16 +256,72 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: 10/13/15 Extract viewholder parent
|
||||
private static class UpdateViewHolder {
|
||||
private final TextView nameTextView;
|
||||
private final TextView descrTextView;
|
||||
private final ImageView leftImageView;
|
||||
private final ImageView rightImageButton;
|
||||
private final Button rightButton;
|
||||
private final ProgressBar progressBar;
|
||||
private final TextView mapDateTextView;
|
||||
private final DownloadActivity context;
|
||||
private final java.text.DateFormat format;
|
||||
|
||||
private UpdateViewHolder(View convertView,
|
||||
final DownloadActivity context) {
|
||||
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);
|
||||
rightButton = (Button) convertView.findViewById(R.id.rightButton);
|
||||
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
|
||||
mapDateTextView = (TextView) convertView.findViewById(R.id.mapDateTextView);
|
||||
this.context = context;
|
||||
format = context.getMyApplication().getResourceManager().getDateFormat();
|
||||
}
|
||||
|
||||
public void bindUpdatesIndexItem(IndexItem indexItem) {
|
||||
if (indexItem.getFileName().equals(context.getString(R.string.everything_up_to_date)) ||
|
||||
indexItem.getFileName().equals(context.getString(R.string.no_index_file_to_download))) {
|
||||
nameTextView.setText(indexItem.getFileName());
|
||||
descrTextView.setText("");
|
||||
return;
|
||||
}
|
||||
|
||||
OsmandRegions osmandRegions =
|
||||
context.getMyApplication().getResourceManager().getOsmandRegions();
|
||||
String eName = indexItem.getVisibleName(context.getMyApplication(), osmandRegions);
|
||||
|
||||
nameTextView.setText(eName.trim().replace('\n', ' ').replace("TTS","")); //$NON-NLS-1$
|
||||
String d = getMapDescription(indexItem);
|
||||
descrTextView.setText(d);
|
||||
|
||||
String sfName = indexItem.getTargetFileName();
|
||||
Map<String, String> indexActivatedFileNames = context.getMyApplication().getResourceManager().getIndexFileNames();
|
||||
String dt = indexActivatedFileNames.get(sfName);
|
||||
mapDateTextView.setText("");
|
||||
if (dt != null) {
|
||||
try {
|
||||
Date tm = format.parse(dt);
|
||||
long days = Math.max(1, (indexItem.getTimestamp() - tm.getTime()) / (24 * 60 * 60 * 1000) + 1);
|
||||
mapDateTextView.setText(days + " " + context.getString(R.string.days_behind));
|
||||
} catch (ParseException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getMapDescription(IndexItem item){
|
||||
String typeName = getTypeName(item, item.getType().getStringResource());
|
||||
String date = item.getDate(format);
|
||||
String size = item.getSizeDescription(getActivity());
|
||||
String size = item.getSizeDescription(context);
|
||||
return typeName + " " + date + " " + size;
|
||||
|
||||
}
|
||||
|
||||
private String getTypeName(IndexItem item, int resId){
|
||||
Activity activity = getActivity();
|
||||
Activity activity = context;
|
||||
if (resId == R.string.download_regular_maps){
|
||||
return activity.getString(R.string.shared_string_map);
|
||||
} else if (resId == R.string.download_wikipedia_maps){
|
||||
|
@ -355,3 +339,4 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,8 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
|||
|
||||
public void bindDownloadEntry(final DownloadEntry downloadEntry, final int progress,
|
||||
boolean isDownloaded) {
|
||||
nameTextView.setText(downloadEntry.baseName);
|
||||
nameTextView.setText(downloadEntry.item.getVisibleName(context,
|
||||
context.getMyApplication().getRegions()));
|
||||
rightImageButton.setVisibility(View.VISIBLE);
|
||||
|
||||
int localProgress = progress;
|
||||
|
@ -152,13 +153,14 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
|||
isIndeterminate = false;
|
||||
onClickListener = activeDownloadOnClickListener;
|
||||
double downloaded = downloadEntry.sizeMB * progress / 100;
|
||||
descrTextView.setText(String.format("%.1f from %.1f MB", downloaded,
|
||||
descrTextView.setText(context.getString(R.string.value_downloaded_from_max, downloaded,
|
||||
downloadEntry.sizeMB));
|
||||
} else if (isDownloaded) {
|
||||
// Downloaded
|
||||
isIndeterminate = false;
|
||||
localProgress = progressBar.getMax();
|
||||
descrTextView.setText(String.format("%.1f MB", downloadEntry.sizeMB));
|
||||
descrTextView.setText(context.getString(R.string.file_size_in_mb,
|
||||
downloadEntry.sizeMB));
|
||||
|
||||
} else {
|
||||
// pending
|
||||
|
@ -169,7 +171,8 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
|||
adapter.remove(downloadEntry);
|
||||
}
|
||||
};
|
||||
descrTextView.setText(String.format("%.1f MB", downloadEntry.sizeMB));
|
||||
descrTextView.setText(context.getString(R.string.file_size_in_mb,
|
||||
downloadEntry.sizeMB));
|
||||
}
|
||||
rightImageButton.setOnClickListener(onClickListener);
|
||||
progressBar.setIndeterminate(isIndeterminate);
|
||||
|
|
|
@ -211,6 +211,7 @@ public class ItemViewHolder {
|
|||
|
||||
public void bindRegion(WorldRegion region, DownloadActivity context) {
|
||||
nameTextView.setText(region.getName());
|
||||
nameTextView.setTextColor(textColorPrimary);
|
||||
if (region.getResourceTypes().size() > 0) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (DownloadActivityType activityType : region.getResourceTypes()) {
|
||||
|
@ -238,6 +239,7 @@ public class ItemViewHolder {
|
|||
break;
|
||||
}
|
||||
leftImageView.setImageDrawable(leftImageDrawable);
|
||||
rightButton.setVisibility(View.GONE);
|
||||
rightImageButton.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package net.osmand.plus.download.items;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -19,26 +22,23 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.WorldRegion;
|
||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||
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 net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||
public static final String TAG = "RegionItemsFragment";
|
||||
private static final Log LOG = PlatformUtil.getLog(RegionItemsFragment.class);
|
||||
private static final MessageFormat formatGb = new MessageFormat("{0, number,<b>#.##</b>} GB", Locale.US);
|
||||
|
||||
private RegionsItemsAdapter listAdapter;
|
||||
private int regionMapsGroupPos = -1;
|
||||
|
@ -91,7 +91,8 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
|
||||
int childPosition, long id) {
|
||||
Object obj = listAdapter.getChild(groupPosition, childPosition);
|
||||
if (obj instanceof WorldRegion) {
|
||||
WorldRegion region = (WorldRegion) obj;
|
||||
|
@ -101,8 +102,17 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
} else if (obj instanceof ItemsListBuilder.ResourceItem) {
|
||||
if (((ItemViewHolder) v.getTag()).isItemAvailable()) {
|
||||
IndexItem indexItem = ((ItemsListBuilder.ResourceItem) obj).getIndexItem();
|
||||
((BaseDownloadActivity) getActivity())
|
||||
.startDownload(indexItem);
|
||||
if (indexItem.getType() == DownloadActivityType.ROADS_FILE) {
|
||||
IndexItem regularMap =
|
||||
((ItemsListBuilder.ResourceItem) listAdapter.getChild(0, 0))
|
||||
.getIndexItem();
|
||||
if (regularMap.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
ConfirmDownloadUnneededMapDialogFragment.createInstance(indexItem)
|
||||
.show(getChildFragmentManager(), "dialog");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
getMyActivity().startDownload(indexItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -200,47 +210,31 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
public View getChildView(final int groupPosition, final int childPosition,
|
||||
boolean isLastChild, 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,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.setSrtmDisabled(srtmDisabled);
|
||||
viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled);
|
||||
viewHolder.setFreeVersion(freeVersion);
|
||||
final Object child = getChild(groupPosition, childPosition);
|
||||
|
||||
if (child instanceof ItemsListBuilder.ResourceItem && groupPosition == regionMapsGroupPos) {
|
||||
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,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.setSrtmDisabled(srtmDisabled);
|
||||
viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled);
|
||||
viewHolder.setFreeVersion(freeVersion);
|
||||
|
||||
if (child instanceof ItemsListBuilder.ResourceItem
|
||||
&& groupPosition == regionMapsGroupPos) {
|
||||
ItemsListBuilder.ResourceItem item = (ItemsListBuilder.ResourceItem) child;
|
||||
viewHolder.bindIndexItem(item.getIndexItem(), getDownloadActivity(), true, false);
|
||||
} else {
|
||||
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,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.setSrtmDisabled(srtmDisabled);
|
||||
viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled);
|
||||
viewHolder.setFreeVersion(freeVersion);
|
||||
|
||||
if (child instanceof WorldRegion) {
|
||||
} else if (child instanceof WorldRegion) {
|
||||
viewHolder.bindRegion((WorldRegion) child, getDownloadActivity());
|
||||
} else if (child instanceof ItemsListBuilder.ResourceItem) {
|
||||
viewHolder.bindIndexItem(((ItemsListBuilder.ResourceItem) child).getIndexItem(),
|
||||
|
@ -249,19 +243,19 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
|
||||
"IndexItem but is of type:" + child.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
|
||||
ViewGroup parent) {
|
||||
View v = convertView;
|
||||
String section = getGroup(groupPosition);
|
||||
|
||||
if (v == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
|
||||
v = LayoutInflater.from(getDownloadActivity())
|
||||
.inflate(R.layout.download_item_list_section, parent, false);
|
||||
}
|
||||
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
||||
nameView.setText(section);
|
||||
|
@ -307,4 +301,35 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfirmDownloadUnneededMapDialogFragment extends DialogFragment {
|
||||
private static final String INDEX_ITEM = "index_item";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final IndexItem indexItem = getArguments().getParcelable(INDEX_ITEM);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.are_you_sure);
|
||||
builder.setMessage(R.string.confirm_download_roadmaps);
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.setPositiveButton(R.string.shared_string_download,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
((DownloadActivity) getActivity()).startDownload(indexItem);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public static ConfirmDownloadUnneededMapDialogFragment createInstance(@NonNull IndexItem indexItem) {
|
||||
ConfirmDownloadUnneededMapDialogFragment fragment =
|
||||
new ConfirmDownloadUnneededMapDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(INDEX_ITEM, indexItem);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ public class SearchItemsFragment extends Fragment {
|
|||
}
|
||||
|
||||
/*
|
||||
Context c = getDownloadActivity();
|
||||
Context c = getMyActivity();
|
||||
for (IndexItem item : indexItems) {
|
||||
String indexLC = item.getVisibleName(c, osmandRegions).toLowerCase();
|
||||
if (isMatch(conds, false, indexLC)) {
|
||||
|
|
Loading…
Reference in a new issue