use of com.squareup.picasso.RequestCreator in project kickmaterial by byoutline.
the class ProjectsAdapter method onBindViewHolder.
// Replace the contents of a view. This is invoked by the layout manager.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
int type = getItemViewType(position);
switch(type) {
case NORMAL_ITEM:
case BIG_ITEM:
Project project = getItem(position);
if (project != null) {
if (holder.projectId == project.id) {
// This view holder appears to already show correct project.
return;
} else {
holder.projectId = project.id;
}
ViewUtils.setTextForViewOrHideIt(holder.projectItemBigTitleTv, project.getProjectName());
holder.projectItemBigProgressSb.setProgress((int) project.getPercentProgress());
Picasso picasso = Picasso.with(context);
final RequestCreator picassoBuilder;
if (type == BIG_ITEM) {
setProjectDetailsInfo(null, holder.projectItemBigDescTv, holder.projectItemBigGatheredMoneyTv, holder.projectItemBigPledgedOfTv, holder.projectItemBigBackersTv, holder.projectItemBigTimeLeft, holder.projectItemBigTimeLeftType, project);
picassoBuilder = picasso.load(project.getBigPhotoUrl()).resize(bigItemWidth, bigItemHeight).placeholder(R.drawable.blank_project_wide);
} else {
picassoBuilder = picasso.load(project.getPhotoUrl()).resize(smallItemWidth, smallItemHeight).placeholder(R.drawable.blank_project_small);
}
picassoBuilder.onlyScaleDown().transform(new AplaTransformation()).centerCrop().into(holder.projectItemBigPhotoIv);
}
break;
}
}
use of com.squareup.picasso.RequestCreator in project scissors by lyft.
the class PicassoBitmapLoader method load.
@Override
public void load(@Nullable Object model, @NonNull ImageView imageView) {
final RequestCreator requestCreator;
if (model instanceof Uri || model == null) {
requestCreator = picasso.load((Uri) model);
} else if (model instanceof String) {
requestCreator = picasso.load((String) model);
} else if (model instanceof File) {
requestCreator = picasso.load((File) model);
} else if (model instanceof Integer) {
requestCreator = picasso.load((Integer) model);
} else {
throw new IllegalArgumentException("Unsupported model " + model);
}
requestCreator.skipMemoryCache().transform(transformation).into(imageView);
}
use of com.squareup.picasso.RequestCreator in project android-sdk-examples by IndoorAtlas.
the class MapsOverlayActivity method fetchFloorPlanBitmap.
/**
* Download floor plan using Picasso library.
*/
private void fetchFloorPlanBitmap(final IAFloorPlan floorPlan) {
final String url = floorPlan.getUrl();
if (mLoadTarget == null) {
mLoadTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(TAG, "onBitmap loaded with dimensions: " + bitmap.getWidth() + "x" + bitmap.getHeight());
setupGroundOverlay(floorPlan, bitmap);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
// N/A
}
@Override
public void onBitmapFailed(Drawable placeHolderDraweble) {
showInfo("Failed to load bitmap");
mOverlayFloorPlan = null;
}
};
}
RequestCreator request = Picasso.with(this).load(url);
final int bitmapWidth = floorPlan.getBitmapWidth();
final int bitmapHeight = floorPlan.getBitmapHeight();
if (bitmapHeight > MAX_DIMENSION) {
request.resize(0, MAX_DIMENSION);
} else if (bitmapWidth > MAX_DIMENSION) {
request.resize(MAX_DIMENSION, 0);
}
request.into(mLoadTarget);
}
use of com.squareup.picasso.RequestCreator in project android-sdk-examples by IndoorAtlas.
the class OpenStreetMapOverlay method fetchFloorPlanBitmap.
/**
* Download floor plan using Picasso library.
*/
private void fetchFloorPlanBitmap(final IAFloorPlan floorPlan) {
final String url = floorPlan.getUrl();
if (mLoadTarget == null) {
mLoadTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(TAG, "onBitmap loaded with dimensions: " + bitmap.getWidth() + "x" + bitmap.getHeight());
setupGroundOverlay(floorPlan, bitmap);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
// N/A
}
@Override
public void onBitmapFailed(Drawable placeHolderDraweble) {
Toast.makeText(OpenStreetMapOverlay.this, "Failed to load bitmap", Toast.LENGTH_SHORT).show();
mOverlayFloorPlan = null;
}
};
}
RequestCreator request = Picasso.with(this).load(url);
final int bitmapWidth = floorPlan.getBitmapWidth();
final int bitmapHeight = floorPlan.getBitmapHeight();
if (bitmapHeight > MAX_DIMENSION) {
request.resize(0, MAX_DIMENSION);
} else if (bitmapWidth > MAX_DIMENSION) {
request.resize(MAX_DIMENSION, 0);
}
request.into(mLoadTarget);
}
use of com.squareup.picasso.RequestCreator in project android-sdk-examples by IndoorAtlas.
the class WayfindingOverlayActivity method fetchFloorPlanBitmap.
/**
* Download floor plan using Picasso library.
*/
private void fetchFloorPlanBitmap(final IAFloorPlan floorPlan) {
final String url = floorPlan.getUrl();
if (mLoadTarget == null) {
mLoadTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(TAG, "onBitmap loaded with dimensions: " + bitmap.getWidth() + "x" + bitmap.getHeight());
setupGroundOverlay(floorPlan, bitmap);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
// N/A
}
@Override
public void onBitmapFailed(Drawable placeHolderDraweble) {
showInfo("Failed to load bitmap");
mOverlayFloorPlan = null;
}
};
}
RequestCreator request = Picasso.with(this).load(url);
final int bitmapWidth = floorPlan.getBitmapWidth();
final int bitmapHeight = floorPlan.getBitmapHeight();
if (bitmapHeight > MAX_DIMENSION) {
request.resize(0, MAX_DIMENSION);
} else if (bitmapWidth > MAX_DIMENSION) {
request.resize(MAX_DIMENSION, 0);
}
request.into(mLoadTarget);
}
Aggregations