package com.example.criminalintent

import android.content.Context
import android.content.Intent
import androidx.core.content.IntentCompat
import androidx.fragment.app.Fragment
import java.util.UUID

class CrimeActivity : SingleFragmentActivity() {

 companion object {
     val EXTRA_CRIME_ID = "com.example.criminalintent.fragment1.crime_id"

     fun newIntent (packageContext: Context?, crimeID: UUID?): Intent {
         val intent = Intent(packageContext!!, CrimeActivity::class.java)
         intent.putExtra(EXTRA_CRIME_ID, crimeID)
         return intent
     }

 }

    override fun createFragment(): Fragment {

        val crimeID:UUID? = IntentCompat.getSerializableExtra(intent,EXTRA_CRIME_ID,UUID::class.java)

            //intent.getSerializableExtra (EXTRA_CRIME_ID) as UUID?
        return CrimeFragment.newInstance (crimeID)
    }

}