gpt4 book ai didi

java - 解析云不返回图像

转载 作者:行者123 更新时间:2023-12-01 10:38:07 25 4
gpt4 key购买 nike

我花了 3 天多的时间从 Parse Cloud 获取图像文件。但它什么也没返回。我已经检查了后端,数据已添加到那里,但它没有返回图像。有天使可以帮我解决这个问题吗?

 // Set up a customized query
ParseQueryAdapter.QueryFactory<AnywallPost> factory =
new ParseQueryAdapter.QueryFactory<AnywallPost>() {
public ParseQuery<AnywallPost> create() {
Location myLoc = (currentLocation == null) ? lastLocation : currentLocation;
ParseQuery<AnywallPost> query = AnywallPost.getQuery();
query.include("user");
query.orderByDescending("createdAt");
query.include("image");
query.whereWithinKilometers("location", geoPointFromLocation(myLoc), radius
* METERS_PER_FEET / METERS_PER_KILOMETER);
query.setLimit(MAX_POST_SEARCH_RESULTS);
return query;
}
};

// Set up the query adapter
postsQueryAdapter = new ParseQueryAdapter<AnywallPost>(this, factory) {
@Override
public View getItemView(AnywallPost post, View view, ViewGroup parent) {
if (view == null) {
view = View.inflate(getContext(), R.layout.anywall_post_item, null);
}
ParseFile photo = (ParseFile) post.get("image");
TextView contentView = (TextView) view.findViewById(R.id.content_view);
image = (ImageView) view.findViewById(R.id.picture_view);
imageloader.DisplayImage(post.getPhoto(),image);
TextView usernameView = (TextView) view.findViewById(R.id.username_view);
contentView.setText(post.getText());
usernameView.setText(post.getUser().getUsername());
post.setPhoto(photo.getUrl());
return view;
}
};

编辑版本:

  // Set up a customized query
ParseQueryAdapter.QueryFactory<AnywallPost> factory =
new ParseQueryAdapter.QueryFactory<AnywallPost>() {
public ParseQuery<AnywallPost> create() {
Location myLoc = (currentLocation == null) ? lastLocation : currentLocation;
ParseQuery<AnywallPost> query = AnywallPost.getQuery();
query.include("user");
query.orderByDescending("createdAt");
query.whereWithinKilometers("location", geoPointFromLocation(myLoc), radius
* METERS_PER_FEET / METERS_PER_KILOMETER);
query.setLimit(MAX_POST_SEARCH_RESULTS);
return query;
}
};

// Set up the query adapter
postsQueryAdapter = new ParseQueryAdapter<AnywallPost>(this, factory) {
@Override
public View getItemView(AnywallPost post, View view, ViewGroup parent) {
if (view == null) {
view = View.inflate(getContext(), R.layout.anywall_post_item, null);
}
ParseFile photo = (ParseFile) post.get("image");
if (photo != null) {
photo.getDataInBackground(new GetDataCallback() {

@Override
public void done(byte[] data, ParseException e) {
// TODO Auto-generated method stub
if (data != null && e == null) {
Bitmap bitmap = BitmapFactory
.decodeByteArray(data, 0,
data.length);
image.setImageBitmap(bitmap);

} else {
//ParseException e
}
}
});
} else {
//picture_not_available
}
TextView contentView = (TextView) view.findViewById(R.id.content_view);
image = (ImageView) view.findViewById(R.id.picture_view);
TextView usernameView = (TextView) view.findViewById(R.id.username_view);
contentView.setText(post.getText());
usernameView.setText(post.getUser().getUsername());
post.setPhoto(photo.getUrl());
return view;
}
};

最佳答案

您必须使用getDataInBackground获取图像资源

if (photo != null) {
photo.getDataInBackground(new GetDataCallback() {

@Override
public void done(byte[] data, ParseException e) {
// TODO Auto-generated method stub
if (data != null && e == null) {
Bitmap bitmap = BitmapFactory
.decodeByteArray(data, 0,
data.length);
image.setImageBitmap(bitmap);

} else {
//ParseException e
}
}
});
} else {
//picture_not_available
}

关于java - 解析云不返回图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34564117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com