Refactor show on map for downloads
This commit is contained in:
parent
eb6cdb77de
commit
356c971f56
7 changed files with 22 additions and 13 deletions
|
@ -231,6 +231,7 @@ public class DownloadResourceGroup {
|
|||
}
|
||||
|
||||
public void addItem(IndexItem i) {
|
||||
i.setRelatedGroup(this);
|
||||
individualResources.add(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
boolean outdated;
|
||||
boolean downloaded;
|
||||
long localTimestamp;
|
||||
DownloadResourceGroup relatedGroup;
|
||||
|
||||
|
||||
public IndexItem(String fileName, String description, long timestamp, String size, long contentSize,
|
||||
|
@ -49,6 +50,14 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
public DownloadActivityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setRelatedGroup(DownloadResourceGroup relatedGroup) {
|
||||
this.relatedGroup = relatedGroup;
|
||||
}
|
||||
|
||||
public DownloadResourceGroup getRelatedGroup() {
|
||||
return relatedGroup;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
|
|||
}
|
||||
ItemViewHolder viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
IndexItem item = getItem(position);
|
||||
viewHolder.bindIndexItem(item, null);
|
||||
viewHolder.bindIndexItem(item);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ public class ItemViewHolder {
|
|||
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
|
||||
}
|
||||
|
||||
public void bindIndexItem(final IndexItem indexItem, final DownloadResourceGroup parentOptional) {
|
||||
public void bindIndexItem(final IndexItem indexItem) {
|
||||
initAppStatusVariables();
|
||||
boolean isDownloading = context.getDownloadThread().isDownloading(indexItem);
|
||||
int progress = -1;
|
||||
|
@ -248,7 +248,7 @@ public class ItemViewHolder {
|
|||
private boolean checkDisabledAndClickAction(final IndexItem item) {
|
||||
RightButtonAction clickAction = getClickAction(item);
|
||||
boolean disabled = clickAction != RightButtonAction.DOWNLOAD;
|
||||
OnClickListener action = getRightButtonAction(item, clickAction, null);
|
||||
OnClickListener action = getRightButtonAction(item, clickAction);
|
||||
if (clickAction != RightButtonAction.DOWNLOAD) {
|
||||
rightButton.setText(R.string.get_plugin);
|
||||
rightButton.setVisibility(View.VISIBLE);
|
||||
|
@ -291,7 +291,7 @@ public class ItemViewHolder {
|
|||
return clickAction;
|
||||
}
|
||||
|
||||
public OnClickListener getRightButtonAction(final IndexItem item, final RightButtonAction clickAction, final DownloadResourceGroup parentOptional) {
|
||||
public OnClickListener getRightButtonAction(final IndexItem item, final RightButtonAction clickAction) {
|
||||
if (clickAction != RightButtonAction.DOWNLOAD) {
|
||||
return new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -335,9 +335,9 @@ public class ItemViewHolder {
|
|||
context.makeSureUserCancelDownload(item);
|
||||
}
|
||||
} else if(item.isDownloaded() && !item.isOutdated()){
|
||||
contextMenu(v, item, parentOptional);
|
||||
contextMenu(v, item, item.getRelatedGroup());
|
||||
} else {
|
||||
download(item, parentOptional);
|
||||
download(item, item.getRelatedGroup());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -220,7 +220,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
} else if (obj instanceof IndexItem) {
|
||||
IndexItem indexItem = (IndexItem) obj;
|
||||
ItemViewHolder vh = (ItemViewHolder) v.getTag();
|
||||
View.OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem), null);
|
||||
View.OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
|
||||
ls.onClick(v);
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
convertView.setTag(viewHolder);
|
||||
}
|
||||
viewHolder.setShowTypeInDesc(true);
|
||||
viewHolder.bindIndexItem(item, null);
|
||||
viewHolder.bindIndexItem(item);
|
||||
} else {
|
||||
DownloadResourceGroup group = (DownloadResourceGroup) obj;
|
||||
DownloadGroupViewHolder viewHolder;
|
||||
|
|
|
@ -150,7 +150,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
|
|||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
|
||||
ItemViewHolder vh = (ItemViewHolder) v.getTag();
|
||||
OnClickListener ls = vh.getRightButtonAction(e, vh.getClickAction(e), null);
|
||||
OnClickListener ls = vh.getRightButtonAction(e, vh.getClickAction(e));
|
||||
ls.onClick(v);
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
|
|||
holder.setShowRemoteDate(true);
|
||||
holder.setShowTypeInDesc(true);
|
||||
holder.setShowParentRegionName(true);
|
||||
holder.bindIndexItem(items.get(position), null);
|
||||
holder.bindIndexItem(items.get(position));
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,9 +186,8 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
return true;
|
||||
} else if (child instanceof IndexItem) {
|
||||
IndexItem indexItem = (IndexItem) child;
|
||||
DownloadResourceGroup groupObj = listAdapter.getGroupObj(groupPosition);
|
||||
ItemViewHolder vh = (ItemViewHolder) v.getTag();
|
||||
OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem), groupObj);
|
||||
OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
|
||||
ls.onClick(v);
|
||||
return true;
|
||||
}
|
||||
|
@ -369,7 +368,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
} else {
|
||||
viewHolder.setShowTypeInDesc(true);
|
||||
}
|
||||
viewHolder.bindIndexItem(item, group);
|
||||
viewHolder.bindIndexItem(item);
|
||||
} else {
|
||||
DownloadResourceGroup group = (DownloadResourceGroup) child;
|
||||
DownloadGroupViewHolder viewHolder;
|
||||
|
|
Loading…
Reference in a new issue