Now items updating after downloading.
This commit is contained in:
parent
9412998625
commit
ac794ecee0
6 changed files with 32 additions and 24 deletions
|
@ -23,8 +23,6 @@ import java.util.Map;
|
|||
|
||||
public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
||||
|
||||
private final Map<String, String> indexFileNames;
|
||||
private final Map<String, String> indexActivatedFileNames;
|
||||
private final java.text.DateFormat dateFormat;
|
||||
|
||||
private boolean srtmDisabled;
|
||||
|
@ -44,12 +42,8 @@ public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
|||
|
||||
public ItemViewHolder(View convertView,
|
||||
DownloadActivity context,
|
||||
DateFormat dateFormat,
|
||||
Map<String, String> indexFileNames,
|
||||
Map<String, String> indexActivatedFileNames) {
|
||||
DateFormat dateFormat) {
|
||||
super(convertView, context);
|
||||
this.indexFileNames = indexFileNames;
|
||||
this.indexActivatedFileNames = indexActivatedFileNames;
|
||||
this.dateFormat = dateFormat;
|
||||
|
||||
TypedValue typedValue = new TypedValue();
|
||||
|
@ -89,7 +83,8 @@ public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
|||
nameTextView.setText(indexItem.getVisibleName(context,
|
||||
context.getMyApplication().getRegions(), false));
|
||||
} else {
|
||||
if (indexItem.getSimplifiedFileName().equals(ItemsListBuilder.WORLD_SEAMARKS_KEY) && nauticalPluginDisabled) {
|
||||
if (indexItem.getSimplifiedFileName().equals(ItemsListBuilder.WORLD_SEAMARKS_KEY)
|
||||
&& nauticalPluginDisabled) {
|
||||
rightButtonAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN;
|
||||
disabled = true;
|
||||
}
|
||||
|
@ -128,6 +123,7 @@ public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
|||
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
Map<String,String> indexFileNames = context.getIndexFileNames();
|
||||
if (indexFileNames != null && indexItem.isAlreadyDownloaded(indexFileNames)) {
|
||||
boolean outdated = false;
|
||||
String date;
|
||||
|
@ -135,6 +131,7 @@ public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
|||
date = indexItem.getDate(dateFormat);
|
||||
} else {
|
||||
String sfName = indexItem.getTargetFileName();
|
||||
Map<String,String> indexActivatedFileNames = context.getIndexActivatedFileNames();
|
||||
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
|
||||
date = updatableResource ? indexActivatedFileNames.get(sfName) : indexFileNames.get(sfName);
|
||||
outdated = DownloadActivity.downloadListIndexThread.checkIfItemOutdated(indexItem);
|
||||
|
|
|
@ -9,13 +9,15 @@ 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 net.osmand.plus.download.DownloadActivity;
|
||||
|
||||
public class RegionDialogFragment extends DialogFragment{
|
||||
public class RegionDialogFragment extends DialogFragment
|
||||
implements DownloadActivity.DataSetChangedListener{
|
||||
public static final String TAG = "RegionDialogFragment";
|
||||
private static final String REGION_ID_DLG_KEY = "world_region_dialog_key";
|
||||
private String regionId;
|
||||
|
@ -114,4 +116,11 @@ public class RegionDialogFragment extends DialogFragment{
|
|||
public void setOnDismissListener(DialogDismissListener listener) {
|
||||
this.dialogDismissListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
((DownloadActivity.DataSetChangedListener)
|
||||
getChildFragmentManager().findFragmentById(R.id.fragmentContainer))
|
||||
.notifyDataSetChanged();
|
||||
}
|
||||
}
|
|
@ -39,7 +39,8 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||
public class RegionItemsFragment extends OsmandExpandableListFragment
|
||||
implements DownloadActivity.DataSetChangedListener {
|
||||
public static final String TAG = "RegionItemsFragment";
|
||||
private static final Log LOG = PlatformUtil.getLog(RegionItemsFragment.class);
|
||||
|
||||
|
@ -110,7 +111,8 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
IndexItem regularMap =
|
||||
((ItemsListBuilder.ResourceItem) listAdapter.getChild(0, 0))
|
||||
.getIndexItem();
|
||||
if (regularMap.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
if (regularMap.getType() == DownloadActivityType.NORMAL_FILE
|
||||
&& regularMap.isAlreadyDownloaded(getMyActivity().getIndexFileNames())) {
|
||||
ConfirmDownloadUnneededMapDialogFragment.createInstance(indexItem)
|
||||
.show(getChildFragmentManager(), "dialog");
|
||||
return true;
|
||||
|
@ -172,6 +174,12 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
LOG.debug("notifyDataSetChanged()");
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private class RegionsItemsAdapter extends OsmandBaseExpandableListAdapter
|
||||
implements ProgressAdapter {
|
||||
|
||||
|
@ -228,9 +236,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView, getMyActivity(),
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
getMyApplication().getResourceManager().getDateFormat());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
@ -318,6 +324,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
progress = -1;
|
||||
if (isFinished) return;
|
||||
if (tag instanceof DownloadEntry) {
|
||||
DownloadEntry updatedEntry = (DownloadEntry) tag;
|
||||
progress = task.getProgressPercentage();
|
||||
outer_loop:
|
||||
for (int i = 0; i < getGroupCount(); i++) {
|
||||
|
@ -325,7 +332,8 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
if ((getChild(i, j) instanceof ItemsListBuilder.ResourceItem)) {
|
||||
final IndexItem child =
|
||||
((ItemsListBuilder.ResourceItem) getChild(i, j)).getIndexItem();
|
||||
if (child.getBasename().equals(((DownloadEntry) tag).baseName)) {
|
||||
if (child.getBasename().equals(updatedEntry.baseName) &&
|
||||
child.getType().equals(updatedEntry.type)) {
|
||||
groupInProgressPosition = i;
|
||||
childInProgressPosition = j;
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -219,9 +219,7 @@ public class SearchItemsFragment extends Fragment {
|
|||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyActivity(),
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
getMyApplication().getResourceManager().getDateFormat());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
|
@ -186,9 +186,7 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
|||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyActivity(),
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexFileNames(),
|
||||
getMyActivity().getIndexActivatedFileNames());
|
||||
getMyApplication().getResourceManager().getDateFormat());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
|
@ -297,9 +297,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment
|
|||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyActivity(),
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
getMyApplication().getResourceManager().getDateFormat());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
Loading…
Reference in a new issue