Permalink
Browse files

Merge branch 'develop' of github.com:novoda/ImageLoader into develop

  • Loading branch information...
2 parents 4885d2e + 0b96069 commit defef1381b6022455054ca351e6c4d2813090868 @friedger friedger committed Oct 1, 2012
@@ -20,8 +20,6 @@
import android.graphics.Bitmap;
import com.novoda.imageloader.core.cache.util.LruCache;
-import java.lang.reflect.Method;
-
/**
* LruBitmapCache overcome the issue with soft reference cache.
* It is in fact keeping all the certain amount of images in memory.
@@ -41,14 +39,8 @@
* @param percentageOfMemoryForCache 1-80
*/
public LruBitmapCache(Context context, int percentageOfMemoryForCache) {
- int memClass = 0;
- ActivityManager am = ((ActivityManager) context.getSystemService(
- Context.ACTIVITY_SERVICE));
- try {
- Method m = ActivityManager.class.getMethod("getMemoryClass");
- memClass = (Integer)m.invoke(am);
- } catch (Exception e) {
- }
+ int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
+
if(memClass == 0) {
memClass = DEFAULT_MEMORY_CAPACITY_FOR_DEVICES_OLDER_THAN_API_LEVEL_4;
}
@@ -75,20 +67,14 @@ public LruBitmapCache(Context context) {
}
private void reset() {
- if (cache!= null) {
+ if (cache != null) {
cache.evictAll();
}
cache = new LruCache<String, Bitmap>(capacity) {
@Override
protected int sizeOf(String key, Bitmap bitmap) {
return bitmap.getRowBytes()*bitmap.getHeight();
}
-
- @Override
- protected void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {
- oldValue.recycle();
- super.entryRemoved(evicted, key, oldValue, newValue); //To change body of overridden methods use File | Settings | File Templates.
- }
};
}
View
@@ -7,7 +7,7 @@
android:versionName="1.5.6">
<uses-sdk
- android:minSdkVersion="4"
+ android:minSdkVersion="7"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
@@ -1,6 +1,8 @@
package com.novoda.imageloader.demo;
import android.app.Application;
+import android.os.Build;
+import android.util.Log;
import com.novoda.imageloader.core.ImageManager;
import com.novoda.imageloader.core.LoaderSettings;
import com.novoda.imageloader.core.LoaderSettings.SettingsBuilder;
@@ -25,6 +27,13 @@ public void onCreate() {
* Normal image manager settings
*/
private void normalImageManagerSettings() {
+ Log.e("Test", "Current API LEVEL : " + android.os.Build.VERSION.SDK_INT);
+ Log.e("Test", "Eclair API LEVEL : " + Build.VERSION_CODES.ECLAIR);
+
+ if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.ECLAIR) {
+ Log.e("Test", "sdk is smaller");
+ }
+
imageManager = new ImageManager(this, new SettingsBuilder()
.withCacheManager(new LruBitmapCache(this))
.build(this));
@@ -20,9 +20,6 @@
private ImageManager imageManager;
private ImageTagFactory imageTagFactory;
- private boolean null_tag;
- private boolean null_url;
-
@Override
protected String getTableName() {
return LongSmallImageList.class.getSimpleName().toLowerCase();
@@ -21,10 +21,14 @@
private SimpleCursorAdapter adapter;
+ protected abstract String getTableName();
+
+ protected abstract ViewBinder getViewBinder();
+
protected int getImageItem() {
return R.layout.image_item;
}
-
+
protected void setAdapter() {
adapter = initAdapter();
ViewBinder binder = getViewBinder();
@@ -34,7 +38,7 @@ protected void setAdapter() {
getListView().setAdapter(adapter);
}
- protected SimpleCursorAdapter initAdapter() {
+ private SimpleCursorAdapter initAdapter() {
return new SimpleCursorAdapter(this, getImageItem(), getCursor(), FROM, TO);
}
@@ -43,14 +47,6 @@ private Cursor getCursor() {
null);
}
- protected abstract String getTableName();
-
- protected abstract ViewBinder getViewBinder();
-
- protected void refreshData(){
- adapter.notifyDataSetChanged();
- }
-
protected void initButtons() {
Button button = (Button) this.findViewById(R.id.refresh_button);
button.setOnClickListener(this);
@@ -79,6 +75,10 @@ public void onClick(View v) {
}
}
+ protected void refreshData(){
+ adapter.notifyDataSetChanged();
+ }
+
protected ImageTag getTag(ImageTagFactory imageTagFactory, String url) {
if (null_tag) {
return null;

0 comments on commit defef13

Please sign in to comment.