refactoring p.6: dialog preparation and update

This commit is contained in:
nazar-kutz 2021-04-16 22:19:26 +03:00
parent ae2eef75f3
commit 2f1e43147d
8 changed files with 214 additions and 192 deletions

View file

@ -12,22 +12,23 @@ import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem;
import java.util.List;
public class MultipleWithModeBottomSheet extends MultipleSelectionBottomSheet {
public class MultipleSelectionWithModeBottomSheet extends MultipleSelectionBottomSheet {
public static final String TAG = MultipleWithModeBottomSheet.class.getSimpleName();
public static final String TAG = MultipleSelectionWithModeBottomSheet.class.getSimpleName();
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
showElements(secondaryDescription, toggleContainer, checkBox,
checkBoxTitle, titleDescription, selectedSize, selectAllButton);
}
public static MultipleWithModeBottomSheet showInstance(@NonNull AppCompatActivity activity,
public static MultipleSelectionWithModeBottomSheet showInstance(@NonNull AppCompatActivity activity,
@NonNull List<SelectableItem> items,
@Nullable List<SelectableItem> selected,
@NonNull List<RadioItem> modes,
boolean usedOnMap) {
MultipleWithModeBottomSheet fragment = new MultipleWithModeBottomSheet();
MultipleSelectionWithModeBottomSheet fragment = new MultipleSelectionWithModeBottomSheet();
fragment.setUsedOnMap(usedOnMap);
fragment.setItems(items);
fragment.setSelectedItems(selected);

View file

@ -180,6 +180,10 @@ public abstract class SelectionBottomSheet extends MenuBottomSheetDialogFragment
listContainer.addView(view);
}
public List<SelectableItem> getAllItems() {
return allItems;
}
@NonNull
public abstract List<SelectableItem> getSelectedItems();

View file

@ -9,6 +9,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import java.io.File;
import java.text.DateFormat;
import java.util.List;
import java.util.Locale;
@ -55,6 +56,13 @@ public abstract class DownloadItem {
return type.getBasename(this);
}
@NonNull
public abstract List<File> getDownloadedFiles(@NonNull OsmandApplication app);
public abstract boolean isUseAbbreviation();
public abstract String getAbbreviationInScopes(Context ctx);
protected abstract double getSizeToDownloadInMb();
public abstract double getArchiveSizeMB();
@ -69,8 +77,7 @@ public abstract class DownloadItem {
public abstract String getFileName();
@NonNull
public abstract List<File> getDownloadedFiles(@NonNull OsmandApplication app);
public abstract String getDate(@NonNull DateFormat dateFormat, boolean remote);
@NonNull
public static String getFormattedMb(@NonNull Context ctx, double sizeInMb) {

View file

@ -1,5 +1,7 @@
package net.osmand.plus.download;
import android.content.Context;
import androidx.annotation.NonNull;
import net.osmand.IndexConstants;
@ -19,6 +21,7 @@ import java.util.Date;
import java.util.List;
public class IndexItem extends DownloadItem implements Comparable<IndexItem> {
private static final Log log = PlatformUtil.getLog(IndexItem.class);
String description;
@ -226,6 +229,16 @@ public class IndexItem extends DownloadItem implements Comparable<IndexItem> {
return format.format(new Date(timestamp));
}
@Override
public boolean isUseAbbreviation() {
return false;
}
@Override
public String getAbbreviationInScopes(Context ctx) {
return "";
}
public static class DownloadEntry {
public long dateModified;
public double sizeMB;
@ -254,5 +267,4 @@ public class IndexItem extends DownloadItem implements Comparable<IndexItem> {
}
}
}

View file

@ -1,5 +1,7 @@
package net.osmand.plus.download;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -7,6 +9,7 @@ import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication;
import java.io.File;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
@ -32,7 +35,7 @@ public class MultipleDownloadItem extends DownloadItem {
return indexes;
}
public List<DownloadItem> getItems() {
public List<DownloadItem> getAllItems() {
return items;
}
@ -96,19 +99,19 @@ public class MultipleDownloadItem extends DownloadItem {
return result;
}
public List<IndexItem> getIndexesToDownload() {
List<IndexItem> indexesToDownload = new ArrayList<>();
for (IndexItem item : getAllIndexes()) {
public List<DownloadItem> getItemsToDownload() {
List<DownloadItem> itemsToDownload = new ArrayList<>();
for (DownloadItem item : getAllItems()) {
if (item.hasActualDataToDownload()) {
indexesToDownload.add(item);
itemsToDownload.add(item);
}
}
return indexesToDownload;
return itemsToDownload;
}
@Override
public boolean hasActualDataToDownload() {
return getIndexesToDownload().size() > 0;
return getItemsToDownload().size() > 0;
}
@Override
@ -141,4 +144,28 @@ public class MultipleDownloadItem extends DownloadItem {
return null;
}
@Override
public boolean isUseAbbreviation() {
for (DownloadItem item : items) {
if (item.isUseAbbreviation()) {
return true;
}
}
return false;
}
@Override
public String getAbbreviationInScopes(Context ctx) {
for (DownloadItem item : items) {
return item.getAbbreviationInScopes(ctx);
}
return "";
}
@Override
public String getDate(@NonNull DateFormat dateFormat, boolean remote) {
return "";
}
}

View file

@ -5,13 +5,12 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import net.osmand.map.OsmandRegions;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.MultipleSelectionBottomSheet;
import net.osmand.plus.base.MultipleSelectionBottomSheet.SelectionUpdateListener;
import net.osmand.plus.base.ModeSelectionBottomSheet;
import net.osmand.plus.base.MultipleWithModeBottomSheet;
import net.osmand.plus.base.MultipleSelectionWithModeBottomSheet;
import net.osmand.plus.base.SelectionBottomSheet;
import net.osmand.plus.base.SelectionBottomSheet.OnApplySelectionListener;
import net.osmand.plus.base.SelectionBottomSheet.OnUiInitializedListener;
@ -24,7 +23,6 @@ import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
import static net.osmand.plus.download.MultipleDownloadItem.getIndexItem;
public class SelectIndexesUiHelper {
@ -57,221 +55,196 @@ public class SelectIndexesUiHelper {
@NonNull DateFormat df,
boolean showRemoteDate,
@NonNull ItemsToDownloadSelectedListener l) {
new SelectIndexesUiHelper(i, a, df, showRemoteDate, l).showDialogInternal();
}
private void showDialogInternal() {
if (downloadItem.getType() == SRTM_COUNTRY_FILE) {
if (downloadItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
if (downloadItem instanceof MultipleDownloadItem) {
showMultipleSrtmDialog();
showSrtmMultipleSelectionDialog();
} else {
showSingleSrtmDialog();
showSrtmModeSelectionDialog();
}
} else if (downloadItem instanceof MultipleDownloadItem) {
showBaseDialog();
showMultipleSelectionDialog();
}
}
private void showBaseDialog() {
MultipleDownloadItem multipleDownloadItem = (MultipleDownloadItem) downloadItem;
List<IndexItem> indexesToDownload = getIndexesToDownload(multipleDownloadItem);
private void showMultipleSelectionDialog() {
List<SelectableItem> allItems = new ArrayList<>();
List<SelectableItem> selectedItems = new ArrayList<>();
OsmandRegions osmandRegions = app.getRegions();
for (IndexItem indexItem : multipleDownloadItem.getAllIndexes()) {
SelectableItem selectableItem = new SelectableItem();
selectableItem.setTitle(indexItem.getVisibleName(app, osmandRegions, false));
prepareItems(allItems, selectedItems);
String size = indexItem.getSizeDescription(app);
String date = indexItem.getDate(dateFormat, showRemoteDate);
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
selectableItem.setDescription(description);
MultipleSelectionBottomSheet msDialog = MultipleSelectionBottomSheet.showInstance(
activity, allItems, selectedItems, true);
this.dialog = msDialog;
selectableItem.setIconId(indexItem.getType().getIconResource());
selectableItem.setObject(indexItem);
allItems.add(selectableItem);
if (indexesToDownload.contains(indexItem)) {
selectedItems.add(selectableItem);
}
}
final MultipleSelectionBottomSheet dialog =
MultipleSelectionBottomSheet.showInstance(activity, allItems, selectedItems, true);
dialog.setUiInitializedListener(new OnUiInitializedListener() {
msDialog.setUiInitializedListener(new OnUiInitializedListener() {
@Override
public void onUiInitialized() {
dialog.setTitle(app.getString(R.string.welmode_download_maps));
}
});
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
msDialog.setSelectionUpdateListener(new SelectionUpdateListener() {
@Override
public void onSelectionUpdate() {
updateSize(dialog, true);
updateSize();
}
});
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
msDialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
private void showSingleSrtmDialog() {
boolean baseSRTM = SrtmDownloadItem.shouldUseMetersByDefault(app);
private void showSrtmMultipleSelectionDialog() {
List<SelectableItem> allItems = new ArrayList<>();
List<SelectableItem> selectedItems = new ArrayList<>();
prepareItems(allItems, selectedItems);
SrtmDownloadItem srtmItem = (SrtmDownloadItem) ((MultipleDownloadItem)downloadItem).getAllItems().get(0);
final int selectedModeOrder = srtmItem.isUseMeters() ? 0 : 1;
final List<RadioItem> radioItems = createSrtmRadioItems();
MultipleSelectionBottomSheet msDialog = MultipleSelectionWithModeBottomSheet.showInstance(
activity, allItems, selectedItems, radioItems, true);
this.dialog = msDialog;
msDialog.setUiInitializedListener(new OnUiInitializedListener() {
@Override
public void onUiInitialized() {
dialog.setTitle(app.getString(R.string.welmode_download_maps));
dialog.setSelectedMode(radioItems.get(selectedModeOrder));
dialog.setSecondaryDescription(app.getString(R.string.srtm_download_list_help_message));
}
});
msDialog.setSelectionUpdateListener(new SelectionUpdateListener() {
@Override
public void onSelectionUpdate() {
updateSize();
}
});
msDialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
private void showSrtmModeSelectionDialog() {
SrtmDownloadItem srtmItem = (SrtmDownloadItem) downloadItem;
final int selectedModeOrder = srtmItem.isUseMeters() ? 0 : 1;
srtmItem.setUseMeters(true);
SelectableItem meterItem = createSrtmSelectableItem(srtmItem.getIndexItem());
srtmItem.setUseMeters(false);
SelectableItem feetItem = createSrtmSelectableItem(srtmItem.getIndexItem());
srtmItem.setUseMeters(baseSRTM);
final List<RadioItem> radioItems = createSrtmRadioItems();
SelectableItem preview = createSelectableItem(srtmItem);
List<RadioItem> radioItems = new ArrayList<>();
RadioItem meters = createRadioItem(meterItem, R.string.shared_string_meters);
RadioItem feet = createRadioItem(feetItem, R.string.shared_string_feets);
radioItems.add(meters);
radioItems.add(feet);
dialog = ModeSelectionBottomSheet.showInstance(activity, preview, radioItems, true);
dialog = ModeSelectionBottomSheet.showInstance(activity,
baseSRTM ? meterItem : feetItem, radioItems, true);
final RadioItem initRadio = baseSRTM ? meters : feet;
final SelectableItem initItem = baseSRTM ? meterItem : feetItem;
dialog.setUiInitializedListener(new OnUiInitializedListener() {
@Override
public void onUiInitialized() {
ModeSelectionBottomSheet dialog = (ModeSelectionBottomSheet) SelectIndexesUiHelper.this.dialog;
dialog.setTitle(app.getString(R.string.srtm_unit_format));
dialog.setPrimaryDescription(app.getString(R.string.srtm_download_single_help_message));
updateSize(dialog, false);
dialog.setSelectedMode(initRadio);
updateSize();
dialog.setSelectedMode(radioItems.get(selectedModeOrder));
}
});
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
private SelectableItem createSrtmSelectableItem(IndexItem indexItem) {
SelectableItem selectableItem = new SelectableItem();
selectableItem.setTitle(indexItem.getVisibleName(app, app.getRegions(), false));
String size = indexItem.getSizeDescription(app);
size += " " + SrtmDownloadItem.getAbbreviationInScopes(app, indexItem);
String date = indexItem.getDate(dateFormat, showRemoteDate);
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
selectableItem.setDescription(description);
selectableItem.setIconId(indexItem.getType().getIconResource());
selectableItem.setObject(indexItem);
return selectableItem;
private void prepareItems(List<SelectableItem> allItems,
List<SelectableItem> selectedItems) {
final MultipleDownloadItem multipleDownloadItem = (MultipleDownloadItem) downloadItem;
final List<DownloadItem> itemsToDownload = getItemsToDownload(multipleDownloadItem);
for (DownloadItem downloadItem : multipleDownloadItem.getAllItems()) {
SelectableItem selectableItem = createSelectableItem(downloadItem);
allItems.add(selectableItem);
if (itemsToDownload.contains(downloadItem)) {
selectedItems.add(selectableItem);
}
}
}
private RadioItem createRadioItem(final SelectableItem selectableItem, int titleId) {
private List<RadioItem> createSrtmRadioItems() {
List<RadioItem> radioItems = new ArrayList<>();
radioItems.add(createSrtmRadioBtn(R.string.shared_string_meters, true));
radioItems.add(createSrtmRadioBtn(R.string.shared_string_feets, false));
return radioItems;
}
private RadioItem createSrtmRadioBtn(int titleId,
final boolean useMeters) {
String title = Algorithms.capitalizeFirstLetter(app.getString(titleId));
RadioItem radioItem = new RadioItem(title);
radioItem.setOnClickListener(new OnRadioItemClickListener() {
@Override
public boolean onRadioItemClick(RadioItem radioItem, View view) {
((ModeSelectionBottomSheet)dialog).setItem(selectableItem);
updateSize(dialog, false);
updateDialogListItems(useMeters);
updateSize();
return true;
}
});
return radioItem;
}
private void showMultipleSrtmDialog() {
List<SelectableItem> selectedItems = new ArrayList<>();
List<IndexItem> indexesToDownload = getIndexesToDownload((MultipleDownloadItem) downloadItem);
private void updateDialogListItems(boolean useMeters) {
List<SelectableItem> items = new ArrayList<>(dialog.getAllItems());
for (SelectableItem item : items) {
DownloadItem downloadItem = (DownloadItem) item.getObject();
if (downloadItem instanceof SrtmDownloadItem) {
((SrtmDownloadItem) downloadItem).setUseMeters(useMeters);
updateSelectableItem(item, downloadItem);
}
}
dialog.setItems(items);
}
List<DownloadItem> allItems = new ArrayList<>(((MultipleDownloadItem) downloadItem).getItems());
List<SelectableItem> itemsList = new ArrayList<>();
for (DownloadItem downloadItem : allItems) {
SrtmDownloadItem srtmItem = (SrtmDownloadItem) downloadItem;
private SelectableItem createSelectableItem(DownloadItem item) {
SelectableItem selectableItem = new SelectableItem();
selectableItem.setTitle(downloadItem.getVisibleName(app, app.getRegions(), false));
updateSelectableItem(selectableItem, item);
return selectableItem;
}
private void updateSelectableItem(SelectableItem selectableItem,
DownloadItem downloadItem) {
selectableItem.setTitle(
downloadItem.getVisibleName(app, app.getRegions(), false));
String size = downloadItem.getSizeDescription(app);
size += " " + SrtmDownloadItem.getAbbreviationInScopes(app, srtmItem);
String date = srtmItem.getDate(dateFormat, showRemoteDate);
if (downloadItem.isUseAbbreviation()) {
size += " " + downloadItem.getAbbreviationInScopes(app);
}
String date = downloadItem.getDate(dateFormat, showRemoteDate);
String description = app.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, date);
selectableItem.setDescription(description);
selectableItem.setIconId(downloadItem.getType().getIconResource());
selectableItem.setObject(downloadItem);
itemsList.add(selectableItem);
if (indexesToDownload.contains(downloadItem)) {
selectedItems.add(selectableItem);
}
}
List<RadioItem> radioItems = new ArrayList<>();
RadioItem meters = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_meters)));
RadioItem feet = new RadioItem(Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_feets)));
final RadioItem selectedMode = SrtmDownloadItem.isMetersItem(downloadItem) ? meters : feet;
radioItems.add(meters);
radioItems.add(feet);
final MultipleWithModeBottomSheet dialog = MultipleWithModeBottomSheet.showInstance(
activity, itemsList, selectedItems, radioItems, true);
meters.setOnClickListener(new OnRadioItemClickListener() {
@Override
public boolean onRadioItemClick(RadioItem radioItem, View view) {
// dialog.recreateList(meterItems);
return true;
}
});
feet.setOnClickListener(new OnRadioItemClickListener() {
@Override
public boolean onRadioItemClick(RadioItem radioItem, View view) {
// dialog.recreateList(feetItems);
return true;
}
});
dialog.setUiInitializedListener(new OnUiInitializedListener() {
@Override
public void onUiInitialized() {
dialog.setTitle(app.getString(R.string.welmode_download_maps));
dialog.setSelectedMode(selectedMode);
dialog.setSecondaryDescription(app.getString(R.string.srtm_download_list_help_message));
}
});
dialog.setSelectionUpdateListener(new SelectionUpdateListener() {
@Override
public void onSelectionUpdate() {
updateSize(dialog, true);
}
});
dialog.setOnApplySelectionListener(getOnApplySelectionListener(listener));
}
private OnApplySelectionListener getOnApplySelectionListener(final ItemsToDownloadSelectedListener listener) {
return new OnApplySelectionListener() {
@Override
public void onSelectionApplied(List<SelectableItem> selectedItems) {
List<IndexItem> indexItems = new ArrayList<>();
List<IndexItem> indexes = new ArrayList<>();
for (SelectableItem item : selectedItems) {
IndexItem index = getIndexItem((DownloadItem) item.getObject());
if (index != null) {
indexItems.add(index);
indexes.add(index);
}
}
listener.onItemsToDownloadSelected(indexItems);
listener.onItemsToDownloadSelected(indexes);
}
};
}
private void updateSize(SelectionBottomSheet dialog,
boolean updateDescription) {
private void updateSize() {
double sizeToDownload = getDownloadSizeInMb(dialog.getSelectedItems());
String size = DownloadItem.getFormattedMb(app, sizeToDownload);
if (updateDescription) {
String total = app.getString(R.string.shared_string_total);
String description = app.getString(R.string.ltr_or_rtl_combine_via_colon, total, size);
dialog.setTitleDescription(description);
}
String btnTitle = app.getString(R.string.shared_string_download);
if (sizeToDownload > 0) {
btnTitle = app.getString(R.string.ltr_or_rtl_combine_via_dash, btnTitle, size);
@ -280,27 +253,23 @@ public class SelectIndexesUiHelper {
}
private double getDownloadSizeInMb(@NonNull List<SelectableItem> selectableItems) {
List<DownloadItem> downloadItems = new ArrayList<>();
double totalSizeMb = 0.0d;
for (SelectableItem i : selectableItems) {
Object obj = i.getObject();
if (obj instanceof DownloadItem) {
downloadItems.add((DownloadItem) obj);
totalSizeMb += ((DownloadItem) obj).getSizeToDownloadInMb();
}
}
double totalSizeMb = 0.0d;
for (DownloadItem item : downloadItems) {
totalSizeMb += item.getSizeToDownloadInMb();
}
return totalSizeMb;
}
private static List<IndexItem> getIndexesToDownload(MultipleDownloadItem multipleDownloadItem) {
if (multipleDownloadItem.hasActualDataToDownload()) {
private static List<DownloadItem> getItemsToDownload(MultipleDownloadItem md) {
if (md.hasActualDataToDownload()) {
// download left regions
return multipleDownloadItem.getIndexesToDownload();
return md.getItemsToDownload();
} else {
// download all regions again
return multipleDownloadItem.getAllIndexes();
return md.getAllItems();
}
}

View file

@ -38,6 +38,10 @@ public class SrtmDownloadItem extends DownloadItem {
this.useMeters = useMeters;
}
public boolean isUseMeters() {
return useMeters;
}
@Nullable
public IndexItem getIndexItem() {
for (IndexItem index : indexes) {
@ -124,6 +128,16 @@ public class SrtmDownloadItem extends DownloadItem {
return getIndexItem().getDate(dateFormat, remote);
}
@Override
public boolean isUseAbbreviation() {
return true;
}
@Override
public String getAbbreviationInScopes(Context ctx) {
return getAbbreviationInScopes(ctx, this);
}
public static boolean shouldUseMetersByDefault(@NonNull OsmandApplication app) {
MetricsConstants metricSystem = app.getSettings().METRIC_SYSTEM.get();
return metricSystem != MetricsConstants.MILES_AND_FEET;
@ -147,7 +161,9 @@ public class SrtmDownloadItem extends DownloadItem {
} else if (item instanceof SrtmDownloadItem) {
return ((SrtmDownloadItem) item).useMeters;
} else if (item instanceof MultipleDownloadItem) {
return isMetersItem(((MultipleDownloadItem) item).getItems().get(0));
for (DownloadItem downloadItem : ((MultipleDownloadItem) item).getAllItems()) {
return isMetersItem(downloadItem);
}
}
return false;
}

View file

@ -44,7 +44,6 @@ import net.osmand.plus.download.IndexItem;
import net.osmand.plus.download.SelectIndexesUiHelper;
import net.osmand.plus.download.SelectIndexesUiHelper.ItemsToDownloadSelectedListener;
import net.osmand.plus.download.MultipleDownloadItem;
import net.osmand.plus.download.SrtmDownloadItem;
import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
@ -52,11 +51,8 @@ import net.osmand.util.Algorithms;
import java.io.File;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.download.DownloadActivityType.SRTM_COUNTRY_FILE;
public class ItemViewHolder {
protected final TextView nameTextView;
@ -211,8 +207,8 @@ public class ItemViewHolder {
MultipleDownloadItem item = (MultipleDownloadItem) downloadItem;
String allRegionsHeader = context.getString(R.string.shared_strings_all_regions);
String regionsHeader = context.getString(R.string.regions);
String allRegionsCount = String.valueOf(item.getItems().size());
String leftToDownloadCount = String.valueOf(item.getIndexesToDownload().size());
String allRegionsCount = String.valueOf(item.getAllItems().size());
String leftToDownloadCount = String.valueOf(item.getItemsToDownload().size());
String header;
String count;
if (item.hasActualDataToDownload()) {
@ -231,8 +227,8 @@ public class ItemViewHolder {
count = allRegionsCount;
}
String fullDescription = context.getString(R.string.ltr_or_rtl_combine_via_colon, header, count);
if (SrtmDownloadItem.isSRTMItem(downloadItem)) {
fullDescription += " " + SrtmDownloadItem.getAbbreviationInScopes(context, item);
if (item.isUseAbbreviation()) {
fullDescription += " " + item.getAbbreviationInScopes(context);
}
if (item.hasActualDataToDownload()) {
fullDescription = context.getString(
@ -240,24 +236,14 @@ public class ItemViewHolder {
item.getSizeDescription(context));
}
descrTextView.setText(fullDescription);
} else if (downloadItem instanceof SrtmDownloadItem) {
SrtmDownloadItem item = (SrtmDownloadItem) downloadItem;
String pattern = context.getString(R.string.ltr_or_rtl_combine_via_bold_point);
String type = item.getType().getString(context);
String size = item.getSizeDescription(context)
+ " " + SrtmDownloadItem.getAbbreviationInScopes(context, item);
String date = item.getDate(dateFormat, showRemoteDate);
String fullDescription = String.format(pattern, size, date);
if (showTypeInDesc) {
fullDescription = String.format(pattern, type, fullDescription);
}
descrTextView.setText(fullDescription);
} else {
IndexItem item = (IndexItem) downloadItem;
String pattern = context.getString(R.string.ltr_or_rtl_combine_via_bold_point);
String type = item.getType().getString(context);
String size = item.getSizeDescription(context);
String date = item.getDate(dateFormat, showRemoteDate);
String type = downloadItem.getType().getString(context);
String size = downloadItem.getSizeDescription(context);
if (downloadItem.isUseAbbreviation()) {
size += " " + downloadItem.getAbbreviationInScopes(context);
}
String date = downloadItem.getDate(dateFormat, showRemoteDate);
String fullDescription = String.format(pattern, size, date);
if (showTypeInDesc) {
fullDescription = String.format(pattern, type, fullDescription);