本文整理汇总了Java中com.squareup.picasso.Picasso.with方法的典型用法代码示例。如果您正苦于以下问题:Java Picasso.with方法的具体用法?Java Picasso.with怎么用?Java Picasso.with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.picasso.Picasso
的用法示例。
在下文中一共展示了Picasso.with方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
/**
* Loads an image into a target view.
* @param context context
* @param image image
* @param centerCrop boolean
* @param errorResourceId image of error
* @param target imageView
* @param callback callback
*/
public static void loadImage(final Context context, final String image,
final boolean centerCrop, final int errorResourceId,
final ImageView target, final Callback callback) {
Picasso pic = Picasso.with(context);
RequestCreator request;
int errorRId = errorResourceId;
if (image != null )
request = pic.load(image).fit();
else {
request = pic.load(errorResourceId).fit();
errorRId = 0;
}
if (centerCrop)
request = request.centerCrop();
if (errorRId != 0)
request = request.error(errorResourceId);
if (callback != null)
request.into(target, callback);
else
request.into(target);
}
示例2: populateUserProfileData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
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);
}
}
示例3: populateUserProfileData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
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);
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);
}
}
示例4: populateFeedViewData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
private void populateFeedViewData(FeedDataEntry feedData) {
authorName.setText(feedData.getAuthorName());
title.setText(feedData.getTitle());
CharSequence desc = Html.fromHtml(Html.fromHtml(feedData.getDescription()).toString());
description.setText(desc);
DateFormat formatter = Utils.createDateFormatterWithTimeZone(context, Utils.DMY_DATE_FORMAT_PATTERN);
Calendar date = feedData.getDate();
action_date.setText(formatter.format(date.getTime()));
Picasso pic = Picasso.with(context);
if (feedData.getAvatarURL() == null || feedData.getAvatarURL().isEmpty()) {
pic.load(R.drawable.octocat)
.fit().centerCrop()
.into(personalProfImage);
} else {
pic.load(feedData.getAvatarURL())
.fit().centerCrop()
.error(R.drawable.octocat)
.into(personalProfImage);
}
}
示例5: populateFollowersViewData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
private void populateFollowersViewData(GitHubUserProfileDataEntry followersDataEntry) {
name.setText(followersDataEntry.getName());
login.setText(followersDataEntry.getLogin());
if (followersDataEntry.getEmail() != null && !followersDataEntry.getEmail().isEmpty() && followersDataEntry.getEmail() != "null") {
email.setText(followersDataEntry.getEmail());
} else {
email.setText(R.string.empty_text);
}
if (followersDataEntry.getLocation() != null && !followersDataEntry.getLocation().isEmpty() && followersDataEntry.getLocation() != "null") {
location.setText(followersDataEntry.getLocation());
} else {
location.setText(R.string.empty_text);
}
Picasso pic = Picasso.with(context);
pic.load(followersDataEntry.getImageUri())
.fit().centerCrop()
.error(R.drawable.octocat)
.into(avatar);
}
示例6: getViewAt
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
@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;
}
示例7: populateFollowingViewData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
private void populateFollowingViewData(GitHubUserProfileDataEntry followingDataEntry) {
name.setText(followingDataEntry.getName());
login.setText(followingDataEntry.getLogin());
if (followingDataEntry.getEmail() != null && !followingDataEntry.getEmail().isEmpty() && followingDataEntry.getEmail() != "null") {
email.setText(followingDataEntry.getEmail());
} else {
email.setText(R.string.empty_text);
}
if (followingDataEntry.getLocation() != null && !followingDataEntry.getLocation().isEmpty() && followingDataEntry.getLocation() != "null") {
location.setText(followingDataEntry.getLocation());
} else {
location.setText(R.string.empty_text);
}
Picasso pic = Picasso.with(context);
Log.v(TAG, "path" + followingDataEntry.getImageUri());
pic.load(followingDataEntry.getImageUri())
.fit().centerCrop()
.error(R.drawable.octocat)
.into(avatar);
}
示例8: onUpdate
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
@Override
public void onUpdate(final Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.sample_widget);
// Load image for all appWidgetIds.
Picasso picasso = Picasso.with();
picasso.load(Data.URLS[new Random().nextInt(Data.URLS.length)]) //
.placeholder(R.drawable.placeholder) //
.error(R.drawable.error) //
.transform(new GrayscaleTransformation(picasso)) //
.into(updateViews, R.id.image, appWidgetIds);
}
示例9: onScrollStateChanged
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
final Picasso picasso = Picasso.with();
if (scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_TOUCH_SCROLL) {
picasso.resumeTag(context);
} else {
picasso.pauseTag(context);
}
}
示例10: populateReposViewData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
private void populateReposViewData(ReposDataEntry reposDataEntry) {
title.setText(reposDataEntry.getTitle());
if (reposDataEntry.getDescription() != null && !reposDataEntry.getDescription().equals("null")) {
description.setText(reposDataEntry.getDescription());
} else {
description.setText("");
}
if (reposDataEntry.getLanguage() != null && !reposDataEntry.getLanguage().isEmpty() && !reposDataEntry.getLanguage().equals("null")) {
int colorId = GithubLanguageColorsMatcher.findMatchedColor(context, reposDataEntry.getLanguage());
Log.v(TAG, " colorId = " + colorId);
if (colorId != 0) {
languageCircle.setColor(context.getResources().getColor(colorId));
} else {
languageCircle.setColor(context.getResources().getColor(R.color.colorred));
}
language.setVisibility(View.VISIBLE);
language.setText(reposDataEntry.getLanguage());
} else {
languageCircle.setVisibility(View.INVISIBLE);
language.setVisibility(View.INVISIBLE);
}
stars.setText(String.format(Locale.getDefault(), "%d", reposDataEntry.getStars()));
forks.setText(String.format(Locale.getDefault(), "%d", reposDataEntry.getForks()));
Picasso pic = Picasso.with(context);
pic.load(R.drawable.repository)
.fit().centerCrop()
.error(R.drawable.octocat)
.into(type);
}
示例11: populateStarsViewData
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
private void populateStarsViewData(StarsDataEntry starsDataEntry) {
title.setText(starsDataEntry.getTitle());
description.setText(starsDataEntry.getDescription());
if (starsDataEntry.getLanguage() != null && !starsDataEntry.getLanguage().isEmpty() && !starsDataEntry.getLanguage().equals("null")) {
Log.v(TAG, " data.getLanguage() = " + starsDataEntry.getLanguage());
int colorId = GithubLanguageColorsMatcher.findMatchedColor(context, starsDataEntry.getLanguage());
Log.v(TAG, " colorId = " + colorId);
if (colorId != 0) {
languageCircle.setColor(context.getResources().getColor(colorId));
} else {
languageCircle.setColor(context.getResources().getColor(R.color.colorred));
}
language.setVisibility(View.VISIBLE);
language.setText(starsDataEntry.getLanguage());
} else {
language.setVisibility(View.INVISIBLE);
}
language.setText(starsDataEntry.getLanguage());
stars.setText(String.format(Locale.getDefault(), "%d", starsDataEntry.getStars()));
forks.setText(String.format(Locale.getDefault(), "%d", starsDataEntry.getForks()));
watchers.setText(String.format(Locale.getDefault(), "%d", starsDataEntry.getWatchers()));
repoShortUri.setText(starsDataEntry.getFullName());
Picasso pic = Picasso.with(context);
pic.load(R.drawable.repository)
.fit().centerCrop()
.error(R.drawable.octocat)
.into(type);
}
示例12: providePicasso
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
@Singleton
@Provides
public Picasso providePicasso(Context context) {
Picasso picasso = Picasso.with(context);
if (BuildConfig.DEBUG) {
picasso.areIndicatorsEnabled();
}
return picasso;
}
示例13: LoadFromUriAsyncTask
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
public LoadFromUriAsyncTask(TextView textView, URLDrawable urlDrawable) {
this.context = textView.getContext();
mImageUtils = Picasso.with(textView.getContext());
mTextViewRef = new WeakReference<>(textView);
mUrlDrawable = urlDrawable;
}
示例14: apply
import com.squareup.picasso.Picasso; //导入方法依赖的package包/类
public static void apply(Context context) {
TweetUi tweetUi = TweetUi.getInstance();
Picasso picasso = Picasso.with(context);
tweetUi.setImageLoader(picasso);
}