use of com.androidquery.AQuery in project androidquery by androidquery.
the class ImageGridFragment method render.
private void render(List<Photo> entries) {
AQUtility.debug("render setup");
ArrayAdapter<Photo> aa = new ArrayAdapter<Photo>(getActivity(), R.layout.grid_item2, entries) {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = aq.inflate(convertView, R.layout.grid_item2, parent);
}
Photo photo = getItem(position);
AQuery aq = aq2.recycle(convertView);
String tbUrl = photo.tb;
if (aq.shouldDelay(position, convertView, parent, tbUrl)) {
//aq.id(R.id.tb).image(placeholder);
aq.id(R.id.tb).clear();
} else {
aq.id(R.id.tb).image(tbUrl, true, true, 200, R.drawable.image_missing, null, 0, 0);
}
return convertView;
}
};
aq.id(R.id.grid).adapter(aa);
}
use of com.androidquery.AQuery in project androidquery by androidquery.
the class ImageLoadingGalleryActivity method renderPhotos.
/*
private boolean shouldDelayG(int position, View convertView, ViewGroup parent, String url){
if(url == null) return false;
boolean hit = BitmapAjaxCallback.getMemoryCached(url, 0) != null;
if(hit){
return false;
}
Gallery gallery = (Gallery) parent;
Integer selected = (Integer) gallery.getTag(AQuery.TAG_LAYOUT);
if(selected == null){
selected = 0;
gallery.setTag(AQuery.TAG_LAYOUT, 0);
gallery.setCallbackDuringFling(false);
Common common = new Common();
common.listen(gallery);
}
int first = gallery.getFirstVisiblePosition();
int last = gallery.getLastVisiblePosition();
int diff = last - first;
int delta = (diff / 2) + 1;
int from = selected - delta;
int to = selected + delta;
if(from < 0){
//shift window back to positive region
to = to - from;
from = 0;
}
if((position >= from && position <= to)){
AQUtility.debug("yes", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_LAYOUT, position);
return false;
}
AQUtility.debug("no", position + ":" + from + "." + to);
convertView.setTag(AQuery.TAG_LAYOUT, null);
return true;
}
*/
public void renderPhotos(String url, XmlDom xml, AjaxStatus status) {
if (xml == null)
return;
List<Photo> entries = convertAll(xml);
listAq = new AQuery(this);
ArrayAdapter<Photo> aa = new ArrayAdapter<Photo>(this, R.layout.gallery_item, entries) {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.gallery_item, parent, false);
}
Photo photo = getItem(position);
AQuery aq = listAq.recycle(convertView);
aq.id(R.id.name).text(photo.title);
String tbUrl = photo.tb;
if (!aq.shouldDelay(position, convertView, parent, tbUrl)) {
aq.id(R.id.tb).image(tbUrl, true, true, 100, 0);
aq.id(R.id.text).text(photo.title).gone();
} else {
aq.id(R.id.tb).clear();
aq.id(R.id.text).text(photo.title).visible();
}
return convertView;
}
};
aq.id(R.id.gallery).adapter(aa);
}
use of com.androidquery.AQuery in project simplefacebook by androidquery.
the class PostActivity method photoPost.
private void photoPost(String id, String message, File file) {
String url = "https://graph.facebook.com/" + id + "/photos";
Map<String, Object> params = new HashMap<String, Object>();
params.put("message", message);
Options size = getSize(photo);
if (bm.getWidth() == size.outWidth) {
AQUtility.debug("use file");
params.put("source", file);
} else {
AQUtility.debug("use byte[]");
params.put("source", toBytes(bm));
}
putLocation(params, place, location);
putPhotoTags(params, tags);
AQUtility.debug("params", params);
AQuery aq = new AQuery(getApplicationContext());
aq.auth(handle).ajax(url, params, JSONObject.class, this, "photoCb");
}
use of com.androidquery.AQuery in project simplefacebook by androidquery.
the class FeedFragment method showLogin.
private void showLogin(boolean show) {
AQuery aq = new AQuery(act);
if (show) {
aq.id(R.id.login_panel).visible();
aq.id(R.id.content_init).gone();
aq.id(R.id.progress_init).gone();
} else {
aq.id(R.id.login_panel).gone();
aq.id(R.id.content_init).visible();
aq.id(R.id.progress_init).gone();
}
}
use of com.androidquery.AQuery in project simplefacebook by androidquery.
the class PostActivity method photoCb.
public void photoCb(String url, JSONObject jo, AjaxStatus status) {
AQUtility.debug(jo);
if (jo != null && jo.has("id")) {
AQuery aq = new AQuery(getApplicationContext());
String url2 = "https://graph.facebook.com/" + jo.optString("id");
aq.auth(handle).ajax(url2, JSONObject.class, this, "photoDetailCb");
} else {
failed();
}
}
Aggregations