[and] Germany missing icons fix.

This commit is contained in:
d-kunin 2014-02-07 15:24:07 +03:00
parent b0ee03b44e
commit 38333edd5f
9 changed files with 74 additions and 6 deletions

View file

@ -1,6 +1,6 @@
GWMvc=122
GWMvn=1.2.2
GWMpn=com.guidewithme.hawaii
GWMapk=Test GuideWithMe
GWMappName=Test GuideWithMe
GWMvc=123
GWMvn=1.2.3
GWMpn=com.guidewithme.germany
GWMapk=GuideWithMe Germany
GWMappName=GuideWithMe Germany
GWMndkFlags=propNdkFlags=V=0 NDK_DEBUG=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -2,12 +2,17 @@ package com.guidewithme.thumb;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.guidewithme.util.CollectionUtils;
import com.guidewithme.util.CollectionUtils.Predicate;
public class ZipThumbnailsProvider implements ThumbnailsProvider
{
@ -27,12 +32,29 @@ public class ZipThumbnailsProvider implements ThumbnailsProvider
}
}
@SuppressWarnings("unchecked")
@Override
public Drawable getThumbnailByUrl(String url)
{
try
{
final ZipEntry ze = mZFile.getEntry("data/thumb/" + url);
final String thumbsPrefix = "data/thumb/";
ZipEntry ze = mZFile.getEntry(thumbsPrefix + url);
if (ze == null)
{
Log.e("GWM " + mContext.getPackageName(), "null entry:" + url);
// Provide random icon in that case
final Predicate<ZipEntry> isThumbEntry = new Predicate<ZipEntry>()
{
@Override
public boolean apply(ZipEntry arg)
{
return arg.getName().startsWith(thumbsPrefix);
}
};
ze = CollectionUtils.any(CollectionUtils.filter((Enumeration<ZipEntry>)mZFile.entries(), isThumbEntry));
}
final InputStream is = mZFile.getInputStream(ze);
return new BitmapDrawable(mContext.getResources(), is);
}

View file

@ -0,0 +1,40 @@
package com.guidewithme.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
public class CollectionUtils
{
public interface Predicate<T>
{
boolean apply(T arg);
}
public static <T> List<T> filter(Collection<T> input, Predicate<T> condition)
{
final ArrayList<T> out = new ArrayList<T>(input.size());
for (final T val : input)
{
if (condition.apply(val))
out.add(val);
}
return out;
}
public static <T> List<T> filter(Enumeration<T> input, Predicate<T> condition)
{
return filter(Collections.list(input), condition);
}
public static <T> T any(List<T> input)
{
if (input.isEmpty())
throw new NoSuchElementException("Input collection is empty");
return input.get(Utils.random(input.size()));
}
}

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Random;
import android.app.Activity;
import android.content.Context;
@ -26,6 +27,11 @@ public class Utils
return view;
}
public static int random(int max)
{
return new Random().nextInt(max);
}
public static View showView(View view)
{
view.setVisibility(View.VISIBLE);