Skip to content

Commit

Permalink
2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HuanTanSheng committed Sep 16, 2019
1 parent e126b98 commit eed7af0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ QQ交流群:[288600953](https://jq.qq.com/?_wv=1027&k=5QGgCDe)


## 更新日志
**2.5.0:**
- 优化:修复ArrayList在多线程中addItem出现的角标越界问题

**2.4.9:**
- 重要:升级到gradle:3.4.2,低版本studio可能因为该项升级而产生错误,建议升级studio或手动修改classpath 'com.android.tools.build:gradle:3.4.2'到你的可用版本
Expand Down
Binary file modified demo/release/demo-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.huantansheng.easyphotos.utils.String.StringUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
* 专辑模型
Expand Down Expand Up @@ -227,7 +227,7 @@ public String getAllAlbumName(Context context) {
*
* @return 当前专辑项目的图片集
*/
public ArrayList<Photo> getCurrAlbumItemPhotos(int currAlbumItemIndex) {
public List<Photo> getCurrAlbumItemPhotos(int currAlbumItemIndex) {
return album.getAlbumItem(currAlbumItemIndex).photos;
}

Expand All @@ -236,7 +236,7 @@ public ArrayList<Photo> getCurrAlbumItemPhotos(int currAlbumItemIndex) {
*
* @return 专辑项目集
*/
public ArrayList<AlbumItem> getAlbumItems() {
public List<AlbumItem> getAlbumItems() {
return album.albumItems;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package com.huantansheng.easyphotos.models.album.entity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;

/**
* 专辑模型实体类
* Created by huan on 2017/10/20.
*/

public class Album {
public ArrayList<AlbumItem> albumItems;
final public List<AlbumItem> albumItems;
private LinkedHashMap<String, AlbumItem> hasAlbumItems;//用于记录专辑项目

public Album() {
albumItems = new ArrayList<>();
albumItems = Collections.synchronizedList(new ArrayList<AlbumItem>());
hasAlbumItems = new LinkedHashMap<>();
}

private void addAlbumItem(AlbumItem albumItem) {
this.hasAlbumItems.put(albumItem.name, albumItem);
this.albumItems.add(albumItem);
synchronized (albumItems) {
boolean absent = !albumItems.contains(albumItem);
if (absent) {
this.albumItems.add(albumItem);
this.hasAlbumItems.put(albumItem.name, albumItem);
}
}

}

public void addAlbumItem(String name, String folderPath, String coverImagePath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.huantansheng.easyphotos.models.album.entity;

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

/**
* 专辑项目实体类
Expand All @@ -11,17 +13,22 @@ public class AlbumItem {
public String name;
public String folderPath;
public String coverImagePath;
public ArrayList<Photo> photos;
public final List<Photo> photos;

AlbumItem(String name, String folderPath, String coverImagePath) {
this.name = name;
this.folderPath = folderPath;
this.coverImagePath = coverImagePath;
this.photos = new ArrayList<>();
this.photos = Collections.synchronizedList(new ArrayList<Photo>());
}

public void addImageItem(Photo imageItem) {
this.photos.add(imageItem);
synchronized (photos) {
boolean absent = !photos.contains(imageItem);
if (absent) {
this.photos.add(imageItem);
}
}
}

public void addImageItem(int index, Photo imageItem) {
Expand Down

0 comments on commit eed7af0

Please sign in to comment.