Source:
<code>public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Intent intent = getActivity().getIntent(); State state; <START> if(intent!=null && intent.getExtras()!=null && intent.getExtras().getSerializable("state")!=null){ <END> state = (State) intent.getExtras().getSerializable("state"); }else{ state = ProductFragment.mState; } product = state.getProduct(); mFragment = this; imageNames = new ArrayList<>(); imagesRecycler = view.findViewById(R.id.images_recycler); imgMap = new HashMap<>(); openFoodAPIClient.getImages(product.getCode(), new OpenFoodAPIClient.OnImagesCallback() { @Override public void onImageResponse(boolean value, String response) { if (value && response != null) { Log.i("response", response); JSONObject jsonObject = null; try { jsonObject = new JSONObject(response); } catch (JSONException e) { e.printStackTrace(); } JSONObject images = null; try { images = jsonObject.getJSONObject("product").getJSONObject("images"); } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.names().length(); i++) { try { if (images.names().getString(i).contains("n") || images.names().getString(i).contains("f") || images.names().getString(i).contains("i") || images.names().getString(i).contains("o")) { continue; } imageNames.add(images.names().getString(i)); } catch (JSONException e) { e.printStackTrace(); } } } SharedPreferences preferences = getActivity().getSharedPreferences("login", 0); String login = preferences.getString("user", null); if (login != null) { adapter = new ImagesAdapter(getContext(), imageNames, product.getCode(), ProductPhotosFragment.this::onImageClick, product, true); } else { adapter = new ImagesAdapter(getContext(), imageNames, product.getCode(), ProductPhotosFragment.this::onImageClick, product, false); } imagesRecycler.setAdapter(adapter); imagesRecycler.setLayoutManager(new GridLayoutManager(getContext(), 3)); } } }); }</code><technical_language>code is properly formatted. for example some missing spaces in **if** command. please care reformat code default android formatting</technical_language>

Target:
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Intent intent = getActivity().getIntent(); State state; if (intent != null && intent.getExtras() != null && intent.getExtras().getSerializable("state") != null) { state = (State) intent.getExtras().getSerializable("state"); } else { state = ProductFragment.mState; } product = state.getProduct(); mFragment = this; imageNames = new ArrayList<>(); imagesRecycler = view.findViewById(R.id.images_recycler); imgMap = new HashMap<>(); openFoodAPIClient.getImages(product.getCode(), new OpenFoodAPIClient.OnImagesCallback() { @Override public void onImageResponse(boolean value, String response) { if (value && response != null) { JSONObject jsonObject = Utils.createJsonObject(response); JSONObject images = null; try { images = jsonObject.getJSONObject("product").getJSONObject("images"); } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.names().length(); i++) { try { if (images.names().getString(i).contains("n") || images.names().getString(i).contains("f") || images.names().getString(i).contains("i") || images.names().getString(i).contains("o")) { continue; } imageNames.add(images.names().getString(i)); } catch (JSONException e) { e.printStackTrace(); } } } SharedPreferences preferences = getActivity().getSharedPreferences("login", 0); String login = preferences.getString("user", null); if (login != null) { adapter = new ImagesAdapter(getContext(), imageNames, product.getCode(), ProductPhotosFragment.this::onImageClick, product, true); } else { adapter = new ImagesAdapter(getContext(), imageNames, product.getCode(), ProductPhotosFragment.this::onImageClick, product, false); } imagesRecycler.setAdapter(adapter); imagesRecycler.setLayoutManager(new GridLayoutManager(getContext(), 3)); } } }); }