Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is `noinspection SimplifiableIfStatement` automatically added to the activity created through the wizard

Tags:

android

My activity created through a wizard hash the following code:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

What is this piece of code here?

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
    return true;
}
like image 484
Max Koretskyi Avatar asked May 15 '15 09:05

Max Koretskyi


1 Answers

Without //noinspection SimplifiableIfStatement, the editor warns you because this could be simplified to:

return id == R.id.action_settings;

But that's probably not what you want here, you will need to put something in the if later (e.g. launch a Settings activity).

like image 121
Bruno Parmentier Avatar answered Sep 21 '22 16:09

Bruno Parmentier