use of com.lauren.simplenews.beans.ImageBean in project SimpleNews by liuling07.
the class ImageJsonUtils method readJsonImageBeans.
/**
* 将获取到的json转换为图片列表对象
* @param res
* @return
*/
public static List<ImageBean> readJsonImageBeans(String res) {
List<ImageBean> beans = new ArrayList<ImageBean>();
try {
JsonParser parser = new JsonParser();
JsonArray jsonArray = parser.parse(res).getAsJsonArray();
for (int i = 1; i < jsonArray.size(); i++) {
JsonObject jo = jsonArray.get(i).getAsJsonObject();
ImageBean news = JsonUtils.deserialize(jo, ImageBean.class);
beans.add(news);
}
} catch (Exception e) {
LogUtils.e(TAG, "readJsonImageBeans error", e);
}
return beans;
}
use of com.lauren.simplenews.beans.ImageBean in project SimpleNews by liuling07.
the class ImageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ImageAdapter.ItemViewHolder holder, int position) {
ImageBean imageBean = mData.get(position);
if (imageBean == null) {
return;
}
holder.mTitle.setText(imageBean.getTitle());
float scale = (float) imageBean.getWidth() / (float) mMaxWidth;
int height = (int) (imageBean.getHeight() / scale);
if (height > mMaxHeight) {
height = mMaxHeight;
}
holder.mImage.setLayoutParams(new LinearLayout.LayoutParams(mMaxWidth, height));
ImageLoaderUtils.display(mContext, holder.mImage, imageBean.getThumburl());
}
Aggregations