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;
}
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);
}
}
Aggregations