21
21
import com .saulmm .material .views .adapters .SamplePagerAdapter ;
22
22
import com .saulmm .material .views .widgets .SlidingTabLayout ;
23
23
24
- public class DialerSampleActivity extends ActionBarActivity implements ViewPager . OnPageChangeListener {
24
+ public class DialerSampleActivity extends ActionBarActivity {
25
25
26
26
private int screenWidth ;
27
27
private ImageButton fabButton ;
@@ -35,50 +35,6 @@ protected void onCreate(Bundle savedInstanceState) {
35
35
setContentView (R .layout .activity_dialer );
36
36
37
37
configureToolbar ();
38
- configurePager ();
39
- configureFab ();
40
- configureDialer ();
41
-
42
- dialerKeysContainer = (FrameLayout ) findViewById (R .id .activity_dialer_frame_container );
43
-
44
- // Get the screen with
45
- Display display = getWindowManager ().getDefaultDisplay ();
46
- Point size = new Point ();
47
- display .getSize (size );
48
- screenWidth = size .x ;
49
- }
50
-
51
- private void configureFab () {
52
-
53
- fabButton = (ImageButton ) findViewById (R .id .view_fab_button );
54
- fabButton .setOnClickListener (new View .OnClickListener () {
55
- @ Override
56
- public void onClick (View v ) {
57
-
58
- absolutefabPosition = v .getX ();
59
- GUIUtils .hideViewByScale (fabButton );
60
- dialerKeysContainer .setVisibility (View .VISIBLE );
61
-
62
- Animation showDialerContainerAnimation = AnimationUtils .loadAnimation (DialerSampleActivity .this , R .anim .translate_down_on );
63
- showDialerContainerAnimation .setAnimationListener (new Animation .AnimationListener () {
64
- @ Override
65
- public void onAnimationStart (Animation animation ) {}
66
-
67
- @ Override
68
- public void onAnimationEnd (Animation animation ) {
69
-
70
- fabButton .setBackgroundResource (R .drawable .ripple_dialer_call );
71
- fabButton .setX (screenWidth / 2 - fabButton .getWidth () / 2 );
72
- GUIUtils .showViewByScale (fabButton );
73
- }
74
-
75
- @ Override
76
- public void onAnimationRepeat (Animation animation ) {}
77
- });
78
-
79
- dialerKeysContainer .startAnimation (showDialerContainerAnimation );
80
- }
81
- });
82
38
}
83
39
84
40
private void configureToolbar () {
@@ -88,77 +44,4 @@ private void configureToolbar() {
88
44
setSupportActionBar (mainToolbar );
89
45
getSupportActionBar ().setTitle ("Dialer" );
90
46
}
91
-
92
- private void configurePager () {
93
-
94
- ViewPager tabsViewPAger = (ViewPager ) findViewById (R .id .activity_dialer_pager );
95
- tabsViewPAger .setAdapter (new SamplePagerAdapter (this ));
96
- tabsViewPAger .setCurrentItem (1 );
97
-
98
- SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout ) findViewById (R .id .activity_dialer_tabs );
99
- mSlidingTabLayout .addPagerListener (this );
100
- mSlidingTabLayout .setViewPager (tabsViewPAger );
101
- }
102
-
103
- private void configureDialer () {
104
-
105
- GridView dialerGrid = (GridView ) findViewById (R .id .activity_dialer_pad );
106
- dialerGrid .setAdapter (new ArrayAdapter <String >(this , R .layout .list_item_dialer ,
107
- getResources ().getStringArray (R .array .dialer_numbers )));
108
- }
109
-
110
- @ Override
111
- public void onPageScrolled (int position , float positionOffset , int positionOffsetPixels ) {
112
-
113
- float fabButtonPosition = (screenWidth / 2 - fabButton .getWidth ()) * positionOffset ;
114
-
115
-
116
- if (fabButtonPosition != 0 && position != 1 ) {
117
-
118
- absolutefabPosition = fabButtonPosition + (screenWidth /2 - fabButton .getWidth ()/2 );
119
- fabButton .setX (absolutefabPosition );
120
- }
121
- }
122
-
123
- @ Override
124
- public void onBackPressed () {
125
-
126
- if (dialerKeysContainer .getVisibility () == View .VISIBLE ) {
127
-
128
- Animation hideAnimation = AnimationUtils .loadAnimation (this , R .anim .translate_down_off );
129
- hideAnimation .setAnimationListener (new Animation .AnimationListener () {
130
- @ Override
131
- public void onAnimationStart (Animation animation ) {
132
-
133
- GUIUtils .hideViewByScale (fabButton );
134
- }
135
-
136
- @ Override
137
- public void onAnimationEnd (Animation animation ) {
138
-
139
- dialerKeysContainer .setVisibility (View .INVISIBLE );
140
- fabButton .setBackgroundResource (R .drawable .ripple_dialer_idle );
141
- GUIUtils .showViewByScale (fabButton );
142
-
143
- fabButton .setX (absolutefabPosition );
144
- }
145
-
146
- @ Override
147
- public void onAnimationRepeat (Animation animation ) {}
148
- });
149
-
150
- dialerKeysContainer .startAnimation (hideAnimation );
151
-
152
-
153
-
154
- } else {
155
- super .onBackPressed ();
156
- }
157
- }
158
-
159
- @ Override
160
- public void onPageSelected (int position ) {}
161
-
162
- @ Override
163
- public void onPageScrollStateChanged (int state ) {}
164
47
}
0 commit comments