상속받은 ArrayList<E>에 Parcelable 적용하기


상속받은 ArrayList


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
 * 체크박스를 가진 어레이 리스트.
 * @param <E>
 */
public class CheckboxArrayList<E> extends ArrayList<E> implements Parcelable {
 
    private boolean isCheckLimitCountExist = false// 체크갯수 한계가 존재하는가?
    private int checkLimitCount = 0;               // 체크 한계 갯수
 
    public CheckboxArrayList(boolean isCheckLimitCountExist, int checkLimitCount)
    {
        this.isCheckLimitCountExist = isCheckLimitCountExist;
        this.checkLimitCount = checkLimitCount;
    }
 
    public boolean isCheckLimitCountExist() {
        return isCheckLimitCountExist;
    }
 
    public int getCheckLimitCount() {
        return checkLimitCount;
    }
 
    /**
     * 체크가 가능한지 여부 판단
     * @return
     */
    public boolean isAddPossible ()
    {
        // 체크갯수 한계가 존재하지 않으면 무조건 가능
        if (isCheckLimitCountExist == false)
        {
            return true;
        }
        else
        {
            // 체크된 갯수가 한계 갯수와 동일하면 불가능
            if (this.getCheckCount() == checkLimitCount)
            {
                return false;
            }
            // 아니면 가능
            else
            {
                return true;
            }
        }
    }
 
    /**
     * 모든 체크리스트 false 변환
     */
    public void setCheckAllFalse ()
    {
        for (int i=0; i<this.size(); i++)
        {
            if (this.get(i) instanceof CheckBoxDto)
            {
                ((CheckBoxDto) this.get(i)).setChecked(false);
            }
        }
    }
 
    /**
     * 체크된 리스트 갯수 반환
     * @return
     */
    public int getCheckCount ()
    {
        int checkCount = 0;
 
        for (int i=0; i<this.size(); i++)
        {
            CheckBoxDto dto = ((CheckBoxDto) this.get(i));
 
            if (dto.isChecked())
            {
                checkCount++;
            }
        }
 
        return checkCount;
    }
 
 
 
 
    @Override
    public int describeContents() {
        return 0;
    }
 
    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(isCheckLimitCountExist ? 1 : 0);
        parcel.writeInt(checkLimitCount);
    }
 
    private CheckboxArrayList (Parcel in) {
 
        isCheckLimitCountExist = in.readInt() == 1 ? true : false;
        checkLimitCount = in.readInt();
    }
 
    public static final Creator<CheckboxArrayList> CREATOR = new Creator<CheckboxArrayList>() {
        public CheckboxArrayList createFromParcel(Parcel in) {
            return new CheckboxArrayList(in);
        }
 
        public CheckboxArrayList[] newArray(int size) {
            return new CheckboxArrayList[size];
        }
    };
}
cs



- 1차 클래스


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
 * 헤더 수신 정보
 */
public class DhFlourDeliveryStatusManagementHeaderResultDto extends CheckBoxDto implements Parcelable
{
 
    private String requestDate;                    // 의뢰일자
    private String requestCode;                    // 의뢰번호
    private String requestTypeName;                // 의뢰타입명
    private String accountCode;                    // 거래처코드
    private String accountName;                    // 거래처명
    private String plantCode;                    // 공장코드
    private String plantName;                    // 공장명
    private String statusName;                  // 상태명
    private String outTime;                     // 출차시간
    private String inScheduleTime;              // 도착예정시간
    private double paletteCount;                // 파레트 수량
 
 
    public DhFlourDeliveryStatusManagementHeaderResultDto() {
        // TODO Auto-generated constructor stub
    }
 
    public DhFlourDeliveryStatusManagementHeaderResultDto(String requestDate,
                                                          String requestCode,
                                                          String requestTypeName,
                                                          String accountCode,
                                                          String accountName,
                                                          String plantCode,
                                                          String plantName,
                                                          String statusName,
                                                          String outTime,
                                                          String inScheduleTime,
                                                          double paletteCount) {
        super();
 
        this.requestDate = requestDate;
        this.requestCode = requestCode;
        this.requestTypeName = requestTypeName;
        this.accountCode = accountCode;
        this.accountName = accountName;
        this.plantCode = plantCode;
        this.plantName = plantName;
        this.statusName = statusName;
        this.outTime = outTime;
        this.inScheduleTime = inScheduleTime;
        this.paletteCount = paletteCount;
        this.setChecked(false);
    }
 
    public String getRequestDate() {
        return requestDate;
    }
 
    public void setRequestDate(String requestDate) {
        this.requestDate = requestDate;
    }
 
    public String getRequestCode() {
        return requestCode;
    }
 
    public void setRequestCode(String requestCode) {
        this.requestCode = requestCode;
    }
 
    public String getRequestTypeName() {
        return requestTypeName;
    }
 
    public void setRequestTypeName(String requestTypeName) {
        this.requestTypeName = requestTypeName;
    }
 
    public String getAccountCode() {
        return accountCode;
    }
 
    public void setAccountCode(String accountCode) {
        this.accountCode = accountCode;
    }
 
    public String getAccountName() {
        return accountName;
    }
 
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }
 
    public String getPlantCode() {
        return plantCode;
    }
 
    public void setPlantCode(String plantCode) {
        this.plantCode = plantCode;
    }
 
    public String getPlantName() {
        return plantName;
    }
 
    public void setPlantName(String plantName) {
        this.plantName = plantName;
    }
 
    public String getStatusName() {
        return statusName;
    }
 
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
 
    public String getOutTime() {
        return outTime;
    }
 
    public void setOutTime(String outTime) {
        this.outTime = outTime;
    }
 
    public String getInScheduleTime() {
        return inScheduleTime;
    }
 
    public void setInScheduleTime(String inScheduleTime) {
        this.inScheduleTime = inScheduleTime;
    }
 
    public double getPaletteCount() {
        return paletteCount;
    }
 
    public void setPaletteCount(double paletteCount) {
        this.paletteCount = paletteCount;
    }
 
 
 
 
 
    @Override
    public int describeContents() {
        return 0;
    }
 
    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(requestDate);
        parcel.writeString(requestCode);
        parcel.writeString(requestTypeName);
        parcel.writeString(accountCode);
        parcel.writeString(accountName);
        parcel.writeString(plantCode);
        parcel.writeString(plantName);
        parcel.writeString(statusName);
        parcel.writeString(outTime);
        parcel.writeString(inScheduleTime);
        parcel.writeDouble(paletteCount);
    }
 
    private DhFlourDeliveryStatusManagementHeaderResultDto(Parcel in) {
 
        requestDate = in.readString();
        requestCode = in.readString();
        requestTypeName = in.readString();
        accountCode = in.readString();
        accountName = in.readString();
        plantCode = in.readString();
        plantName = in.readString();
        statusName = in.readString();
        outTime = in.readString();
        inScheduleTime = in.readString();
        paletteCount = in.readDouble();
    }
 
    public static final Creator<DhFlourDeliveryStatusManagementHeaderResultDto> CREATOR = new Creator<DhFlourDeliveryStatusManagementHeaderResultDto>() {
        public DhFlourDeliveryStatusManagementHeaderResultDto createFromParcel(Parcel in) {
            return new DhFlourDeliveryStatusManagementHeaderResultDto(in);
        }
 
        public DhFlourDeliveryStatusManagementHeaderResultDto[] newArray(int size) {
            return new DhFlourDeliveryStatusManagementHeaderResultDto[size];
        }
    };
 
 
}
cs



- CheckBoxDto


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class CheckBoxDto implements Serializable
{
 
    boolean isChecked;  // 체크여부
 
    public CheckBoxDto ()
    {
        super();
 
        isChecked = false;
    }
 
    public CheckBoxDto (boolean isChecked)
    {
        super();
 
        this.isChecked = isChecked;
    }
 
    public boolean isChecked() {
        return isChecked;
    }
 
    public void setChecked(boolean checked) {
        isChecked = checked;
    }
}
 
cs



- 전송 및 수신


1
2
3
4
5
6
7
8
9
// 전송
Intent intentToStart = new Intent(getActivity(), DhFlourDeliveryStatusManagementLineActivity.class);
intentToStart.putParcelableArrayListExtra("putExtra_selectData", selectData);
intentToStart.putExtra("putExtra_IOdate", putExtra_IOdate);
intentToStart.putExtra("putExtra_workSLInfo", userMenuManager.getWorkSLControl().getWorkSLInfo());
 
// 수신
Intent intent = getIntent();
getIntent_array_headerSelectData = (CheckboxArrayList<DhFlourDeliveryStatusManagementHeaderResultDto>) intent.getParcelableExtra("putExtra_selectData");
cs


CheckBox.isChecked 사용시에도 Parcelable 적용이 필요 없는지는 확인해봐야 할 듯 하다.

이 글을 공유하기


댓글(0)

Designed by CMSFactory.NET