Android - RecyclerView 2

In het verlengde van het vorige artikel zal in dit artikel het project worden uitgebreid met een FAB (Floating Action Button) die een PopUp toont voor het toevoegen van een item.
Android Studio 4.0.0
Projectnaam RVPTH
SDK API 19
Bron https://developer.android.com/guide/topics/ui/floating-action-button | https://developer.android.com/guide/topics/ui/dialogs

public class MainActivity extends AppCompatActivity {

    private AlertDialog.Builder builder;
    private AlertDialog dialog;
    private EditText editText;
    private Button saveButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final List<MyListData> myListData = new ArrayList<MyListData>();
        final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        myListData.add(new MyListData("Email", android.R.drawable.ic_dialog_email));
        myListData.add(new MyListData("Info", android.R.drawable.ic_dialog_info));
        myListData.add(new MyListData("Delete", android.R.drawable.ic_delete));
        myListData.add(new MyListData("Dialer", android.R.drawable.ic_dialog_dialer));
        myListData.add(new MyListData("Alert", android.R.drawable.ic_dialog_alert));
        myListData.add(new MyListData("Map", android.R.drawable.ic_dialog_map));

        final MyListAdapter adapter = new MyListAdapter(myListData);

        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(adapter);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                builder = new AlertDialog.Builder(MainActivity.this);
                View view = getLayoutInflater().inflate(R.layout.popup, null);

                editText = view.findViewById(R.id.editText);
                saveButton = view.findViewById(R.id.saveButton);
                saveButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        String s = editText.getText().toString();

                        dialog.dismiss();

                        if (!s.isEmpty()) {

                            myListData.add(new MyListData(s, android.R.drawable.ic_dialog_alert));
                            final MyListAdapter adapter = new MyListAdapter(myListData);
                            recyclerView.setAdapter(adapter);

                        }

                    }
                });

                builder.setView(view);
                dialog = builder.create();
                dialog.show();

            }

        });

    }

}

<resources>
    <string name="app_name">RVPTH</string>
    <string name="enter_item">Toevoegen</string>
    <string name="hint_item">Vul in...</string>
    <string name="save_button">OK</string>
</resources>