|
|
@@ -4,7 +4,6 @@
|
|
|
package kr.co.zumo.app.lifeplus.view;
|
|
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
-import android.widget.Checkable;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -19,12 +18,12 @@ import java.util.List;
|
|
|
* @history 민효동 [2019. 1. 18.] [최초 작성]
|
|
|
* @since 2019. 1. 18.
|
|
|
*/
|
|
|
-public class SingleSelector {
|
|
|
+public class SingleSelector<T> {
|
|
|
|
|
|
- List<Checkable> boxes;
|
|
|
- Listener listener;
|
|
|
+ private List<T> boxes;
|
|
|
+ private Listener<T> listener;
|
|
|
|
|
|
- public SingleSelector(Listener listener) {
|
|
|
+ public SingleSelector(Listener<T> listener) {
|
|
|
boxes = new ArrayList<>();
|
|
|
this.listener = listener;
|
|
|
}
|
|
|
@@ -34,7 +33,7 @@ public class SingleSelector {
|
|
|
*
|
|
|
* @param box
|
|
|
*/
|
|
|
- public void addChildBox(Checkable box) {
|
|
|
+ public void addChildBox(T box) {
|
|
|
boxes.add(box);
|
|
|
}
|
|
|
|
|
|
@@ -45,7 +44,7 @@ public class SingleSelector {
|
|
|
* @return 없으면 null 반환
|
|
|
*/
|
|
|
@Nullable
|
|
|
- public Checkable getChildBoxAt(int index) {
|
|
|
+ public T getChildBoxAt(int index) {
|
|
|
|
|
|
if (boxes.size() <= index) {
|
|
|
return null;
|
|
|
@@ -59,12 +58,12 @@ public class SingleSelector {
|
|
|
*
|
|
|
* @param trigger
|
|
|
*/
|
|
|
- public void check(Checkable trigger, boolean isTriggerChecked) {
|
|
|
+ public void check(T trigger, boolean isTriggerChecked) {
|
|
|
// 리스트에 속한 박스라면 다른 박스를 해제 시킨다.
|
|
|
if (boxes.indexOf(trigger) > -1) {
|
|
|
- List<Checkable> list = new ArrayList<>();
|
|
|
+ List<T> list = new ArrayList<>();
|
|
|
if (isTriggerChecked) {
|
|
|
- for (Checkable checkable : boxes) {
|
|
|
+ for (T checkable : boxes) {
|
|
|
if (trigger != checkable) {
|
|
|
list.add(checkable);
|
|
|
}
|
|
|
@@ -79,10 +78,10 @@ public class SingleSelector {
|
|
|
*
|
|
|
* @param box
|
|
|
*/
|
|
|
- public void uncheck(Checkable box) {
|
|
|
+ public void uncheck(T box) {
|
|
|
if (boxes.indexOf(box) > -1) {
|
|
|
- List<Checkable> list = new ArrayList<>();
|
|
|
- for (Checkable checkable : boxes) {
|
|
|
+ List<T> list = new ArrayList<>();
|
|
|
+ for (T checkable : boxes) {
|
|
|
if (box != checkable) {
|
|
|
list.add(checkable);
|
|
|
}
|
|
|
@@ -97,7 +96,7 @@ public class SingleSelector {
|
|
|
* @param box
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean contains(Checkable box) {
|
|
|
+ public boolean contains(T box) {
|
|
|
return boxes.contains(box);
|
|
|
}
|
|
|
|
|
|
@@ -108,8 +107,8 @@ public class SingleSelector {
|
|
|
boxes = null;
|
|
|
}
|
|
|
|
|
|
- public interface Listener {
|
|
|
- void onChecked(Checkable trigger, boolean isTriggerChecked, List<Checkable> unchecked);
|
|
|
- void onUnchecked(List<Checkable> unchecked);
|
|
|
+ public interface Listener<T> {
|
|
|
+ void onChecked(T trigger, boolean isTriggerChecked, List<T> unchecked);
|
|
|
+ void onUnchecked(List<T> unchecked);
|
|
|
}
|
|
|
}
|