Java Code Examples for com.squareup.picasso.Picasso#with()

The following examples show how to use com.squareup.picasso.Picasso#with() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserGoodsAdapter.java    From school_shop with MIT License 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
	GoodsEntity goodsEntity = list.get(position);
	
	holder.price.setText("¥"+goodsEntity.getGoodPrice());
	holder.title.setText(goodsEntity.getGoodName());
	holder.desp.setText(goodsEntity.getGoodDescribe());
	
	if(goodsEntity.getGoodImages()!=null){
		String imgUrls[] = goodsEntity.getGoodImages().split(";");
		Log.i("tag", "imgUrls[0]===="+imgUrls[0]);
		Picasso picasso = Picasso.with(holder.imageView.getContext());
        picasso.load(imgUrls[0]).placeholder(R.drawable.ic_img_loading).into(holder.imageView);
	}
	holder.itemView.setTag(goodsEntity);
}
 
Example 2
Source File: StackWidgetService.java    From GitJourney with Apache License 2.0 6 votes vote down vote up
@Override
public RemoteViews getViewAt(int position) {
    Log.v(TAG, "getViewAt: position = " + position);

    // Construct a remote views item based on the app widget item XML file,
    // and set the text based on the position.
    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_list_item);
    Intent fillInIntent = new Intent();
    fillInIntent.putExtra(EXTRA_LIST_VIEW_ROW_NUMBER, position);
    rv.setOnClickFillInIntent(R.id.main_list_item, fillInIntent);

    rv.setTextViewText(R.id.w_author_name, widgetDatas.get(position).getAuthorName());
    rv.setTextViewText(R.id.w_title, widgetDatas.get(position).getTitle());
    Picasso pic = Picasso.with(context);
    try {
        Bitmap map = pic.load(widgetDatas.get(position).getAvatar()).get();
        rv.setImageViewBitmap(R.id.w_github_user_image, map);
    } catch (IOException e) {
        Log.e(TAG, "", e);
    }
    return rv;
}
 
Example 3
Source File: ImageLoader.java    From KlyphMessenger with MIT License 6 votes vote down vote up
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	if (uri == null || uri.length() == 0)
		uri = FAKE_URI;

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	requestCreator.into(imageView, listener);
}
 
Example 4
Source File: ImageLoader.java    From Klyph with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	/*uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("�", URLEncoder.encode("�"));
	uri = uri.replace("'", URLEncoder.encode("'"));
	uri = uri.replace("�", URLEncoder.encode("�"));*/
	
	uri = Uri.encode(uri, ALLOWED_URI_CHARS);

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 5
Source File: ComposerView.java    From twitter-kit-android with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    imageLoader = Picasso.with(getContext());
    // TODO: make color vary depending on the style
    mediaBg = new ColorDrawable(context.getResources()
            .getColor(R.color.tw__composer_light_gray));
    inflate(context, R.layout.tw__composer_view, this);
}
 
Example 6
Source File: DemoScrollListener.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    final Picasso picasso = Picasso.with(context);
    if (scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_TOUCH_SCROLL) {
        picasso.resumeTag(context);
    } else {
        picasso.pauseTag(context);
    }
}
 
Example 7
Source File: TweetUi.java    From twitter-kit-android with Apache License 2.0 5 votes vote down vote up
TweetUi() {
    final TwitterCore twitterCore = TwitterCore.getInstance();

    context = Twitter.getInstance().getContext(getIdentifier());
    sessionManager = twitterCore.getSessionManager();
    guestSessionProvider = twitterCore.getGuestSessionProvider();
    tweetRepository = new TweetRepository(new Handler(Looper.getMainLooper()),
            twitterCore.getSessionManager());
    imageLoader = Picasso.with(Twitter.getInstance().getContext(getIdentifier()));
}
 
Example 8
Source File: SampleListFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_list_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);

    int listLayout = getArguments().getInt(ARG_LAYOUT);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout);
    listView.setAdapter(adapter);

    return view;
}
 
Example 9
Source File: SampleBubbleFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_chat_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);

    int listLayout1 = getArguments().getInt(ARG_LAYOUT_1);
    int listLayout2 = getArguments().getInt(ARG_LAYOUT_2);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2);
    listView.setAdapter(adapter);

    return view;
}
 
Example 10
Source File: ImageLoader.java    From Contacts with MIT License 5 votes vote down vote up
public static void display(ImageView imageView, Uri uri, boolean fadeIn, int stubImage, ImageLoaderListener listener)
{
	/*if (uri == null || uri.length() == 0)
		uri = FAKE_URI;
	
	//uri = Uri.encode(uri, ALLOWED_URI_CHARS);*/

	Picasso picasso = Picasso.with(imageView.getContext());
	RequestCreator requestCreator = picasso.load(uri);

	if (stubImage != 0)
	{
		requestCreator.placeholder(stubImage);
		requestCreator.error(stubImage);
	}

	if (!(fadeIn && FADE_ENABLED))
		requestCreator.noFade();

	LayoutParams params = imageView.getLayoutParams();

	if (params.width > 0 && params.height > 0)
	{
		requestCreator.resize(params.width, params.height, true);
	}

	requestCreator.inSampleSize(true);
	requestCreator.into(imageView, listener);
}
 
Example 11
Source File: ProcessListAdapter.java    From AndroidProcesses with Apache License 2.0 5 votes vote down vote up
public ProcessListAdapter(Context context, List<AndroidAppProcess> processes) {
  this.context = context.getApplicationContext();
  this.inflater = LayoutInflater.from(context);
  this.iconSize = Utils.toPx(context, 46);
  this.picasso = Picasso.with(context);
  this.processes = processes;
}
 
Example 12
Source File: SampleBubbleFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_chat_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);

    int listLayout1 = getArguments().getInt(ARG_LAYOUT_1);
    int listLayout2 = getArguments().getInt(ARG_LAYOUT_2);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2);
    listView.setAdapter(adapter);

    return view;
}
 
Example 13
Source File: MovieDetailsFragment.java    From udacity-p1-p2-popular-movies with MIT License 4 votes vote down vote up
private void updateMovieDetails() {
    Picasso picasso = Picasso.with(getActivity());

    mToolbar.setTitle(mMovie.getTitle());

    if (mAnimBackdropAnimateAlpha) {
        mBackdrop.setAlpha(0f); // wait for enter animation
    }
    mBackdrop.setTranslationY(0);
    int backdropWidth = mBackdrop.getWidth();   // this will be correct because this function is
                                                // only called after layout is complete
    int backdropHeight = getResources().getDimensionPixelSize(R.dimen.details_backdrop_height);
    RequestCreator backdropRequest = picasso
            .load(TMDbUtil.buildBackdropUrl(mMovie.getBackdropPath(), backdropWidth))
            .resize(backdropWidth, backdropHeight)
            .centerCrop()
            .transform(PaletteTransformation.instance());
    if (! mAnimBackdropAnimateAlpha) {
        backdropRequest.noFade();
    }
    backdropRequest.into(mBackdrop, new PaletteTransformationCallback(mBackdrop));

    if (mAnimBackdropAnimateAlpha) {
        mPoster.setAlpha(0f); // wait for enter animation
    }
    mPoster.setTranslationY(0);
    int posterWidth = getResources().getDimensionPixelSize(R.dimen.details_poster_width);
    int posterHeight = getResources().getDimensionPixelSize(R.dimen.details_poster_height);
    RequestCreator posterRequest = picasso
            .load(TMDbUtil.buildPosterUrl(mMovie.getPosterPath(), posterWidth))
            .resize(posterWidth, posterHeight)
            .centerCrop();
    if (! mAnimBackdropAnimateAlpha) {
        posterRequest.noFade();
    }
    posterRequest.into(mPoster);

    mTitle.setText(mMovie.getTitle());

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(mMovie.getReleaseDate());
    mReleaseDate.setText(String.valueOf(calendar.get(Calendar.YEAR)));

    mRating.setText(String.format("%1$2.1f", mMovie.getRating()));
    mSynopsis.setText(mMovie.getSynopsis());
}
 
Example 14
Source File: PickImgGridAdapter.java    From school_shop with MIT License 4 votes vote down vote up
@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		int type = getItemViewType(position);
		int width = context.getResources().getDisplayMetrics().widthPixels / 3;
		if (type == TYPE_PHOTO) {
			ViewHolder holder = null;
			if (convertView == null) {
				convertView = inflater.inflate(R.layout.item_photopick_gridlist,parent, false);
				holder = new ViewHolder();
				holder.imgView = (ImageView)convertView.findViewById(R.id.item_photo_img);
				convertView.setTag(holder);
			}else {
				holder = (ViewHolder) convertView.getTag();
			}
			
			Picasso picasso = Picasso.with(holder.imgView.getContext());
	        picasso.load(mData.get(position).path).resize(width, width).placeholder(R.drawable.ic_img_loading).into(holder.imgView);
			
		} else {
            final GridCameraHolder cameraHolder;
            if (convertView == null) {

                lastTime = System.currentTimeMillis();

                convertView = inflater.inflate(R.layout.photopick_gridlist_item_camera, parent, false);

                ViewGroup.LayoutParams layoutParams = convertView.getLayoutParams();
                layoutParams.height = width;
                layoutParams.width = width;

                cameraHolder = new GridCameraHolder();
//                cameraHolder.cameraPreview = (CameraPreview) convertView.findViewById(R.id.cameraPreview);
//                cameraHolder.cameraPreview.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        cameraHolder.cameraPreview.stopAndReleaseCamera();
//                        camera();
//                    }
//                });
            }
        }
//		try {
//			holder.imgView.setImageBitmap(Bimp.revitionImageSize(mData.get(position).path));
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		return convertView;
	}
 
Example 15
Source File: MizuuApplication.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
public static Picasso getPicasso(Context context) {
	if (sPicasso == null)
		sPicasso = Picasso.with(context);
	return sPicasso;
}
 
Example 16
Source File: CustomViewHolderFactory.java    From easyrecycleradapters with Apache License 2.0 4 votes vote down vote up
public CustomViewHolderFactory(Context context) {
    super(context);
    this.picasso = Picasso.with(context);
}
 
Example 17
Source File: FeedViewModule.java    From protohipster with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
Picasso providePicasso(@ForApplication Context context) {
    return Picasso.with(context);
}
 
Example 18
Source File: VideoItemFragment.java    From android-tv-leanback with Apache License 2.0 4 votes vote down vote up
public MovieAdapter(Context context) {
    super(context, R.layout.video_card, null, 0);
    this.mPicasso = Picasso.with(context);
}
 
Example 19
Source File: SimpleYoutubeListAdapter.java    From RxTube with Apache License 2.0 4 votes vote down vote up
public SimpleYoutubeListAdapter(Context context, List<Video> videoListResponses) {
  super(context);

  videos = videoListResponses;
  picasso = Picasso.with(context);
}
 
Example 20
Source File: SampleAdapter.java    From scalpel with Apache License 2.0 4 votes vote down vote up
public SampleAdapter(Context context) {
  inflater = LayoutInflater.from(context);
  picasso = Picasso.with(context);
}