Added animations for recycler view and navigation#3
Conversation
|
@AndresGarciaSobrado91 Approve? |
|
@AndresGarciaSobrado91 and hurry up, don't know for what the hell I'm paying you... |
|
... |
| binding.clustersList.scheduleLayoutAnimation() | ||
| } | ||
|
|
||
| private fun showLoading() { |
There was a problem hiding this comment.
this method should be defined inside the MainActivity as public
| (activity as MainActivity).binding.navHostFragment.visibility = View.GONE | ||
| } | ||
|
|
||
| private fun hideLoading() { |
There was a problem hiding this comment.
this method should be defined inside the MainActivity as public
| class MainActivity : AppCompatActivity() { | ||
| private var _binding: ActivityMainBinding? = null | ||
| private val binding get() = _binding!! | ||
| val binding get() = _binding!! |
There was a problem hiding this comment.
should never set binding as public, it must be handled only by the main activity. We can write some public methods that modify the binding state
There was a problem hiding this comment.
updated and fixed in theory!
| return view | ||
| } | ||
|
|
||
| private fun showLoading() { |
There was a problem hiding this comment.
method belongs to main activity
| (activity as MainActivity).binding.navHostFragment.visibility = View.GONE | ||
| } | ||
|
|
||
| private fun hideLoading() { |
| fun deleteCluster(cluster: Cluster) { | ||
| viewModelScope.launch(dispatcher) { | ||
| _processingData.postValue(true) | ||
| clusterRepository.deleteCluster(cluster) |
There was a problem hiding this comment.
what if the cluster deletion fails? like if we set as argument an inexistent cluster in the DB? Maybe we should wait for the deletion result and show a message to the user
There was a problem hiding this comment.
I show a message in case the delete succeeds or fails. It was out of the scope of "animations" but I'll everything to make you happy
| app:layout_constraintTop_toBottomOf="@+id/toolbar" | ||
| app:navGraph="@navigation/nav_graph" /> | ||
|
|
||
| <ProgressBar |
There was a problem hiding this comment.
maybe you want a frameLayout matching parent width and height, containing inside the progressBar.. just to be able to set some opacity and disable all views while loading is shown
There was a problem hiding this comment.
I put a card instead of a frameLayout, found that it's easier to customize. Tested adding oppacity, but it looked horrible, but if it makes you happy, I'll add it
|
if you just would pay on time... |
…added and updated unit tests
|
@AndresGarciaSobrado91 did the fixes, all green, please work... |
|
|
||
| // Sets observer to show progress bar when deleting a cluster | ||
| clustersViewModel.processingData.observe(viewLifecycleOwner) { | ||
| if (it) (activity as MainActivity).showLoading() |
There was a problem hiding this comment.
maybe we could create a new fragment extension function so we just call showLoading(true/false) directly
| } | ||
| binding.addCluster.isEnabled = !it | ||
| binding.updateCluster.isEnabled = !it | ||
| if (it) (activity as MainActivity).showLoading() |
| val connectionTestSuccessful: LiveData<Boolean?> | ||
| get() = _connectionTestSuccessful | ||
| private val _displayMessage = MutableLiveData<Int?>(null) | ||
| val displayMessage: LiveData<Int?> |
There was a problem hiding this comment.
val displayMessage: LiveData<Int?> = _displayMessage
AndresGarciaSobrado91
left a comment
There was a problem hiding this comment.
just minor comments
|
|
||
| // Function that init the viewModel | ||
| fun getCluster(clusterId: Long, authMethods: List<String>, clusterRepository: ClusterRepository = ClusterRepositoryImplementation()) { | ||
| this.clusterId = clusterId |
There was a problem hiding this comment.
here for example, it would be great to have this repo injected in the constructor of the class
I am a jobless man... please pay me what is mine |
No description provided.