Code Monkey home page Code Monkey logo

droid-fu's People

Contributors

abombss avatar bartvandendriessche avatar bramp avatar cklossek avatar jwpage avatar michaelengland avatar mttkay avatar ppicazo avatar ysamlan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

droid-fu's Issues

Loading spinner graphic plays indefinetly after failing to retrieve graphic

The loading spinner should offer a fallback plan for a default if the graphic cannot be sourced correctly. At the moment I have a list of images and sometimes the graphic fails to load which I can observe from the log but to a user they wrongly will believe that the graphic is still attempting to load.

Use app cache for caching

Droid-Fu uses the app data storage for caching images.

Any way to have it use the app's cache, so that users can manage (read: clear) the app cache without affecting settings, etc.?

Handle ImageCache Exceptions Better

I am getting the following errors in my application which appear to be cache misses. The AbstractCache should better handle more exceptions so users don't experience a force a close.

java.lang.IllegalArgumentException: size must be > 0
at java.io.BufferedInputStream.(BufferedInputStream.java:112)
at xxx.cachefu.ImageCache.readValueFromDisk(ImageCache.java:48)
at xxx.cachefu.ImageCache.readValueFromDisk(ImageCache.java:30)
at xxx.cachefu.AbstractCache.get(AbstractCache.java:236)
at xxx.cachefu.ImageCache.getBitmap(ImageCache.java:59)
at xxx.widgets.BetterWebImageView.loadImage(BetterWebImageView.java:133)

AbstractCache.cacheToDisk() spams log

There's an incessant log message about using the default 8k buffer because none was specified in AbstractCache.cacheToDisk when creating the BufferedOutputStream.

This is a trivial fix; we just changed the line to add:

BufferedOutputStream ostream = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE);

where BUFFER_SIZE is 8192. It cleans the logs a bit.

Cachefu classes don't compile with Java 1.5

The existing POM file depends on 1.5. However, the cachefu classes use the @OverRide functionality on interface implementations, which are only allowed in 1.6.

This can be fixed either by depending on Java 1.6 or removing the @OverRide annotations. Personally I like using @OverRide on interface implementations, but I don't know if there's a reason it's built for 1.5.

Broken mvn install due to com.google.android.maps:maps:jar:9_r2 dependency

Trying to build the jar file using "mvn install" fails when accessing the http://powermock.googlecode.com/svn/repo:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.github.droidfu:droid-fu:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 61, column 15
[WARNING] The expression ${build.directory} is deprecated. Please use ${project.build.directory} instead.
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Droid-Fu 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.android.maps:maps:jar:9_r2 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.031s
[INFO] Finished at: Sat May 28 11:18:30 CEST 2011
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project droid-fu: Could not resolve dependencies for project com.github.droidfu:droid-fu:jar:1.0-SNAPSHOT: Failure to find com.google.android.maps:maps:jar:9_r2 in http://powermock.googlecode.com/svn/repo/ was cached in the local repository, resolution will not be reattempted until the update interval of powermock-repo has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

force close?

hi, i don't see any tutorial, and it's FC every time I exit the test app the simple code below, could you please provide useful link or sample source code to implement BetterDefaultActivity?

thanks in advance.

public class Main extends BetterDefaultActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
    }
}

ImageCache.getBitmap() causing OutOfMemoryError

This is a similar issue to a previously closed bug. While using the WebImageView, which uses ImageLoader.start(...) I get the following OutOfMemoryError.

Here's the exception stack:

E AndroidRuntime: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
E AndroidRuntime: at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
E AndroidRuntime: at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:392)
E AndroidRuntime: at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:405)
E AndroidRuntime: at com.github.droidfu.cachefu.ImageCache.getBitmap(ImageCache.java:67)
E AndroidRuntime: at com.github.droidfu.imageloader.ImageLoader.setOrLoadImage(ImageLoader.java:185)
E AndroidRuntime: at com.github.droidfu.imageloader.ImageLoader.start(ImageLoader.java:178)
E AndroidRuntime: at com.github.droidfu.widgets.WebImageView.loadImage(WebImageView.java:161)

Could the cache length of BetterHttp be made non-static?

Currently to configure the cache I use somthing like this:

 BetterHttp.enableResponseCache(context, 10, cacheLengthMins, 4, AbstractCache.DISK_CACHE_INTERNAL);

It would be nice to have multiple instances of the HTTP each with different cache lengths.

Perhaps you could have to option to overide the cache length on individual requests, e.g.

BetterHttpRequest request = BetterHttp.get(_url, _useCache);
request.setCachelLength(cacheLengthMinsShort);   // Override the default cache length

BetterHttpRequest request2 = BetterHttp.get(_url2, _useCache);
request2.setCachelLength(cacheLengthMinsLong);   // Override the default cache length

BetterHttpRequest request3 = BetterHttp.get(_url3, _useCache); 
// Will have the default cache length set from enableResponseCache

Also would be nice if this could be done for connection time outs too (BetterHttp.setSocketTimeout)

Love the project by the way.
Cheers,
Rob.

OAuthConsumer

Hi there. I have difficulties building this jar file.
When loading your project in eclipse, this project has several errors. I had to delete the test files from the build path, after that i had an error OAuthConsumer couldn't be found.

I tried building the Jar file a different way, with mvn, there I got an error android:android:jar:1.5_r2 is missing. Too be honest I don't know how to link it. If you could give me a hint there..

Thanks in advance,
Antek

Transparency lost for WebImageView

When I use the WebImageView the image seems to loose transparency. It doesn't matter if I use my own xml layout or if I copy directly from your blog(part two).

One of the images I'm trying to display is:
http://nnug.no/images/scal/08_24.gif

This image gets a black background when using the WebImageView. When downloading the same image, adding it as a reference and display it using a regular ImageView the image displays correctly, with transparency.

Extracting the following code from the ImageLoader, using it directly in the ListAdapter also works:

ImageView image = (ImageView) row.findViewById(id);
URL url = new URL(imageUrl);
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
image.setImageBitmap(bitmap);

WebImageView can't display link without "Content-Length" in the response header

The image link does not necessarily contain a "Content-Length" header in their response header (at least in my test case on google finance chart like http://www.google.com/finance/chart?cht=c&q=INDEXDJX:.DJI,INDEXSP:.INX,INDEXNASDAQ:.IXIC&tlf=12h), while the ImageLoader.retrieveImageData will return null if the header does not exist.
I think the image data array could be initialized by the method doesn't involve testing the header field, here's my code (I didn't handle if the connection returning a HTTP status not equal to "OK", but that is out of the topic in this issue):

protected byte[] retrieveImageData() throws IOException {
URL url = new URL(imageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int BUFFER_SIZE = 1024*16;
byte[] imageData;

    // download the file
    Log.d(LOG_TAG, "fetching image " + imageUrl);
    BufferedInputStream istream = new BufferedInputStream(connection.getInputStream());
    ByteArrayOutputStream  out = new ByteArrayOutputStream(BUFFER_SIZE);
    byte[] tem = new byte[BUFFER_SIZE];
    int bytesRead = 0;
    bytesRead = istream.read(tem);
    while(bytesRead != -1){
        out.write(tem, 0, bytesRead);
        //Log.d(AsyncImageLoader.class.getName(), "size:"+out.size()+",url:"+imageUrl);
        bytesRead = istream.read(tem);
    }

    if (out.size() != 0){
        imageData = out.toByteArray();
    }
    out.close();
    istream.close();
    connection.disconnect();

    return imageData;
} 

Sorry I am not familiar with Git, thus the coding part looks strange, i don't know why =_=??

proguard

Having trouble getting this to work properly with proguard. Can some instructions be added to the wiki? Thanks!

Maveb POM Build - Latest Version does not build

Hey,

Since you have updated the POM file to Android 2.3, I am unable to build Droid-Fu.

I keep getting Build Failures regarding the android maps jar, and how its unable to find them on the repo? Im very new to Maven, so its a little tricky for me to solve this.

Any help would be appreciated.

ImageLoader - problem with trying to get the image size

Not always a image's server setting a "Content-Length" header in the response message, so ImageLoader class can't download it. The method retrieveImageData() is expecting the size:

    int fileSize = connection.getContentLength();
    if (fileSize < 0) {
        return null;
    }
    //...
    while (bytesRead != -1 && offset < fileSize) {
        bytesRead = istream.read(imageData, offset, fileSize - offset);
        imageData.write(buffer, offset, len)
        offset += bytesRead;
    }

I suggest using the ByteArrayOutputStream class:

    ByteArrayOutputStream imageData = new ByteArrayOutputStream();
    BufferedInputStream istream = new BufferedInputStream(connection.getInputStream());
    int bytesRead = 0;
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    while ((bytesRead = istream.read(buffer)) != -1) {  
        imageData.write(buffer, 0, bytesRead);  
    }

Improve hyperlinks of generated docs

The online docs available at http://kaeppler.github.com/droid-fu/ can be improved by hyperlinking them to the android reference docs where appropriate. This can be done using the -link or -linkoffline parameters of the javadoc tool, as documented at http://stackoverflow.com/questions/2818204/how-to-generate-links-to-the-android-classes-reference-in-javadoc and the javadoc man page. For instance, when I generate my own local version of the droid-fu documentation, I use the following bash script:

#!/bin/sh

javadoc -sourcepath ../droid-fu/src/main/java/ \
    -linkoffline http://d.android.com/reference \
    file:/Users/gradha/instalacion_manual/android-sdk-r10-mac_x86/docs/reference \
    -classpath .:/Users/gradha/instalacion_manual/android-sdk-r10-mac_x86/platforms/android-7/android.jar \
    -subpackages com &&
    open index.html

This script is stored inside my project checkout directory, and hence the relative paths for sourcepath to find the original droid-fu checkout. The generated docs will now contain hyperlinks to the android classes, making reading the documentation much comfortable.

Add noImageDrawable as a XML parameter

I have done it for me:

<com.blah.WebImageView
android:id="@+id/user_logo"
android:layout_width="60dp"
android:layout_height="60dp"
ntm:autoLoad="false"
blah:noImageDrawable="@drawable/no_user"/>

In public WebImageView(Context context, AttributeSet attributes)

I added:
int noImage = attributes.getAttributeResourceValue(XMLNS, "noImageDrawable", -1);
if ( noImage != -1 ) {
setNoImageDrawable(noImage);

Google MapMaker classloader issue [was: Image Cache Problem]

"Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Google Collections to your system class path."

Getting this error for a reason I don't know. I've also pastebin'd the text for an easier view.

http://pastebin.com/VwkTSw6X

Cache fails when device has no sdcard.

Looks like the cache always tries to write to /mnt/sdcard and not all devices have that. I was seeing errors in logcat on my Samsung Galaxy Tab 10.1.

WebImageView doesn't handle URL redirection well.

WebImageView fails on URL redirection, especially requests made with Facebook's Graph API for pictures using an Access Token.

Add this snippet of code in ImageLoader to get the redirected URL:

URL url = new URL(originalURL);
HttpURLConnection ucon = (HttpURLConnection) url.openConnection();
ucon.setInstanceFollowRedirects(false);
URL redirectedURL = new URL(ucon.getHeaderField("Location"));
original = redirectedURL.toString();

Animation of WebImageView still occurs within a list view

The animation of the appearance of the image still occurs even after loaded when WebImageView is used within a ListView. The imageSrc is set dynamically with loadImage() which loads the image accordingly but the animation still remains after the image was loaded. This is apparent when you scroll down a list and then come back to the original position. Applying the logic within the efficient adapter from the API demos or removing the animation after the image was loaded could be 2 potential solution. I will work on a solution but though about creating the issue before hand.

Create a BetterTabActivity

One base Android Activity that isn't included in the DroidFu extensions is TabActivity. After a quick glance, it looks like the code from BetterDefaultActivity could probably be copied into a new class like:
BetterTabActivity extends TabActivity implements BetterActivity {
...
}

I think it would be a 2-minute addition, not including testing of course.
I was going to do this in my own package for an app I'm currently working on, but BetterActivityHelper.handleApplicationClosing() is not public so I can't call it.

ImageCache.getBitmap throws OutOfMemoryError (bitmap size exceeds VM budget)

Hello,
Thanks for making this awesome cache library. Everything in your library is working well, but I noticed that in my Android Market crash reports, there is a crash originating from droid-fu. (two reports in the last week).

I am using ImageLoader to fetch small 48x48 images, three at a time, approximately every thirty seconds. The image size is quite small (12kb each).

Could the in-memory cache be filling up?

I am building with the Android 1.6 library.

Here is the Stack trace
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:392)
at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:405)
at com.github.droidfu.cachefu.ImageCache.getBitmap(ImageCache.java:67)
at com.github.droidfu.imageloader.ImageLoader.start(ImageLoader.java:153)
at com.github.droidfu.imageloader.ImageLoader.start(ImageLoader.java:121)

Back button closes progress dialog, doesn't cancel task

I'm using the BetterAsyncTask with a progress dialog, and when the user presses the back button on the device the progress dialog is dismissed but the task continues running. I've managed to override this implementing the onCreateDialog() method on my activity and attaching there an OnCancelListener, but still it doesn't look too god, because I'm using globals to communicate with the task.

It would be better if the cancel listener flagged the task as cancelled and the task itself could check for this with the isCancelled() method.

WebImageView race conditions in WebGalleryAdapter

I've released an application using some droid-fu widgets. The program works ok most of the time, but sometimes the WebImageView widgets seem to not update correctly their picture. When a WebImageView downloads the image for the first time, it seems to work always. However, when the WebImageView is loading the image from the memory/disk cache, sometimes the image doesn't reach the widget and the widget shows the loading resource instead forever. Sliding the cell out of the view and back in reloads fixes the problem.

It's quite difficult to explain, not reproducible, and most surely depends on the phase of the moon, so I don't know what do do about it. In fact, since this is best seen in a WebGalleryAdapter and that means I'm not using any of my code, the race condition bug must be present in either the gallery widget or the WebImageView widget.

I've put a 11MB video of the effect I experience at: http://dl.dropbox.com/u/145894/droid-fu-gallery.mp4. The app can be downloaded free from https://market.android.com/details?id=net.efaber.irekia. You can see in the video how many of the icons for "loading" are replaced correctly by the image after I scroll them out of the screen, and there's no network update or any other kind of work being done in the background.

Force closing when trying to implement BetterASyncTask

Hi

Hoping someone can point me in the right direction as to how to implement the betterasynctask.

I have been trying to make an example project to test out the library but when ever i go to run the app it keeps force closing. Could you provide an example project or files which demonstrates how to use it.

Thanks
Adam

Alternative source only install

Instead of using maven I was experimenting on how to use droid-fu as a source dependency rather than jar. I figured out how to do it (gradha@2461c7e) but unfortunately in the process I had to remove the map related activities and assertions tests because I was getting compilation problems (gradha@a78d7c6).

This is not a big deal for me since I don't plan to use anything map related, but I wonder if the map activity compilation issues are due to the way I'm including the source or they are related to the other issues you have opened in github about including the google libraries inside the jar.

Provide an Ant build file

Perhaps this is just a personal preference, but it would be very nice if this project didn't require Maven in order to build it. This project is my first attempt to use Maven and it's already leading to hours of frustration and no jars. Using Maven for Android stuff is uncommon, which then leaves a bunch of non-Maven-familiar developers banging their heads for hours trying to get their first build going.

From what I've seen, most Android projects/developers use Eclipse, some use Ant and a few use Maven. Following this distribution could help more Android developers use this library.

Wrong WebImageView default density

When using the WebImageView on devices with higher display density than medium (also affects emulators) the images shown are scaled incorrectly. The problem is in BitmapFactory.decodeByteArray setting the device's density on the returned bitmaps. When I modify this to force the default density (medium) on the Bitmaps, everything works like on medium density devices. Here is a Grid/Gallery using WebImageViews without modification and after the forced density change: https://www.dropbox.com/gallery/145894/1/droid-fu-density?h=7894c8

Nullpointer in AbstractCache

I don't get very many of these reports, but they are still showing up:

Caused by: java.lang.NullPointerException
at com.github.droidfu.cachefu.AbstractCache.enableDiskCache(AbstractCache.java:137)
at com.github.droidfu.imageloader.ImageLoader.initialize(ImageLoader.java:100)

which is the appcontext assignment from ImageLoader's context:

AbstractCache:
public boolean enableDiskCache(Context context, int storageDevice) {

    Context appContext = context.getApplicationContext();

ImageLoader:
public static synchronized void initialize(Context context) {
if (executor == null) {
executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(DEFAULT_POOL_SIZE);
}
if (imageCache == null) {
imageCache = new ImageCache(25, expirationInMinutes, DEFAULT_POOL_SIZE);
imageCache.enableDiskCache(context, ImageCache.DISK_CACHE_SDCARD);
}
}

Could it just be the app is running low on memory and the context is null? I set this onCreate for the parent class, so maybe for some reason the context is not available?

I made one change in EnableDiskCache whereby I would just return false if the context was null, but it was causing all images to stop delivering for periods of time for some testers.

static ImageLoader.clearCache() can throw null exception

I don't really understand how the pull thing works, but I've commited at commit:1e7f0df6170907d3b1e0 (not sure if that works, full url gradha@1e7f0df) a simple fix for a null exception being thrown. Apparently github merges all pull requests into one, so they are being updated automatically as part of the #36 issue. In the future I'll create first the ticket and then use manual references like at #44, which seems saner.

The nature of the fix is simple, avoid using a null object which might not be initialised.

Do not include google classes in jar file

I noticed that the jar you provide has some classes which can also be found in the google guava library. I think it's not good to package these inside your jar because it means trouble for anyone using guava.

Maven: kaeppler-droid-fu-f80edb9 won't compile

Hi,

I was trying to build a jar file as described in the "How do I install it?" section, however the build fails with an dependency missing error. As this is the first time I've ever tried to build a maven project, I am quite clueless as to how I resolve a missing dependency problem ("com.google.android.maps:maps:jar:9_r2" in this case). Any pointers?

[INFO] ------------------------------------------------------------------------
[INFO] Building Droid-Fu 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.android.maps:maps:jar:9_r2 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.892s
[INFO] Finished at: Thu Oct 06 09:42:56 CEST 2011
[INFO] Final Memory: 6M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project droid-fu: Could not resolve dependencies for project com.github.droidfu:droid-
fu:jar:1.0-SNAPSHOT: Failure to find com.google.android.maps:maps:jar:9_r2 in http://powermock.googlecode.com/svn/repo/
was cached in the local repository, resolution will not be reattempted until the update interval of powermock-repo has e
lapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

BetterHttpResponse send method hangs forever

When the underlying network changes from 3G to Wi-Fi, Wi-Fi to 3G, or the 3G signal is lost (say when you get in an elevator), if you are in the middle of executing a request, the send method hangs forever, no timeout, no retry logic, just hangs forever. Any ideas on how to handle this?

Do not have time out mechanism

When I try to get image from web using my phone, sometimes it keeps loading and the image will not shown.
I think that's because when you get image from web, it keeps trying to connect to the target url. When the network is poor, it uses long time to get connect, but the widget doesn't know.
So I wonder if you could offer a mechanism to set timeout manually.

Thanks

NullPointerException when using disk cache and expiration time for url is reached

First, the Stack Trace :

09-06 20:00:46.842: DEBUG/HttpCache(736): MEM cache hit for http://oscope.org/t/time.php
09-06 20:00:50.272: DEBUG/HttpCache(736): DISK cache expiration for file /data/data/org.foo/cache/cachefu/http_cache/http+oscope+org+t+time+php
09-06 20:00:54.273: WARN/System.err(736): java.lang.NullPointerException
09-06 20:00:54.283: WARN/System.err(736):     at com.github.ignition.support.http.cache.CachedHttpResponse$ResponseData.access$0(CachedHttpResponse.java:25)
09-06 20:00:54.293: WARN/System.err(736):     at com.github.ignition.support.http.cache.CachedHttpResponse.getResponseBodyAsString(CachedHttpResponse.java:55)
09-06 20:00:54.293: WARN/System.err(736):     at org.foo.AndroidTestingActivity$GetTime.doInBackground(AndroidTestingActivity.java:46)

Scenario:

  1. Use BetterHttp or IgniteHttp to get a cacheable time string from "http://oscope.org/t/time.php"
  2. Set the expiry time to something short like 1 minute
  3. Wait for expiry time to elapse and make the same call again.
  4. Watch for nullpointerexception
  5. Making the same call again gets the time from the url correctly (only after the NPE in step four occurs).

Code Samples

The Activity :

public class AndroidTestingActivity extends Activity 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        BetterHttp.setContext(this);
        // one minute expiry time 
        BetterHttp.enableResponseCache(this, 25, 1L, 1, AbstractCache.DISK_CACHE_INTERNAL);
        BetterHttp.setupHttpClient();
        ImageLoader.initialize(this);
        ImageLoader.setMaxDownloadAttempts(2);
        setContentView(R.layout.droidfu);
        super.onCreate(savedInstanceState);
        findViewById(R.id.go).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                new GetTimeAsyncTask().execute();

            }
        });
        new GetTimeAsyncTask().execute();
    }

    private class GetTimeAsyncTask extends AsyncTask<Void, Void, String>{

        @Override
        protected String doInBackground(Void... params) {
            try {
                String url = "http://oscope.org/t/time.php";
                BetterHttpRequest request = BetterHttp.get(url, true);
                BetterHttpResponse resp =  request.send();
                String time = resp.getResponseBodyAsString();
                return time;
            } catch (ConnectException ex) {
            } catch (Exception ex) {
                ex.printStackTrace();
                Log.e("org.foo", "doInBackground:");
                Log.e("org.foo", "UNCAUGHT: " +  ex.getClass().getName () + ": " + ex.getMessage());
                Log.e("org.foo", "UNCAUGHT:" + ex.getMessage());
                Log.e("org.foo", "UNCAUGHT:" + "ex" , ex);
            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            Log.w("org.foo", "result = " + result);
            TextView txt = (TextView) findViewById(R.id.text);
            if (txt != null && result!=null){
                txt.setText(result);
            }
        }

    }

XML file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:id="@+id/text" android:layout_height="wrap_content"
        android:layout_width="wrap_content" />
    <Button android:id="@+id/go" android:text="go"
        android:layout_height="wrap_content" android:layout_width="wrap_content" />
</LinearLayout>

Some other Notes

  1. This doesnt occur if disk cache is not enabled.
  2. This occurs on a few devices I have (HTC Thunderbolt, Droid X, Galaxy Tab IO, and the emulator)
  3. I'm still starting to learn GIT and MAVEN. Otherwise, I'd prolly have a fix.

Source for the 1.0 SNAPSHOT download

I like the fact that I can get a easily consumable JAR, but it does not include the sources at the time of that snapshot. I tried to find a tag in the repo that looked like it corresponded to that build, but I'm a total git newbie, but I could not find any tags at all on master (using Eclipse's git client).
Can you provide a source ZIP that corresponds to the 1.0-SNAPSHOT JAR build?
Thanks.

progressDialogTitleId and progressDialogMsgId should be saved in state bundle

If the user calls setProgressDialogMsgId or setProgressDialogTitleId, setting the related instance variable, then these values should be stored in onSaveInstanceState and restored in onCreate or onRestoreInstanceState; otherwise, if the user rotates the screen while a BetterAsyncTask is running then the wrong text will be displayed, or the application will crash if the default DroidFu resources are not defined.

Eliminate BetterActivity dependency in BetterAsyncTask

Just a humble suggestion...
The logic in BetterAsyncTask checks the passed-in Context to determine if it's a BetterActivity. It uses that info for only two purposes, both of which appear to be candidates for elimination:

  1. The progress dialog is only shown if the Context is a BetterActivity, but that seems overly restrictive because it doesn't rely on the BetterActivity interface. It does assume that dialog ID 0 will be available if the activity is a BetterActivity, but I think a sensible default behavior would be to make the default dialog ID be -1 instead of 0. I guess there's some default "fall-through" behavior in the BetterActivity implementations for handling dialog ID 0, but I'm not sure that really is worth it.

  2. It's also used to check the window features of the passed-in activity, but the default implementation of BetterActivity.getWindowFeatures() just calls BetterActivityHelper, which BetterAsyncTask could call directly itself. Furthermore, BetterActivityHelper.getWindowFeatures()'s comments indicate that it's broken anyway.

It seems to me that if these checks for BetterActivity were eliminated, BetterAsyncTask would be more useful for use from non-BetterActivity activities.

Provide updated JAR file

Hello,

I was just wondering if it was possible to provide an updated JAR file. The one that you currently provide in GitHub is over a year old I believe. The code has been much updated since then.

Thanks!

DroidFuApp's onClose can not work

I use droidfu in samsung p1000,then I notice that DroidFuApp can't receive onClose method.
I have read some source code about DroidFu.I know it overload onKeyDown to check activity's back action.
But it really have some issues,such as following:
1.If I overload onKeyDown,and prevent default back action,and handler exit by myself.It won't work.Why do not you use onDestroy to check?
2.To check if the activity is the last of app.DroidFu use something wrong strategy.Firstly,not every android device use the default launcher,so check packageName==com.android.launcher is not right.Secondly,if I start myApp from another app.Then,whatever they are in different.onClose will work not as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.