我从解析云调用图像并使用毕加索将它们加载到我的gridview持有者中。
这是doInbackGround
@Override
protected Void doInBackground(Void... Params) {
feedsarraylist = new ArrayList<ParseFeeds>();
try {
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("AroundMe");
query.orderByDescending("createdAt");
//query.whereWithinKilometers()
ob = query.find();
for (ParseObject feeds : ob) {
ParseFile thumb = (ParseFile) feeds.get("videoThumbs");
//ParseFile video = (ParseFile) feeds.get("file");
ParseFeeds map = new ParseFeeds();
//map.setImage(thumb.getUrl());
//Uri videoUri = Uri.parse(video.getUrl());
map.setImage(thumb.getUrl());
feedsarraylist.add(map);
}
} catch (ParseException e) {
Log.e("ParseException", "parse: " + e);
}
return null;
}
ParseFeeds.class
public String getImage() {
return videoThumbs;
}
public void setImage(String videoThumbs) {
this.videoThumbs = videoThumbs;
}
我把它加载到GridViewAdapter.class
Picasso.with(context).load(feedsarraylist.get(position).getImage()).into(holder.ThumbView);
Logcat详细信息
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.parse.ParseFile.getUrl()' on a null object reference
at com.teamtreehouse.ribbit.FeedsFragment$RemoteDataTask.doInBackground(FeedsFragment.java:67)
at com.teamtreehouse.ribbit.FeedsFragment$RemoteDataTask.doInBackground(FeedsFragment.java:45)
答案 0 :(得分:0)
我只是在这里猜测,因为你没有指明错误发生的位置。
ParseFile thumb = (ParseFile) feeds.get("videoThumbs");
map.setImage(thumb.getUrl())
如果feeds
没有videoThumbs
元素,则thumb
将为null
因此您的错误。检查feeds
元素的内容。