@Override public void onCreate() { super.onCreate(); if(!FirebaseApp.getApps(this).isEmpty()){ FirebaseDatabase.getInstance().setPersistenceEnabled(true); } Picasso.Builder builder = new Picasso.Builder(this); builder.downloader(new OkHttp3Downloader(this, Integer.MAX_VALUE)); Picasso built = builder.build(); built.setIndicatorsEnabled(false); built.setLoggingEnabled(true); Picasso.setSingletonInstance(built); }
private void setUpBackdrop(View view) { Context context = view.getContext(); ImageView imgBackdrop = (ImageView) view.findViewById(R.id.iv_movie_backdrop); View viewOverlay = view.findViewById(R.id.view_backdrop_overlay); TextView tvTitle = (TextView) view.findViewById(R.id.tv_movie_detail_title); Picasso.with(context) .load(R.mipmap.civil_war_backdrop) .transform(new GrayscaleTransformation(Picasso.with(context))) .into(imgBackdrop); imgBackdrop.setContentDescription(mTitle); viewOverlay.setAlpha((float) 0.8); }
@Override public View getItemView(int sectionIndex, int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate( R.layout.pic_view, parent, false); } ImageView img = (ImageView) convertView.findViewById(R.id.pic); if (hideImages) { int idx = position % colors.length; img.setBackgroundColor(colors[idx]); } else { Shot s = (Shot)(this.section.getData().get(position)); Picasso.with(context) .load(s.getImage_teaser_url()) .into(img); } return convertView; }
@Override public void onBindViewHolder(MyViewHolder holder, final int position) { if(holder.itemView.getScrollX()!=0){ ((HorizontalScrollView)holder.itemView).fullScroll(View.FOCUS_UP);//如果item的HorizontalScrollView没在初始位置,则滚动回顶部 } holder.ll.setMinimumWidth(screenwidth);//设置LinearLayout宽度为屏幕宽度 holder.tv.setText("图"+position); Picasso.with(LineActivity2.this).load(meizis.get(position).getUrl()).into(holder.iv); holder.ll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SnackbarUtil.ShortSnackbar(coordinatorLayout,"点击第"+position+"个",SnackbarUtil.Info).show(); } }); }
@Override public void initData() { mCurrentUser = BmobUser.getCurrentUser(User.class); BmobFile userPhotoFile = mCurrentUser.getUserPhoto(); String nick = mCurrentUser.getNick(); String objectId = mCurrentUser.getObjectId(); if (!TextUtils.isEmpty(nick)) { mTvName.setText(nick); } if (!TextUtils.isEmpty(objectId)) { mTvID.setText("飞鸽号:" + objectId); } if (userPhotoFile == null) { mCivUserPhoto.setImageResource(R.drawable.ic_default); } else { Picasso.with(getContext()).load(userPhotoFile.getFileUrl()).into(mCivUserPhoto); } }
@Override public View getView(int i, View view) { ImageView iv = new ImageView(context); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setBackgroundColor(Color.parseColor("#f5f5f5")); Picasso.with(context).load(getUrl(i)).placeholder(new ColorDrawable(Color.parseColor("#f5f5f5"))).into(iv); return iv; }
void bind(Article article) { mData = article; if (!TextUtils.isEmpty(article.getCoverUrl())) { mBinding.coverView.setVisibility(View.VISIBLE); Picasso.with(itemView.getContext()) .load(article.getCoverUrl()) .centerCrop() .fit() .into(mBinding.coverView); } else { mBinding.coverView.setVisibility(View.GONE); } mBinding.titleView.setText(article.getTitle()); mBinding.descriptionView.setText(article.getDescription()); }
@Override public void onBindViewHolder(NewsVH holder, int position) { if (position == (mNewsArticleList.size()-1)) { mOnBottomReachedListener.onBottomReached(); } final NewsArticle article = mNewsArticleList.get(position); String imageUrl = getNewsImagePath(article.getPulseImage().getCloudId()); holder.newsTitle.setText(article.getTitle()); holder.newsDate.setText(TextUtils. getFormattedDateForArticleFromUnixEpoch(article.getCreatedTimestamp())); Picasso.with(mContext) .load(imageUrl) .placeholder(R.drawable.placeholder_image) .into(holder.newsImage); holder.newsCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mNewsArticleListener.onNewsArticleClickListener(article); } }); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView==null) { holder=new ViewHolder(); inflater=LayoutInflater.from(context); convertView= inflater.inflate(R.layout.videolist, parent, false); holder.tvtitle=(TextView) convertView.findViewById(R.id.videoTitletextview); holder.ivthumbnail=(ImageView) convertView.findViewById(R.id.videoPreviewThumb); convertView.setTag(holder); } else { holder=(ViewHolder)convertView.getTag(); } holder.tvtitle.setText(video.get(position).getName()); holder.tvtitle.setTypeface(typeface); Picasso.with(context).load("https://i.ytimg.com/vi/"+video.get(position).getVideoId().toString()+"/hqdefault.jpg").placeholder(R.drawable.logowhite).into(holder.ivthumbnail); return convertView; }
@Override public void onBindViewHolder(RecyclerTestHolder holder, int position) { HomepageData.RecSpecialistBean data = datalist.get(position); HomepageData.RecSpecialistBean.ExperInfoBean experInfo = datalist.get(position).getExperInfo(); Picasso.with(context) .load(UrlInfo.PREFIX_IMAGE_URL + experInfo.getAvatar()) .into(holder.ivSchemeicon); String name = experInfo.getSname() + experInfo.getGname(); holder.tvExpertName.setText(name); if (data.getTitle()!= null) { holder.tvExperttitle.setText(data.getTitle() + ""); } else { holder.tvExperttitle.setText(""); } holder.tvCompanyName.setText(experInfo.getEmployer()); if (data.getSpecialty()!= null) { holder.tvExpertServiceMoney.setText("擅长:" + data.getSpecialty()); } else { holder.tvExpertServiceMoney.setText("擅长:"); } holder.BuyTimes.setText("已服务100次"); }
private View getImageView(Context context, int resId) { /* 设置某一页面的view */ RelativeLayout relativeLayout = new RelativeLayout(context); ImageView imageView = new ImageView(context); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(layoutParams); // 设置一个半透明的黑色背景,防止白字受白色图片干扰而无法显示 ImageView background = new ImageView(context); background.setLayoutParams(layoutParams); background.setBackgroundResource(R.color.colorCycleViewBannerBackground); relativeLayout.addView(imageView); relativeLayout.addView(background); Picasso.with(context).load(resId).into(imageView); return relativeLayout; }
private void populateUserProfileData() { repositories.setText(String.format(Locale.getDefault(), "%d", entry.getPublicRepos())); followers.setText(String.format(Locale.getDefault(), "%d", entry.getFollowers())); following.setText(String.format(Locale.getDefault(), "%d", entry.getFollowing())); Picasso pic = Picasso.with(this.getContext()); if (entry.getImageUri() == null || entry.getImageUri().isEmpty()) { pic.load(R.drawable.octocat) .fit().centerCrop() .into(profilePoster); } else { pic.load(entry.getImageUri()) .fit().centerCrop() .error(R.drawable.octocat) .into(profilePoster); } }
public void bindView(FeedItem feedItem, String userId) { this.feedItem = feedItem; Picasso.with(itemView.getContext()) .load(Uri.parse(feedItem.getUserAvatarUrl())) .into(ivUserAvatar); tvUserName.setText(feedItem.getUserNickname()); Picasso.with(itemView.getContext()) .load(Uri.parse(feedItem.getPhotoSourceUrl())) .into(ivPhoto); if (feedItem.getPhotoDescription().isEmpty()) { tvDescription.setVisibility(View.GONE); } else { tvDescription.setVisibility(View.VISIBLE); tvDescription.setText( getStylizedText(feedItem.getUserNickname(), feedItem.getPhotoDescription())); } List<String> userLikes = feedItem.getUserLikes(); int likesCount = userLikes != null ? userLikes.size() : 0; btnLike.setImageResource( userLikes != null && userLikes.contains(userId) ? R.drawable.ic_heart_red : R.drawable.ic_heart_outline_grey); tsLikesCounter.setCurrentText( itemView.getResources().getQuantityString(R.plurals.likes_count, likesCount, likesCount)); }
@Override public RemoteViews notificationChange(Notification notification, int notificationId, RemoteViews remoteViews) { if (mImageNotification != null) { remoteViews.setViewVisibility(R.id.notification_icon, View.VISIBLE); Picasso.with(this).load(mImageNotification) .into(remoteViews, R.id.notification_icon, notificationId, notification); } remoteViews.setViewVisibility(R.id.notification_title, View.VISIBLE); remoteViews.setTextViewText(R.id.notification_title, mTitle.getText().toString()); remoteViews.setViewVisibility(R.id.notification_subtitle, View.VISIBLE); remoteViews.setTextViewText(R.id.notification_subtitle, mSubtitle.getText().toString()); if (!mStop.isChecked()) { remoteViews.setViewVisibility(R.id.stop_icon, View.GONE); } if (!mPlayPause.isChecked()) { remoteViews.setViewVisibility(R.id.play_icon, View.GONE); remoteViews.setViewVisibility(R.id.pause_icon, View.GONE); } return remoteViews; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animal_detail); supportPostponeEnterTransition(); Bundle extras = getIntent().getExtras(); AnimalItem animalItem = extras.getParcelable(RecyclerViewActivity.EXTRA_ANIMAL_ITEM); ImageView imageView = (ImageView) findViewById(R.id.animal_detail_image_view); TextView textView = (TextView) findViewById(R.id.animal_detail_text); textView.setText(animalItem.detail); String imageUrl = animalItem.imageUrl; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String imageTransitionName = extras.getString(RecyclerViewActivity.EXTRA_ANIMAL_IMAGE_TRANSITION_NAME); imageView.setTransitionName(imageTransitionName); } Picasso.with(this) .load(imageUrl) .noFade() .into(imageView, new Callback() { @Override public void onSuccess() { supportStartPostponedEnterTransition(); } @Override public void onError() { supportStartPostponedEnterTransition(); } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); AnimalItem animalItem = getArguments().getParcelable(EXTRA_ANIMAL_ITEM); String transitionName = getArguments().getString(EXTRA_TRANSITION_NAME); TextView detailTextView = (TextView) view.findViewById(R.id.animal_detail_text); detailTextView.setText(animalItem.detail); ImageView imageView = (ImageView) view.findViewById(R.id.animal_detail_image_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { imageView.setTransitionName(transitionName); } Picasso.with(getContext()) .load(animalItem.imageUrl) .noFade() .into(imageView, new Callback() { @Override public void onSuccess() { startPostponedEnterTransition(); } @Override public void onError() { startPostponedEnterTransition(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.picasso_activity_a); final ImageView imageView = (ImageView) findViewById(R.id.picasso_activity_a_imageView); Picasso.with(this) .load(TIGER_PIC_URL) .fit() .centerCrop() .into(imageView); Button button = (Button) findViewById(R.id.picasso_activity_a_btn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(PicassoActivityA.this, PicassoActivityB.class); ActivityOptionsCompat options = ActivityOptionsCompat. makeSceneTransitionAnimation(PicassoActivityA.this, imageView, ViewCompat.getTransitionName(imageView)); startActivity(intent, options.toBundle()); } }); }
void bindTv(TV tv, int position) { mTV = tv; positionView.setText(String.valueOf(position + 1)); Drawable placeholder = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.background_reel, null); Picasso.with(mContext) .load(Constants.TMDB_IMAGE_URL + Constants.POSTER_SIZE_W342 + tv.getPosterPath()) .placeholder(placeholder) .fit().centerCrop() .noFade() .into(posterView); nameView.setText(tv.getName()); originalNameView.setText(mContext.getString(R.string.movie_original_name, tv.getOriginalName(), StringUtils.getYear(tv.getFirstAirDate()))); voteAverageView.setText(String.valueOf(tv.getVoteAverage())); voteCountView.setText(String.valueOf(tv.getVoteCount())); }
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { TutoriaData tutoria = tutorias.get(position); holder.title.setText(tutoria.getTitle()); if (!tutoria.getLastModify().isEmpty()) { holder.date.setText(tutoria.getLastModify()); } else { holder.date.setText(""); } Picasso.with(context).load(tutoria.getTeacherPicture()).into(holder.tpicture); holder.subject.setText(AppManager.capFirstLetter(tutoria.getSubjectName())); holder.llayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { listener.onItemClick(position); } return false; } }); }
public void setimg(final Context ctx, final String postimag) { final ImageView postimage = (ImageView)view.findViewById(R.id.postimage); Picasso.with(ctx).load(postimag).networkPolicy(NetworkPolicy.OFFLINE).into(postimage, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(ctx).load(postimag).into(postimage); } }); }
@Override public void onBindViewHolder(WallpViewHolder holder, int position) { Hit photo = this.hit.get(position); RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) holder.discWallp.getLayoutParams(); float height =photo.getPreviewHeight(); float width = photo.getPreviewWidth(); float ratio = height/width ; rlp.height = (int) (rlp.width * ratio); holder.discWallp.setLayoutParams(rlp); holder.discWallp.setRatio(ratio); File file = new File(Environment.getExternalStoragePublicDirectory("/"+R.string.app_name), photo.getId()+context.getResources().getString(R.string.jpg)); Picasso.with(context) .load(file) .placeholder(R.drawable.plh) .into(holder.discWallp); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == GALLERY_INTENT && resultCode == RESULT_OK) { Uri uri = data.getData(); StorageReference filepath = mStorage.child("Photos").child(uri.getLastPathSegment()); filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { downloadURL = taskSnapshot.getDownloadUrl().toString(); Picasso.with(getApplicationContext()).load(downloadURL).into(imageItem); Toast.makeText(AddItemActivity.this, "Upload Done", Toast.LENGTH_LONG).show(); } }); } }
@Override protected Bitmap doInBackground(ScraperImage... params) { ScraperImage poster = params[0]; // Save in DB and download if (poster.setAsDefault(getActivity(), -1)) { // -1 means for the whole show (not for a given season) poster.download(getActivity()); } // Update the bitmap Bitmap bitmap=null; try { bitmap = Picasso.get() .load(poster.getLargeUrl()) .noFade() .get(); } catch (IOException e) { Log.d(TAG, "ShowPosterSaverTask Picasso load exception", e); } return bitmap; }
private void updateAvatar(String avatarName) { api = RetrofitClient.getSocialSystemAPI(); addSubscription(api.updateAvatar(App.getUser().getUserID(), avatarName) .flatMap(NetworkFailureHandler.httpFailureFilter) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(response -> ((UserResponse) response).getResult()) .subscribe( result -> { User user = new User(result, context); App.setUser(user); Picasso.with(context).load(App.getUser().getAvatarUrl()).into(imgUserAvatar); ToastUtil.showShort("上传成功"); bottomDialog.dismiss(); }, NetworkFailureHandler.loginErrorHandler )); }
/** * 用户信息 */ private void setProfileInfo(UserBean userBean) { String userProfileImagUrl = userBean.getProfileImage(); String userAvatarUrl = userBean.getAvatar(); String userName = userBean.getUsername(); String userNick = userBean.getNick(); if (userName != null && !userName.equals("")) { userNameTv.setText(userName.trim()); } if (userAvatarUrl != null && !userAvatarUrl.equals("")) { Picasso.with(mContext).load(userAvatarUrl).placeholder(R.mipmap.profile_fail).error(R.mipmap.profile_fail).into(avatarImg); } if (userProfileImagUrl != null && !userProfileImagUrl.equals("")) { Picasso.with(mContext).load(userProfileImagUrl).placeholder(R.mipmap.header).error(R.mipmap.header).into(profileImg); } }
/** * non blocking (using Picasso to load the Uri) * * @param imageUri */ protected void updateCardView(Uri imageUri, long videoId, boolean isLarge) { if(!(mImageCardViewTarget.getLastUri()!=null&&mImageCardViewTarget.getLastUri().equals(imageUri) && mImageCardViewTarget.isLastStateError())) { mImageCardViewTarget.setLastUri(imageUri); mCardView.setMainImageDimensions(getWidth(mContext, isLarge), getHeight(mContext, isLarge)); mImageCardViewTarget.setVideoId(videoId); Picasso.get() // must use an Uri here, does not work with path only .load(imageUri) .resize(getWidth(mContext, isLarge), getHeight(mContext, isLarge)) .centerCrop() .error(mErrorDrawable) .into(mImageCardViewTarget); } //if last update of vh failed with the same uri else updateCardView(mErrorDrawable); }
@Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); if (response.getRsm() != null) { // 显示用户个人信息 UserInfo info = response.getRsm(); setTitle(info.getUser_name() + "的主页"); Picasso.with(UserActivity.this).load(info.getAvatar_file()).into(imgAvatar); MenuItem item = menu.findItem(R.id.action_focus); if (info.getHas_focus() == 1) { item.setTitle("取消关注"); } else { item.setTitle("关注"); } } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == Constants.RQ_STORY_TO_IMAGE && resultCode == RESULT_OK && data != null) { ImageView coverStory = findViewById(R.id.coverStory); Picasso.with(getBaseContext()).load(data.getStringExtra(Constants.EXTRA_FILE)).into(coverStory); hasNewCover = true; isDefaultCover = false; } else if (requestCode == Constants.RQ_STORY_TO_SCAN_LAN && resultCode == RESULT_OK && data != null) { ArrayList<DeviceDAO> devices = data.getParcelableArrayListExtra(Constants.EXTRA_DEVICES); if (story == null) { story = new StoryDAO(); } story.setDevices(devices); populateDevices(); } }
void setPhotoUrl(String image, ViewHolder vh){ ImageView event_image = vh.cardview.findViewById(R.id.commentorProfileImageView); final ProgressBar progressBar = vh.cardview.findViewById(R.id.progressBar2); Picasso.with(event_image.getContext()) .load(image) .into(event_image, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { Toast.makeText(getApplicationContext(), "Network error: failed to load image", Toast.LENGTH_SHORT).show(); } }); }
@Override public void onBindViewHolder(BookmarkAdapter.ViewHolder holder, final int position) { RestaurantItem item = mList.get(position); holder.name.setText(CommonFunctions.checkNull(item.getName())); holder.location.setText(CommonFunctions.checkNull(item.getLocation())); if (!CommonFunctions.checkNull(item.getImage()).equals("")) { Picasso.with(context) .load(RetroInterface.IMAGE_URL+item.getImage()) .resize(200,200) .placeholder(R.drawable.placeholder_200) .error(R.drawable.placeholder_200) .into(holder.image); } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (clickListener != null) { clickListener.onItemClickListener(view, position); } } }); }
@Override public void onBindViewHolder(LeaderBoardAdapter.ViewHolder holder, final int position) { holder.name.setText("User " + position); holder.location.setText("Location " + position); Picasso.with(context) .load(R.drawable.im_backdrop) .transform(new CircleTransform()) .placeholder(R.drawable.placeholder_200) .error(R.drawable.placeholder_200) .into(holder.image); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (clickListener != null) { clickListener.onItemClickListener(view, position); } } }); }
private void setPreview(String site) { String path = ""; if (site.equals(YOUTUBE)){ path = MoviesTask.getUrlThumbnailYoutube(movieKey); } Picasso.with(activity). load(path). placeholder(R.drawable.loading_placeholder_square). error(R.drawable.not_availible). into(ivPreview); }
public static void setImage(ImageView imageView, String url) { //Point screen = Utils.getScreenSize(imageView.getContext()); imageView.setVisibility(View.VISIBLE); Picasso.with(imageView.getContext()) .cancelRequest(imageView); Picasso.with(imageView.getContext()) .load(url) .placeholder(R.drawable.audi_4) .noFade() .stableKey(url) .fit() .centerCrop() .into(imageView); }
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { User item = list.get(position); //TODO EXTRA holder.userName.setText(item.getName()); if (item.getImage() != null && !item.getImage().equals("")) { Picasso.with(context) .load(item.getImage()) .transform(new CircleTransform()) .placeholder(R.drawable.placeholder_200) .error(R.drawable.placeholder_200) .into(holder.userImage); } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (clickListener != null) { clickListener.onItemClickListener(view, position); } } }); }
/** * This function fill the layout with the correct values. * * @param holder : The holder of the elements on the view. * @param position : The position in the team array. */ public void onBindViewHolder(ViewHolder holder, int position) { String link = APIConstants.SONO_AVATAR + team.get(position).getAvatar(); Picasso.with(ctx).load(link).placeholder(R.drawable.ic_user).error(R.drawable.ic_user) .into(holder.avatar); holder.name.setText(ctx.getString(R.string.emptyField)); if (team.get(position).getName() != null) { holder.name.setText(team.get(position).getName()); } }
@Override public void onBindViewHolder(final GalleryAdapter.ViewHolder holder, final int position) { ImageView imageView = holder.image; //loading images using picasso Picasso.with(imageView.getContext()).load(mCursor.getString(GalleryLoader.Query.COLUMN_IMAGE_PATH)) .placeholder(R.color.photo_placeholder) .error(R.color.primary_dark) .into(imageView); }
@Override public void loadThumbnail(Context context, int resize, ImageView imageView, Uri uri) { Picasso.with(context) .load(uri) .resize(resize, resize) .centerCrop() .into(imageView); }
private void setBackground() { String s = mTeacher.getTeacher_background(); if (FunctionHelper.isEmpty(s)) { img_background.setImageResource(R.drawable.background); } else { Picasso.with(mContext) .load("file://" + s) .error(R.drawable.background) .into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { img_background.setImageBitmap(bitmap); } @Override public void onBitmapFailed(Drawable errorDrawable) { img_background.setImageDrawable(errorDrawable); FunctionHelper.makeLToast(mContext, mResources.getString(R.string.error_load_image)); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }); } }