Search in sources :

Example 1 with Picasso

use of com.squareup.picasso.Picasso in project kickmaterial by byoutline.

the class ProjectsAdapter method onBindViewHolder.

// Replace the contents of a view. This is invoked by the layout manager.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    int type = getItemViewType(position);
    switch(type) {
        case NORMAL_ITEM:
        case BIG_ITEM:
            Project project = getItem(position);
            if (project != null) {
                if (holder.projectId == project.id) {
                    // This view holder appears to already show correct project.
                    return;
                } else {
                    holder.projectId = project.id;
                }
                ViewUtils.setTextForViewOrHideIt(holder.projectItemBigTitleTv, project.getProjectName());
                holder.projectItemBigProgressSb.setProgress((int) project.getPercentProgress());
                Picasso picasso = Picasso.with(context);
                final RequestCreator picassoBuilder;
                if (type == BIG_ITEM) {
                    setProjectDetailsInfo(null, holder.projectItemBigDescTv, holder.projectItemBigGatheredMoneyTv, holder.projectItemBigPledgedOfTv, holder.projectItemBigBackersTv, holder.projectItemBigTimeLeft, holder.projectItemBigTimeLeftType, project);
                    picassoBuilder = picasso.load(project.getBigPhotoUrl()).resize(bigItemWidth, bigItemHeight).placeholder(R.drawable.blank_project_wide);
                } else {
                    picassoBuilder = picasso.load(project.getPhotoUrl()).resize(smallItemWidth, smallItemHeight).placeholder(R.drawable.blank_project_small);
                }
                picassoBuilder.onlyScaleDown().transform(new AplaTransformation()).centerCrop().into(holder.projectItemBigPhotoIv);
            }
            break;
    }
}
Also used : Project(com.byoutline.kickmaterial.model.Project) Picasso(com.squareup.picasso.Picasso) AplaTransformation(com.byoutline.kickmaterial.utils.AplaTransformation) RequestCreator(com.squareup.picasso.RequestCreator)

Example 2 with Picasso

use of com.squareup.picasso.Picasso in project Klyph by jonathangerbaud.

the class ImageLoader method display.

public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) {
    if (uri == null || uri.length() == 0)
        uri = FAKE_URI;
    /*uri = uri.replace("�", URLEncoder.encode("�"));
		uri = uri.replace("�", URLEncoder.encode("�"));
		uri = uri.replace("'", URLEncoder.encode("'"));
		uri = uri.replace("�", URLEncoder.encode("�"));*/
    uri = Uri.encode(uri, ALLOWED_URI_CHARS);
    Picasso picasso = Picasso.with(imageView.getContext());
    RequestCreator requestCreator = picasso.load(uri);
    if (stubImage != 0) {
        requestCreator.placeholder(stubImage);
        requestCreator.error(stubImage);
    }
    if (!(fadeIn && FADE_ENABLED))
        requestCreator.noFade();
    LayoutParams params = imageView.getLayoutParams();
    if (params.width > 0 && params.height > 0) {
        requestCreator.resize(params.width, params.height, true);
    }
    requestCreator.inSampleSize(true);
    requestCreator.into(imageView, listener);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Picasso(com.squareup.picasso.Picasso) RequestCreator(com.squareup.picasso.RequestCreator)

Example 3 with Picasso

use of com.squareup.picasso.Picasso in project cw-omnibus by commonsguy.

the class QuestionsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View result = super.onCreateView(inflater, container, savedInstanceState);
    setRetainInstance(true);
    OkHttpClient.Builder okb = new OkHttpClient.Builder();
    TrustManagerBuilder tmb = new TrustManagerBuilder().withManifestConfig(getActivity());
    try {
        OkHttp3Integrator.applyTo(tmb, okb);
        OkHttpClient ok = okb.build();
        picasso = new Picasso.Builder(getActivity()).downloader(new OkHttp3Downloader(ok)).build();
        Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.stackexchange.com").client(ok).addConverterFactory(GsonConverterFactory.create()).build();
        StackOverflowInterface so = retrofit.create(StackOverflowInterface.class);
        so.questions("android").enqueue(this);
    } catch (Exception e) {
        Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
        Log.e(getClass().getSimpleName(), "Exception from TrustManagerBuilder setup", e);
    }
    return (result);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) TrustManagerBuilder(com.commonsware.cwac.netsecurity.TrustManagerBuilder) Picasso(com.squareup.picasso.Picasso) OkHttp3Downloader(com.jakewharton.picasso.OkHttp3Downloader) TrustManagerBuilder(com.commonsware.cwac.netsecurity.TrustManagerBuilder) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 4 with Picasso

use of com.squareup.picasso.Picasso in project UltimateAndroid by cymcsg.

the class SampleListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_list_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);
    int listLayout = getArguments().getInt(ARG_LAYOUT);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout);
    listView.setAdapter(adapter);
    return view;
}
Also used : ListView(android.widget.ListView) Picasso(com.squareup.picasso.Picasso) ArrayAdapter(android.widget.ArrayAdapter) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView)

Example 5 with Picasso

use of com.squareup.picasso.Picasso in project iNGAGE by davis123123.

the class App method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(true);
    // built.setLoggingEnabled(true);
    Picasso.setSingletonInstance(built);
}
Also used : Picasso(com.squareup.picasso.Picasso) OkHttpDownloader(com.squareup.picasso.OkHttpDownloader)

Aggregations

Picasso (com.squareup.picasso.Picasso)26 View (android.view.View)9 TextView (android.widget.TextView)7 RequestCreator (com.squareup.picasso.RequestCreator)7 ImageView (android.widget.ImageView)6 ArrayAdapter (android.widget.ArrayAdapter)5 ListView (android.widget.ListView)5 OkHttp3Downloader (com.jakewharton.picasso.OkHttp3Downloader)4 Bitmap (android.graphics.Bitmap)3 Drawable (android.graphics.drawable.Drawable)3 OkHttpDownloader (com.squareup.picasso.OkHttpDownloader)3 Target (com.squareup.picasso.Target)3 TargetApi (android.annotation.TargetApi)2 SharedPreferences (android.content.SharedPreferences)2 ViewTreeObserver (android.view.ViewTreeObserver)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 GridView (android.widget.GridView)2 Callback (com.squareup.picasso.Callback)2 LruCache (com.squareup.picasso.LruCache)2