Search in sources :

Example 6 with AQuery

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);
}
Also used : AQuery(com.androidquery.AQuery) ViewGroup(android.view.ViewGroup) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo) View(android.view.View) ArrayAdapter(android.widget.ArrayAdapter)

Example 7 with AQuery

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);
}
Also used : AQuery(com.androidquery.AQuery) ViewGroup(android.view.ViewGroup) Photo(com.androidquery.test.image.ImageLoadingList4Activity.Photo) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 8 with AQuery

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");
}
Also used : AQuery(com.androidquery.AQuery) Options(android.graphics.BitmapFactory.Options) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject)

Example 9 with AQuery

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();
    }
}
Also used : AQuery(com.androidquery.AQuery)

Example 10 with AQuery

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();
    }
}
Also used : AQuery(com.androidquery.AQuery)

Aggregations

AQuery (com.androidquery.AQuery)31 View (android.view.View)17 ViewGroup (android.view.ViewGroup)9 ArrayAdapter (android.widget.ArrayAdapter)8 AdapterView (android.widget.AdapterView)5 TextView (android.widget.TextView)5 AbsListView (android.widget.AbsListView)4 ImageView (android.widget.ImageView)4 JSONObject (org.json.JSONObject)4 Activity (android.app.Activity)3 ExpandableListView (android.widget.ExpandableListView)3 Photo (com.androidquery.test.image.ImageLoadingList4Activity.Photo)3 ArrayList (java.util.ArrayList)3 Dialog (android.app.Dialog)2 Bitmap (android.graphics.Bitmap)2 ProgressBar (android.widget.ProgressBar)2 JSONArray (org.json.JSONArray)2 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1