title: NullPointerException with adapter
body: <p>I have this observer for my viewmodel so that I can setup my adapter but, when I run the app, it gives me the NullPointerException error on this line:</p>
  <pre><code>japaneseAdapter = it.data?.let { it1 -&gt; JapaneseAdapter(it1) }!!
  </code></pre>
  <p>This is the activity with that line:</p>
  <pre><code>@AndroidEntryPoint
  class JapaneseActivity : AppCompatActivity() {
     private lateinit var binding: ActivityJapaneseBinding
     private val japaneseViewModel by viewModels&lt;JapaneseViewModel&gt;()
     private lateinit var japaneseAdapter: JapaneseAdapter
  
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         binding = ActivityJapaneseBinding.inflate(layoutInflater)
         setContentView(binding.root)
  
         japaneseViewModel.japaneseResponse.observe(this, {
             when(it.status){
                 Resource.Status.LOADING -&gt; { }
                 Resource.Status.SUCCESS -&gt; {
                     japaneseAdapter = it.data?.let { it1 -&gt; JapaneseAdapter(it1) }!!
                     binding.rvNews.adapter = japaneseAdapter
                 }
                 Resource.Status.ERROR -&gt; { Log.d(&quot;ERROR&quot;,&quot;ERROR RAISED&quot;) }
             }
         })
     }
  }
  </code></pre>
  <p>This is the adapter:</p>
  <pre><code>class JapaneseAdapter(private var japaneseResponse: List&lt;JapaneseResponse&gt;) :
      RecyclerView.Adapter&lt;JapaneseAdapter.ViewHolder&gt;() {
  
      inner class ViewHolder(
          view: View
      ) : RecyclerView.ViewHolder(view) {
          private val binding = NewsItemsBinding.bind(view)
  
          private val itemTitle: TextView = binding.tvTitle
          private val itemImage: ImageView = binding.ivNews
          private val itemDescription: TextView = binding.tvDescription
  
          fun bind(response: JapaneseResponse) {
              Picasso.get().load(response.urlToImage).into(itemImage)
              itemTitle.text = response.Title
              itemDescription.text = response.Description
          }
      }
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
          val v = LayoutInflater.from(parent.context).inflate(R.layout.news_items, parent, false)
          return ViewHolder(v)
      }
  
      override fun onBindViewHolder(holder: ViewHolder, position: Int) {
          holder.bind(japaneseResponse[position])
      }
  
      override fun getItemCount(): Int {
          return japaneseResponse.size
      }
  
  }
  </code></pre>
  <p>Generic data source:</p>
  <pre><code>abstract class BaseDataSource {
  
      protected suspend fun &lt;T&gt; getResult(call: suspend () -&gt; Response&lt;ApiResponse&lt;T&gt;&gt;): Resource&lt;T&gt; {
          try {
              val response = call()
  //            if(response.isSuccessful) {
  //                val body = response.body()?.data
  //                if(body != null) return Resource.success(body)
  //            }
              val body = response.body()?.data
              return Resource.success(body)
              //return Resource.error(&quot;${response.code()}: ${response.message()}&quot;)
          } catch (e: Exception) {
              return Resource.error(e.message ?: &quot;Generic error&quot;)
          }
      }
  }
  
  data class Resource&lt;out T&gt;(val status: Status, val data: T?, val message: String?) : Serializable {
  
      enum class Status {
          SUCCESS,
          ERROR,
          LOADING
      }
  
      companion object {
          fun &lt;T&gt; success(data: T?): Resource&lt;T&gt; {
              return Resource(
                  Status.SUCCESS,
                  data,
                  null
              )
          }
  
          fun &lt;T&gt; error(message: String, data: T? = null): Resource&lt;T&gt; {
              return Resource(
                  Status.ERROR,
                  data,
                  message
              )
          }
  
          fun &lt;T&gt; loading(data: T? = null): Resource&lt;T&gt; {
              return Resource(
                  Status.LOADING,
                  data,
                  null
              )
          }
      }
  
      fun isSuccessful() = status == Status.SUCCESS
  
      fun isError() = status == Status.ERROR
  
      fun isLoading() = status == Status.LOADING
  }
  </code></pre>
  <p>The data source for the Japanese news:</p>
  <pre><code>class JapaneseDataSource @Inject constructor(private val japaneseService: JapaneseService) :
      BaseDataSource() {
  
      suspend fun getJpNews() = getResult { japaneseService.jpNews() }
  }
  </code></pre>
  <p>Repository:</p>
  <pre><code>class JapaneseRepository @Inject constructor(
      private val remote: JapaneseDataSource
  ) {
      suspend fun jpNews() =
          remote.getJpNews()
  }
  </code></pre>
  <p>The service:</p>
  <pre><code>interface JapaneseService {
      @GET(&quot;/v2/top-headlines?country=jp&amp;apiKey=77acc490875643c5b2328fb615e0cf83&quot;)
      suspend fun jpNews(): Response&lt;ApiResponse&lt;List&lt;JapaneseResponse&gt;&gt;&gt;
  }
  </code></pre>
  <p>I can see that the response is there since I have okhttp logging it for me but for some reason it seems to be null and I am not sure why...
  Any help?</p>