Java Code Examples for com.squareup.picasso.Picasso

The following examples show how to use com.squareup.picasso.Picasso. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Retrofit_Example_Part_1   Source File: MyContactAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
        View view = mInflater.inflate(R.layout.layout_row_view, parent, false);
        vh = ViewHolder.create((RelativeLayout) view);
        view.setTag(vh);
    } else {
        vh = (ViewHolder) convertView.getTag();
    }

    Contact item = getItem(position);

    vh.textViewName.setText(item.getName());
    vh.textViewEmail.setText(item.getEmail());
    Picasso.with(context).load(item.getProfilePic()).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher).into(vh.imageView);

    return vh.rootView;
}
 
Example 2
Source Project: InstaMaterial   Source File: UserProfileActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_profile);

    this.avatarSize = getResources().getDimensionPixelSize(R.dimen.user_profile_avatar_size);
    this.profilePhoto = getString(R.string.user_profile_photo);

    Picasso.with(this)
            .load(profilePhoto)
            .placeholder(R.drawable.img_circle_placeholder)
            .resize(avatarSize, avatarSize)
            .centerCrop()
            .transform(new CircleTransformation())
            .into(ivUserProfilePhoto);

    setupTabs();
    setupUserProfileGrid();
    setupRevealBackground(savedInstanceState);
}
 
Example 3
Source Project: AndroidPlayground   Source File: InvitedDialogFragment.java    License: MIT License 6 votes vote down vote up
private void setupView(View view) {
    mAvatar = findById(view, R.id.mFromAvatar);
    Picasso.with(getContext()).load(mFromUserAvatar).into(mAvatar);

    CountdownView countdownView = findById(view, R.id.mCountDownTimber);
    countdownView.start(INVITE_EXPIRE_MILLIS);
    countdownView.setOnCountdownEndListener(new CountdownView.OnCountdownEndListener() {
        @Override
        public void onEnd(CountdownView cv) {
            dismiss();
        }
    });

    ImageView deny = findById(view, R.id.mIvDeny);
    deny.setOnClickListener(this);
    ImageView accept = findById(view, R.id.mIvAccept);
    accept.setOnClickListener(this);
}
 
Example 4
@Override
public void onBindViewHolder(@NonNull final ViewHolderScaleTeam holder, int position) {
    TeamsUploads item = getItem(position);

    Picasso picasso = Picasso.get();
    RequestCreator requestCreator;
    String url = UserImage.BASE_URL + "moulinette.jpg";
    requestCreator = picasso.load(url).resize(200, 240);
    requestCreator.into(holder.imageViewUser);

    holder.textViewCorrector.setText(R.string.project_moulinette);
    holder.textViewScale.setText(String.valueOf(item.finalMark));
    holder.textViewComment.setText(item.comment);
    holder.groupFeedback.setVisibility(View.GONE);
    holder.textViewUserFeedback.setVisibility(View.GONE);

}
 
Example 5
private void bindOneImage(int position, ImageView monsterImageView, Integer monsterId, boolean alreadyIgnored) {
	MyLog.entry("position = " + position);

	monsterImageView.clearColorFilter();

	if (monsterId != null && mTaskFragment.getMonsterInfoHelper() != null) {
		monsterImageView.setVisibility(View.VISIBLE);
		try {
			final MonsterInfoModel monsterInfo = mTaskFragment.getMonsterInfoHelper().getMonsterInfo(monsterId);
			mImageHelper.fillImage(monsterImageView, monsterInfo);

			if (!alreadyIgnored) {
				monsterImageView.setColorFilter(Color.parseColor("#99000000"), PorterDuff.Mode.DARKEN);
			}
		} catch (UnknownMonsterException e) {
			Picasso.with(getContext())
					.load(R.drawable.no_monster_image)
					.into(monsterImageView);
		}
	} else {
		MyLog.debug("no monster at " + position + ", ignored");
		monsterImageView.setVisibility(View.INVISIBLE);
	}
	MyLog.exit();
}
 
Example 6
Source Project: catnut   Source File: FantasyFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
	boolean fitXY = getArguments().getBoolean(FIT_XY);
	if (getActivity() instanceof HelloActivity) {
		if (!((HelloActivity) getActivity()).isNetworkAvailable()) {
			if (fitXY) {
				Toast.makeText(getActivity(), R.string.network_unavailable, Toast.LENGTH_SHORT).show();
				mFantasy.setImageResource(R.drawable.default_fantasy);
				return; // 没有网络,直接结束第一张fantasy
			}
		}
	}
	RequestCreator creator = Picasso.with(getActivity()).load(mUrl);
	if (fitXY) {
		creator.placeholder(R.drawable.default_fantasy);
	}
	creator.error(R.drawable.error)
			.into(target);
}
 
Example 7
Source Project: material   Source File: ContactEditText.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ContactView v = (ContactView)convertView;
    if (v == null)
        v = new ContactView(getContext(), null, 0, R.style.ContactView);

    Recipient recipient = (Recipient) getItem(position);
    v.setNameText(recipient.name);
    v.setAddressText(recipient.number);

    if(TextUtils.isEmpty(recipient.lookupKey))
        v.setAvatarResource(mDefaultAvatarId);
    else
        Picasso.with(getContext())
                .load(Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, recipient.lookupKey))
                .placeholder(mDefaultAvatarId)
                .into(v);

    return v;
}
 
Example 8
Source Project: MaterialWpp   Source File: OtherAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final MyHolder holder, final int position) {
        Picasso.with(holder.itemView.getContext()).load(datums.get(position).getSmallImgUrl())
        .noPlaceholder()
        .into(holder.imageView);
        holder.title.setText(datums.get(position).getLikesCount());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent(holder.itemView.getContext(), DetailActivity.class);
            intent.putExtra("id",pid);
            intent.putExtra("index",position);
            intent.putExtra("sourcetype",3);
            intent.putExtra("order","1");
            intent.putExtra("update",0);
            holder.itemView.getContext().startActivity(intent);
        }
    });

        }
 
Example 9
Source Project: Ruisi   Source File: PostAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
void setData(int position) {
    final SingleArticleData single = datalist.get(position);
    title.setText(single.title);
    userName.setText(single.username);
    String imgUrl = UrlUtils.getAvaterurlm(single.getImg());
    if (single.uid > 0) {
        Picasso.get()
            .load(imgUrl)
            .resize(size, size)
            .placeholder(R.drawable.image_placeholder)
            .error(R.drawable.image_placeholder)
            .into(userAvatar);
    } else {
        Picasso.get()
            .load(R.drawable.image_placeholder)
            .resize(size, size)
            .into(userAvatar);
    }
    
    String postTime = "发表于:" + single.postTime;
    this.postTime.setText(postTime);
    HtmlView.parseHtml(single.content).into(content);
}
 
Example 10
Source Project: monolog-android   Source File: AppContext.java    License: MIT License 6 votes vote down vote up
public void loadImg(ImageView v, String url, int width) {
    String absoluteUrl = url;
    try {
        Picasso.with(this)
                .load(absoluteUrl)
                .placeholder(R.drawable.img_bg)
                .error(R.drawable.ic_action_picture)
                .transform(new CropSquareTransformation())
                .resize(width, width)
                .into(v);
    } catch (Exception ex) {
        Picasso.with(this)
                .load(R.drawable.img_bg)
                .transform(new CropSquareTransformation())
                .into(v);
    }
}
 
Example 11
Source Project: Cheerleader   Source File: ArtistView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Set the {@link SoundCloudUser} used as model.
 *
 * @param artist user used as artist.
 */
public void setModel(SoundCloudUser artist) {
    mModel = artist;
    if (mModel != null) {
        Picasso.with(getContext())
                .load(
                        SoundCloudArtworkHelper.getCoverUrl(
                                mModel,
                                SoundCloudArtworkHelper.XLARGE
                        )
                )
                .fit()
                .centerInside()
                .into(mAvatar);
        mArtistName.setText(mModel.getFullName());
        mTracks.setText(
                String.format(
                        getResources().getString(R.string.artist_view_track_count),
                        mModel.getTrackCount()
                )
        );
        mDescription.setText(Html.fromHtml(mModel.getDescription()));
        this.setVisibility(VISIBLE);
    }
}
 
Example 12
Source Project: android-tv-leanback   Source File: VideoDetailsFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected DetailsOverviewRow doInBackground(Video... videos) {
    DetailsOverviewRow row = new DetailsOverviewRow(videos[0]);
    try {
        Bitmap poster = Picasso.with(getActivity())
                .load(videos[0].getThumbUrl())
                .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()),
                        dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext()))
                .centerCrop()
                .get();
        row.setImageBitmap(getActivity(), poster);
    } catch (IOException e) {
        Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e);
    }

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();
    adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString(
            R.string.action_play)));
    adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later)));
    row.setActionsAdapter(adapter);

    return row;
}
 
Example 13
Source Project: android   Source File: PicassoDataRequestHandler.java    License: MIT License 6 votes vote down vote up
@Override
public Result load(Request request, int networkPolicy) {
    String uri = request.uri.toString();
    String imageDataBytes = uri.substring(uri.indexOf(",") + 1);
    byte[] bytes = Base64.decode(imageDataBytes.getBytes(), Base64.DEFAULT);
    Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);

    if (bitmap == null) {
        String show = uri.length() > 50 ? uri.substring(0, 49) + "..." : uri;
        RuntimeException malformed = new RuntimeException("Malformed data uri: " + show);
        Log.e("Could not load image", malformed);
        throw malformed;
    }

    return new Result(bitmap, Picasso.LoadedFrom.NETWORK);
}
 
Example 14
Source Project: AndroidPlayground   Source File: InvitingDialogViewHolder.java    License: MIT License 5 votes vote down vote up
public void setupView() {
    mRootView.setVisibility(View.VISIBLE);
    mAvatar = findById(mRootView, R.id.mToAvatar);
    Picasso.with(mContext).load(mToUserAvatar).into(mAvatar);

    CountdownView countdownView = findById(mRootView, R.id.mCountDownTimber);
    countdownView.start(INVITE_EXPIRE_MILLIS);
    countdownView.setOnCountdownEndListener(new CountdownView.OnCountdownEndListener() {
        @Override
        public void onEnd(CountdownView cv) {
            if (mController != null) {
                mController.denied();
            }
        }
    });

    TextView tvToUsername = findById(mRootView, R.id.mTvToUsername);
    tvToUsername.setText(mToUsername);

    // TODO simulate accepted
    tvToUsername.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (mController != null) {
                mController.accepted(mFromUserAvatar, mFromUsername, mToUserAvatar, mToUsername,
                        mToUid);
            }
        }
    }, 5000);
}
 
Example 15
@Override
public void onBindFeaturedViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof FeaturedViewHolder) {
        FeaturedViewHolder featuredViewHolder = (FeaturedViewHolder) holder;
        Picasso.with(holder.itemView.getContext()).load(images[position % 4]).into(featuredViewHolder.ivBackground);
        featuredViewHolder.tvHeading.setText(data.get(position));
    } else if (holder instanceof DummyViewHolder) {
        //Do nothing
    }
}
 
Example 16
Source Project: ExoPlayer-Wrapper   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * ExoPlayerListener
 */

@Override
public void onThumbImageViewReady(ImageView imageView) {
    Picasso.get()
            .load(THUMB_IMG_URL)
            //.fit()
            .placeholder(R.drawable.place_holder)
            .error(R.drawable.error_image)
            .into(imageView);
}
 
Example 17
Source Project: android-player-samples   Source File: VideoListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, @SuppressLint("RecyclerView") final int position) {
    final Video video = videoList.get(position);
    holder.videoTitleText.setText(video.getName());

    Object descriptionObj = video.getProperties().get(PROPS_SHORT_DESCRIPTION);
    if (descriptionObj instanceof String) {
        holder.videoDescriptionText.setText((String) descriptionObj);
    }

    int duration = video.getDuration();
    if (duration > 0) {
        holder.videoDurationText.setText(millisecondsToString(duration));
        holder.videoDurationText.setVisibility(View.VISIBLE);
    } else {
        holder.videoDurationText.setText(null);
        holder.videoDurationText.setVisibility(View.GONE);
    }

    URI imageUri = video.getStillImageUri();
    if (imageUri == null) {
        holder.videoThumbnailImage.setImageResource(R.drawable.movie);
    } else {
        Picasso.get().load(imageUri.toASCIIString()).into(holder.videoThumbnailImage);
    }

    holder.videoThumbnailImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            clickListener.itemClicked(view, video, position);
        }
    });
}
 
Example 18
Source Project: UpcomingMoviesMVP   Source File: MovieDetailsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void renderMovie(MovieDetails movieDetails) {
  Picasso.with(getActivity().getApplicationContext())
      .load(getImageUrl(movieDetails.getMovie().getBackdropImage()))
      .into(ivBackDrop);
  tvTitle.setText(movieDetails.getMovie().getTitle());
  tvGenres.setText(new GenresFormatter().format(movieDetails.getGenres()));
  tvDescription.setText(movieDetails.getMovie().getOverview());
}
 
Example 19
Source Project: arcusandroid   Source File: ClipRecyclerViewAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public void bind(ClipModel clipModel) {
    long currentMilliseconds = System.currentTimeMillis();
    long expirationMilliseconds = clipModel.getDeleteTime().getTime();
    long millisToExpiry = Math.max(0, expirationMilliseconds - currentMilliseconds);

    Picasso.with(itemView.getContext()).load(clipModel.getCachedClipFile()).fit().into(imageView);
    trashImage.setVisibility(View.VISIBLE);
    downloadImage.setVisibility(View.VISIBLE);
    String unknownValue = ArcusApplication.getContext().getString(R.string.camera_duration_size_unknown);
    if (unknownValue.equals(clipModel.getDurationString()) && unknownValue.equals(clipModel.getSizeString())) {
        durationAndSize.setText(ArcusApplication.getContext().getString(R.string.camera_recording_in_progress));
        trashImage.setVisibility(View.INVISIBLE);
        downloadImage.setVisibility(View.INVISIBLE);
    } else {
        durationAndSize.setText(String.format("%s", clipModel.getDurationString()));
    }

    if(clipModel.getCameraName().isEmpty()){
        cameraName.setVisibility(View.GONE);
    } else {
        cameraName.setVisibility(View.VISIBLE);
        cameraName.setText(clipModel.getCameraName());
    }
    timeRecorded.setText(clipModel.getTimeString());
    if (clipModel.isDownloadDeleteAvailable()) {
        trashImage.setEnabled(true);
        trashImage.setAlpha(1f);
        downloadImage.setEnabled(true);
        downloadImage.setAlpha(1f);
    } else {
        trashImage.setEnabled(false);
        trashImage.setAlpha(.4f);
        downloadImage.setEnabled(false);
        downloadImage.setAlpha(.4f);
    }

    setPins(clipModel, millisToExpiry);
}
 
Example 20
Source Project: RxAndroidBootstrap   Source File: MainModelAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(MainModelViewHolder holder, int position) {
    MainListViewModel model = models.get(position);

    holder.titleTextView.setText(model.getTitle());
    Picasso.with(holder.view.getContext()).load(model.getImageUrl()).into(holder.imageView);

}
 
Example 21
Source Project: twitter-kit-android   Source File: TweetMediaView.java    License: Apache License 2.0 5 votes vote down vote up
void setMediaImage(ImageView imageView, String imagePath) {
    final Picasso imageLoader = dependencyProvider.getImageLoader();
    if (imageLoader == null) return;

    imageLoader.load(imagePath)
            .fit()
            .centerCrop()
            .error(photoErrorResId)
            .into(imageView, new PicassoCallback(imageView));
}
 
Example 22
Source Project: Ruisi   Source File: PostAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
void setData(int position) {
    final SingleArticleData single = datalist.get(position);
    username.setText(single.username);
    //判断是不是楼主
    boolean isLz = datalist.get(position).username.equals(datalist.get(0).username);
    labelLz.setVisibility(isLz ? View.VISIBLE : View.GONE);
    boolean isReply = single.replyUrlTitle.contains("action=reply");
    btnReplyCz.setVisibility(isReply ? View.VISIBLE : View.GONE);
    String imgUrl = UrlUtils.getAvaterurlm(single.getImg());
    if (single.uid > 0) {
        Picasso.get()
            .load(imgUrl)
            .resize(size, size)
            .placeholder(R.drawable.image_placeholder)
            .error(R.drawable.image_placeholder)
            .into(avatar);
    } else {
        Picasso.get()
            .load(R.drawable.image_placeholder)
            .resize(size, size)
            .into(avatar);
    }
    replyTime.setText(single.postTime);
    index.setText(single.index);
    HtmlView.parseHtml(single.content).into(comment);
}
 
Example 23
Source Project: UberClone   Source File: DriverHome.java    License: MIT License 5 votes vote down vote up
public void initDrawer(){
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    View navigationHeaderView=navigationView.getHeaderView(0);
    TextView tvName=(TextView)navigationHeaderView.findViewById(R.id.tvDriverName);
    TextView tvStars=(TextView)navigationHeaderView.findViewById(R.id.tvStars);
    CircleImageView imageAvatar=(CircleImageView) navigationHeaderView.findViewById(R.id.imageAvatar);

    tvName.setText(Common.currentUser.getName());
    if(Common.currentUser.getRates()!=null &&
            !TextUtils.isEmpty(Common.currentUser.getRates()))
        tvStars.setText(Common.currentUser.getRates());

     if(isLoggedInFacebook)
        Picasso.get().load("https://graph.facebook.com/" + Common.userID + "/picture?width=500&height=500").into(imageAvatar);
    else if(account!=null)
        Picasso.get().load(account.getPhotoUrl()).into(imageAvatar);

    if(Common.currentUser.getAvatarUrl()!=null &&
            !TextUtils.isEmpty(Common.currentUser.getAvatarUrl()))
    Picasso.get().load(Common.currentUser.getAvatarUrl()).into(imageAvatar);
}
 
Example 24
Source Project: STUer-client   Source File: PhotoActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photo);
    ButterKnife.inject(this);
    final String picName = getIntent().getStringExtra("picName");
    RequestCreator requestCreator = Picasso.with(this)
            .load(IMAGE_HOST + picName + ".jpg");
    requestCreator.into(mImageView);
    requestCreator.fetch(new Callback() {
        @Override
        public void onSuccess() {
            // 一开始为wrap_content使其居中,成功加载后match_parent使其放缩效果更佳
            mImageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
        }

        @Override
        public void onError() {
            Toast.makeText(PhotoActivity.this, "加载图片失败", Toast.LENGTH_SHORT).show();
        }
    });


    mAttacher = new PhotoViewAttacher(mImageView);
    mAttacher.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(PhotoActivity.this);
            builder.setItems(new String[]{"保存"}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    savePhoto(picName);
                }
            });
            builder.create().show();
            return false;
        }
    });

}
 
Example 25
Source Project: UltimateAndroid   Source File: ImageGridAdapter.java    License: Apache License 2.0 5 votes vote down vote up
void bindData(final Image data){
    if(data == null) return;
    // 处理单选和多选状态
    if(showSelectIndicator){
        indicator.setVisibility(View.VISIBLE);
        if(mSelectedImages.contains(data)){
            // 设置选中状态
            indicator.setImageResource(R.drawable.multi_image_select_btn_selected);
        }else{
            // 未选择
            indicator.setImageResource(R.drawable.multi_image_select_btn_unselected);
        }
    }else{
        indicator.setVisibility(View.GONE);
    }
    File imageFile = new File(data.path);

    if(mItemSize > 0) {
        // 显示图片
        Picasso.with(mContext)
                .load(imageFile)
                .placeholder(R.drawable.multi_image_select_default_error)
                        //.error(R.drawable.default_error)
                .resize(mItemSize, mItemSize)
                .centerCrop()
                .into(image);
    }
}
 
Example 26
Source Project: wikijourney_app   Source File: PoiListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void displayArticleImage(ViewHolder holder, String mPoiImageUrl) {
    Picasso.with(context).load(mPoiImageUrl)
            .placeholder(R.drawable.logo_cut)
            .fit()
            .centerCrop()
            .into(holder.mPoiPicture);
}
 
Example 27
Source Project: FriendlyDemo   Source File: ApplicationModule.java    License: Apache License 2.0 5 votes vote down vote up
@Provides
@NonNull
@Singleton
public Picasso providePicasso(@NonNull Application boxBeeApplication, @NonNull OkHttpClient okHttpClient) {
    return new Picasso.Builder(boxBeeApplication)
            .downloader(new OkHttp3Downloader(okHttpClient))
            .build();
}
 
Example 28
Source Project: school_shop   Source File: UserShareAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
	ShareEntity shareEntity = list.get(position);
	
	holder.price.setText("¥"+shareEntity.getGoodsPrice());
	holder.title.setText(shareEntity.getTitle());
	holder.desp.setText(shareEntity.getShareReason());
	
	if(shareEntity.getImgUrl()!=null){
		String imgUrls[] = shareEntity.getImgUrl().split(";");
		Picasso picasso = Picasso.with(holder.imageView.getContext());
        picasso.load(imgUrls[0]).placeholder(R.drawable.ic_img_loading).into(holder.imageView);
	}
	holder.itemView.setTag(shareEntity);
}
 
Example 29
Source Project: BuildingForAndroidTV   Source File: TVGridFragment.java    License: MIT License 5 votes vote down vote up
protected void updateBackground(URI uri) {
	Picasso.with(getActivity())
			.load(uri.toString())
			.resize(mMetrics.widthPixels, mMetrics.heightPixels)
			.centerInside()
			.error(mDefaultBackground)
			.into(mBackgroundTarget);
}
 
Example 30
Source Project: Amphitheatre   Source File: CardPresenter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    Drawable bitmapDrawable = new BitmapDrawable(mCardView.getContext().getResources(), bitmap);
    mCardView.setMainImage(bitmapDrawable);

    Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                Utils.animateColorChange(
                        mCardView.findViewById(R.id.info_field),
                        mCardView.getContext().getResources().getColor(R.color.lb_basic_card_info_bg_color),
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_BACKGROUND_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_info_bg_color))
                );
            }
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_TITLE_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                ((TextView)mCardView.findViewById(R.id.title_text)).setTextColor(
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_TITLE_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_title_text_color))
                );
            }
            if (Enums.PalettePresenterType.valueOf(mSharedPrefs.getString(Constants.PALETTE_CONTENT_VISIBLE, "")) == Enums.PalettePresenterType.ALLCARDS) {
                ((TextView)mCardView.findViewById(R.id.content_text)).setTextColor(
                        Utils.getPaletteColor(
                                palette,
                                mSharedPrefs.getString(Constants.PALETTE_CONTENT_UNSELECTED, ""),
                                mCardView.getContext().getResources().getColor(R.color.lb_basic_card_content_text_color))
                );
            }
        }
    });
}