Removed second row in live updates item

This commit is contained in:
GaidamakUA 2015-12-23 15:10:14 +02:00
parent e8b3055626
commit 5ea6f5108c
3 changed files with 21 additions and 13 deletions

View file

@ -40,6 +40,7 @@
android:layout_marginRight="7dp"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:visibility="gone"
tools:text="11.1 MB"/>
<TextView

View file

@ -13,6 +13,7 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.CompoundButton;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
@ -26,7 +27,6 @@ import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.download.AbstractDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
import net.osmand.plus.resources.IncrementalChangesManager;
import net.osmand.util.Algorithms;
@ -268,6 +268,8 @@ public class LiveUpdatesFragment extends Fragment {
}
private static class LocalFullMapsViewHolder {
public static final int UPDATES_ENABLED_ITEM_HEIGHT = 72;
public static final int UPDATES_DISABLED_ITEM_HEIGHT = 50;
private final ImageView icon;
private final TextView nameTextView;
private final TextView subheaderTextView;
@ -301,6 +303,7 @@ public class LiveUpdatesFragment extends Fragment {
Algorithms.getFileNameWithoutExtension(new File(item.getFileName()));
nameTextView.setText(getNameToDisplay(item, fragment.getMyActivity()));
AbsListView.LayoutParams layoutParams = (AbsListView.LayoutParams) view.getLayoutParams();
if (shouldUpdatePreference.get()) {
final Integer frequencyId = preferenceUpdateFrequency(item, fragment.getSettings()).get();
final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId];
@ -309,20 +312,14 @@ public class LiveUpdatesFragment extends Fragment {
.getColor(R.color.osmand_orange));
icon.setImageDrawable(context.getIconsCache().getIcon(R.drawable.ic_map, R.color.osmand_orange));
options.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_overflow_menu_white));
layoutParams.height = (int) dpToPx(view.getContext(), UPDATES_ENABLED_ITEM_HEIGHT);
} else {
String size;
long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension);
updatesSize /= (1 << 10);
if (updatesSize > 100) {
size = DownloadActivity.formatMb.format(new Object[]{(float) updatesSize / (1 << 10)});
} else {
size = updatesSize + " KB";
}
subheaderTextView.setText(size);
subheaderTextView.setTextColor(secondaryColor);
subheaderTextView.setVisibility(View.GONE);
icon.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_map));
options.setImageDrawable(getSecondaryColorPaintedIcon(R.drawable.ic_action_plus));
layoutParams.height = (int) dpToPx(view.getContext(), UPDATES_DISABLED_ITEM_HEIGHT);
}
view.setLayoutParams(layoutParams);
final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension);
String formattedDate = formatDateTime(fragment.getActivity(), timestamp);
@ -388,4 +385,8 @@ public class LiveUpdatesFragment extends Fragment {
adapter.sort();
}
}
public static float dpToPx(final Context context, final float dp) {
return dp * context.getResources().getDisplayMetrics().density;
}
}

View file

@ -351,11 +351,17 @@ public class IncrementalChangesManager {
RegionUpdateFiles ruf = regions.get(fileName.toLowerCase());
for (List<RegionUpdate> regionUpdates : ruf.dayUpdates.values()) {
for (RegionUpdate regionUpdate : regionUpdates) {
regionUpdate.file.delete();
boolean successful = Algorithms.removeAllFiles(regionUpdate.file);
if (successful) {
resourceManager.closeFile(regionUpdate.file.getName());
}
}
}
for (RegionUpdate regionUpdate : ruf.monthUpdates.values()) {
regionUpdate.file.delete();
boolean successful = Algorithms.removeAllFiles(regionUpdate.file);
if (successful) {
resourceManager.closeFile(regionUpdate.file.getName());
}
}
}