use of com.gracecode.android.presentation.dao.Pin in project Presentation by feelinglucky.
the class PstRequest method getPinsFromResponse.
private int getPinsFromResponse(String response) {
JsonObject jsonObject = (JsonObject) new JsonParser().parse(response);
JsonArray jsonArrayPins = jsonObject.getAsJsonArray("pins");
mAffectedRows = 0;
for (int i = 0; i < jsonArrayPins.size(); i++) {
JsonObject tmp = (JsonObject) jsonArrayPins.get(i);
Pin pin = mGson.fromJson(tmp, Pin.class);
Pin.File file = mGson.fromJson(tmp.getAsJsonObject("file"), Pin.File.class);
pin.setKey(file.key);
pin.setWidth(file.width);
pin.setHeight(file.height);
// ignore gif and some 'bad' images.
if (file.frames == 1 && (file.width / (float) file.height < .38f)) {
try {
Dao.CreateOrUpdateStatus status = mDatabaseHelper.getPinsDAO().createOrUpdate(pin);
mAffectedRows += status.getNumLinesChanged();
} catch (SQLException e) {
Logger.e(e.getMessage());
}
}
}
mListener.onSaved(mAffectedRows);
return mAffectedRows;
}
use of com.gracecode.android.presentation.dao.Pin in project Presentation by feelinglucky.
the class PinsAdapter method getView.
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
Pin pin = getItem(i);
String imageUrl = mHuabanApp.isDownloadRetinaImage() ? pin.getRetinaSquareThumbUrl() : pin.getSquareThumbUrl();
if (view == null) {
LayoutInflater inflater = LayoutInflater.from(mContext);
view = inflater.inflate(R.layout.grid, null);
}
if (i > getCount() - 2) {
loadPinsByMaxId(true);
}
Holder h = Holder.get(view);
Logger.v("Load image from " + imageUrl);
h.mImageView.setImageUrl(imageUrl, mHuabanApp.getImageLoader());
h.mTitle.setText(pin.getText());
if (pin.getText().trim().length() > 0) {
h.mTitle.setVisibility(View.VISIBLE);
} else {
h.mTitle.setVisibility(View.INVISIBLE);
}
return view;
}
Aggregations