use of com.androidquery.AQuery in project androidquery by androidquery.
the class Common method showProgress.
public static void showProgress(Object p, String url, boolean show) {
if (p != null) {
if (p instanceof View) {
View pv = (View) p;
ProgressBar pbar = null;
if (p instanceof ProgressBar) {
pbar = (ProgressBar) p;
}
if (show) {
pv.setTag(AQuery.TAG_URL, url);
pv.setVisibility(View.VISIBLE);
if (pbar != null) {
pbar.setProgress(0);
pbar.setMax(100);
}
} else {
Object tag = pv.getTag(AQuery.TAG_URL);
if (tag == null || tag.equals(url)) {
pv.setTag(AQuery.TAG_URL, null);
if (pbar == null || pbar.isIndeterminate()) {
pv.setVisibility(View.GONE);
}
}
}
} else if (p instanceof Dialog) {
Dialog pd = (Dialog) p;
AQuery aq = new AQuery(pd.getContext());
if (show) {
aq.show(pd);
} else {
aq.dismiss(pd);
}
} else if (p instanceof Activity) {
Activity act = (Activity) p;
;
act.setProgressBarIndeterminateVisibility(show);
act.setProgressBarVisibility(show);
if (show) {
act.setProgress(0);
}
}
}
}
use of com.androidquery.AQuery in project androidquery by androidquery.
the class Progress method showProgress.
private void showProgress(Object p, String url, boolean show) {
if (p != null) {
if (p instanceof View) {
View pv = (View) p;
ProgressBar pbar = null;
if (p instanceof ProgressBar) {
pbar = (ProgressBar) p;
}
if (show) {
pv.setTag(AQuery.TAG_URL, url);
pv.setVisibility(View.VISIBLE);
if (pbar != null) {
pbar.setProgress(0);
pbar.setMax(100);
}
} else {
Object tag = pv.getTag(AQuery.TAG_URL);
if (tag == null || tag.equals(url)) {
pv.setTag(AQuery.TAG_URL, null);
if (pbar != null && pbar.isIndeterminate()) {
pv.setVisibility(View.GONE);
}
}
}
} else if (p instanceof Dialog) {
Dialog pd = (Dialog) p;
AQuery aq = new AQuery(pd.getContext());
if (show) {
aq.show(pd);
} else {
aq.dismiss(pd);
}
} else if (p instanceof Activity) {
Activity act = (Activity) p;
;
act.setProgressBarIndeterminateVisibility(show);
act.setProgressBarVisibility(show);
if (show) {
act.setProgress(0);
}
}
}
}
use of com.androidquery.AQuery in project androidquery by androidquery.
the class AQueryImageTest method testCachedImageWithRecycle.
public void testCachedImageWithRecycle() {
clearCache();
final AQuery listAq = new AQuery(this.getActivity());
final View view = aq.id(R.id.image).getView();
AQUtility.post(new Runnable() {
@Override
public void run() {
AQuery aq = listAq.recycle(view);
Bitmap bm = aq.getCachedImage(R.drawable.icon);
assertNotNull(bm);
}
});
waitAsync(2000);
}
use of com.androidquery.AQuery in project androidquery by androidquery.
the class ImageGridFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.image_grid_fragment, container, false);
aq = new AQuery(getActivity(), view);
aq2 = new AQuery(getActivity());
return view;
}
use of com.androidquery.AQuery in project androidquery by androidquery.
the class ImageLoadingListActivity 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>();
addItems(ja, items);
addItems(ja, items);
addItems(ja, items);
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) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.content_item_s, null);
}
JSONObject jo = getItem(position);
AQuery aq = listAq.recycle(convertView);
aq.id(R.id.name).text(jo.optString("titleNoFormatting", "No Title"));
aq.id(R.id.meta).text(jo.optString("publisher", ""));
String tb = jo.optJSONObject("image").optString("tbUrl");
aq.id(R.id.tb).progress(R.id.progress).image(tb, true, true, 0, 0, null, AQuery.FADE_IN_NETWORK, 1.0f);
return convertView;
}
};
aq.id(R.id.list).adapter(aa);
}
Aggregations