99import android .view .View ;
1010import android .widget .Toast ;
1111
12+ import com .daimajia .swipe .SimpleSwipeListener ;
1213import com .daimajia .swipe .SwipeLayout ;
1314import com .nineoldandroids .view .ViewHelper ;
1415
1516public class MyActivity extends Activity {
1617
17- private SwipeLayout sample1 , sample2 ,sample3 ;
18+ private SwipeLayout sample1 , sample2 , sample3 ;
1819
1920 @ Override
2021 protected void onCreate (Bundle savedInstanceState ) {
@@ -26,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
2627
2728 //sample1
2829
29- sample1 = (SwipeLayout )findViewById (R .id .sample1 );
30+ sample1 = (SwipeLayout ) findViewById (R .id .sample1 );
3031 sample1 .setShowMode (SwipeLayout .ShowMode .LayDown );
3132 sample1 .setDragEdge (SwipeLayout .DragEdge .Left );
3233 sample1 .addRevealListener (R .id .delete , new SwipeLayout .OnRevealListener () {
@@ -38,7 +39,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
3839
3940 //sample2
4041
41- sample2 = (SwipeLayout )findViewById (R .id .sample2 );
42+ sample2 = (SwipeLayout ) findViewById (R .id .sample2 );
4243 sample2 .setShowMode (SwipeLayout .ShowMode .LayDown );
4344// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
4445 sample2 .findViewById (R .id .star ).setOnClickListener (new View .OnClickListener () {
@@ -65,34 +66,19 @@ public void onClick(View v) {
6566 sample2 .findViewById (R .id .click ).setOnClickListener (new View .OnClickListener () {
6667 @ Override
6768 public void onClick (View v ) {
68- Toast .makeText (MyActivity .this , "Yo" ,Toast .LENGTH_SHORT ).show ();
69+ Toast .makeText (MyActivity .this , "Yo" , Toast .LENGTH_SHORT ).show ();
6970 }
7071 });
71- sample1 .addSwipeListener (new SwipeLayout .SwipeListener () {
72- @ Override
73- public void onClose (SwipeLayout layout ) {
74-
75- }
76-
77- @ Override
78- public void onUpdate (SwipeLayout layout , int leftOffset , int topOffset ) {
79-
80- }
81-
72+ sample1 .addSwipeListener (new SimpleSwipeListener () {
8273 @ Override
8374 public void onOpen (SwipeLayout layout ) {
84-
85- }
86-
87- @ Override
88- public void onHandRelease (SwipeLayout layout , float xvel , float yvel ) {
89-
75+ Toast .makeText (MyActivity .this , "Opened" , Toast .LENGTH_SHORT ).show ();
9076 }
9177 });
9278
9379 //sample3
9480
95- sample3 = (SwipeLayout )findViewById (R .id .sample3 );
81+ sample3 = (SwipeLayout ) findViewById (R .id .sample3 );
9682 sample3 .setDragEdge (SwipeLayout .DragEdge .Top );
9783 sample3 .addRevealListener (R .id .bottom_wrapper_child1 , new SwipeLayout .OnRevealListener () {
9884 @ Override
@@ -102,7 +88,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
10288 ViewHelper .setTranslationY (star , d * fraction );
10389 ViewHelper .setScaleX (star , fraction + 0.6f );
10490 ViewHelper .setScaleY (star , fraction + 0.6f );
105- int c = (Integer )evaluate (fraction , Color .parseColor ("#dddddd" ), Color .parseColor ("#4C535B" ));
91+ int c = (Integer ) evaluate (fraction , Color .parseColor ("#dddddd" ), Color .parseColor ("#4C535B" ));
10692 child .setBackgroundColor (c );
10793 }
10894 });
@@ -131,7 +117,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
131117 if (id == R .id .action_listview ) {
132118 startActivity (new Intent (this , ListViewExample .class ));
133119 return true ;
134- }else if (id == R .id .action_gridview ){
120+ } else if (id == R .id .action_gridview ) {
135121 startActivity (new Intent (this , GridViewExample .class ));
136122 return true ;
137123 }
@@ -154,9 +140,9 @@ public Object evaluate(float fraction, Object startValue, Object endValue) {
154140 int endG = (endInt >> 8 ) & 0xff ;
155141 int endB = endInt & 0xff ;
156142
157- return (int )((startA + (int )(fraction * (endA - startA ))) << 24 ) |
158- (int )((startR + (int )(fraction * (endR - startR ))) << 16 ) |
159- (int )((startG + (int )(fraction * (endG - startG ))) << 8 ) |
160- (int )((startB + (int )(fraction * (endB - startB ))));
143+ return (int ) ((startA + (int ) (fraction * (endA - startA ))) << 24 ) |
144+ (int ) ((startR + (int ) (fraction * (endR - startR ))) << 16 ) |
145+ (int ) ((startG + (int ) (fraction * (endG - startG ))) << 8 ) |
146+ (int ) ((startB + (int ) (fraction * (endB - startB ))));
161147 }
162148}
0 commit comments