Search in sources :

Example 1 with RequestCreator

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;
    }
}
Also used : Project(com.byoutline.kickmaterial.model.Project) Picasso(com.squareup.picasso.Picasso) AplaTransformation(com.byoutline.kickmaterial.utils.AplaTransformation) RequestCreator(com.squareup.picasso.RequestCreator)

Example 2 with RequestCreator

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);
}
Also used : Uri(android.net.Uri) File(java.io.File) RequestCreator(com.squareup.picasso.RequestCreator)

Example 3 with RequestCreator

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);
}
Also used : Target(com.squareup.picasso.Target) Bitmap(android.graphics.Bitmap) Picasso(com.squareup.picasso.Picasso) Drawable(android.graphics.drawable.Drawable) RequestCreator(com.squareup.picasso.RequestCreator)

Example 4 with RequestCreator

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);
}
Also used : Target(com.squareup.picasso.Target) Bitmap(android.graphics.Bitmap) Picasso(com.squareup.picasso.Picasso) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GeoPoint(org.osmdroid.util.GeoPoint) RequestCreator(com.squareup.picasso.RequestCreator)

Example 5 with RequestCreator

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);
}
Also used : Target(com.squareup.picasso.Target) Bitmap(android.graphics.Bitmap) Picasso(com.squareup.picasso.Picasso) Drawable(android.graphics.drawable.Drawable) RequestCreator(com.squareup.picasso.RequestCreator)

Aggregations

RequestCreator (com.squareup.picasso.RequestCreator)27 Picasso (com.squareup.picasso.Picasso)10 View (android.view.View)8 ImageView (android.widget.ImageView)8 TextView (android.widget.TextView)8 Bitmap (android.graphics.Bitmap)5 Drawable (android.graphics.drawable.Drawable)5 VafContext (com.tmall.wireless.vaf.framework.VafContext)5 IImageLoaderAdapter (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.IImageLoaderAdapter)5 Listener (com.tmall.wireless.vaf.virtualview.Helper.ImageLoader.Listener)5 ImageBase (com.tmall.wireless.vaf.virtualview.view.image.ImageBase)5 ArrayList (java.util.ArrayList)5 RecyclerView (android.support.v7.widget.RecyclerView)4 Target (com.squareup.picasso.Target)4 File (java.io.File)4 JSONException (org.json.JSONException)4 JSONObject (org.json.JSONObject)4 TargetApi (android.annotation.TargetApi)3 Intent (android.content.Intent)3 Uri (android.net.Uri)3