please check this image我认为这似乎令人困惑。但是请您告诉我这是什么问题...我当时有一个回收站视图来显示图像,但是我的问题是我只想要上面的图像应该在回收器视图中显示1000个赞...我尝试实现,后来我的朋友告诉我,回收器视图纯粹是ui ..无法在回收器视图中完成..所以我创建了一个保存的接口这样的listviewholder 和2个模型类实现listviewmodel
interface ListViewModel {
int VIEW_TYPE_PHOTO = 1;
int VIEW_TYPE_VIDEO = 2;
int getViewType();
}
PhotoViewModel
class PhotoViewModel implements ListViewModel {
String imagePath;
String date_created;
String description;
public PhotoViewModel(String imagePath, String date_created, String description) {
this.imagePath = imagePath;
this.date_created = date_created;
this.description = description;
}
public PhotoViewModel(){}
@Override
public int getViewType() {
return VIEW_TYPE_PHOTO;
}
}
VideoViewModel
class VideoViewModel implements ListViewModel{
String image_path;
public VideoViewModel(String image_path) {
this.image_path = image_path;
}
@Override
public int getViewType() {
return VIEW_TYPE_VIDEO;
}
}
在帖子片段中,我得到图像和其他东西主要是位于..中的回收站。
List<Photo> photos = mPhotos;
List<ListViewModel> listViewModels = new ArrayList<>();
for (Photo photo : photos) {
if(photo.getPopularlist().contains("true")){
if(photo.getType_post().equals("Photo")){
//I thought this code will pass the photo.imagepath and description
listViewModels.add(new PhotoViewModel(photo.getImage_path(),photo.getDescription(),photo.getDate_created()));[please look at this image][1]
}
if(photo.getType_post().equals("Video")){
listViewModels.add(new VideoViewModel(photo.getImage_path()));
}
}
}
问题来了,我可以获取主体,但是图像却没有。.当日志显示为空时。.我认为图像路径未通过..我认为
在适配器中
PhotoViewModel photoViewModel = new PhotoViewModel();
imageLoader.displayImage(photoViewModel.imagePath,imageview);
我使用此代码获取图像路径...不起作用...是否有人知道如何解决...当我登录时显示为空
这是我的模型课程
public class Photo implements Parcelable{
private String description;
private String image_path;
private String photo_id;
private String user_id;
private String tags;
private List<Likes> likes;
private String popularlist;
private List<Comment> comments;
private String links;
private String type_post;
private String date_created;
private String category;
protected Photo(Parcel in) {
description = in.readString();
image_path = in.readString();
photo_id = in.readString();
user_id = in.readString();
tags = in.readString();
popularlist = in.readString();
links = in.readString();
type_post = in.readString();
date_created = in.readString();
category = in.readString();
}
public static final Creator<Photo> CREATOR = new Creator<Photo>() {
@Override
public Photo createFromParcel(Parcel in) {
return new Photo(in);
}
@Override
public Photo[] newArray(int size) {
return new Photo[size];
}
};
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImage_path() {
return image_path;
}
public void setImage_path(String image_path) {
this.image_path = image_path;
}
public String getPhoto_id() {
return photo_id;
}
public void setPhoto_id(String photo_id) {
this.photo_id = photo_id;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public List<Likes> getLikes() {
return likes;
}
public void setLikes(List<Likes> likes) {
this.likes = likes;
}
public String getPopularlist() {
return popularlist;
}
public void setPopularlist(String popularlist) {
this.popularlist = popularlist;
}
public List<Comment> getComments() {
return comments;
}
public void setComments(List<Comment> comments) {
this.comments = comments;
}
public String getLinks() {
return links;
}
public void setLinks(String links) {
this.links = links;
}
public String getType_post() {
return type_post;
}
public void setType_post(String type_post) {
this.type_post = type_post;
}
public String getDate_created() {
return date_created;
}
public void setDate_created(String date_created) {
this.date_created = date_created;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public Photo() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(description);
dest.writeString(image_path);
dest.writeString(photo_id);
dest.writeString(user_id);
dest.writeString(tags);
dest.writeString(popularlist);
dest.writeString(links);
dest.writeString(type_post);
dest.writeString(date_created);
dest.writeString(category);
}
public Photo(String description, String image_path, String photo_id, String user_id, String tags, List<Likes> likes, String popularlist, List<Comment> comments, String links, String type_post, String date_created, String category) {
this.description = description;
this.image_path = image_path;
this.photo_id = photo_id;
this.user_id = user_id;
this.tags = tags;
this.likes = likes;
this.popularlist = popularlist;
this.comments = comments;
this.links = links;
this.type_post = type_post;
this.date_created = date_created;
this.category = category;
}
@Override
public String toString() {
return "Photo{" +
"description='" + description + '\'' +
", image_path='" + image_path + '\'' +
", photo_id='" + photo_id + '\'' +
", user_id='" + user_id + '\'' +
", tags='" + tags + '\'' +
", likes=" + likes +
", popularlist='" + popularlist + '\'' +
", comments=" + comments +
", links='" + links + '\'' +
", type_post='" + type_post + '\'' +
", date_created='" + date_created + '\'' +
", category='" + category + '\'' +
'}';
}
}