Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

massive refactoring

  • Loading branch information...
commit 3eb7a2b120967b3dd17ea3d43aeafb7f00bc17f1 1 parent 600af23
@luigi-agosti luigi-agosti authored
Showing with 722 additions and 496 deletions.
  1. +3 −0  .gitignore
  2. +177 −0 LICENCE.txt
  3. +22 −20 README
  4. +9 −2 core/src/main/java/com/novoda/imageloader/core/BaseImageLoader.java
  5. +5 −6 core/src/main/java/com/novoda/imageloader/core/CacheManager.java
  6. +31 −36 core/src/main/java/com/novoda/imageloader/core/Settings.java
  7. +44 −0 core/src/main/java/com/novoda/imageloader/core/SettingsBuilder.java
  8. +4 −0 core/src/main/java/com/novoda/imageloader/core/cache/ImageCache.java
  9. +11 −0 core/src/main/java/com/novoda/imageloader/core/cache/MapCache.java
  10. +10 −5 core/src/main/java/com/novoda/imageloader/core/cache/NoCache.java
  11. +19 −8 core/src/main/java/com/novoda/imageloader/core/cache/SoftMapCache.java
  12. +39 −30 core/src/main/java/com/novoda/imageloader/core/file/FileUtil.java
  13. +3 −3 core/src/main/java/com/novoda/imageloader/core/service/CacheCleaner.java
  14. +3 −2 core/src/main/java/com/novoda/imageloader/core/util/BitmapUtil.java
  15. +28 −28 demo/AndroidManifest.xml
  16. +0 −10 demo/default.properties
  17. +0 −53 demo/gen/com/novoda/lib/imageloadertester/R.java
  18. +3 −6 demo/pom.xml
  19. +1 −1  demo/src/com/novoda/{lib/imageloadertester → imageloader/demo}/BaseListActivity.java
  20. +118 −0 demo/src/com/novoda/imageloader/demo/ImageLoaderDemoActivity.java
  21. +31 −0 demo/src/com/novoda/imageloader/demo/ImageLoaderDemoApplication.java
  22. +1 −1  demo/src/com/novoda/{lib/imageloadertester → imageloader/demo}/provider/CustomUriMatcher.java
  23. +2 −2 demo/src/com/novoda/{lib/imageloadertester → imageloader/demo}/provider/DatabaseManager.java
  24. +77 −0 demo/src/com/novoda/imageloader/demo/provider/ImageLoaderDemoProvider.java
  25. +66 −0 demo/src/com/novoda/imageloader/demo/provider/SqlFile.java
  26. +0 −106 demo/src/com/novoda/lib/imageloadertester/ImageLoaderTestActivity.java
  27. +0 −31 demo/src/com/novoda/lib/imageloadertester/ImageLoaderTesterApplication.java
  28. +0 −76 demo/src/com/novoda/lib/imageloadertester/provider/ImageLoaderTestProvider.java
  29. +0 −66 demo/src/com/novoda/lib/imageloadertester/provider/SqlFile.java
  30. +15 −4 pom.xml
View
3  .gitignore
@@ -3,5 +3,8 @@
**/libs
**.settings
**/target
+**/bin
+**/gen
**/*.pydevproject
.project
+release.properties
View
177 LICENCE.txt
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
View
42 README
@@ -1,12 +1,20 @@
+=========================================================
+General information
+=========================================================
ImageLoader component
-- imageLoader contains a java maven based project
-- imageLoaderTest mvn android based project to test imageLoader
-- imageLoaderDemoTest mvn android based project with robotium test
-- imageLoaderMonkeyRunner some example that take a snapshot using monkey runner
+- core contains a java maven based project
+- demo mvn android based project to test imageLoader
+- acceptance mvn android based project with robotium test
+- monkey some example that take a snapshot using monkey runner
For client project that need to include the image loader you just need the jar
you can find the jar at : https://github.com/novoda/public-mvn-repo
+
+=========================================================
+How to use the library
+=========================================================
+
If you are using maven you need to define the repo and then the dependency
<repositories>
<repository>
@@ -20,23 +28,17 @@ If you are using maven you need to define the repo and then the dependency
</repositories>
<dependency>
- <groupId>com.novoda.lib</groupId>
- <artifactId>imageloader</artifactId>
- <version>0.1.0</version>
+ <groupId>com.novoda.imageloader.core</groupId>
+ <artifactId>imageloader-core</artifactId>
+ <version>1.3.3</version>
</dependency>
+=========================================================
Working with eclipse
-REQUIREMENTS
-- better to use eclipse 3.7 and maven 3.0.3
-- Download from eclipse marketplace the maven eclipse integration (m2e) [alternatively go to http://download.eclipse.org/technology/m2e/releases]
-
-- import existing maven project and select the root of the project
-
+=========================================================
-Eclipsify is not longer necessary but if you want these are the steps
-- execute the following command in the root of the project : mvn clean eclipse:clean eclipse:eclipse install
-- from eclipse select File > Import > Existing Projects into workspace > select the root of the project (should import both of them)
-- for the android imageLoaderTester you need three more steps:
- - remove the folder target/generated-sources/r from the classpath
- - add gen folder to the classpath
- - on properties of the project select android tools > fix android setup
+better to use eclipse 3.7 and maven 3.0.3
+import core as maven project
+for acceptance and demo :
+- run : mvn clean package
+- create a new android project in eclipse
View
11 core/src/main/java/com/novoda/imageloader/core/BaseImageLoader.java
@@ -25,8 +25,7 @@
public BaseImageLoader(Context context, Settings settings) {
this.bitmapUtil = new BitmapUtil();
this.settings = settings;
- this.cacheManager = new CacheManager(this, createCache(),
- bitmapUtil.decodeImageResourceAndScaleBitmap(context, settings));
+ this.cacheManager = new CacheManager(this, initCache(context, settings));
}
@Override
@@ -97,9 +96,17 @@ public void cleanCache() {
}
protected ImageCache createCache() {
+ //TODO default image ?
return new SoftMapCache();
}
+ private ImageCache initCache(Context context, Settings settings) {
+ Bitmap b = bitmapUtil.decodeImageResourceAndScaleBitmap(context, settings);
+ ImageCache cache = createCache();
+ cache.setDefaultImage(b);
+ return cache;
+ }
+
private void sendCacheCleanUpBroadcast(Context context, long expirationPeriod) {
String path = settings.getCacheDir().getAbsolutePath();
Intent i = CacheCleaner.getCleanCacheIntent(path, expirationPeriod);
View
11 core/src/main/java/com/novoda/imageloader/core/CacheManager.java
@@ -15,7 +15,6 @@
private static final String TAG = "ImageLoader";
private ImageCache cache;
- private Bitmap defaultImage;
private PhotosLoader thread;
private Stack<Image> stack;
private ImageManager imageLoader;
@@ -30,17 +29,16 @@ public Image(String u, ImageView i) {
}
}
- public CacheManager(ImageManager imageLoader, ImageCache cache, Bitmap defaultImage) {
+ public CacheManager(ImageManager imageLoader, ImageCache cache) {
this.imageLoader = imageLoader;
this.cache = cache;
- this.defaultImage = defaultImage;
this.stack = new Stack<Image>();
thread = new PhotosLoader();
thread.setPriority(Thread.NORM_PRIORITY - 1);
}
public void push(Image p) {
- p.imageView.setImageBitmap(defaultImage);
+ p.imageView.setImageBitmap(cache.getDefaultImage());
if (TextUtils.isEmpty(p.url)) {
return;
}
@@ -103,7 +101,7 @@ public void run() {
Image image = stack.pop();
Bitmap bmp = imageLoader.getBitmap(image.url, true);
if (bmp == null) {
- bmp = defaultImage;
+ bmp = cache.getDefaultImage();
clean(image);
} else {
cache.put(image.url, bmp);
@@ -136,7 +134,7 @@ public void run() {
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
} else {
- imageView.setImageBitmap(defaultImage);
+ imageView.setImageBitmap(cache.getDefaultImage());
}
}
}
@@ -152,4 +150,5 @@ public Bitmap getImageFromCache(String url) {
public void resetCache(ImageCache cache) {
this.cache.clean();
}
+
}
View
67 core/src/main/java/com/novoda/imageloader/core/Settings.java
@@ -1,65 +1,60 @@
package com.novoda.imageloader.core;
import java.io.File;
-import java.lang.ref.SoftReference;
-
-import com.novoda.imageloader.core.file.FileUtil;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
public class Settings {
- // It is better to consider period greater than 1500 millisec
- private static final long EXPIRATION_PERIOD_DEFAULT = 7l * 24l * 3600l * 1000l;
- private static final String DEFAULT_NAME = "imagedata";
+ private static final long DEFAULT_EXPIRATION_PERIOD = 7l * 24l * 3600l * 1000l;
+
private File cacheDir;
- private File phoneCacheDir;
- //String packageName = context.getApplicationContext().getPackageName();
- //android.os.Environment.getExternalStorageDirectory()
+
+ private long expirationPeriod;
private int imageHeight;
private int imageWidth;
private int defaultImageId;
- private long expirationPeriod;
- private String relativePath;
- private SoftReference<Bitmap> defaultBitmap;
+
+ public Settings() {
+ this.expirationPeriod = DEFAULT_EXPIRATION_PERIOD;
+ }
+
+ public File getCacheDir() {
+ return cacheDir;
+ }
+
+ public void setCacheDir(File cacheDir) {
+ this.cacheDir = cacheDir;
+ }
- public Settings(FileUtil fileUtil, File phoneCacheDir, String relativePath, int imageHeight, int imageWidth, int defaultImageId,
- long fileCacheExpirationPeriod) {
+ public int getImageHeight() {
+ return imageHeight;
+ }
+
+ public void setImageHeight(int imageHeight) {
this.imageHeight = imageHeight;
- this.imageWidth = imageWidth;
- this.expirationPeriod = fileCacheExpirationPeriod;
- this.defaultImageId = defaultImageId;
- this.relativePath = relativePath;
- this.cacheDir = fileUtil.prepareCacheDir(phoneCacheDir, relativePath);
}
public int getImageWidth() {
return imageWidth;
}
- public int getImageHeight() {
- return imageHeight;
+ public void setImageWidth(int imageWidth) {
+ this.imageWidth = imageWidth;
}
- public File getCacheDir() {
- return cacheDir;
+ public int getDefaultImageId() {
+ return defaultImageId;
+ }
+
+ public void setDefaultImageId(int defaultImageId) {
+ this.defaultImageId = defaultImageId;
}
public long getExpirationPeriod() {
return expirationPeriod;
}
- public Bitmap getDefaultBitmap(Context context) {
- if (defaultBitmap != null) {
- return defaultBitmap.get();
- }
- Bitmap b = BitmapFactory.decodeResource(context.getResources(), defaultImageId);
- defaultBitmap = new SoftReference<Bitmap>(b);
- return b;
+ public void setExpirationPeriod(long expirationPeriod) {
+ this.expirationPeriod = expirationPeriod;
}
-
-
}
View
44 core/src/main/java/com/novoda/imageloader/core/SettingsBuilder.java
@@ -0,0 +1,44 @@
+package com.novoda.imageloader.core;
+
+import android.content.Context;
+import android.view.Display;
+import android.view.WindowManager;
+
+import com.novoda.imageloader.core.file.FileUtil;
+
+public class SettingsBuilder {
+
+ private Settings settings;
+ private boolean isSizeSet = false;
+
+ public SettingsBuilder() {
+ settings = new Settings();
+ }
+
+ public SettingsBuilder setImageSize(int height, int width) {
+ settings.setImageHeight(height);
+ settings.setImageWidth(width);
+ isSizeSet = true;
+ return this;
+ }
+
+ public SettingsBuilder setDefaultImageId(int defaultImageId) {
+ settings.setDefaultImageId(defaultImageId);
+ return this;
+ }
+
+ public Settings build(Context context){
+ settings.setCacheDir(new FileUtil().prepareCacheDirectory(context));
+ if(!isSizeSet) {
+ setDisplayImageSize(context);
+ }
+ return settings;
+ }
+
+ private void setDisplayImageSize(Context context) {
+ Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
+ .getDefaultDisplay();
+ settings.setImageHeight(display.getHeight());
+ settings.setImageWidth(display.getWidth());
+ }
+}
View
4 core/src/main/java/com/novoda/imageloader/core/cache/ImageCache.java
@@ -11,5 +11,9 @@
void put(String url, Bitmap bmp);
void clean();
+
+ Bitmap getDefaultImage();
+
+ void setDefaultImage(Bitmap defaultImage);
}
View
11 core/src/main/java/com/novoda/imageloader/core/cache/MapCache.java
@@ -7,6 +7,7 @@
public class MapCache implements ImageCache {
private HashMap<String, Bitmap> cache = new HashMap<String, Bitmap>();
+ private Bitmap defaultImage;
@Override
public boolean hasImage(String url) {
@@ -28,4 +29,14 @@ public void clean() {
cache.clear();
}
+ @Override
+ public Bitmap getDefaultImage() {
+ return defaultImage;
+ }
+
+ @Override
+ public void setDefaultImage(Bitmap defaultImage) {
+ this.defaultImage = defaultImage;
+ }
+
}
View
15 core/src/main/java/com/novoda/imageloader/core/cache/NoCache.java
@@ -6,25 +6,30 @@
@Override
public boolean hasImage(String url) {
- // TODO Auto-generated method stub
return false;
}
@Override
public Bitmap get(String url) {
- // TODO Auto-generated method stub
return null;
}
@Override
public void put(String url, Bitmap bmp) {
- // TODO Auto-generated method stub
-
}
@Override
public void clean() {
- // TODO
+ }
+
+ @Override
+ public Bitmap getDefaultImage() {
+ return null;
+ }
+
+ @Override
+ public void setDefaultImage(Bitmap defaultImage) {
+
}
}
View
27 core/src/main/java/com/novoda/imageloader/core/cache/SoftMapCache.java
@@ -8,25 +8,26 @@
public class SoftMapCache implements ImageCache {
private HashMap<String, SoftReference<Bitmap>> cache = new HashMap<String, SoftReference<Bitmap>>();
+ private Bitmap defaultImage;
@Override
public boolean hasImage(String url) {
- if (cache.containsKey(url)) {
- if (cache.get(url) != null) {
- return true;
- }
+ if (!cache.containsKey(url)) {
return false;
}
- return false;
+ if (cache.get(url) == null) {
+ return false;
+ }
+ return true;
}
@Override
public Bitmap get(String url) {
SoftReference<Bitmap> bmpr = cache.get(url);
- if (bmpr != null) {
- return bmpr.get();
+ if (bmpr == null) {
+ return null;
}
- return null;
+ return bmpr.get();
}
@Override
@@ -39,4 +40,14 @@ public void clean() {
cache.clear();
}
+ @Override
+ public Bitmap getDefaultImage() {
+ return defaultImage;
+ }
+
+ @Override
+ public void setDefaultImage(Bitmap defaultImage) {
+ this.defaultImage = defaultImage;
+ }
+
}
View
69 core/src/main/java/com/novoda/imageloader/core/file/FileUtil.java
@@ -10,13 +10,14 @@
import java.io.OutputStream;
import java.net.URL;
+import android.content.Context;
import android.util.Log;
public class FileUtil {
- private static final String TAG = "ImageLoader";
-
private static final String NOMEDIA_FILE_NAME = ".nomedia";
+ private static final String DEFAULT_IMAGE_FOLDER_NAME = "/imagedata";
+ private static final String TAG = "ImageLoader";
public void retrieveImage(String url, File f) {
InputStream is = null;
@@ -80,25 +81,6 @@ public boolean reduceFileCache(String cacheDirFullPath, long expirationPeriod) {
return true;
}
- public boolean isMounted() {
- if (android.os.Environment.getExternalStorageState().equals(
- android.os.Environment.MEDIA_MOUNTED)) {
- return true;
- }
- return false;
- }
-
- public File getExternalStorageDirectory() {
- return android.os.Environment.getExternalStorageDirectory();
- }
-
- public void createNomediaFile(File dir) {
- try {
- new File(dir, NOMEDIA_FILE_NAME).createNewFile();
- } catch (Exception e) {
- }
- }
-
public void copy(File src, File dst) {
InputStream in = null;
OutputStream out = null;
@@ -118,17 +100,44 @@ public void copy(File src, File dst) {
}
}
- public File prepareCacheDir(File phoneCacheDir, String relativePath) {
- File cacheDir = null;
- if (isMounted()) {
- cacheDir = new File(getExternalStorageDirectory(), relativePath);
+ public File prepareCacheDirectory(Context context) {
+ File dir = null;
+ if(!isMounted()) {
+ dir = preparePhoneCacheDir(context);
} else {
- cacheDir = phoneCacheDir;
+ dir = prepareExternalCacheDir(context);
}
- if (!cacheDir.exists()) {
- cacheDir.mkdirs();
- new FileUtil().createNomediaFile(cacheDir);
+ addNomediaFile(dir);
+ return dir;
+ }
+
+ private File prepareExternalCacheDir(Context context) {
+ String relativepath = context.getPackageName() + DEFAULT_IMAGE_FOLDER_NAME;
+ File file = new File(android.os.Environment.getExternalStorageDirectory(), relativepath);
+ if (!file.isDirectory()) {
+ file.mkdirs();
}
- return cacheDir;
+ return file;
}
+
+ private File preparePhoneCacheDir(Context context) {
+ return context.getCacheDir();
+ }
+
+ private boolean isMounted() {
+ if (android.os.Environment.getExternalStorageState().equals(
+ android.os.Environment.MEDIA_MOUNTED)) {
+ return true;
+ }
+ return false;
+ }
+
+ private void addNomediaFile(File dir) {
+ try {
+ new File(dir, NOMEDIA_FILE_NAME).createNewFile();
+ } catch(Exception e) {
+ //Don't care if doesn't save the file
+ }
+ }
+
}
View
6 core/src/main/java/com/novoda/imageloader/core/service/CacheCleaner.java
@@ -8,9 +8,9 @@
public class CacheCleaner extends IntentService {
- public static final String CLEAN_CACHE_ACTION = "com.novoda.lib.imageloader.action.CLEAN_CACHE";
- public static final String EXPIRATION_PERIOD_EXTRA = "com.novoda.lib.imageloader.extra.EXPIRATION_PERIOD";
- public static final String CACHE_DIR_EXTRA = "com.novoda.lib.imageloader.extra.CACHE_DIR";
+ public static final String CLEAN_CACHE_ACTION = "com.novoda.imageloader.core.action.CLEAN_CACHE";
+ public static final String EXPIRATION_PERIOD_EXTRA = "com.novoda.imageloader.core.extra.EXPIRATION_PERIOD";
+ public static final String CACHE_DIR_EXTRA = "com.novoda.imageloader.core.extra.CACHE_DIR";
public static final Intent getCleanCacheIntent(String directoryFullPath, long expirationPeriod) {
Intent i = new Intent(CLEAN_CACHE_ACTION);
View
5 core/src/main/java/com/novoda/imageloader/core/util/BitmapUtil.java
@@ -46,8 +46,9 @@ public Bitmap scaleBitmap(Bitmap b, int width, int height) {
}
public Bitmap decodeImageResourceAndScaleBitmap(Context context, Settings settings) {
- return scaleBitmap(settings.getDefaultBitmap(context), settings.getImageWidth(),
- settings.getImageHeight());
+ Bitmap image = BitmapFactory.decodeResource(context.getResources(),
+ settings.getDefaultImageId());
+ return scaleBitmap(image, settings.getImageWidth(), settings.getImageHeight());
}
}
View
56 demo/AndroidManifest.xml
@@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
- package="com.novoda.lib.imageloadertester"
- a:versionCode="1"
- a:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
- <uses-sdk a:minSdkVersion="8" />
- <uses-sdk a:targetSdkVersion="8" />
+ package="com.novoda.imageloader.demo" a:versionCode="1" a:versionName="1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-sdk a:minSdkVersion="8" />
+ <uses-sdk a:targetSdkVersion="8" />
- <application a:icon="@drawable/icon" a:label="@string/app_name" a:name=".ImageLoaderTesterApplication">
- <activity a:name=".ImageLoaderTestActivity" a:theme="@android:style/Theme.NoTitleBar">
- <intent-filter>
- <action a:name="android.intent.action.MAIN" />
- <category a:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <provider
- a:name=".provider.ImageLoaderTestProvider"
- a:authorities="com.novoda.imageloadertest" />
+ <application a:icon="@drawable/icon" a:label="@string/app_name"
+ a:name=".ImageLoaderDemoApplication">
+ <activity a:name=".ImageLoaderDemoActivity" a:theme="@android:style/Theme.NoTitleBar">
+ <intent-filter>
+ <action a:name="android.intent.action.MAIN" />
+ <category a:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
- <service a:name="com.novoda.lib.imageloader.service.CacheCleaner" a:exported="true">
- <intent-filter>
- <action a:name="com.novoda.lib.imageloader.action.REDUCE_CACHE" />
- </intent-filter>
- <intent-filter>
- <action a:name="com.novoda.lib.imageloader.action.CLEAN_CACHE" />
- </intent-filter>
- </service>
- </application>
-
- <uses-permission a:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission a:name="android.permission.INTERNET" />
+ <provider a:name=".provider.ImageLoaderDemoProvider"
+ a:authorities="com.novoda.imageloaderdemo" />
+
+ <service a:name="com.novoda.imageloader.core.service.CacheCleaner"
+ a:exported="true">
+ <intent-filter>
+ <action a:name="com.novoda.imageloader.core.action.REDUCE_CACHE" />
+ </intent-filter>
+ <intent-filter>
+ <action a:name="com.novoda.imageloader.core.action.CLEAN_CACHE" />
+ </intent-filter>
+ </service>
+ </application>
+
+ <uses-permission a:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission a:name="android.permission.INTERNET" />
</manifest>
View
10 demo/default.properties
@@ -1,11 +1 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
target=android-8
View
53 demo/gen/com/novoda/lib/imageloadertester/R.java
@@ -1,53 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.novoda.lib.imageloadertester;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int bg_header=0x7f020000;
- public static final int bg_img_loading=0x7f020001;
- public static final int icon=0x7f020002;
- }
- public static final class id {
- public static final int clear_cache_btn=0x7f060001;
- public static final int clear_sd_btn=0x7f060002;
- public static final int list_item=0x7f060004;
- public static final int list_item_image=0x7f060005;
- public static final int new_activity_btn=0x7f060000;
- public static final int reduce_sd_btn=0x7f060003;
- }
- public static final class layout {
- public static final int action_bar=0x7f030000;
- public static final int image_item=0x7f030001;
- public static final int main=0x7f030002;
- }
- public static final class string {
- public static final int app_name=0x7f040000;
- public static final int btn_activity=0x7f040001;
- public static final int btn_clear_cache=0x7f040002;
- public static final int btn_clear_sd=0x7f040003;
- public static final int btn_reduce_sd=0x7f040004;
- }
- public static final class style {
- /** Generic styles
- */
- public static final int Fill=0x7f050001;
- public static final int Fill_VerticalOrientation=0x7f050002;
- public static final int FillHorizontaly=0x7f050003;
- public static final int FillHorizontaly_VerticalOrientation=0x7f050004;
- /** Theme
- */
- public static final int Virtualboard=0x7f050000;
- public static final int Wrap=0x7f050005;
- /** Styles for bar
- */
- public static final int Wrap_ButtonText=0x7f050006;
- }
-}
View
9 demo/pom.xml
@@ -19,15 +19,12 @@
<scope>provided</scope>
</dependency>
<dependency>
- <!-- <groupId>com.novoda.imageloader</groupId> <artifactId>imageloader-core</artifactId>
- <version>1.3.3-SNAPSHOT</version> -->
- <groupId>com.novoda.lib</groupId>
- <artifactId>imageloader</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <groupId>com.novoda.imageloader</groupId>
+ <artifactId>imageloader-core</artifactId>
+ <version>1.3.3-SNAPSHOT</version>
</dependency>
</dependencies>
-
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
View
2  ...ovoda/lib/imageloadertester/BaseListActivity.java → ...com/novoda/imageloader/demo/BaseListActivity.java
@@ -1,4 +1,4 @@
-package com.novoda.lib.imageloadertester;
+package com.novoda.imageloader.demo;
import android.app.ListActivity;
View
118 demo/src/com/novoda/imageloader/demo/ImageLoaderDemoActivity.java
@@ -0,0 +1,118 @@
+package com.novoda.imageloader.demo;
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SimpleCursorAdapter;
+import android.widget.SimpleCursorAdapter.ViewBinder;
+
+import com.novoda.imageloader.core.ImageManager;
+
+public class ImageLoaderDemoActivity extends BaseListActivity {
+
+ private static final String[] FROM = new String[] { "url" };
+ private static final int[] TO = new int[] { R.id.list_item_image };
+ private static final Uri URI = Uri.parse("content://com.novoda.imageloadertest/image");
+
+ // TODO add this to your class
+ private ImageManager imageLoader;
+ //
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ // TODO add this to your class
+ imageLoader = ImageLoaderDemoApplication.getImageLoader();
+ //
+ setAdapter();
+ setNewActivityButton();
+ setClearCacheButton();
+ setClearFileCache();
+ setReduceFileCache();
+ }
+
+ private ViewBinder getViewBinder() {
+ return new ViewBinder() {
+ @Override
+ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
+ try {
+ ((ImageView) view).setTag(cursor.getString(columnIndex));
+ // TODO add this to your class
+ imageLoader.load(cursor.getString(columnIndex), ImageLoaderDemoActivity.this,
+ (ImageView) view);
+ //
+ } catch (Exception e) {
+ Log.e("ImageLoader", "exception : " + e.getMessage());
+ }
+ return true;
+ }
+ };
+ }
+
+ private SimpleCursorAdapter initAdapter() {
+ return new SimpleCursorAdapter(this, R.layout.image_item, getCursor(), FROM, TO);
+ }
+
+ private Cursor getCursor() {
+ return managedQuery(URI, null, null, null, null);
+ }
+
+ private void setAdapter() {
+ SimpleCursorAdapter adapter = initAdapter();
+ ListView lv = getListView();
+ ViewBinder binder = getViewBinder();
+ if (binder != null) {
+ adapter.setViewBinder(binder);
+ }
+ lv.setAdapter(adapter);
+ }
+
+ private void setReduceFileCache() {
+ Button reduceFileCache = (Button) findViewById(R.id.reduce_sd_btn);
+ reduceFileCache.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ imageLoader.reduceFileCache(getApplicationContext());
+ }
+ });
+ }
+
+ private void setClearFileCache() {
+ Button clearFileCache = (Button) findViewById(R.id.clear_sd_btn);
+ clearFileCache.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ imageLoader.deleteFileCache(getApplicationContext());
+ }
+ });
+ }
+
+ private void setClearCacheButton() {
+ Button clearCache = (Button) findViewById(R.id.clear_cache_btn);
+ clearCache.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ imageLoader.cleanCache();
+ }
+ });
+ }
+
+ private void setNewActivityButton() {
+ Button newActivity = (Button) findViewById(R.id.new_activity_btn);
+ newActivity.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(new Intent(ImageLoaderDemoActivity.this, ImageLoaderDemoActivity.class));
+ }
+ });
+ }
+
+}
View
31 demo/src/com/novoda/imageloader/demo/ImageLoaderDemoApplication.java
@@ -0,0 +1,31 @@
+package com.novoda.imageloader.demo;
+
+import android.app.Application;
+
+import com.novoda.imageloader.core.BaseImageLoader;
+import com.novoda.imageloader.core.ImageManager;
+import com.novoda.imageloader.core.Settings;
+import com.novoda.imageloader.core.SettingsBuilder;
+
+public class ImageLoaderDemoApplication extends Application {
+
+ // TODO add this to your class
+ private static ImageManager imageLoader;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ // TODO add this to your classs
+ SettingsBuilder builder = new SettingsBuilder();
+ builder.setDefaultImageId(R.drawable.bg_img_loading);
+ Settings settings = builder.build(this);
+ imageLoader = new BaseImageLoader(this, settings);
+ //
+ }
+
+ // TODO add this to your class
+ public static ImageManager getImageLoader() {
+ return imageLoader;
+ }
+
+}
View
2  .../imageloadertester/provider/CustomUriMatcher.java → ...a/imageloader/demo/provider/CustomUriMatcher.java
@@ -1,4 +1,4 @@
-package com.novoda.lib.imageloadertester.provider;
+package com.novoda.imageloader.demo.provider;
import android.content.UriMatcher;
import android.net.Uri;
View
4 ...b/imageloadertester/provider/DatabaseManager.java → ...da/imageloader/demo/provider/DatabaseManager.java
@@ -1,4 +1,4 @@
-package com.novoda.lib.imageloadertester.provider;
+package com.novoda.imageloader.demo.provider;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -15,7 +15,7 @@
private Context context;
public DatabaseManager(Context context) {
- super(context, "com.novoda.imageloadertest", null, 13);
+ super(context, "com.novoda.imageloaderdemo", null, 13);
this.context = context;
}
View
77 demo/src/com/novoda/imageloader/demo/provider/ImageLoaderDemoProvider.java
@@ -0,0 +1,77 @@
+package com.novoda.imageloader.demo.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.util.Log;
+
+public class ImageLoaderDemoProvider extends ContentProvider {
+
+ private CustomUriMatcher matcher = new CustomUriMatcher();
+ private DatabaseManager databaseManager;
+ private SQLiteDatabase database;
+
+ protected SQLiteDatabase getDataBase() {
+ if (database == null) {
+ databaseManager = new DatabaseManager(getContext());
+ database = databaseManager.getWritableDatabase();
+ }
+ return database;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ String type = null;
+ switch (matcher.match(uri)) {
+ case CustomUriMatcher.IMAGE_INCOMING_COLLECTION: {
+ type = CustomUriMatcher.IMAGE_COLLECTION_TYPE;
+ break;
+ }
+ default: {
+ Log.e("ImageLoader", "Problem with query, not Implemented for : " + uri);
+ throw new RuntimeException("Problem with query, not Implemented for : " + uri);
+ }
+ }
+ return type;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return false;
+ }
+
+ @Override
+ public int delete(Uri arg0, String arg1, String[] arg2) {
+ return 0;
+ }
+
+ @Override
+ public Uri insert(Uri arg0, ContentValues arg1) {
+ return null;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ Cursor cursor;
+ switch (matcher.match(uri)) {
+ case CustomUriMatcher.IMAGE_INCOMING_COLLECTION: {
+ cursor = getDataBase().query("image", projection, selection, selectionArgs, null, null,
+ sortOrder);
+ break;
+ }
+ default: {
+ Log.e("ImageLoader", "Problem with query, not Implemented for : " + uri);
+ throw new RuntimeException("Problem with query, not Implemented for : " + uri);
+ }
+ }
+ return cursor;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}
View
66 demo/src/com/novoda/imageloader/demo/provider/SqlFile.java
@@ -0,0 +1,66 @@
+package com.novoda.imageloader.demo.provider;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SqlFile {
+
+ private BufferedReader reader;
+
+ private List<String> statements;
+
+ private boolean inComment = false;
+
+ public void parse(Reader in) throws IOException {
+ reader = new BufferedReader(in);
+ statements = new ArrayList<String>();
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ line.trim();
+ if (line.length() == 0) {
+ continue;
+ }
+ if (line.startsWith("--"))
+ continue;
+
+ if (line.startsWith("/*")) {
+ inComment = true;
+ continue;
+ }
+
+ if (line.endsWith("*/") && inComment == true) {
+ inComment = false;
+ continue;
+ }
+
+ if (inComment == true)
+ continue;
+
+ statements.add(line);
+ }
+ reader.close();
+ }
+
+ public List<String> getStatements() {
+ return statements;
+ }
+
+ public static List<String> statementsFrom(Reader reader) throws IOException {
+ SqlFile file = new SqlFile();
+ file.parse(reader);
+ return file.getStatements();
+ }
+
+ public static List<String> statementsFrom(File sqlfile) throws IOException {
+ FileReader reader = new FileReader(sqlfile);
+ SqlFile file = new SqlFile();
+ file.parse(reader);
+ return file.getStatements();
+ }
+
+}
View
106 demo/src/com/novoda/lib/imageloadertester/ImageLoaderTestActivity.java
@@ -1,106 +0,0 @@
-package com.novoda.lib.imageloadertester;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.SimpleCursorAdapter;
-import android.widget.SimpleCursorAdapter.ViewBinder;
-
-import com.novoda.lib.imageloader.ImageManager;
-
-public class ImageLoaderTestActivity extends BaseListActivity {
-
- private static final String[] FROM = new String[] {"url"};
- private static final int[] TO = new int[] {R.id.list_item_image};
- private static final Uri URI = Uri.parse("content://com.novoda.imageloadertest/image");
-
- //TODO add this to your class
- private ImageManager imageLoader;
- //
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- //TODO add this to your class
- imageLoader = ImageLoaderTesterApplication.getImageLoader();
- //
-
- SimpleCursorAdapter adapter = initAdapter();
- ListView lv = getListView();
- ViewBinder binder = getViewBinder();
- if(binder != null) {
- adapter.setViewBinder(binder);
- }
- lv.setAdapter(adapter);
-
-
- Button newActivity = (Button)findViewById(R.id.new_activity_btn);
- newActivity.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(ImageLoaderTestActivity.this, ImageLoaderTestActivity.class));
- }
- });
-
- Button clearCache = (Button)findViewById(R.id.clear_cache_btn);
- clearCache.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- imageLoader.cleanCache();
- }
- });
-
- Button clearFileCache = (Button)findViewById(R.id.clear_sd_btn);
- clearFileCache.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- imageLoader.deleteFileCache(getApplicationContext());
- }
- });
-
- Button reduceFileCache = (Button)findViewById(R.id.reduce_sd_btn);
- reduceFileCache.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- imageLoader.reduceFileCache(getApplicationContext());
- }
- });
- }
-
- private ViewBinder getViewBinder() {
- return new ViewBinder() {
- @Override
- public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
- try {
- ((ImageView) view).setTag(cursor.getString(columnIndex));
-
- //TODO add this to your class
- imageLoader.load(cursor.getString(columnIndex),
- ImageLoaderTestActivity.this, (ImageView) view);
- //
- } catch(Exception e) {
- Log.e("ImageLoader", "exception : " + e.getMessage());
- }
- return true;
- }
- };
- }
-
- private SimpleCursorAdapter initAdapter() {
- return new SimpleCursorAdapter(this, R.layout.image_item, getCursor(), FROM, TO);
- }
-
- private Cursor getCursor() {
- return managedQuery(URI, null, null, null, null);
- }
-
-}
View
31 demo/src/com/novoda/lib/imageloadertester/ImageLoaderTesterApplication.java
@@ -1,31 +0,0 @@
-package com.novoda.lib.imageloadertester;
-
-import android.app.Application;
-import android.content.Context;
-import android.view.Display;
-import android.view.WindowManager;
-
-import com.novoda.lib.imageloader.BaseImageLoader;
-import com.novoda.lib.imageloader.ImageManager;
-import com.novoda.lib.imageloader.Settings;
-
-public class ImageLoaderTesterApplication extends Application {
-
- //TODO add this to your class
- private static ImageManager imageLoader;
-
- @Override
- public void onCreate() {
- super.onCreate();
- //TODO add this to your classs
- Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
- Settings settings = new Settings(this, display.getHeight(), display.getWidth(), R.drawable.bg_img_loading);
- imageLoader = new BaseImageLoader(this, settings);
- //
- }
-
- //TODO add this to your class
- public static ImageManager getImageLoader() {
- return imageLoader;
- }
-}
View
76 demo/src/com/novoda/lib/imageloadertester/provider/ImageLoaderTestProvider.java
@@ -1,76 +0,0 @@
-package com.novoda.lib.imageloadertester.provider;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.util.Log;
-
-public class ImageLoaderTestProvider extends ContentProvider {
-
- private CustomUriMatcher matcher = new CustomUriMatcher();
- private DatabaseManager databaseManager;
- private SQLiteDatabase database;
-
- protected SQLiteDatabase getDataBase() {
- if (database == null) {
- databaseManager = new DatabaseManager(getContext());
- database = databaseManager.getWritableDatabase();
- }
- return database;
- }
-
- @Override
- public String getType(Uri uri) {
- String type = null;
- switch (matcher.match(uri)) {
- case CustomUriMatcher.IMAGE_INCOMING_COLLECTION: {
- type = CustomUriMatcher.IMAGE_COLLECTION_TYPE;
- break;
- }
- default: {
- Log.e("ImageLoader", "Problem with query, not Implemented for : " + uri);
- throw new RuntimeException("Problem with query, not Implemented for : " + uri);
- }
- }
- return type;
- }
-
- @Override
- public boolean onCreate() {
- return false;
- }
-
- @Override
- public int delete(Uri arg0, String arg1, String[] arg2) {
- return 0;
- }
-
- @Override
- public Uri insert(Uri arg0, ContentValues arg1) {
- return null;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- Cursor cursor;
- switch (matcher.match(uri)) {
- case CustomUriMatcher.IMAGE_INCOMING_COLLECTION: {
- cursor = getDataBase().query("image", projection, selection,
- selectionArgs, null, null, sortOrder);
- break;
- }
- default: {
- Log.e("ImageLoader", "Problem with query, not Implemented for : " + uri);
- throw new RuntimeException("Problem with query, not Implemented for : " + uri);
- }
- }
- return cursor;
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- return 0;
- }
-}
View
66 demo/src/com/novoda/lib/imageloadertester/provider/SqlFile.java
@@ -1,66 +0,0 @@
-package com.novoda.lib.imageloadertester.provider;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-public class SqlFile {
-
- private BufferedReader reader;
-
- private List<String> statements;
-
- private boolean inComment = false;
-
- public void parse(Reader in) throws IOException {
- reader = new BufferedReader(in);
- statements = new ArrayList<String>();
- String line = null;
- while ((line = reader.readLine()) != null) {
- line.trim();
- if (line.length() == 0) {
- continue;
- }
- if (line.startsWith("--"))
- continue;
-
- if (line.startsWith("/*")) {
- inComment = true;
- continue;
- }
-
- if (line.endsWith("*/") && inComment == true) {
- inComment = false;
- continue;
- }
-
- if (inComment == true)
- continue;
-
- statements.add(line);
- }
- reader.close();
- }
-
- public List<String> getStatements() {
- return statements;
- }
-
- public static List<String> statementsFrom(Reader reader) throws IOException {
- SqlFile file = new SqlFile();
- file.parse(reader);
- return file.getStatements();
- }
-
- public static List<String> statementsFrom(File sqlfile) throws IOException {
- FileReader reader = new FileReader(sqlfile);
- SqlFile file = new SqlFile();
- file.parse(reader);
- return file.getStatements();
- }
-
-}
View
19 pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.novoda</groupId>
@@ -10,13 +11,23 @@
<artifactId>imageloader-parent</artifactId>
<version>1.3.3-SNAPSHOT</version>
<name>imageloader-parent</name>
- <url />
<packaging>pom</packaging>
<properties>
<android.version>2.2.1</android.version>
</properties>
+ <repositories>
+ <repository>
+ <id>public-mvn-repo-snapshots</id>
+ <url>https://github.com/novoda/public-mvn-repo/raw/master/snapshots</url>
+ </repository>
+ <repository>
+ <id>public-mvn-repo-releases</id>
+ <url>https://github.com/novoda/public-mvn-repo/raw/master/releases</url>
+ </repository>
+ </repositories>
+
<scm>
<url>http://github.com/novoda/ImageLoader/tree/${scm.branch}</url>
<connection>scm:git:git://github.com/novoda/ImageLoader.git</connection>
@@ -53,8 +64,8 @@
<modules>
<module>core</module>
- <module>demo</module>
- <module>acceptance</module>
+ <module>demo</module>
+ <module>acceptance</module>
<!-- <module>monkey</module> -->
</modules>
Please sign in to comment.
Something went wrong with that request. Please try again.