use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AjaxLoadingActivity method async_file_custom.
public void async_file_custom() {
String url = "https://picasaweb.google.com/data/feed/base/featured?max-results=16";
File ext = Environment.getExternalStorageDirectory();
File target = new File(ext, "aquery/myfolder2/photos1.xml");
aq.progress(R.id.progress).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);
}
}
});
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AjaxAuthActivity method auth_facebook.
public void auth_facebook() {
FacebookHandle handle = new FacebookHandle(this, APP_ID, PERMISSIONS) {
@Override
public boolean expired(AbstractAjaxCallback<?, ?> cb, AjaxStatus status) {
//custom check if re-authentication is required
if (status.getCode() == 401) {
return true;
}
return super.expired(cb, status);
}
};
String url = "https://graph.facebook.com/me/feed";
aq.auth(handle).progress(R.id.progress).ajax(url, JSONObject.class, this, "facebookCb");
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AjaxLoadingActivity method async_post_entity.
/*
public void async_post2(){
String url = "your url";
//get your byte array or file
byte[] data = new byte[1000];
Map<String, Object> params = new HashMap<String, Object>();
//put your post params
params.put("paramName", data);
AjaxCallback<byte[]> cb = new AjaxCallback<byte[]>() {
@Override
public void callback(String url, byte[] data, AjaxStatus status) {
System.out.println(data);
System.out.println(status.getCode() + ":" + status.getError());
}
};
cb.url(url).type(byte[].class);
//set Content-Length header
cb.params(params).header("Content-Length", Integer.toString(data.length));
cb.async(this);
}
*/
public void async_post_entity() throws UnsupportedEncodingException {
String url = "http://search.twitter.com/search.json";
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("q", "androidquery"));
HttpEntity entity = new UrlEncodedFormEntity(pairs, "UTF-8");
Map<String, Object> params = new HashMap<String, Object>();
params.put(AQuery.POST_ENTITY, entity);
aq.progress(R.id.progress).ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject json, AjaxStatus status) {
showResult(json, status);
}
});
}
use of com.androidquery.callback.AjaxStatus 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);
}
});
}
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AjaxLoadingActivity method async_put.
public void async_put() throws JSONException, UnsupportedEncodingException {
String url = "http://www.androidquery.com/p/doNothing";
JSONObject input = new JSONObject();
input.put("param1", "value1");
input.put("param2", "value2");
StringEntity entity = new StringEntity(input.toString(), "UTF-8");
aq.progress(R.id.progress).put(url, "application/json", entity, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
showResult(jo);
}
});
}
Aggregations