Skip to content

Commit 4195ce3

Browse files
committed
Update build file and some bug fixes
1 parent 205a6a8 commit 4195ce3

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

build.xml

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
<project default="package">
2+
<!-- Project properties -->
23
<property name="version.num" value="1.0.0" />
3-
<buildnumber file="build.num" />
4+
<property name="project" value="android-smart-image-view" />
5+
6+
<!-- Standard jar stuff -->
7+
<property name="jarfile" value="${project}-${version.num}.jar" />
48
<property name="lib.dir" value="/usr/local/android_sdk/platforms/android-7/" />
59
<property name="build.dir" value="./build"/>
610
<property name="classes.dir" value="${build.dir}/classes"/>
11+
<buildnumber file="build.num" />
712

13+
<!-- Set up classpath -->
814
<path id="classpath">
915
<fileset dir="${lib.dir}" includes="**/*.jar" />
1016
</path>
1117

18+
<!-- Compile java files into classes -->
1219
<target name="compile">
1320
<mkdir dir="${build.dir}" />
1421
<mkdir dir="${classes.dir}" />
15-
<javac srcdir="src" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false">
16-
<compilerarg value="-Xlint:unchecked"/>
17-
</javac>
22+
<javac srcdir="." destdir="${classes.dir}" classpathref="classpath" />
1823
</target>
1924

25+
<!-- Package a jar from compiled class files -->
2026
<target name="jar" depends="compile">
21-
<delete file="smart-image.jar" />
27+
<delete file="${jarfile}" />
2228
<delete file="MANIFEST.MF" />
2329
<manifest file="MANIFEST.MF">
2430
<attribute name="Built-By" value="${user.name}" />
2531
<attribute name="Implementation-Version" value="${version.num}-b${build.number}"/>
2632
</manifest>
2733

28-
<jar destfile="smart-image.jar" basedir="build/classes" includes="**/*.class" manifest="MANIFEST.MF" />
34+
<jar destfile="${jarfile}" basedir="build/classes" includes="**/*.class" manifest="MANIFEST.MF" />
2935
</target>
3036

37+
<!-- Clean out the build files -->
3138
<target name="clean">
3239
<delete dir="build" />
3340
<delete>
34-
<fileset dir="." includes="smart-image.jar*"/>
41+
<fileset dir="." includes="${jarfile}"/>
3542
<fileset file="MANIFEST.MF"/>
36-
</delete>
43+
</delete>
3744
</target>
3845

46+
<!-- Compile and package a jar -->
3947
<target name="package" depends="compile,jar" />
4048
</project>

src/com/loopj/android/image/SmartImageView.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void setImage(final SmartImage image, final Integer fallbackResource) {
6767

6868
public void setImage(final SmartImage image, final Integer fallbackResource, final Integer loadingResource) {
6969
// Set a loading resource
70-
if(loadingResource != null && getDrawable() == null){
70+
if(loadingResource != null){
7171
setImageResource(loadingResource);
7272
}
7373

@@ -97,7 +97,7 @@ public void onComplete(Bitmap bitmap) {
9797
threadPool.execute(currentTask);
9898
}
9999

100-
private static void cancelAllTasks() {
100+
public static void cancelAllTasks() {
101101
threadPool.shutdownNow();
102102
threadPool = Executors.newFixedThreadPool(LOADING_THREADS);
103103
}

src/com/loopj/android/image/WebImage.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import android.graphics.BitmapFactory;
1010

1111
public class WebImage implements SmartImage {
12-
private static final int CONNECT_TIMEOUT = 1000;
13-
private static final int READ_TIMEOUT = 1000;
12+
private static final int CONNECT_TIMEOUT = 5000;
13+
private static final int READ_TIMEOUT = 10000;
1414

1515
private static WebImageCache webImageCache;
1616

@@ -27,11 +27,14 @@ public Bitmap getBitmap(Context context) {
2727
}
2828

2929
// Try getting bitmap from cache first
30-
Bitmap bitmap = webImageCache.get(url);
31-
if(bitmap == null) {
32-
bitmap = getBitmapFromUrl(url);
33-
if(bitmap != null){
34-
webImageCache.put(url, bitmap);
30+
Bitmap bitmap = null;
31+
if(url != null) {
32+
bitmap = webImageCache.get(url);
33+
if(bitmap == null) {
34+
bitmap = getBitmapFromUrl(url);
35+
if(bitmap != null){
36+
webImageCache.put(url, bitmap);
37+
}
3538
}
3639
}
3740

src/com/loopj/android/image/WebImageCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void run() {
106106
if(diskCacheEnabled) {
107107
BufferedOutputStream ostream = null;
108108
try {
109-
ostream = new BufferedOutputStream(new FileOutputStream(new File(diskCachePath, getCacheKey(url))));
109+
ostream = new BufferedOutputStream(new FileOutputStream(new File(diskCachePath, getCacheKey(url))), 2*1024);
110110
bitmap.compress(CompressFormat.PNG, 100, ostream);
111111
} catch (FileNotFoundException e) {
112112
e.printStackTrace();

0 commit comments

Comments
 (0)