Search in sources :

Example 31 with AjaxStatus

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

the class AjaxLoadingActivity method async_progress_dialogbar.

public void async_progress_dialogbar() {
    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setIndeterminate(false);
    dialog.setCancelable(true);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setTitle("Loading...");
    String url = "http://farm6.static.flickr.com/5035/5802797131_a729dac808_b.jpg";
    File ext = Environment.getExternalStorageDirectory();
    File target = new File(ext, "aquery/myfolder2/photo.jpg");
    aq.progress(dialog).download(url, target, new AjaxCallback<File>() {

        public void callback(String url, File file, AjaxStatus status) {
            if (file != null) {
                showResult("File:" + file.length() + ":" + file, status);
            } else {
                showResult("Failed", status);
            }
        }
    });
}
Also used : ProgressDialog(android.app.ProgressDialog) File(java.io.File) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 32 with AjaxStatus

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

the class AjaxLoadingActivity method async_transformer.

public void async_transformer() {
    String url = "https://graph.facebook.com/205050232863343";
    GsonTransformer t = new GsonTransformer();
    aq.transformer(t).progress(R.id.progress).ajax(url, Profile.class, new AjaxCallback<Profile>() {

        public void callback(String url, Profile profile, AjaxStatus status) {
            Gson gson = new Gson();
            showResult("GSON Object:" + gson.toJson(profile), status);
        }
    });
}
Also used : Gson(com.google.gson.Gson) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 33 with AjaxStatus

use of com.androidquery.callback.AjaxStatus 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 34 with AjaxStatus

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

the class AQueryXmlTest method testMalformXml.

public void testMalformXml() {
    String url = "http://fotbollskanalen.apps.tv4.se/news/topnews";
    AjaxCallback<XmlDom> cb = new AjaxCallback<XmlDom>() {

        @Override
        public void callback(String url, XmlDom object, AjaxStatus status) {
            done(url, object, status);
        }
    };
    cb.url(url).type(XmlDom.class);
    aq.ajax(cb);
    waitAsync();
    XmlDom xml = (XmlDom) result;
    assertNotNull(xml);
    AQUtility.debug(xml);
}
Also used : XmlDom(com.androidquery.util.XmlDom) AjaxCallback(com.androidquery.callback.AjaxCallback) BitmapAjaxCallback(com.androidquery.callback.BitmapAjaxCallback) AjaxStatus(com.androidquery.callback.AjaxStatus)

Example 35 with AjaxStatus

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

the class AQueryLocationTest method testLocationIter2Acc10000.

public void testLocationIter2Acc10000() {
    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 == 2) {
                assertEquals("gps", loc.getProvider());
            }
        }
    };
    cb.timeout(30 * 1000).accuracy(10000).iteration(2).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