Search in sources :

Example 11 with PQuery

use of com.androidquery.simplefeed.PQuery in project simplefacebook by androidquery.

the class DialogUtility method makeDialog.

public static Dialog makeDialog(final Activity act, final List<ActionItem> items, final OnClickListener listener) {
    final PQuery aq = new PQuery(act);
    ArrayAdapter<ActionItem> adapter = new ArrayAdapter<DialogUtility.ActionItem>(act, R.layout.item_dialog, items) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView = aq.inflate(convertView, R.layout.item_dialog, parent);
            aq.recycle(convertView);
            ActionItem item = getItem(position);
            String name = item.name;
            String tb = item.tb;
            if (name == null && item.text > 0) {
                aq.id(R.id.tb).image(item.icon).background(0).getImageView().setScaleType(ScaleType.FIT_CENTER);
                String text = convertView.getContext().getString(item.text);
                if (item.count > 0) {
                    text += " (" + item.count + ")";
                }
                aq.id(R.id.name).text(text);
            } else if (name != null) {
                aq.id(R.id.tb).background(R.color.ph).image(tb, true, true, 0, 0, null, AQuery.FADE_IN_NETWORK, 1.0f);
                // + " (" + act.getString(R.string.wall) + ")";
                String text = item.name;
                aq.id(R.id.name).text(text);
            }
            /*
    			String tb = item.tb;
    			
    			if(tb == null){
    				aq.id(R.id.tb).image(item.icon).background(0).getImageView().setScaleType(ScaleType.FIT_CENTER);
    				String text = convertView.getContext().getString(item.text);
    				if(item.count >= 0){
    					text += " (" + item.count + ")";
    				}
    				aq.id(R.id.name).text(text);
    			}else{
    				aq.id(R.id.tb).background(R.color.ph).image(tb, true, true, 0, 0, null, AQuery.FADE_IN_NETWORK, 1.0f);
    				String text = item.name;// + " (" + act.getString(R.string.wall) + ")";
    				aq.id(R.id.name).text(text);
    			}
    			*/
            return convertView;
        }
    };
    OnClickListener ocl = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            ActionItem item = items.get(which);
            listener.onClick(dialog, item.id);
        }
    };
    AlertDialog dia = new AlertDialog.Builder(act).setAdapter(adapter, ocl).create();
    dia.setCanceledOnTouchOutside(true);
    dia.setInverseBackgroundForced(false);
    return dia;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) PQuery(com.androidquery.simplefeed.PQuery) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) View(android.view.View) ArrayAdapter(android.widget.ArrayAdapter)

Example 12 with PQuery

use of com.androidquery.simplefeed.PQuery in project simplefacebook by androidquery.

the class FeedFragment method notiCb.

public void notiCb(String url, JSONObject jo, AjaxStatus status) {
    AQUtility.debug("noti", jo);
    if (jo != null) {
        int count = 0;
        PQuery aq = aq2.recycle(header);
        /*
    		JSONObject sum = jo.optJSONObject("summary");
    		
    		if(sum != null){
    			count = sum.optInt("unseen_count", 0); 		    			
    		}*/
        JSONArray ja = jo.optJSONArray("data");
        for (int i = 0; i < ja.length(); i++) {
            JSONObject noti = ja.optJSONObject(i);
            if (noti.optInt("unread", 0) != 0) {
                count++;
            }
        }
        String message = count + " " + getString(R.string.n_notifications);
        aq.id(R.id.text_noti).text(message);
        int colorId = R.color.noti;
        int tf = Typeface.BOLD;
        if (count == 0) {
            colorId = R.color.grey;
            tf = Typeface.NORMAL;
        }
        aq.textColor(getResources().getColor(colorId)).getTextView().setTypeface(null, tf);
    }
}
Also used : JSONObject(org.json.JSONObject) PQuery(com.androidquery.simplefeed.PQuery) JSONArray(org.json.JSONArray)

Aggregations

PQuery (com.androidquery.simplefeed.PQuery)12 Entity (com.androidquery.simplefeed.data.Entity)4 View (android.view.View)3 ViewGroup (android.view.ViewGroup)2 ArrayAdapter (android.widget.ArrayAdapter)2 JSONObject (org.json.JSONObject)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 WebView (android.webkit.WebView)1 TextView (android.widget.TextView)1 MarketService (com.androidquery.service.MarketService)1 PTransformer (com.androidquery.simplefeed.callback.PTransformer)1 FeedItem (com.androidquery.simplefeed.data.FeedItem)1 FeedMode (com.androidquery.simplefeed.enums.FeedMode)1 PagedAdapter (greendroid.widget.PagedAdapter)1 PagedView (greendroid.widget.PagedView)1 OnPagedViewChangeListener (greendroid.widget.PagedView.OnPagedViewChangeListener)1 JSONArray (org.json.JSONArray)1