1
1
package fr .free .nrw .commons ;
2
2
3
3
import android .app .Activity ;
4
- import android .content .Context ;
5
4
import android .support .v4 .view .PagerAdapter ;
6
5
import android .view .LayoutInflater ;
7
6
import android .view .View ;
11
10
import butterknife .OnClick ;
12
11
13
12
public class WelcomePagerAdapter extends PagerAdapter {
14
-
15
- private Context context ;
16
-
17
13
private static final int PAGE_FINAL = 4 ;
18
14
19
15
static final int [] PAGE_LAYOUTS = new int []{
@@ -24,10 +20,6 @@ public class WelcomePagerAdapter extends PagerAdapter {
24
20
R .layout .welcome_final
25
21
};
26
22
27
- public WelcomePagerAdapter (Context context ) {
28
- this .context = context ;
29
- }
30
-
31
23
@ Override
32
24
public int getCount () {
33
25
return PAGE_LAYOUTS .length ;
@@ -40,11 +32,11 @@ public boolean isViewFromObject(View view, Object object) {
40
32
41
33
@ Override
42
34
public Object instantiateItem (ViewGroup container , int position ) {
43
- LayoutInflater inflater = LayoutInflater .from (context );
35
+ LayoutInflater inflater = LayoutInflater .from (container . getContext () );
44
36
ViewGroup layout = (ViewGroup ) inflater .inflate (PAGE_LAYOUTS [position ], container , false );
45
37
46
38
if (position == PAGE_FINAL ) {
47
- ViewHolder holder = new ViewHolder (layout , context );
39
+ ViewHolder holder = new ViewHolder (layout );
48
40
layout .setTag (holder );
49
41
}
50
42
container .addView (layout );
@@ -57,16 +49,13 @@ public void destroyItem(ViewGroup container, int position, Object obj) {
57
49
}
58
50
59
51
public static class ViewHolder {
60
- private Context context ;
61
-
62
- public ViewHolder (View view , Context context ) {
52
+ public ViewHolder (View view ) {
63
53
ButterKnife .bind (this , view );
64
- this .context = context ;
65
54
}
66
55
67
56
@ OnClick (R .id .welcomeYesButton )
68
- void onClicked () {
69
- ((Activity ) context ).finish ();
57
+ void onClicked (View view ) {
58
+ ((Activity ) view . getContext () ).finish ();
70
59
}
71
60
}
72
61
}
0 commit comments