Skip to content

Commit 493dbfe

Browse files
committed
Renamed obnoxiously long checkChildrenOnGroupCheck and added an attrs.xml file with richedittext examples.
1 parent 32c5b76 commit 493dbfe

3 files changed

Lines changed: 56 additions & 34 deletions

File tree

res/values/attrs.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<declare-styleable name="MultiChoiceExpandableListView">
5+
<attr name="testType">
6+
<enum name="regexp" value="0" />
7+
<enum name="numeric" value="1" />
8+
<enum name="alpha" value="2" />
9+
<enum name="alphaNumeric" value="3" />
10+
<enum name="email" value="4" />
11+
<enum name="creditCard" value="5" />
12+
<enum name="phone" value="6" />
13+
<enum name="domainName" value="7" />
14+
<enum name="ipAddress" value="8" />
15+
<enum name="webUrl" value="9" />
16+
<enum name="nocheck" value="10" />
17+
<enum name="custom" value="11" />
18+
</attr>
19+
<attr name="testErrorString" format="string" />
20+
<attr name="emptyErrorString" format="string" />
21+
<attr name="customRegexp" format="string" />
22+
<attr name="emptyAllowed" format="boolean" />
23+
<attr name="classType" format="string" />
24+
<attr name="fontName" format="string" />
25+
<attr name="showClearButton" format="boolean" />
26+
<attr name="showFormattingOptions" format="boolean" />
27+
<attr name="checkChildrenWithGroup" format="boolean" />
28+
</declare-styleable>
29+
30+
</resources>

src/com/kemallette/MultiChoiceExpandableList/MultiCheckable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ public interface MultiCheckable extends
166166
* @return
167167
*/
168168
public MultiCheckable
169-
checkChildrenOnGroupCheck(boolean checkChildrenOnGroupCheck);
169+
checkChildrenWithGroup(boolean checkChildrenWithGroup);
170170

171171

172-
public boolean isCheckChildrenOnGroupCheckEnabled();
172+
public boolean checkChildrenWithGroup();
173173

174174

175175
/***********************************************************

src/com/kemallette/MultiChoiceExpandableList/MultiChoiceExpandableListView.java

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ public class MultiChoiceExpandableListView extends
1818
ExpandableListView implements
1919
MultiCheckable{
2020

21-
private static final String TAG = "MultiChoiceExpandableListView";
21+
private static final String TAG = "MultiChoiceExpandableListView";
2222

2323

2424
/**
2525
* Flag indicating if an item's checked state change is from a user actually
2626
* touching the screen
2727
*/
28-
private boolean isCheckChangeFromTouch = false;
28+
private boolean isCheckChangeFromTouch = false;
2929

3030
/**
3131
* If true, on a group check change, that group's children will match the
3232
* group's check state. In other words, if you check a group, all its
3333
* children will also be checked and the reverse. If a group is unchecked,
3434
* all its children will be unchecked.
3535
*/
36-
private boolean checkChildrenOnGroupCheck = false;
36+
private boolean checkChildrenWithGroup = false;
3737

38-
private int groupChoiceMode = CHECK_MODE_NONE;
39-
private int childChoiceMode = CHECK_MODE_NONE;
38+
private int groupChoiceMode = CHECK_MODE_NONE;
39+
private int childChoiceMode = CHECK_MODE_NONE;
4040

4141
private CheckStateStore mCheckStore;
4242
private MultiCheckListener mClientCheckListener;
@@ -52,7 +52,7 @@ public MultiChoiceExpandableListView( final Context context,
5252
attrs,
5353
defStyle);
5454

55-
// TODO: set check modes and checkChildrenOnGroupCheck from xml attrs
55+
// TODO: set check modes and checkChildrenWithGroup from xml attrs
5656

5757
}
5858

@@ -109,7 +109,7 @@ else if (mAdapterWrapper == null)
109109
this);
110110
else
111111
mAdapterWrapper.setWrappedAdapter(adapter);
112-
112+
113113
super.setAdapter(mAdapterWrapper);
114114

115115
mCheckStore = new CheckStateStore(this); // Must do this to ensure
@@ -134,13 +134,12 @@ public void onGroupCheckChange(final Checkable checkedView,
134134
final long groupId,
135135
final boolean isChecked){
136136

137-
if (groupChoiceMode != CHECK_MODE_NONE){
137+
if (groupChoiceMode != CHECK_MODE_NONE)
138138
setGroupCheckedState( groupPosition,
139139
isChecked);
140-
}else{
140+
else
141141
Log.i( TAG,
142142
"onGroupCheckChange called, but groupChoice mode is NONE");
143-
}
144143

145144
if (mClientCheckListener != null)
146145
mClientCheckListener.onGroupCheckChange(checkedView,
@@ -159,16 +158,13 @@ public void onChildCheckChange(final Checkable checkedView,
159158
final boolean isChecked){
160159

161160

162-
if (childChoiceMode != CHECK_MODE_NONE){
163-
161+
if (childChoiceMode != CHECK_MODE_NONE)
164162
setChildCheckedState( groupPosition,
165163
childPosition,
166164
isChecked);
167-
168-
}else{
165+
else
169166
Log.i( TAG,
170167
"onChildCheckChange called, but childChoice mode is NONE");
171-
}
172168

173169
if (mClientCheckListener != null)
174170
mClientCheckListener.onChildCheckChange(checkedView,
@@ -365,21 +361,21 @@ public int getChildPosition(final long groupId, final long childId){
365361
switch(groupChoiceMode){// Don't need to do anything for MULTI
366362

367363
case CHECK_MODE_ONLY_ONE:
368-
if (!checkChildrenOnGroupCheck)
364+
if (!checkChildrenWithGroup)
369365
mCheckStore.clearAll();
370366
else
371367
Log.e( TAG,
372368
"Choice Mode is ONLY_ONE, but checkChildreOnGroupCheck is true. This can't happen.");
373369
break;
374370

375371
case GROUP_CHECK_MODE_ONE:
376-
mCheckStore.clearGroups(checkChildrenOnGroupCheck);
372+
mCheckStore.clearGroups(checkChildrenWithGroup);
377373
break;
378374
}
379375

380376
mCheckStore.setGroupState( groupPosition,
381377
isChecked,
382-
checkChildrenOnGroupCheck);
378+
checkChildrenWithGroup);
383379

384380
refreshVisibleCheckableViews();
385381

@@ -397,7 +393,7 @@ public int getChildPosition(final long groupId, final long childId){
397393
switch(childChoiceMode){
398394

399395
case CHECK_MODE_ONLY_ONE:
400-
if (!checkChildrenOnGroupCheck)
396+
if (!checkChildrenWithGroup)
401397
mCheckStore.clearAll();
402398
else
403399
Log.e( TAG,
@@ -459,9 +455,8 @@ public int getChildChoiceMode(){
459455
@Override
460456
public MultiCheckable setGroupChoiceMode(final int choiceMode){
461457

462-
if (choiceMode != CHECK_MODE_MULTI){
458+
if (choiceMode != CHECK_MODE_MULTI)
463459
mCheckStore.clearAll();
464-
}
465460

466461
groupChoiceMode = choiceMode;
467462
return this;
@@ -471,28 +466,27 @@ public MultiCheckable setGroupChoiceMode(final int choiceMode){
471466
@Override
472467
public MultiCheckable setChildChoiceMode(final int choiceMode){
473468

474-
if (choiceMode != CHECK_MODE_MULTI){
469+
if (choiceMode != CHECK_MODE_MULTI)
475470
mCheckStore.clearAll();
476-
}
477471
childChoiceMode = choiceMode;
478472
return this;
479473
}
480474

481475

482476
@Override
483477
public MultiCheckable
484-
checkChildrenOnGroupCheck(final boolean checkChildrenOnGroupCheck){
478+
checkChildrenWithGroup(final boolean checkChildrenWithGroup){
485479

486-
this.checkChildrenOnGroupCheck = checkChildrenOnGroupCheck;
480+
this.checkChildrenWithGroup = checkChildrenWithGroup;
487481

488482
return this;
489483
}
490484

491485

492486
@Override
493-
public boolean isCheckChildrenOnGroupCheckEnabled(){
487+
public boolean checkChildrenWithGroup(){
494488

495-
return checkChildrenOnGroupCheck;
489+
return checkChildrenWithGroup;
496490
}
497491

498492

@@ -623,7 +617,7 @@ public MultiCheckable clearAllChoices(){
623617
@Override
624618
public MultiCheckable clearCheckedGroups(){
625619

626-
mCheckStore.clearGroups(checkChildrenOnGroupCheck);
620+
mCheckStore.clearGroups(checkChildrenWithGroup);
627621

628622
refreshVisibleCheckableViews();
629623

@@ -732,13 +726,11 @@ protected long[] getGroupChildrenIds(final int groupPosition){
732726

733727
if (hasStableIds()){
734728
ids = new long[childCount];
735-
for (int i = 0; i < childCount; i++){
729+
for (int i = 0; i < childCount; i++)
736730
ids[i] = getChildId(groupPosition,
737731
i);
738-
}
739-
}else{
732+
}else
740733
ids = new long[0];
741-
}
742734

743735
return ids;
744736
}

0 commit comments

Comments
 (0)