Search in sources :

Example 6 with BitmapAjaxCallback

use of com.androidquery.callback.BitmapAjaxCallback in project androidquery by androidquery.

the class AdhocActivity method work.

private void work() throws IOException {
    String url = "";
    BitmapAjaxCallback cb = new BitmapAjaxCallback();
    cb.url(url).ratio(AQuery.RATIO_PRESERVE).expire(3600 * 1000);
    aq.id(R.id.image).image(cb);
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback)

Example 7 with BitmapAjaxCallback

use of com.androidquery.callback.BitmapAjaxCallback in project androidquery by androidquery.

the class ImageLoadingActivity method image_file_custom.

public void image_file_custom() {
    String imageUrl = "http://farm6.static.flickr.com/5035/5802797131_a729dac808_b.jpg";
    File file = aq.getCachedFile(imageUrl);
    final int tint = 0x77AA0000;
    if (file != null) {
        aq.id(R.id.image).progress(R.id.progress).visible().image(file, true, 300, new BitmapAjaxCallback() {

            @Override
            public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
                iv.setImageBitmap(bm);
                iv.setColorFilter(tint, PorterDuff.Mode.SRC_ATOP);
                showMeta(status);
            }
        });
    }
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) File(java.io.File) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 8 with BitmapAjaxCallback

use of com.androidquery.callback.BitmapAjaxCallback in project simplefacebook by androidquery.

the class PostActivity method attachPhoto.

private void attachPhoto(File file) {
    if (file == null || !file.exists() || file.length() < 10) {
        aq.id(R.id.image_box).gone();
        return;
    }
    AQUtility.debug("photo", file.length());
    sendEnable(false);
    BitmapAjaxCallback cb = new BitmapAjaxCallback() {

        @Override
        protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
            sendEnable(true);
            if (photo != null && bm != null) {
                iv.setImageBitmap(bm);
                String dim = bm.getWidth() + "x" + bm.getHeight();
                aq.id(R.id.text_dim).text(dim);
                String length = FormatUtility.scientificShort(photo.length()) + "b";
                aq.id(R.id.text_size).text(length);
                PostActivity.this.bm = bm;
            }
        }
    };
    //.targetDim(false);
    cb.file(file).targetWidth(720);
    aq.id(R.id.image_photo).image(cb);
    clear();
    this.photo = file;
    refreshButtons();
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 9 with BitmapAjaxCallback

use of com.androidquery.callback.BitmapAjaxCallback in project androidquery by androidquery.

the class AQueryImageTest method testImageIOError.

public void testImageIOError() {
    clearCache();
    AQUtility.cleanCache(AQUtility.getCacheDir(getActivity()), 0, 0);
    File file = aq.getCachedFile(LAND_URL);
    assertNull(file);
    AQUtility.TEST_IO_EXCEPTION = true;
    AQUtility.post(new Runnable() {

        @Override
        public void run() {
            BitmapAjaxCallback cb = new BitmapAjaxCallback() {

                protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
                    AQUtility.debug("bm", bm);
                    //iv.setImageBitmap(bm);
                    bmResult = bm;
                }
            };
            aq.id(R.id.image).image(LAND_URL, true, true, 0, 0, cb);
        }
    });
    waitAsync(2000);
    assertNull(bmResult);
    File file2 = aq.getCachedFile(LAND_URL);
    if (file2 != null) {
        AQUtility.debug("file length", file2.length());
    }
    assertNull(file2);
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) File(java.io.File) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 10 with BitmapAjaxCallback

use of com.androidquery.callback.BitmapAjaxCallback in project androidquery by androidquery.

the class AQueryImageTest method testImageByCallback.

public void testImageByCallback() {
    clearCache();
    AQUtility.post(new Runnable() {

        @Override
        public void run() {
            //aq.id(R.id.image).image(ICON_URL, true, true, 0, 0, null, AQuery.FADE_IN);
            BitmapAjaxCallback cb = new BitmapAjaxCallback();
            cb.url(ICON_URL);
            aq.id(R.id.image).image(cb);
        }
    });
    waitAsync(2000);
    assertLoaded(aq.getImageView(), true);
    Bitmap bm = aq.getCachedImage(ICON_URL);
    assertNotNull(bm);
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) Bitmap(android.graphics.Bitmap)

Aggregations

BitmapAjaxCallback (com.androidquery.callback.BitmapAjaxCallback)11 Bitmap (android.graphics.Bitmap)7 ImageView (android.widget.ImageView)5 AjaxStatus (com.androidquery.callback.AjaxStatus)5 File (java.io.File)2