1
1
package fr .free .nrw .commons ;
2
2
3
- import android .app . Activity ;
3
+ import android .support . annotation . Nullable ;
4
4
import android .support .v4 .view .PagerAdapter ;
5
5
import android .view .LayoutInflater ;
6
6
import android .view .View ;
11
11
12
12
public class WelcomePagerAdapter extends PagerAdapter {
13
13
private static final int PAGE_FINAL = 4 ;
14
+ private Callback callback ;
15
+
16
+ public interface Callback {
17
+ void onYesClicked ();
18
+ }
14
19
15
20
static final int [] PAGE_LAYOUTS = new int []{
16
21
R .layout .welcome_wikipedia ,
@@ -20,6 +25,10 @@ public class WelcomePagerAdapter extends PagerAdapter {
20
25
R .layout .welcome_final
21
26
};
22
27
28
+ public void setCallback (@ Nullable Callback callback ) {
29
+ this .callback = callback ;
30
+ }
31
+
23
32
@ Override
24
33
public int getCount () {
25
34
return PAGE_LAYOUTS .length ;
@@ -48,14 +57,16 @@ public void destroyItem(ViewGroup container, int position, Object obj) {
48
57
container .removeView ((View ) obj );
49
58
}
50
59
51
- public static class ViewHolder {
52
- public ViewHolder (View view ) {
60
+ class ViewHolder {
61
+ ViewHolder (View view ) {
53
62
ButterKnife .bind (this , view );
54
63
}
55
64
56
65
@ OnClick (R .id .welcomeYesButton )
57
- void onClicked (View view ) {
58
- ((Activity ) view .getContext ()).finish ();
66
+ void onClicked () {
67
+ if (callback != null ) {
68
+ callback .onYesClicked ();
69
+ }
59
70
}
60
71
}
61
72
}
0 commit comments