Search in sources :

Example 16 with AjaxStatus

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

the class AQueryImageTest method testImageByCallback2.

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

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

                protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
                    iv.setImageBitmap(bm);
                }
            };
            aq.id(R.id.image).image(ICON_URL, true, true, 0, 0, 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) ImageView(android.widget.ImageView) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 17 with AjaxStatus

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

the class AQueryImageTest method testAutoRotate.

/*
	public void testIfModified() {
		
		String url = ICON_URL;
		
		AjaxCallback<Bitmap> cb = new AjaxCallback<Bitmap>();
		cb.type(Bitmap.class).url(url);
		
		aq.sync(cb);
		
		Bitmap bm = cb.getResult();
		AjaxStatus status = cb.getStatus();
		
		assertNotNull(bm);
		
		assertEquals(304, status.getCode());
		
		File file;
		
		
	}
	*/
public void testAutoRotate() throws IOException {
    String imageUrl = "http://res.dbkon.co.kr/resource/201302091360376386575001.jpg";
    BitmapAjaxCallback cb = new BitmapAjaxCallback();
    cb.url(imageUrl).targetWidth(300).rotate(true);
    aq.id(R.id.image).image(cb);
    cb.block();
    Bitmap bm = cb.getResult();
    AjaxStatus status = cb.getStatus();
    assertNotNull(bm);
}
Also used : BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) Bitmap(android.graphics.Bitmap) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 18 with AjaxStatus

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

the class AQueryLocationTest method testLocationIter3Acc10000.

public void testLocationIter3Acc10000() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            assertNotNull(loc);
            if (n == 3) {
                assertEquals("gps", loc.getProvider());
            }
        }
    };
    cb.timeout(30 * 1000).accuracy(10000).iteration(3).tolerance(-1);
    cb.async(getActivity());
    waitAsync(5000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Example 19 with AjaxStatus

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

the class AQueryLocationTest method testLocationIter2AccFail.

public void testLocationIter2AccFail() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            if (n == 2) {
                assertNull(loc);
                assertEquals(AjaxStatus.TRANSFORM_ERROR, status.getCode());
            } else if (n < 2) {
                assertNotNull(loc);
            } else {
                assertTrue(false);
            }
        }
    };
    cb.timeout(5 * 1000).accuracy(-1).iteration(2).tolerance(-1);
    cb.async(getActivity());
    waitAsync(6000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Example 20 with AjaxStatus

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

the class AQueryLocationTest method testLocationIter1Acc10000.

public void testLocationIter1Acc10000() {
    LocationAjaxCallback cb = new LocationAjaxCallback() {

        private int n;

        @Override
        public void callback(String url, Location loc, AjaxStatus status) {
            n++;
            AQUtility.debug(n);
            AQUtility.debug(loc);
            assertNotNull(loc);
            if (n == 1) {
                assertEquals("gps", loc.getProvider());
            }
        }
    };
    cb.timeout(5 * 1000).accuracy(10000).iteration(1).tolerance(-1);
    cb.async(getActivity());
    waitAsync(5000);
}
Also used : LocationAjaxCallback(com.androidquery.callback.LocationAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus) Location(android.location.Location)

Aggregations

AjaxStatus (com.androidquery.callback.AjaxStatus)55 BitmapAjaxCallback (com.androidquery.callback.BitmapAjaxCallback)33 AjaxCallback (com.androidquery.callback.AjaxCallback)28 AbstractAjaxCallback (com.androidquery.callback.AbstractAjaxCallback)27 JSONObject (org.json.JSONObject)27 File (java.io.File)15 HashMap (java.util.HashMap)11 LinkedHashMap (java.util.LinkedHashMap)10 JsonObject (com.google.gson.JsonObject)8 Bitmap (android.graphics.Bitmap)7 Location (android.location.Location)4 ImageView (android.widget.ImageView)4 LocationAjaxCallback (com.androidquery.callback.LocationAjaxCallback)4 ArrayList (java.util.ArrayList)3 NameValuePair (org.apache.http.NameValuePair)3 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)3 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)3 ProxyHandle (com.androidquery.callback.ProxyHandle)2 Gson (com.google.gson.Gson)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2