content: package net.alexbarry.alexgames;
  
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Adapter;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  import androidx.annotation.NonNull;
  import androidx.fragment.app.Fragment;
  import androidx.fragment.app.FragmentManager;
  import androidx.lifecycle.ViewModelProvider;
  import androidx.navigation.fragment.NavHostFragment;
  import androidx.recyclerview.widget.RecyclerView;
  
  public class SecondFragment extends Fragment {
  
      private AlexGamesViewModel viewModel;
  
      @Override
      public View onCreateView(
              LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState
      ) {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_second, container, false);
      }
  
      public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  
          String[] games_list = new AlexGamesJni().getGamesList(); // TODO clean up
          ListView game_sel = view.findViewById(R.id.game_sel);
          ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_list_item_1, games_list);
          game_sel.setAdapter(adapter);
          viewModel = new ViewModelProvider(requireActivity()).get(AlexGamesViewModel.class);
          game_sel.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                  String game_id = games_list[position];
                  viewModel.setGameId(game_id);
                  NavHostFragment.findNavController(SecondFragment.this)
                          .navigate(R.id.action_SecondFragment_to_FirstFragment);
              }
          });
      }
  }
  