@@ -50,8 +50,6 @@ public class MaterialCollectionItem extends MaterialWidget implements HasClickHa
5050 private final ToggleStyleMixin <MaterialCollectionItem > dismissableMixin = new ToggleStyleMixin <>(this , "dismissable" );
5151
5252 private HandlerRegistration handlerReg ;
53- private Runnable swipeLeftCallback ;
54- private Runnable swipeRightCallback ;
5553
5654 public MaterialCollectionItem () {
5755 super (Document .get ().createLIElement ());
@@ -62,52 +60,52 @@ public MaterialCollectionItem() {
6260 @ Override
6361 protected void onLoad () {
6462 super .onLoad ();
65- initDismissableCollection (getSwipeLeftCallback (), getSwipeRightCallback () );
63+ initDismissableCollection ();
6664 }
6765
68- private native void initDismissableCollection (Runnable swipeLeftCallback , Runnable swipeRightCallback ) /*-{
69- $wnd.initDismissableCollection(swipeLeftCallback, swipeRightCallback );
66+ private native void initDismissableCollection () /*-{
67+ $wnd.initDismissableCollection();
7068 }-*/ ;
7169
7270 public void setType (CollectionType type ) {
7371 switch (type ) {
74- case AVATAR :
75- addStyleName (type .getCssName ());
76- break ;
77- case CHECKBOX :
78- if (getWidgetCount () > 0 ) {
79- getWidget (0 ).getElement ().getStyle ().setProperty ("display" , "inline" );
80- }
81- if (handlerReg != null ) {
82- handlerReg .removeHandler ();
83- }
84- handlerReg = addClickHandler (new ClickHandler () {
85- @ Override
86- public void onClick (ClickEvent event ) {
87- for (Widget w : MaterialCollectionItem .this ) {
88- if (w instanceof MaterialCollectionSecondary ) {
89- for (Widget a : (MaterialCollectionSecondary )w ) {
90- if (a instanceof HasValue ) {
91- try {
92- @ SuppressWarnings ("unchecked" )
93- HasValue <Boolean > cb = (HasValue <Boolean >) a ;
94- if (cb .getValue ()) {
95- cb .setValue (false );
96- } else {
97- cb .setValue (true );
72+ case AVATAR :
73+ addStyleName (type .getCssName ());
74+ break ;
75+ case CHECKBOX :
76+ if (getWidgetCount () > 0 ) {
77+ getWidget (0 ).getElement ().getStyle ().setProperty ("display" , "inline" );
78+ }
79+ if (handlerReg != null ) {
80+ handlerReg .removeHandler ();
81+ }
82+ handlerReg = addClickHandler (new ClickHandler () {
83+ @ Override
84+ public void onClick (ClickEvent event ) {
85+ for (Widget w : MaterialCollectionItem .this ) {
86+ if (w instanceof MaterialCollectionSecondary ) {
87+ for (Widget a : (MaterialCollectionSecondary )w ) {
88+ if (a instanceof HasValue ) {
89+ try {
90+ @ SuppressWarnings ("unchecked" )
91+ HasValue <Boolean > cb = (HasValue <Boolean >) a ;
92+ if (cb .getValue ()) {
93+ cb .setValue (false );
94+ } else {
95+ cb .setValue (true );
96+ }
97+ } catch (ClassCastException ex ) {
98+ // Ignore non-boolean has value handlers.
9899 }
99- } catch (ClassCastException ex ) {
100- // Ignore non-boolean has value handlers.
101100 }
102101 }
103102 }
104103 }
105104 }
106- }
107- });
108- break ;
109- default :
110- break ;
105+ });
106+ break ;
107+ default :
108+ break ;
111109 }
112110 }
113111
@@ -135,20 +133,4 @@ public boolean isAvatar() {
135133 public HandlerRegistration addClickHandler (ClickHandler handler ) {
136134 return addDomHandler (handler , ClickEvent .getType ());
137135 }
138-
139- public Runnable getSwipeLeftCallback () {
140- return swipeLeftCallback ;
141- }
142-
143- public void setSwipeLeftCallback (Runnable swipeLeftCallback ) {
144- this .swipeLeftCallback = swipeLeftCallback ;
145- }
146-
147- public Runnable getSwipeRightCallback () {
148- return swipeRightCallback ;
149- }
150-
151- public void setSwipeRightCallback (Runnable swipeRightCallback ) {
152- this .swipeRightCallback = swipeRightCallback ;
153- }
154136}
0 commit comments