當前位置: 首頁>>代碼示例>>Java>>正文


Java Picasso.with方法代碼示例

本文整理匯總了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);
}
 
開發者ID:an-garcia,項目名稱:MovieGuide,代碼行數:34,代碼來源:ActivityUtils.java

示例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);
    }
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:18,代碼來源:UserProfileFragment.java

示例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);
    }
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:18,代碼來源:PersonalActivity.java

示例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);
    }
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:22,代碼來源:FeedListAdapter.java

示例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);
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:21,代碼來源:FollowersListAdapter.java

示例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;
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:23,代碼來源:StackWidgetService.java

示例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);
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:21,代碼來源:FollowingListAdapter.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:SampleWidgetProvider.java

示例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);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:SampleScrollListener.java

示例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);
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:32,代碼來源:ReposListAdapter.java

示例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);
}
 
開發者ID:OlgaKuklina,項目名稱:GitJourney,代碼行數:30,代碼來源:StarsListAdapter.java

示例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;
}
 
開發者ID:npdess,項目名稱:mining,代碼行數:11,代碼來源:NetworkModule.java

示例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;
}
 
開發者ID:didikee,項目名稱:cnBetaGeek,代碼行數:7,代碼來源:LoadFromUriAsyncTask.java

示例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);
}
 
開發者ID:netceteragroup,項目名稱:react-native-twitterkit,代碼行數:6,代碼來源:ImageLoaderFix.java


注:本文中的com.squareup.picasso.Picasso.with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。