@@ -207,11 +207,10 @@ public boolean onCreateOptionsMenu(Menu menu) {
207
207
*/
208
208
@ Override
209
209
public boolean onOptionsItemSelected (MenuItem item ) {
210
- switch (item .getItemId ()) {
211
- case R .id .share :
210
+ if (item .getItemId () == R .id .share ) {
212
211
share ();
213
212
return true ;
214
- default :
213
+ } else {
215
214
return super .onOptionsItemSelected (item );
216
215
}
217
216
}
@@ -225,8 +224,7 @@ public boolean onNavigationItemSelected(MenuItem item) {
225
224
menuItems .setCheckedItems (item );
226
225
zoomView .resetZoom ();
227
226
228
- switch (id ){
229
- case R .id .activity_main_drawer_draw :
227
+ if (id == R .id .activity_main_drawer_draw ) {
230
228
if (topology .equals ("phone" ) && !menuItems .isInputPhoneSelected ())
231
229
menuItems .setPhoneInput ();
232
230
@@ -238,8 +236,7 @@ public boolean onNavigationItemSelected(MenuItem item) {
238
236
else
239
237
startWithInput (lstopo , 1 , "" , topology , options );
240
238
setMode ("draw" );
241
- break ;
242
- case R .id .activity_main_drawer_text :
239
+ } else if (id == R .id .activity_main_drawer_text ) {
243
240
if (topology .equals ("phone" ) && !menuItems .isInputPhoneSelected ())
244
241
menuItems .setPhoneInput ();
245
242
@@ -255,12 +252,10 @@ public boolean onNavigationItemSelected(MenuItem item) {
255
252
setMode ("txt" );
256
253
String lstopoText = readFile (txtFile );
257
254
lstopo .text (lstopoText , 0 , 0 , 0 , 0 , 0 , -1 );
258
- break ;
259
255
} catch (IOException e ) {
260
256
e .printStackTrace ();
261
- break ;
262
257
}
263
- case R .id .activity_main_drawer_xml :
258
+ } else if ( id == R .id .activity_main_drawer_xml ) {
264
259
if (topology .equals ("phone" ) && !menuItems .isInputPhoneSelected ())
265
260
menuItems .setPhoneInput ();
266
261
@@ -276,46 +271,36 @@ public boolean onNavigationItemSelected(MenuItem item) {
276
271
setMode ("xml" );
277
272
String lstopoText = readFile (xmlFile );
278
273
lstopo .text (lstopoText , 0 , 0 , 0 , 0 , 0 , -1 );
279
- break ;
280
274
} catch (IOException e ) {
281
275
e .printStackTrace ();
282
- break ;
283
276
}
284
- case R .id .activity_main_drawer_MyPhone :
277
+ } else if ( id == R .id .activity_main_drawer_MyPhone ) {
285
278
topology = "phone" ;
286
279
layout .removeAllViews ();
287
280
288
281
start (lstopo , 1 , "" , options );
289
282
menuItems .setDrawFormat ();
290
283
mode = "draw" ;
291
- break ;
292
- case R .id .activity_main_drawer_database :
284
+ } else if (id == R .id .activity_main_drawer_database ) {
293
285
/* menuItems.setDrawFormat();
294
286
downloadTopology(); */
295
287
Uri uriDatabase = Uri .parse ("https://hwloc.gitlabpages.inria.fr/xmls/" );
296
288
Intent intentDatabase = new Intent (Intent .ACTION_VIEW , uriDatabase );
297
289
startActivity (intentDatabase );
298
- break ;
299
- case R .id .activity_main_drawer_LocalXML :
290
+ } else if (id == R .id .activity_main_drawer_LocalXML ) {
300
291
file_picker ();
301
- break ;
302
- case R .id .activity_main_drawer_Synthetic_Topology :
292
+ } else if (id == R .id .activity_main_drawer_Synthetic_Topology ) {
303
293
createSyntheticLayout ();
304
- break ;
305
- case R .id .activity_main_drawer_debug :
294
+ } else if (id == R .id .activity_main_drawer_debug ) {
306
295
final Uri data = FileProvider .getUriForFile (this , "com.hwloc.lstopo.fileprovider" , debugFile );
307
296
this .grantUriPermission (this .getPackageName (), data , Intent .FLAG_GRANT_READ_URI_PERMISSION );
308
297
final Intent intent = new Intent (Intent .ACTION_VIEW )
309
298
.setDataAndType (data , "text/plain" )
310
299
.addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
311
300
this .startActivity (intent );
312
- break ;
313
- case R .id .activity_main_drawer_about :
301
+ } else if (id == R .id .activity_main_drawer_about ) {
314
302
Intent intentAbout = new Intent (MainActivity .this , About .class );
315
303
startActivityForResult (intentAbout , 5 );
316
- break ;
317
- default :
318
- break ;
319
304
}
320
305
321
306
this .drawerLayout .closeDrawer (GravityCompat .START );
0 commit comments