|
|
@@ -39,6 +39,9 @@ public class BookMarkListModel extends Model {
|
|
|
private List<BookmarkBean> bookmarkBeans;
|
|
|
private boolean[] categoryIndies;
|
|
|
private List<Integer> categoryAnchorIndies;
|
|
|
+ private List<BookmarkBean> categorizedBookmarkList;
|
|
|
+
|
|
|
+ private int categoryIndex;
|
|
|
|
|
|
private int hashCode = this.hashCode();
|
|
|
|
|
|
@@ -95,6 +98,14 @@ public class BookMarkListModel extends Model {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public int getCategoryIndex() {
|
|
|
+ return categoryIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setCategoryIndex(int categoryIndex) {
|
|
|
+ this.categoryIndex = categoryIndex;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 최신순 정렬된 리스트 반환
|
|
|
* - 데이터 변형 없이 로딩된 자체
|
|
|
@@ -107,7 +118,7 @@ public class BookMarkListModel extends Model {
|
|
|
|
|
|
/**
|
|
|
* 카테고리로 구분/정렬된 리스트 반환
|
|
|
- * - 카테고리 인덱스 배열도 함께 저장되므로 이후 사용할 수 있다. {@code getCategoryIndies()}
|
|
|
+ * - 카테고리 인덱스 배열도 별도 저장되므로 이후 사용할 수 있다. {@code getCategoryIndies()}
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -130,26 +141,8 @@ public class BookMarkListModel extends Model {
|
|
|
if (StringUtil.isEmpty(categoryNumber)) {
|
|
|
categoryNumber = "";
|
|
|
}
|
|
|
- switch (categoryNumber) {
|
|
|
- case CategoryID.CATEGORY_1:
|
|
|
- index = 0;
|
|
|
- break;
|
|
|
- case CategoryID.CATEGORY_2:
|
|
|
- index = 1;
|
|
|
- break;
|
|
|
- case CategoryID.CATEGORY_3:
|
|
|
- index = 2;
|
|
|
- break;
|
|
|
- case CategoryID.CATEGORY_4:
|
|
|
- index = 3;
|
|
|
- break;
|
|
|
- case CategoryID.CATEGORY_5:
|
|
|
- index = 4;
|
|
|
- break;
|
|
|
- default:
|
|
|
- index = -1;
|
|
|
- break;
|
|
|
- }
|
|
|
+
|
|
|
+ index = getCategoryIndexById(categoryNumber);
|
|
|
|
|
|
if (index > -1) {
|
|
|
List<BookmarkBean> beans = bookmarks.get(index);
|
|
|
@@ -165,7 +158,7 @@ public class BookMarkListModel extends Model {
|
|
|
categoryAnchorIndies = new ArrayList<>();
|
|
|
categoryIndies = new boolean[bookmarks.size()];
|
|
|
|
|
|
- List<BookmarkBean> categorizedBookmarkList = new ArrayList<>();
|
|
|
+ categorizedBookmarkList = new ArrayList<>();
|
|
|
int len = bookmarks.size();
|
|
|
for (int i = 0; i < len; ++i) {
|
|
|
List<BookmarkBean> beans = bookmarks.get(i);
|
|
|
@@ -195,6 +188,31 @@ public class BookMarkListModel extends Model {
|
|
|
return categorizedBookmarkList;
|
|
|
}
|
|
|
|
|
|
+ private int getCategoryIndexById(String categoryNumber) {
|
|
|
+ int index;
|
|
|
+ switch (categoryNumber) {
|
|
|
+ case CategoryID.CATEGORY_1:
|
|
|
+ index = 0;
|
|
|
+ break;
|
|
|
+ case CategoryID.CATEGORY_2:
|
|
|
+ index = 1;
|
|
|
+ break;
|
|
|
+ case CategoryID.CATEGORY_3:
|
|
|
+ index = 2;
|
|
|
+ break;
|
|
|
+ case CategoryID.CATEGORY_4:
|
|
|
+ index = 3;
|
|
|
+ break;
|
|
|
+ case CategoryID.CATEGORY_5:
|
|
|
+ index = 4;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ index = -1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return index;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 카테고리 인덱스 배열
|
|
|
* - {@code getCategorizedBookmarkList()} 후 세팅된다.
|
|
|
@@ -233,6 +251,27 @@ public class BookMarkListModel extends Model {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 카테고리 구분된 index 로 해당 카테고리 index 를 반환
|
|
|
+ * - 없으면 -1 반환
|
|
|
+ *
|
|
|
+ * @param categorizedIndex
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int getCategoryIndexOfCategorized(int categorizedIndex) {
|
|
|
+ String categoryNumber = CategoryID.CATEGORY_NONE;
|
|
|
+ if (null != categorizedBookmarkList) {
|
|
|
+ BookmarkBean bean = categorizedBookmarkList.get(categorizedIndex);
|
|
|
+ if (null != bean) {
|
|
|
+ categoryNumber = bean.getCategoryNumber();
|
|
|
+ if (StringUtil.isEmpty(categoryNumber)) {
|
|
|
+ categoryNumber = CategoryID.CATEGORY_NONE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return getCategoryIndexById(categoryNumber);
|
|
|
+ }
|
|
|
+
|
|
|
public void loadBookMarkList() {
|
|
|
disposableBookMarkList = BookmarkModelHelper.getInstance().loadMyBookmark(new PageRequestBean(), new IAPISimpleModuleListener<BookmarkListResultBean>() {
|
|
|
@Override
|
|
|
@@ -298,4 +337,5 @@ public class BookMarkListModel extends Model {
|
|
|
public void clearFlagChanged() {
|
|
|
ContentsFlagHelper.getInstance().clearChanged(hashCode);
|
|
|
}
|
|
|
+
|
|
|
}
|