9
9
import android .view .View ;
10
10
import android .widget .Toast ;
11
11
12
+ import com .daimajia .swipe .SimpleSwipeListener ;
12
13
import com .daimajia .swipe .SwipeLayout ;
13
14
import com .nineoldandroids .view .ViewHelper ;
14
15
15
16
public class MyActivity extends Activity {
16
17
17
- private SwipeLayout sample1 , sample2 ,sample3 ;
18
+ private SwipeLayout sample1 , sample2 , sample3 ;
18
19
19
20
@ Override
20
21
protected void onCreate (Bundle savedInstanceState ) {
@@ -26,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
26
27
27
28
//sample1
28
29
29
- sample1 = (SwipeLayout )findViewById (R .id .sample1 );
30
+ sample1 = (SwipeLayout ) findViewById (R .id .sample1 );
30
31
sample1 .setShowMode (SwipeLayout .ShowMode .LayDown );
31
32
sample1 .setDragEdge (SwipeLayout .DragEdge .Left );
32
33
sample1 .addRevealListener (R .id .delete , new SwipeLayout .OnRevealListener () {
@@ -38,7 +39,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
38
39
39
40
//sample2
40
41
41
- sample2 = (SwipeLayout )findViewById (R .id .sample2 );
42
+ sample2 = (SwipeLayout ) findViewById (R .id .sample2 );
42
43
sample2 .setShowMode (SwipeLayout .ShowMode .LayDown );
43
44
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
44
45
sample2 .findViewById (R .id .star ).setOnClickListener (new View .OnClickListener () {
@@ -65,34 +66,19 @@ public void onClick(View v) {
65
66
sample2 .findViewById (R .id .click ).setOnClickListener (new View .OnClickListener () {
66
67
@ Override
67
68
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 ();
69
70
}
70
71
});
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 () {
82
73
@ Override
83
74
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 ();
90
76
}
91
77
});
92
78
93
79
//sample3
94
80
95
- sample3 = (SwipeLayout )findViewById (R .id .sample3 );
81
+ sample3 = (SwipeLayout ) findViewById (R .id .sample3 );
96
82
sample3 .setDragEdge (SwipeLayout .DragEdge .Top );
97
83
sample3 .addRevealListener (R .id .bottom_wrapper_child1 , new SwipeLayout .OnRevealListener () {
98
84
@ Override
@@ -102,7 +88,7 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
102
88
ViewHelper .setTranslationY (star , d * fraction );
103
89
ViewHelper .setScaleX (star , fraction + 0.6f );
104
90
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" ));
106
92
child .setBackgroundColor (c );
107
93
}
108
94
});
@@ -131,7 +117,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
131
117
if (id == R .id .action_listview ) {
132
118
startActivity (new Intent (this , ListViewExample .class ));
133
119
return true ;
134
- }else if (id == R .id .action_gridview ){
120
+ } else if (id == R .id .action_gridview ) {
135
121
startActivity (new Intent (this , GridViewExample .class ));
136
122
return true ;
137
123
}
@@ -154,9 +140,9 @@ public Object evaluate(float fraction, Object startValue, Object endValue) {
154
140
int endG = (endInt >> 8 ) & 0xff ;
155
141
int endB = endInt & 0xff ;
156
142
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 ))));
161
147
}
162
148
}
0 commit comments