Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - CircularFlow by Rodrigo Dominguez #129

Merged
merged 9 commits into from Feb 11, 2021

Conversation

rodrigomartind
Copy link
Contributor

@rodrigomartind rodrigomartind commented Feb 2, 2021

CircularFlow

I add a class called CircularFlow which allows us to group views with circular references.

constraint_referenced_ids : It receives id's of the views that will add the references (Eg. "view2, view3, view4,view5,view6").

circularflow_viewCenter : It receives the id of the view of the center where the views received in constraint_referenced_ids (Eg. "view1")

circularflow_angles : Receive the angles that you will assign to each view (Eg. "45,90,135,180,225")

circularflow_radiusInDP : Receive the radios in DP that you will assign to each view (Eg. "90,100,110,120,130")

How add a view at runtime?

With method addViewToCircularFlow you can add new views to CircularFlow.

 /**
 * Add a view to the CircularFlow. The referenced view need to be a child of the container parent.
 * The view also need to have its id set in order to be added.
 * The views previous need to have its radius and angle set in order to be added correctly a new view.
 * @param view
 * @param radius
 * @param angle
 * @return
 */

Eg.

findViewById<View>(R.id.view7).setOnClickListener {
            findViewById<CircularFlow>(R.id.circularFlow).addViewToCircularFlow(
                it, 140, 200F
            )
        }

Demo add view in emulator

AddViewToCircularFlow.mp4

How remove a view at runtime?

With method removeViewFromCircularFlow you can remove a view from CircularFlow.

 /**
     * Remove a given view from the CircularFlow.
     *
     * @param view
     */

Eg.

findViewById<View>(R.id.view2).setOnClickListener {
            findViewById<CircularFlow>(R.id.circularFlow).removeViewFromCircularFlow(
                it
            )
        }

Demo remove view in emulator

Demo_removeView.mp4

Demos in AS:

Grabacion.de.pantalla.2021-02-02.a.la.s.16.33.48.mov
Grabacion.de.pantalla.2021-02-02.a.la.s.16.37.50.mov

@google-cla
Copy link

google-cla bot commented Feb 2, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla
Copy link

google-cla bot commented Feb 2, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@rodrigomartind
Copy link
Contributor Author

@googlebot I consent

@google-cla
Copy link

google-cla bot commented Feb 2, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla
Copy link

google-cla bot commented Feb 2, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@rodrigomartindMeli
Copy link
Contributor

@googlebot I consent.

@rodrigomartind rodrigomartind marked this pull request as ready for review February 3, 2021 12:59
/**
* @hide
*/
protected float[] mAngles = new float[32];
Copy link
Collaborator

Choose a reason for hiding this comment

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

those added variables should be in CircularFlow, not in ConstraintHelper (mAngles, mRadius, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@@ -112,6 +138,12 @@ protected void init(AttributeSet attrs) {
} else if (attr == R.styleable.ConstraintLayout_Layout_constraint_referenced_tags) {
mReferenceTags = a.getString(attr);
setReferenceTags(mReferenceTags);
} else if (attr == R.styleable.ConstraintLayout_Layout_circularflow_angles) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar -- you should add that in CircularFlow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

Copy link
Collaborator

@camaelon camaelon left a comment

Choose a reason for hiding this comment

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

looks good! if you can address the minor comments I added we can submit this. Thanks!

@@ -0,0 +1,252 @@
/*
* Copyright (C) 2019 The Android Open Source Project
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably want 2021 :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@rodrigomartind rodrigomartind changed the title Feature - Circular Flow by Rodrigo Dominguez Feature - CircularFlow by Rodrigo Dominguez Feb 11, 2021
|| index >= angles.length) {
return angles;
}
float[] anotherArray = new float[32];
Copy link
Collaborator

Choose a reason for hiding this comment

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

er -- you probably want to size this array according to the current size of the angles array, which technically could be more than 32 no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

|| index >= radius.length) {
return radius;
}
int[] anotherArray = new int[32];
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@rodrigomartind
Copy link
Contributor Author

Thanks for your review Nicolas 🚀

*
* @param view
*/
public void removeViewFromCircularFlow(View view){
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor nit, but if there's no additional arguments, why not override removeView() ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor done ✅

@camaelon camaelon merged commit 8ed8750 into androidx:main Feb 11, 2021
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.

None yet

3 participants