Last active
April 22, 2020 20:40
-
-
Save Nimrodda/86d7923e7181cc6bdfcef1fa92a23dc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WorkoutSummaryActivity : AppCompatActivity() { | |
private lateinit var binding: WorkoutSummaryActivityBinding | |
private val viewModel: WorkoutSummaryViewModel by viewModels() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// We use View Binding here | |
binding = WorkoutSummaryActivityBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
// Set up Epoxy controller with RecyclerView | |
val workoutSummaryController = WorkoutSummaryController() | |
binding.recyclerView.adapter = workoutSummaryController.adapter | |
viewModel.viewState.observe(this) { viewState -> | |
workoutSummaryController.setData(viewState) | |
} | |
// Make sure data is loaded only once in case of config change | |
if (savedInstanceState == null) { | |
viewModel.loadData(intent.getIntExtra("workouId", 0)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment