|
|
@@ -83,18 +83,42 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
protected void modifyContents(List<CategoryContentsBean> contentsBeans) {
|
|
|
}
|
|
|
|
|
|
- private boolean isFilterApplied = false;
|
|
|
-
|
|
|
@Override
|
|
|
- public void loadContents(String categoryNumber) {
|
|
|
+ public void loadContents() {
|
|
|
if (isFilterApplied) {
|
|
|
+ filteringOrder = getCurrentOrder();
|
|
|
+ loadFilteringContents(waiterCaller, e -> {
|
|
|
+ if (e.getEventId() == Event.SUCCESS) {
|
|
|
+ parseResult(filterSearchResultBean);
|
|
|
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).integer(Event.FILTER_COMMIT).build());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ onResult(new Event.Builder(Event.ERROR).integer(Event.FILTER_COMMIT).build());
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
else {
|
|
|
- super.loadContents(categoryNumber);
|
|
|
+ contentsOrder = getCurrentOrder();
|
|
|
+ super.loadContents();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 필터링 처리 중 정렬을 변경 항 뒤 가 리셋 되거나 하나도 선택되지 않았을 경우
|
|
|
+ * 기존 contentsBeans 를 이용하면 정렬 순서가 다를 수 있다.
|
|
|
+ */
|
|
|
+ private int contentsOrder; // 전체 컨텐츠를 로딩할 때 정렬 순서
|
|
|
+ private int filteringOrder; // 필터링 중 정렬 순서
|
|
|
+
|
|
|
+ public int getContentsOrder() {
|
|
|
+ return contentsOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getFilteringOrder() {
|
|
|
+ return filteringOrder;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 검색 결과에 맞게 bean 추가 해줌
|
|
|
*/
|
|
|
@@ -105,22 +129,24 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
* -> 결과 일부 있음 => hash 수가 다름
|
|
|
* -> 결과 모두 있음 => hash 수가 맞음
|
|
|
*/
|
|
|
- contentsBeans = null;
|
|
|
+ committedFilteringContents = null;
|
|
|
|
|
|
- if (null != resultBean.getData()) {
|
|
|
- contentsBeans = new ArrayList<>(resultBean.getData());
|
|
|
+ if (null != resultBean && null != resultBean.getData()) {
|
|
|
+ committedFilteringContents = new ArrayList<>(resultBean.getData());
|
|
|
+ listCount = resultBean.getListCount();
|
|
|
}
|
|
|
- listCount = resultBean.getListCount();
|
|
|
|
|
|
- if (null == contentsBeans) {
|
|
|
- contentsBeans = new ArrayList<>();
|
|
|
+ if (null == committedFilteringContents) {
|
|
|
+ committedFilteringContents = new ArrayList<>();
|
|
|
listCount = 0;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private boolean isFilterApplied = false;
|
|
|
private int listCount = 0;
|
|
|
private CategoryFilterContentsResultBean filterSearchResultBean;
|
|
|
+ private List<CategoryContentsBean> committedFilteringContents;
|
|
|
|
|
|
/**
|
|
|
* 검색 필터 데이터
|
|
|
@@ -131,6 +157,10 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
return filterSectionBeans;
|
|
|
}
|
|
|
|
|
|
+ public boolean isFilterApplied() {
|
|
|
+ return isFilterApplied;
|
|
|
+ }
|
|
|
+
|
|
|
public final void loadFilter(String categoryNumber) {
|
|
|
if (null != filterSectionBeans) {
|
|
|
onResult(new Event.Builder(Event.SUCCESS).integer(Event.LOADED_FILTER).build());
|
|
|
@@ -186,7 +216,9 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
|
|
|
// 필터 적용
|
|
|
if (applyFilter(requestBean) == false) {
|
|
|
+ isFilterApplied = false;
|
|
|
filterSearchResultBean = null;
|
|
|
+ listCount = 0;
|
|
|
listener.onEvent(new Event.Builder(Event.SUCCESS).integer(0).build());
|
|
|
return;
|
|
|
}
|
|
|
@@ -197,9 +229,9 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
filterSearchResultBean = resultBean;
|
|
|
if (null != filterSearchResultBean) {
|
|
|
isFilterApplied = true;
|
|
|
- int count = filterSearchResultBean.getListCount();
|
|
|
+ listCount = filterSearchResultBean.getListCount();
|
|
|
|
|
|
- listener.onEvent(new Event.Builder(Event.SUCCESS).integer(count).build());
|
|
|
+ listener.onEvent(new Event.Builder(Event.SUCCESS).integer(listCount).build());
|
|
|
}
|
|
|
else {
|
|
|
this.onApiError("data is null.....", new APIError(APIError.ERROR_INVAlID_RESULT));
|
|
|
@@ -358,7 +390,12 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
|
|
|
@Override
|
|
|
public List<CategoryContentsBean> getContents() {
|
|
|
- return contentsBeans;
|
|
|
+ if (isFilterApplied) {
|
|
|
+ return committedFilteringContents;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return contentsBeans;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -407,15 +444,9 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (null == filterSearchResultBean) {
|
|
|
- isFilterApplied = false;
|
|
|
- }
|
|
|
- else {
|
|
|
- isFilterApplied = true;
|
|
|
- parseResult(filterSearchResultBean);
|
|
|
+ parseResult(filterSearchResultBean);
|
|
|
|
|
|
- onResult(new Event.Builder(Event.SUCCESS).integer(Event.FILTER_COMMIT).build());
|
|
|
- }
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).integer(Event.FILTER_COMMIT).build());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -435,6 +466,7 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
*/
|
|
|
public void resetFilter() {
|
|
|
isFilterApplied = false;
|
|
|
+ listCount = 0;
|
|
|
|
|
|
int len = filterSectionBeans.size();
|
|
|
for (int i = 0; i < len; ++i) {
|
|
|
@@ -447,9 +479,9 @@ public abstract class CategoryFilterModel extends CategoryMainModel {
|
|
|
}
|
|
|
|
|
|
// 정렬 순서 초기값
|
|
|
- if (FilterBean.FILTER_TYPE_ORDER.equals(bean.getSectionType())) {
|
|
|
- bean.getFilterBeans().get(0).setSelected(true);
|
|
|
- }
|
|
|
+// if (FilterBean.FILTER_TYPE_ORDER.equals(bean.getSectionType())) {
|
|
|
+// bean.getFilterBeans().get(0).setSelected(true);
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
|