标签: picasso

毕加索图书馆今天停止使用facebook图片图片链接

在我的应用程序中,我使用Picasso库从URL加载图像.它是一个很好的工作,易于导入和使用的库,只是做我需要的东西.

然而,今天它停止工作,而不是在开发它时停止在编译的apk上工作.

所以在我搜索并搜索了我发现这个有问题的东西的原因之后:

我使用facebook图表网址加载个人资料图片.

这是一个像: profile pictre,

链接实际上是" http://graph.facebook.com/1464090949/picture?type=large "

但它重定向到:https: //fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/572518_1464090949_1222130273_n.jpg

当然,两个url调用都在浏览器中工作,你可以看到个人资料图片.

但是当我用Picasso测试两个链接时:

    ImageView iv = (ImageView)findViewById(R.id.imageView1);

    //Url1 NOT working, loads nothing.
    String url1 = "http://graph.facebook.com/1464090949/picture?type=large";

    //Url2 is the same as URL1, i just copied it from a browser, and this is working
    String url2 = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/572518_1464090949_1222130273_n.jpg";


    Picasso.with(this).load(url2).into(iv);
Run Code Online (Sandbox Code Playgroud)

所以结论是,Facebook可能会改变一些东西,从现在开始Picasso无法从图形加载图像.

有人可以建议我做些什么吗?当然,我可以尝试不同的图书馆,但如果有另一种方式,我会非常高兴.

android picasso

14
推荐指数
2
解决办法
6586
查看次数

毕加索没有加载图像

这是毕加索的代码:

ImageView img = (ImageView)findViewById(R.id.product_image);
    Picasso.with(this)
    .load(_url)
    .fit()
    .into(img, new Callback() {

        @Override
        public void onSuccess() {


        }

        @Override
        public void onError() {


        }
    });
Run Code Online (Sandbox Code Playgroud)

这是_url的价值:http: //kiagallery.ir/Images/Upload/Collection%20101/Spring%20101/d4a03b66dc7b46c694615c549b78b2e9.jpg

这是xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView 
    android:id="@+id/product_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView 
    android:id="@+id/product_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="13sp"
    android:layout_below="@id/product_image"/>

<TextView
    android:id="@+id/product_price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="13sp"
    android:layout_below="@id/product_name"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

你可以看到图像可以通过浏览器访问,但毕加索无法加载它,我已经检查了onError函数,它从未被调用,我很安静地丢失在这里,任何帮助将不胜感激.

编辑:当我给imageview的宽度和高度固定值像200dp时,它加载图像,但当我将其更改为wrap_content时,它不显示图像.

android imageview picasso

14
推荐指数
2
解决办法
2万
查看次数

Picasso IllegalArgumentException目标不能为null

我正在尝试通过在我的项目中使用Picasso库来设置图像.

当我点击View的图像时,我在Picasso执行时遇到错误.

该应用程序的Logcat

  java.lang.IllegalArgumentException: Target must not be null.
            at com.squareup.picasso.RequestCreator.into(RequestCreator.java:340)
            at com.squareup.picasso.RequestCreator.into(RequestCreator.java:326)
            at com.zafer.celaloglu.FragmentsandActivities.UnfoldableDetailsFragment.openDetails(UnfoldableDetailsFragment.java:89)
            at com.zafer.celaloglu.model.PaintingsAdapter.onClick(PaintingsAdapter.java:52)
            at android.view.View.performClick(View.java:4084)
            at android.view.View$PerformClick.run(View.java:16966)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

UnfoldableDetailsFragment 89 =

public void openDetails(View coverView, Painting painting) {
    ImageView image = (ImageView) coverView.findViewById(R.id.details_image);
    TextView title = (TextView) coverView.findViewById(R.id.details_title);
    TextView description = (TextView) coverView.findViewById(R.id.details_text);

    Picasso.with(getActivity()).load(painting.getImageId()).into(image); ->89. LINE
    Log.i("bilgi", "basildi");

    title.setText(painting.getTitle());

    SpannableBuilder builder = new SpannableBuilder(getActivity());
    builder
            .createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
            .append(R.string.year).append(": …
Run Code Online (Sandbox Code Playgroud)

android picasso

14
推荐指数
2
解决办法
2万
查看次数

毕加索图书馆 - 内存不足

我在我的应用程序中使用Picasso库最新版本2.4.0来下载和缓存图像.大约有25-30张图像,每张300KB-400KB.我认为这不是一件大事或沉重的事情.

即使应用程序运行正常,我的logcat中的内存分配也没有了.谁能解释为什么会这样?

在GridView适配器中加载图像的代码:

Picasso.with(mContext).load(getUrl()).placeholder(R.drawable.placeholder)
            .into(viewholder.image);
Run Code Online (Sandbox Code Playgroud)

这是我的Logcat输出:

I/dalvikvm-heap(11142): Grow heap (frag case) to 53.860MB for 2720016-byte allocation
I/dalvikvm-heap(11142): Forcing collection of SoftReferences for 3265936-byte allocation
E/dalvikvm-heap(11142): Out of memory on a 3265936-byte allocation.
I/dalvikvm(11142): "Picasso-/images/posters/34.71.jpg" prio=5 tid=18 RUNNABLE
I/dalvikvm(11142):   | group="main" sCount=0 dsCount=0 obj=0x4283f248 self=0x60a47830
I/dalvikvm(11142):   | sysTid=11196 nice=10 sched=0/0 cgrp=apps/bg_non_interactive I/dalvikvm(11142):   | state=R schedstat=( 2070202497 1858185620 3947 ) utm=172 stm=35 core=3
I/dalvikvm(11142):   at android.graphics.Bitmap.nativeCreate(Native Method)
I/dalvikvm(11142):   at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
I/dalvikvm(11142):   at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
I/dalvikvm(11142):   at android.graphics.Bitmap.createBitmap(Bitmap.java:636)
I/dalvikvm(11142):   at com.squareup.picasso.BitmapHunter.transformResult(BitmapHunter.I/dalvikvm(11142):   at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:168)
I/dalvikvm(11142): …
Run Code Online (Sandbox Code Playgroud)

android picasso

14
推荐指数
1
解决办法
1万
查看次数

检查Cache Picasso中是否存在图像

我想检查图像URL是否包含在缓存中.我正在使用Picasso图像加载器.

这是我的代码

new Picasso.Builder(this).downloader(new OkHttpDownloader(client)).build();
Run Code Online (Sandbox Code Playgroud)

现在Picasso.getCache() 没有get(key).

虽然 Cacheclass内部使用LRUDiskCache但它的private

有任何想法吗??

android picasso

14
推荐指数
1
解决办法
3571
查看次数

Image uri不会在某些Android设备上的ImageView上显示图像

我有一个ImageView.当您单击ImageView时,它将打开图库,您将获取图像并在ImageView上显示它.我有一个条件,当我关闭我的应用程序,然后我打开它,图像将保留在那里.所以,为此,我将图像Uri存储在sharedprefrence上.在打开应用程序时,我正在检索相同的Uri并尝试在imageView上显示图像.

然而在一些手机中 - 图像看起来像Mi(Lollipop),三星(KitKat)一样完美,但它并没有出现在像摩托罗拉(Marshmallow),One Plus One(Marshmallow)这样的手机中.知道为什么会这样吗?这是我的代码

拿起我正在使用的图像

Intent intent=new Intent();intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), Constants.SELECT_PICTURE);
Run Code Online (Sandbox Code Playgroud)

在OnActivityResult()代码上

 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);

     if(requestCode==Constants.SELECT_PICTURE && resultCode==RESULT_OK && null!=data) {
         Uri uri=data.getData();
         Picasso.with(UsersProfileActivity.this)
             .load(uri)
             .centerCrop()
             .resize(200,200)
             .into(img_photo);

         // This profile image i am storing into a sharedpreference        
         profile_image=uri.toString();
     }
Run Code Online (Sandbox Code Playgroud)

在从sharedprefrence检索时,我通过使用将String转换为uri Uri.parse(profile_image)

但是如果我注意到,uri为不同的Android手机返回如下

Mi(Lollipop)- Uri=content://media/external/images/media/12415
samsung(KitKat)-Uri=content://media/external/images/media/786
Motorola(Marshmallow)- Uri=content://com.android.providers.media.documents/document/image%3A30731
One Plus One (Marshmallow)- Uri=content://com.android.providers.media.documents/document/image%3A475
Run Code Online (Sandbox Code Playgroud)

因此,当uri内容是-content:// media/external/images/media /是在ImageView Perfect上显示图像时,在其他情况下它不是

android uri image imageview picasso

14
推荐指数
1
解决办法
1万
查看次数

Android Picasso配置LruCache大小

我在我的项目中使用趋势毕加索,但我已经倾倒了堆,它看起来像这样.现在昨天它给了我48M LruCache用于毕加索.

我怎么能指定它的大小?

注意:我加载的图像显然很大.

如果有人提出fit()或者centerCrop(),我已经知道这些功能会减少图像尺寸,对吗?但有时我必须ListView在全视图中显示小图像.

现在,这些功能是否缓存缩小的图像?

在此输入图像描述

android picasso

13
推荐指数
1
解决办法
2万
查看次数

毕加索:将图片加载到widget listview

我正在使用基于本教程的listview实现小部件:http://laaptu.wordpress.com/2013/07/24/populate-appwidget-listview-with-remote-datadata-from-web/(源代码:https: //github.com/laaptu/appwidget-listview/tree/appwidget-listview2/).

ListView项目包含文本和图像,对于图像加载我使用Picasso.

getViewAt实现:

public RemoteViews getViewAt(int position) {
    final RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.listview_item);
    ListItem listItem = listItemList.get(position);
    remoteView.setTextViewText(R.id.headline, listItem.headline);
    final String imageUrl = listItem.image;
    handler.post(new Runnable() {
        @Override
        public void run() {
            if (!Utils.isEmpty(imageUrl)) {
                picasso.load(imageUrl)
                        .placeholder(R.drawable.empty_photo)
                        .into(remoteView, R.id.picture, new int[] { appWidgetId });
            }
        }
    });

    return remoteView;
}
Run Code Online (Sandbox Code Playgroud)

加载图像时,它会破坏布局.

什么可能是一个问题?或者我做错了什么?

没有图片加载:

截图

如何加载图像:

截图

更新:

如果我只是添加几个嵌套的远程视图(所有从一个布局中充气),也会发生同样的情况

UPDATE2:

报告了一个问题:https://github.com/square/picasso/issues/587

android listview android-widget picasso

13
推荐指数
2
解决办法
5510
查看次数

在加载毕加索之后,android得到Drawable图像

我正在使用Picasso库从url加载图像.我使用的代码如下.

Picasso.with(getContext()).load(url).placeholder(R.drawable.placeholder)
                .error(R.drawable.placeholder).into(imageView);
Run Code Online (Sandbox Code Playgroud)

我想做的是获取从url加载的图像.我用了

Drawable image = imageView.getDrawable();
Run Code Online (Sandbox Code Playgroud)

但是,这将始终返回占位符图像,而不是来自url的图像加载.你们有什么想法吗?我应该如何访问刚刚从url加载的可绘制图像.

提前致谢.

android callback target drawable picasso

13
推荐指数
1
解决办法
2万
查看次数

Picasso + convertView:我在这里做错了什么?

这是我的getView().

我显然在这里做错了,因为我列表中的第一项始终没有显示图片.

这里的问题是the convertview因为如果我不回收它,没有问题.

请问我做错了什么?

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if(convertView==null) //IF I DELETE THIS IF EVERYTHING OK!!!
    convertView = inflater.inflate(R.layout.square, null);
    ImageView image = (ImageView) convertView.findViewById(R.id.background_image);
    if (data.get(position).isFollowed()) {
        int approprieteimage = getApproppreiateImage(data.get(position));
        Picasso.with(context).load(approprieteimage).centerCrop().error(R.drawable.no_image_available).transform(new TealTransformation(context)).fit().into(image);
    } else {
        int approprieteimage = getApproppreiateImage(data.get(position));
        Picasso.with(context).load(approprieteimage).centerCrop().error(R.drawable.no_image_available).fit().into(image);

    }
    AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(width / 2, width / 2);
    convertView.setLayoutParams(layoutParams);
    return convertView;
}
Run Code Online (Sandbox Code Playgroud)

android convertview picasso

13
推荐指数
2
解决办法
751
查看次数