Skip to content

Added animations for recycler view and navigation#3

Open
fer1592 wants to merge 8 commits into
mainfrom
feat/animations
Open

Added animations for recycler view and navigation#3
fer1592 wants to merge 8 commits into
mainfrom
feat/animations

Conversation

@fer1592
Copy link
Copy Markdown
Owner

@fer1592 fer1592 commented Jun 5, 2022

No description provided.

@fer1592 fer1592 marked this pull request as ready for review June 7, 2022 01:07
@fer1592
Copy link
Copy Markdown
Owner Author

fer1592 commented Jun 7, 2022

@AndresGarciaSobrado91 Approve?

@fer1592
Copy link
Copy Markdown
Owner Author

fer1592 commented Jun 7, 2022

@AndresGarciaSobrado91 and hurry up, don't know for what the hell I'm paying you...

@fer1592
Copy link
Copy Markdown
Owner Author

fer1592 commented Jun 12, 2022

...

binding.clustersList.scheduleLayoutAnimation()
}

private fun showLoading() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should be defined inside the MainActivity as public

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

(activity as MainActivity).binding.navHostFragment.visibility = View.GONE
}

private fun hideLoading() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should be defined inside the MainActivity as public

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

class MainActivity : AppCompatActivity() {
private var _binding: ActivityMainBinding? = null
private val binding get() = _binding!!
val binding get() = _binding!!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated and fixed in theory!

return view
}

private fun showLoading() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method belongs to main activity

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

(activity as MainActivity).binding.navHostFragment.visibility = View.GONE
}

private fun hideLoading() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fun deleteCluster(cluster: Cluster) {
viewModelScope.launch(dispatcher) {
_processingData.postValue(true)
clusterRepository.deleteCluster(cluster)
Copy link
Copy Markdown
Collaborator

@AndresGarciaSobrado91 AndresGarciaSobrado91 Jun 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

@AndresGarciaSobrado91 AndresGarciaSobrado91 Jun 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@AndresGarciaSobrado91
Copy link
Copy Markdown
Collaborator

AndresGarciaSobrado91 commented Jun 12, 2022

@AndresGarciaSobrado91 and hurry up, don't know for what the hell I'm paying you...

if you just would pay on time...

@fer1592
Copy link
Copy Markdown
Owner Author

fer1592 commented Jun 24, 2022

@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()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

val connectionTestSuccessful: LiveData<Boolean?>
get() = _connectionTestSuccessful
private val _displayMessage = MutableLiveData<Int?>(null)
val displayMessage: LiveData<Int?>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val displayMessage: LiveData<Int?> = _displayMessage

Copy link
Copy Markdown
Collaborator

@AndresGarciaSobrado91 AndresGarciaSobrado91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just minor comments


// Function that init the viewModel
fun getCluster(clusterId: Long, authMethods: List<String>, clusterRepository: ClusterRepository = ClusterRepositoryImplementation()) {
this.clusterId = clusterId
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here for example, it would be great to have this repo injected in the constructor of the class

@AndresGarciaSobrado91
Copy link
Copy Markdown
Collaborator

@AndresGarciaSobrado91 did the fixes, all green, please work...

I am a jobless man... please pay me what is mine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants