Why getContext() sometimes returns null? I pass context to LastNewsRVAdapter.java as an argument. But LayoutInflater.from(contex
When you are sure fragment is attached to its host(onResume, onViewCreated, etc) use this instead of getContext() :
requireContext()
It will not be inspected by lint, but it will throw an Exception if context detached!
Then you should check nullity by if clouse (or some thing) or be sure that if the program reaches this line, it isn't null.
In retrofit calls or retrofit (and may others in the same way), it will return a disposable that must be cleared or disposed before onDestroy.