Commit 28dc40091109755d2fc92b1f487daa8fdccbed2c
1 parent
5fd9eebf
Déconnexion !!!!!
Showing
2 changed files
with
19 additions
and
13 deletions
Show diff stats
PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java
... | ... | @@ -95,6 +95,9 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
95 | 95 | if(item.getItemId() == R.id.action_settings){ |
96 | 96 | getFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).addToBackStack("settings").commit(); |
97 | 97 | } |
98 | + else if(item.getItemId() == R.id.action_disconnect){ | |
99 | + disconnect(); | |
100 | + } | |
98 | 101 | |
99 | 102 | return super.onOptionsItemSelected(item); |
100 | 103 | } |
... | ... | @@ -152,9 +155,7 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
152 | 155 | } |
153 | 156 | } |
154 | 157 | else{ |
155 | - Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
156 | - final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
157 | - viewPager.setCurrentItem(0); | |
158 | + disconnect(); | |
158 | 159 | } |
159 | 160 | } |
160 | 161 | |
... | ... | @@ -194,9 +195,7 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
194 | 195 | } |
195 | 196 | } |
196 | 197 | else{ |
197 | - Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
198 | - final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
199 | - viewPager.setCurrentItem(0); | |
198 | + disconnect(); | |
200 | 199 | } |
201 | 200 | } |
202 | 201 | |
... | ... | @@ -239,9 +238,7 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
239 | 238 | } |
240 | 239 | } |
241 | 240 | else{ |
242 | - Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
243 | - final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
244 | - viewPager.setCurrentItem(0); | |
241 | + disconnect(); | |
245 | 242 | } |
246 | 243 | } |
247 | 244 | |
... | ... | @@ -299,9 +296,7 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
299 | 296 | } |
300 | 297 | } |
301 | 298 | else{ |
302 | - Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
303 | - final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
304 | - viewPager.setCurrentItem(0); | |
299 | + disconnect(); | |
305 | 300 | } |
306 | 301 | } |
307 | 302 | |
... | ... | @@ -373,4 +368,15 @@ public class MainActivite extends Activity implements ASyncResponse, main_tab_fr |
373 | 368 | public long getTimeToken(){ |
374 | 369 | return mTimeToken; |
375 | 370 | } |
371 | + | |
372 | + public void disconnect(){ | |
373 | + mToken = null; | |
374 | + mDroit = 0; | |
375 | + mUser = null; | |
376 | + mTimeToken = 0; | |
377 | + | |
378 | + Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_SHORT).show(); | |
379 | + final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
380 | + viewPager.setCurrentItem(0); | |
381 | + } | |
376 | 382 | } | ... | ... |
PremiereActivite/app/src/main/res/menu/menu.xml
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | app:showAsAction="ifRoom|withText" /> |
10 | 10 | |
11 | 11 | <item |
12 | - android:id="@+id/action_delete" | |
12 | + android:id="@+id/action_disconnect" | |
13 | 13 | android:icon="@android:drawable/ic_menu_delete" |
14 | 14 | android:title="@string/disconnect" |
15 | 15 | android:showAsAction="ifRoom|withText" | ... | ... |