Search in sources :

Example 1 with AQuery

use of com.androidquery.AQuery in project androidquery by androidquery.

the class GoogleHandle method accountDialog.

private void accountDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
    //builder.setTitle("Select a Google account");
    accs = am.getAccountsByType("com.google");
    int size = accs.length;
    if (size == 1) {
        auth(accs[0]);
    } else {
        String[] names = new String[size];
        for (int i = 0; i < size; i++) {
            names[i] = accs[i].name;
        }
        builder.setItems(names, this);
        builder.setOnCancelListener(this);
        //.show();
        AlertDialog dialog = builder.create();
        new AQuery(act).show(dialog);
    }
}
Also used : AlertDialog(android.app.AlertDialog) AQuery(com.androidquery.AQuery)

Example 2 with AQuery

use of com.androidquery.AQuery in project androidquery by androidquery.

the class ImageLoadingList2Activity method work.

public void work() {
    List<String> items = new ArrayList<String>();
    items.add("http://farm4.static.flickr.com/3531/3769416703_b76406f9de.jpg");
    items.add("http://farm3.static.flickr.com/2490/3770244988_c9e93c3799.jpg");
    items.add("http://farm4.static.flickr.com/3008/2636284089_3a4383e9a4.jpg");
    items.add("http://farm3.static.flickr.com/2113/2263237656_e40b912b46.jpg");
    listAq = new AQuery(this);
    ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.content_item_s, items) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.content_item_s2, null);
            }
            String url = getItem(position);
            AQuery aq = listAq.recycle(convertView);
            aq.id(R.id.tb).progress(R.id.pbar).image(url, true, true, 0, 0, null, 0, AQuery.RATIO_PRESERVE);
            return convertView;
        }
    };
    aq.id(R.id.list).adapter(aa);
}
Also used : AQuery(com.androidquery.AQuery) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) View(android.view.View) ArrayAdapter(android.widget.ArrayAdapter)

Example 3 with AQuery

use of com.androidquery.AQuery in project androidquery by androidquery.

the class ImageLoadingList3Activity method renderNews.

public void renderNews(String url, JSONObject json, AjaxStatus status) {
    if (json == null)
        return;
    JSONArray ja = json.optJSONObject("responseData").optJSONArray("results");
    if (ja == null)
        return;
    List<JSONObject> items = new ArrayList<JSONObject>();
    for (int i = 0; i < 10; i++) {
        addItems(ja, items);
    }
    listAq = new AQuery(this);
    ArrayAdapter<JSONObject> aa = new ArrayAdapter<JSONObject>(this, R.layout.content_item_s, items) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = getLayoutInflater().inflate(R.layout.content_item_s, parent, false);
                holder.imageview = (ImageView) convertView.findViewById(R.id.tb);
                holder.progress = (ProgressBar) convertView.findViewById(R.id.progress);
                holder.name = (TextView) convertView.findViewById(R.id.name);
                holder.meta = (TextView) convertView.findViewById(R.id.meta);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            JSONObject jo = getItem(position);
            String tb = jo.optJSONObject("image").optString("tbUrl");
            AQuery aq = listAq.recycle(convertView);
            aq.id(holder.name).text(jo.optString("titleNoFormatting", "No Title"));
            aq.id(holder.meta).text(jo.optString("publisher", ""));
            aq.id(holder.imageview).progress(holder.progress).image(tb, true, true, 0, 0, null, 0, 1.0f);
            return convertView;
        }
    };
    aq.id(R.id.list).adapter(aa);
}
Also used : AQuery(com.androidquery.AQuery) JSONObject(org.json.JSONObject) ViewGroup(android.view.ViewGroup) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with AQuery

use of com.androidquery.AQuery in project androidquery by androidquery.

the class ImageLoadingList4Activity method renderPhotos.

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.photo_item, entries) {

        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.photo_item, parent, false);
            }
            Photo photo = getItem(position);
            AQuery aq = listAq.recycle(convertView);
            aq.id(R.id.name).text(photo.title);
            aq.id(R.id.meta).text(photo.author);
            String tbUrl = photo.tb;
            Bitmap placeholder = aq.getCachedImage(R.drawable.image_ph);
            if (aq.shouldDelay(position, convertView, parent, tbUrl)) {
                aq.id(R.id.tb).image(placeholder);
            } else {
                aq.id(R.id.tb).image(tbUrl, true, true, 0, R.drawable.image_missing, placeholder, AQuery.FADE_IN_NETWORK, 0);
            }
            return convertView;
        }
    };
    aq.id(R.id.list).adapter(aa);
//aq.scrolledBottom(this, "scrolledBottom");
}
Also used : AQuery(com.androidquery.AQuery) Bitmap(android.graphics.Bitmap) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 5 with AQuery

use of com.androidquery.AQuery in project androidquery by androidquery.

the class IntentListActivity method getAA.

private ArrayAdapter<ActivityItem> getAA() {
    list = new ArrayList<ActivityItem>();
    int[] ids = getResList();
    String[] names = getResources().getStringArray(ids[0]);
    String[] values = getResources().getStringArray(ids[1]);
    for (int i = 0; i < names.length; i++) {
        String name = names[i];
        String value = values[i];
        if (value.startsWith("http")) {
            list.add(new ActivityItem(null, name, value, null));
        } else {
            String[] vs = value.split(":");
            String meta = null;
            if (vs.length > 2) {
                meta = vs[2];
            }
            list.add(makeActivity(vs[0], name, vs[1], meta));
        }
    }
    if (type == null && (TestUtility.isTestDevice(this) || TestUtility.isEmulator())) {
        list.add(makeActivity("com.androidquery.test.AdhocActivity", "Ad Hoc Debug", "", null));
        list.add(makeActivity("com.androidquery.test.AdhocActivity2", "Ad Hoc Debug2", "", null));
    }
    ArrayAdapter<ActivityItem> result = new ArrayAdapter<ActivityItem>(this, R.layout.list_item, list) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = getLayoutInflater().inflate(R.layout.list_item, null);
            }
            ActivityItem ai = (ActivityItem) getItem(position);
            AQuery aq = new AQuery(convertView);
            String text = ai.getName();
            String meta = ai.getMeta();
            if (meta != null) {
                text += "   <small><small><font color=\"red\">" + meta + "</font></small></small>";
            }
            Spanned span = Html.fromHtml(text);
            aq.id(R.id.name).text(span);
            return convertView;
        }
    };
    return result;
}
Also used : AQuery(com.androidquery.AQuery) ViewGroup(android.view.ViewGroup) View(android.view.View) AdapterView(android.widget.AdapterView) Spanned(android.text.Spanned) ArrayAdapter(android.widget.ArrayAdapter)

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