@Override public void bindView(View view, Context context, Cursor cursor) { Uri contactUri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY)); ViewHolder holder = (ViewHolder) view.getTag(); holder.text1.setText(cursor.getString(ContactsQuery.DISPLAY_NAME)); holder.icon.assignContactUri(contactUri); PicassoProvider.get() .load(contactUri) .placeholder(R.drawable.contact_picture_placeholder) .tag(context) .into(holder.icon); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SampleListDetailActivity activity = (SampleListDetailActivity) getActivity(); View view = LayoutInflater.from(activity) .inflate(R.layout.sample_list_detail_detail, container, false); TextView urlView = view.findViewById(R.id.url); ImageView imageView = view.findViewById(R.id.photo); Bundle arguments = getArguments(); String url = arguments.getString(KEY_URL); urlView.setText(url); PicassoProvider.get() .load(url) .fit() .tag(activity) .into(imageView); return view; } }
@Override public View getView(int position, View view, ViewGroup parent) { ViewHolder holder; if (view == null) { view = LayoutInflater.from(context).inflate(R.layout.sample_list_detail_item, parent, false); holder = new ViewHolder(); holder.image = view.findViewById(R.id.photo); holder.text = view.findViewById(R.id.url); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } // Get the image URL for the current position. String url = getItem(position); holder.text.setText(url); // Trigger the download of the URL asynchronously into the image view. PicassoProvider.get() .load(url) .placeholder(R.drawable.placeholder) .error(R.drawable.error) .resizeDimen(R.dimen.list_detail_image_size, R.dimen.list_detail_image_size) .centerInside() .tag(context) .into(holder.image); return view; }
@Test public void appWidgetActionWithCustomTag() { new RequestCreator(picasso, URI_1, 0).tag("tag") .into(mockRemoteViews(), 0, new int[] { 1, 2, 3 }); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue().getTag()).isEqualTo("tag"); }
@Test public void targetActionWithCustomTag() { new RequestCreator(picasso, URI_1, 0).tag("tag").into(mockTarget()); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue().getTag()).isEqualTo("tag"); }
@Test public void imageViewActionWithCustomTag() { new RequestCreator(picasso, URI_1, 0).tag("tag").into(mockImageViewTarget()); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue().getTag()).isEqualTo("tag"); }
@Test public void notificationActionWithCustomTag() { new RequestCreator(picasso, URI_1, 0).tag("tag") .into(mockRemoteViews(), 0, 0, mockNotification()); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue().getTag()).isEqualTo("tag"); }
@Override public View getView(int position, View convertView, ViewGroup parent) { SquaredImageView view = (SquaredImageView) convertView; if (view == null) { view = new SquaredImageView(context); view.setScaleType(CENTER_CROP); } // Get the image URL for the current position. String url = getItem(position); // Trigger the download of the URL asynchronously into the image view. PicassoProvider.get() // .load(url) // .placeholder(R.drawable.placeholder) // .error(R.drawable.error) // .fit() // .tag(context) // .into(view); return view; }