Skip to content

Commit

Permalink
fix: check if binding is null
Browse files Browse the repository at this point in the history
E AndroidRuntime: java.lang.NullPointerException: Attempt to read from field 'androidx.recyclerview.widget.RecyclerView xtr.keymapper.databinding.FragmentProfilesViewBinding.profiles' on a null object reference
at xtr.keymapper.profiles.ProfilesViewFragment.setAdapter(ProfilesViewFragment.java:66)
  • Loading branch information
Xtr126 committed Nov 12, 2023
1 parent 4c52d98 commit cb0c8f9
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import xtr.keymapper.R;
import xtr.keymapper.databinding.FragmentProfilesViewBinding;

Expand Down Expand Up @@ -62,8 +59,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
}

private void setAdapter() {
profilesViewAdapter = new ProfilesViewAdapter(getContext(), this::setAdapter);
binding.profiles.setAdapter(profilesViewAdapter);
if (binding != null) {
profilesViewAdapter = new ProfilesViewAdapter(getContext(), this::setAdapter);
binding.profiles.setAdapter(profilesViewAdapter);
}
}

@Override
Expand Down

0 comments on commit cb0c8f9

Please sign in to comment.