Permalink
Browse files

updates + cleanup

  • Loading branch information...
1 parent 4c467fe commit d6b5aead5dace93d6c680cf3f9df2c571fb6dd84 @zeusbaba committed May 16, 2011
View
8 README
@@ -1,7 +1,11 @@
GenericStore aims to abstract usage of ObjectCache and SharedPreferences.
-I'm using this impl for FotoLIcKE, MayorMonster and ongoign Android apps -> works like a charm! :-)
+I'm using this impl for FotoFeed, MayorMonster, CheckInNINJA and ongoing Android apps -> works like a charm! :-)
p.s. I made use of Droid-Fu caching (https://github.com/kaeppler/droid-fu),
which was covering Image caching, I extended into using generic object caching too.
-
+
+clone the project from github, then import as "library", after that it is easy to include in your projects.
+
+TODO: I'll add some example code as soon as possible, in meantime feel free to ping me if you need any help
+yg at wareninja.com
@@ -17,13 +17,22 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
+import java.security.SecureRandom;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.X509TrustManager;
+
import org.apache.http.impl.cookie.DateUtils;
import android.content.Context;
@@ -45,19 +54,8 @@
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.os.Bundle;
-import android.text.TextUtils;
import android.util.Log;
-import java.security.SecureRandom;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.X509TrustManager;
-
public class WareNinjaUtils {
@@ -329,6 +327,42 @@ public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
return output;
}
+
+ /**
+ * Creates rounded bitmap
+ * @param bitmap the source bitmap
+ * @return the rounded bitmap
+ */
+ // source from: http://android-devblog.blogspot.com/2010/08/rounding-picture.html#more
+ public static Bitmap createRoundedBitmap(Bitmap bitmap, int round) {
+ if (bitmap == null) {
+ return null;
+ }
+
+ Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
+
+ // create output bitmap
+ Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
+
+ // assign canvas with output bitmap
+ Canvas canvas = new Canvas(output);
+ canvas.drawARGB(0, 0, 0, 0);
+
+ // initialize paint
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+
+ // draw rounded rect to bitmap
+ paint.setColor(0xFFFFFFFF);
+ canvas.drawRoundRect(new RectF(rect), round, round, paint);
+
+ // copy original bitmap to rounded area
+ paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
+ canvas.drawBitmap(bitmap, rect, rect, paint);
+
+ return output;
+ }
+
public static String encodeUrl(Bundle parameters) {
if (parameters == null) {
@@ -54,6 +54,21 @@ public WebService(String serviceName){
webServiceUrl = serviceName;
}
+ public WebService(){
+ HttpParams myParams = new BasicHttpParams();
+
+ HttpConnectionParams.setConnectionTimeout(myParams, 20000);
+ HttpConnectionParams.setSoTimeout(myParams, 20000);
+ httpClient = new DefaultHttpClient(myParams);
+ localContext = new BasicHttpContext();
+ }
+ public void setWebServiceUrl(String serviceName){
+ webServiceUrl = serviceName;
+ }
+ public String getWebServiceUrl(String serviceName){
+ return webServiceUrl;
+ }
+
// added by YG
public String getJsonFromParams(Map<String, Object> params) {
@@ -117,7 +132,7 @@ private String webInvoke(String methodName, String data, String contentType) {
httpPost.setEntity(tmp);
- Log.d(TAG, webServiceUrl + "?" + data);
+ if(LOGGING.DEBUG)Log.d(TAG, webServiceUrl + "?" + data);
try {
response = httpClient.execute(httpPost,localContext);
@@ -157,7 +172,7 @@ public String webGet(String methodName, Map<String, String> params) {
}
httpGet = new HttpGet(getUrl);
- Log.e(TAG, "WebGetURL: "+getUrl);
+ if(LOGGING.DEBUG)Log.d(TAG, "WebGetURL: "+getUrl);
try {
response = httpClient.execute(httpGet);
@@ -17,11 +17,6 @@
import java.util.List;
-import com.wareninja.opensource.common.WareNinjaUtils;
-import com.wareninja.opensource.droidfu.cachefu.ImageCache;
-import com.wareninja.opensource.droidfu.imageloader.ImageLoaderHandler;
-import com.wareninja.opensource.droidfu.widgets.WebImageView;
-
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
@@ -33,9 +28,13 @@
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.Gallery;
-import android.widget.ImageView;
import android.widget.Gallery.LayoutParams;
+import com.wareninja.opensource.common.WareNinjaUtils;
+import com.wareninja.opensource.droidfu.cachefu.ImageCache;
+import com.wareninja.opensource.droidfu.imageloader.ImageLoaderHandler;
+import com.wareninja.opensource.droidfu.widgets.WebImageView;
+
/**
* Can be used as an adapter for an Android {@link Gallery} view. This adapter loads the images to
@@ -23,8 +23,6 @@
import java.io.IOException;
import java.io.Serializable;
-import android.util.Log;
-
/**
* Implements a cache capable of caching Serializable objects.
* It exposes helper methods to immediately access objects
@@ -23,14 +23,13 @@
import android.content.Context;
-import android.view.View;
-import android.widget.Gallery;
-import android.widget.ImageView;
-
import android.graphics.Camera;
import android.graphics.Matrix;
import android.util.AttributeSet;
+import android.view.View;
import android.view.animation.Transformation;
+import android.widget.Gallery;
+import android.widget.ImageView;
public class CoverFlowGallery extends Gallery {
@@ -27,7 +27,6 @@
import android.widget.ViewSwitcher;
import android.widget.ImageView.ScaleType;
-import com.wareninja.opensource.common.WareNinjaUtils;
import com.wareninja.opensource.droidfu.cachefu.ImageCache;
import com.wareninja.opensource.droidfu.imageloader.ImageLoader;
import com.wareninja.opensource.droidfu.imageloader.ImageLoaderHandler;
@@ -20,17 +20,15 @@
import java.io.Serializable;
import java.util.List;
-import com.wareninja.opensource.common.LOGGING;
-import com.wareninja.opensource.common.ObjectSerializer;
-//import com.wareninja.opensource.droidfu.cachefu.ImageCache;
-import com.wareninja.opensource.droidfu.cachefu.ObjectCache;
-import com.wareninja.opensource.genericstore.ApplicationWareNinja;
-
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
+import com.wareninja.opensource.common.LOGGING;
+import com.wareninja.opensource.common.ObjectSerializer;
+import com.wareninja.opensource.droidfu.cachefu.ObjectCache;
+
public class GenericStore {
private static final String TAG = "GenericStore";

0 comments on commit d6b5aea

Please sign in to comment.