Java Code Examples for com.squareup.picasso.Picasso#setLoggingEnabled()

The following examples show how to use com.squareup.picasso.Picasso#setLoggingEnabled() . 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 check out the related API usage on the sidebar.
Example 1
Source File: mImage.java    From intra42 with Apache License 2.0 6 votes vote down vote up
public static void setPicasso(Uri url, ImageView imageView, @DrawableRes int placeHolder) {

        Picasso picasso = Picasso.get();

        if (BuildConfig.DEBUG)
            picasso.setLoggingEnabled(true);

        RequestCreator requestCreator = picasso.load(url);

        if (placeHolder != 0) {
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                requestCreator.placeholder(placeHolder);
                requestCreator.error(placeHolder);
            } else {
                Drawable drawable = ContextCompat.getDrawable(imageView.getContext(), placeHolder);
                requestCreator.placeholder(drawable);
                requestCreator.error(drawable);
            }
        }

        requestCreator.into(imageView);
    }
 
Example 2
Source File: ImageLoader.java    From cnode-android with MIT License 6 votes vote down vote up
public static void load(ImageView view, String url) {
    url = normalizeUrl(url);

    // TODO: 暂时的 workaround, 未做仔细处理
    // 将 Gravatar 默认的 48x48 替换成 120x120(按我们的 ImageView 大小是 40dp,xxhdpi 分辨率计算)
    if (url.contains("gravatar.com") && url.contains("size=48")) {
        url = url.replace("size=48", "size=120");
    }
    // 将 GitHub 默认的 40x40 替换成 120x120
    if (url.contains("avatars.githubusercontent.com") && url.contains("s=40")) {
        url = url.replace("s=40", "s=120");
    }

    Picasso picasso = Picasso.with(view.getContext());
    picasso.setLoggingEnabled(BuildConfig.DEBUG);
    picasso.load(url).placeholder(R.drawable.image_placeholder).into(view);
}
 
Example 3
Source File: Capabilities.java    From ChatApp with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate()
{
    super.onCreate();

    // For offline use

    FirebaseDatabase.getInstance().setPersistenceEnabled(true);

    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));

    Picasso build = builder.build();
    build.setLoggingEnabled(true);
    Picasso.setSingletonInstance(build);

    // If user disconnect

    if(FirebaseAuth.getInstance().getCurrentUser() != null)
    {
        final DatabaseReference userDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(FirebaseAuth.getInstance().getCurrentUser().getUid());
        userDatabase.addValueEventListener(new ValueEventListener()
        {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot)
            {
                if(dataSnapshot != null)
                {
                    userDatabase.child("online").onDisconnect().setValue(ServerValue.TIMESTAMP);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError)
            {
                Log.d(TAG, "usersDatabase failed: " + databaseError.getMessage());
            }
        });
    }
}
 
Example 4
Source File: SimpleBlog.java    From Simple-Blog-App with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (!FirebaseApp.getApps(this).isEmpty()) {
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);//offlinecapability
    }
    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(false);
    built.setLoggingEnabled(true);
    Picasso.setSingletonInstance(built);
}
 
Example 5
Source File: Global.java    From Simple-Blog-App with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttp3Downloader(this,Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(true);
    built.setLoggingEnabled(true);
    Picasso.setSingletonInstance(built);

}
 
Example 6
Source File: ModuleRest.java    From AndroidStarter with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
public Picasso providePicasso(@NonNull final Context poContext) {
    final Picasso loPicasso = Picasso.with(poContext);
    loPicasso.setIndicatorsEnabled(true);
    loPicasso.setLoggingEnabled(true);
    return loPicasso;
}
 
Example 7
Source File: ModuleRest.java    From AndroidStarterAlt with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
public Picasso providePicasso(@NonNull final Context poContext) {
    final Picasso loPicasso = Picasso.with(poContext);
    loPicasso.setIndicatorsEnabled(true);
    loPicasso.setLoggingEnabled(true);
    return loPicasso;
}
 
Example 8
Source File: ViewerFragment.java    From meizhi with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    Picasso picasso = Picasso.with(activity);
    picasso.setLoggingEnabled(true);
    picasso.load(url).into(image);
}
 
Example 9
Source File: AlbumAdapter.java    From meizhi with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindItemViewHolder(ViewHolder holder, final int position) {
    Image item = getItem(position);

    Picasso picasso = Picasso.with(context);
    picasso.setLoggingEnabled(true);
    picasso.load(item.url + "?imageView2/1/w/360/h/360").into(holder.thumb);

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onPhotoItemClick(position);
        }
    });
}
 
Example 10
Source File: GalleryAdapter.java    From meizhi with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindItemViewHolder(ItemViewHolder holder, final int position) {
    Album item = getItem(position);

    Picasso picasso = Picasso.with(context);
    picasso.setLoggingEnabled(true);
    picasso.load(item.cover + "?imageView2/1/w/540/h/540").into(holder.cover);

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onAlbumItemClick(position);
        }
    });
}
 
Example 11
Source File: HtmlImageGetter.java    From cnode-android with MIT License 5 votes vote down vote up
@Override
public Drawable getDrawable(String source) {
    final BitmapDrawablePlaceHolder placeHolder = new BitmapDrawablePlaceHolder();
    final String url = ImageLoader.normalizeUrl(source);

    Picasso picasso = Picasso.with(context);
    picasso.setLoggingEnabled(BuildConfig.DEBUG);
    picasso.load(url).into(new Target() {
        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            Log.d(TAG, "onPrepareLoad " + url);
        }

        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Log.d(TAG, "onBitmapLoaded " + url);
            placeHolder.setDrawable(new BitmapDrawable(context.getResources(), bitmap));
            onImageLoaded();
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            Log.d(TAG, "onBitmapFailed " + url);
        }
    });

    return placeHolder;
}
 
Example 12
Source File: SampleListFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 13
Source File: SampleBubbleFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_chat_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);

    int listLayout1 = getArguments().getInt(ARG_LAYOUT_1);
    int listLayout2 = getArguments().getInt(ARG_LAYOUT_2);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2);
    listView.setAdapter(adapter);

    return view;
}
 
Example 14
Source File: SampleListFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 15
Source File: SampleBubbleFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.shape_image_fragment_chat_sample, container, false);
    final Picasso picasso = Picasso.with(getActivity());
    picasso.setLoggingEnabled(true);
    picasso.setIndicatorsEnabled(false);

    int listLayout1 = getArguments().getInt(ARG_LAYOUT_1);
    int listLayout2 = getArguments().getInt(ARG_LAYOUT_2);
    final ListView listView = (ListView) view.findViewById(R.id.list);
    Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2);
    listView.setAdapter(adapter);

    return view;
}
 
Example 16
Source File: PicturePresenter.java    From AndroidDemo with MIT License 4 votes vote down vote up
public void loadImageView() {

        iPictureView.clearImageView();

        boolean cache = iPictureView.getCache();
        boolean disk = iPictureView.getDisk();
        boolean transformation = iPictureView.getTransformation();

        Picasso picasso = Picasso.with(context.get());
        picasso.setIndicatorsEnabled(true);
        picasso.setLoggingEnabled(true);

        String path = "https://avatars2.githubusercontent.com/u/9563634?s=400&u=6c9844a5ee91e0385888cbd5708af59f4062d651&v=4";
        RequestCreator requestCreator = picasso.load(path)
                .config(Bitmap.Config.RGB_565)
                .placeholder(R.drawable.ic_empty_zhihu)
                .error(R.drawable.ic_failed)
                .fit();

        if (!cache) {
            requestCreator.memoryPolicy(MemoryPolicy.NO_CACHE);
        }
        if (!disk) {
            requestCreator.networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE);
        }

        if (transformation) {
            final Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setColor(0xffcccccc);
            paint.setStyle(Paint.Style.FILL);
            final float round = Tools.dip2pxf(context.get(), 8);
            requestCreator.transform(new Transformation() {
                @Override
                public Bitmap transform(Bitmap source) {

                    Bitmap src = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight());
                    Canvas canvas = new Canvas(src);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                        float r = source.getWidth() / 4 * 3;
                        canvas.drawCircle(source.getWidth() / 2, source.getHeight() / 2, r, paint);
                    } else {
                        canvas.drawRoundRect(round, round, source.getWidth() - round, source.getHeight() - round,
                                round, round, paint);
                    }
                    canvas.drawBitmap(source, 0, 0, paint);
                    if (!source.isRecycled()) {
                        source.recycle();
                    }
                    return src;
                }

                @Override
                public String key() {
                    return "PicassoTransformation";
                }
            });
        }
        requestCreator.into(iPictureView.getTarget(), new Callback() {
            @Override
            public void onSuccess() {
                iPictureView.showToast("success");
            }

            @Override
            public void onError() {
                iPictureView.showToast("error");
            }
        });
    }