package me.iwf.photopicker.entity;

import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by donglua on 15/6/28.
 */
public class PhotoDirectory {

  private String id;
  private String coverPath;
  private String name;
  private long   dateAdded;
  private List<Photo> photos = new ArrayList<>();

  @Override public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof PhotoDirectory)) return false;

    PhotoDirectory directory = (PhotoDirectory) o;

    boolean hasId = !TextUtils.isEmpty(id);
    boolean otherHasId = !TextUtils.isEmpty(directory.id);

    if (hasId && otherHasId) {
      if (!TextUtils.equals(id, directory.id)) {
        return false;
      }

      return TextUtils.equals(name, directory.name);
    }

    return false;
  }

  @Override public int hashCode() {
    if (TextUtils.isEmpty(id)) {
      if (TextUtils.isEmpty(name)) {
        return 0;
      }

      return name.hashCode();
    }

    int result = id.hashCode();

    if (TextUtils.isEmpty(name)) {
      return result;
    }

    result = 31 * result + name.hashCode();
    return result;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getCoverPath() {
    return coverPath;
  }

  public void setCoverPath(String coverPath) {
    this.coverPath = coverPath;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public long getDateAdded() {
    return dateAdded;
  }

  public void setDateAdded(long dateAdded) {
    this.dateAdded = dateAdded;
  }

  public List<Photo> getPhotos() {
    return photos;
  }

  public void setPhotos(List<Photo> photos) {
    this.photos = photos;
  }

  public List<String> getPhotoPaths() {
    List<String> paths = new ArrayList<>(photos.size());
    for (Photo photo : photos) {
      paths.add(photo.getPath());
    }
    return paths;
  }

  public void addPhoto(int id, String path) {
    photos.add(new Photo(id, path));
  }

}

@@ -113,16 +113,60 @@
 .List;%0A%0A
+import me.iwf.photopicker.utils.FileUtils;%0A%0A
 /**%0A * C
@@ -1799,24 +1799,298 @@
 %3E photos) %7B%0A
+    if (photos == null) return;%0A    for (int i = 0, j = 0, num = photos.size(); i %3C num; i++) %7B%0A        Photo p = photos.get(j);%0A        if (p == null %7C%7C !FileUtils.fileIsExists(p.getPath())) %7B%0A            photos.remove(j);%0A        %7D else %7B%0A            j++;%0A        %7D%0A    %7D%0A
     this.pho
@@ -2095,32 +2095,32 @@
 hotos = photos;%0A
-
   %7D%0A%0A  public Li
@@ -2343,24 +2343,66 @@
 ing path) %7B%0A
+    if (FileUtils.fileIsExists(path)) %7B%0A  
     photos.a
@@ -2426,15 +2426,21 @@
 path));%0A
+    %7D%0A
   %7D%0A%0A%7D%0A

Update PhotoDirectory.java