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

ProteusGridLayoutManager and ViewPager Example implemented #166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

raviranjan19750
Copy link

  1. ProteusGridLayoutManager

With respect to linear layout i have added GridLayout view because it is more generic and easy to use. it provides both the orientation of linear layout when span count of grid is set to 1 and changing the orientation of grid layout i.e 

span count = 1 & grid layout orientation  = Vertical,  will work just like vertical linear layout 
span count = 1 & grid layout orientation  = Horizontal , will work just like horizontal linear layout 

One can also reverse the layout with the help of boolean "reverseLayout".

In short gridLayout provides the same functionality of linear layout along with extra features of grid layout. 

the attribute for the orientation is received as "int" data type from the json and not as "string", and default value is set to 1 i.e  "GridLayoutManager.VERTICAL". By setting it to 0, it corresponds to "GridLayoutManager.HORIZONTAL". 
  1. ViewPager example

the library supports the viewpager but there was no working example/demo in the code. just the logic part was implemented. i have extended it from logic part to demo part in "layouts.json" file with the attribute "ViewPagerExample". 

I am using the recycler view with the help of linear snap helper to mimic the behaviour of viewpager. 

gridView with proteus view logic implemented and tested
viewPager example added and tested in layouts.json file
data of user.json is edited
Copy link
Collaborator

@adityasharat adityasharat left a comment

Choose a reason for hiding this comment

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

Thank you for contributing. I have left some tiny review comments to address.
Apologies for getting to this after soon.

@@ -1,6 +1,6 @@
{
"0": {
"name": "John Doe",
"name": "Ravi Ranjan",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please revert this?

Comment on lines +223 to +224


Copy link
Collaborator

Choose a reason for hiding this comment

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

Can these excess new lines be removed?

Comment on lines 191 to 193
private void registerDefaultLayoutManagers() {
register(LAYOUT_MANAGER_LINEAR, ProteusLinearLayoutManager.BUILDER);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be deleted now?

Comment on lines +13 to +45


private static final String ATTRIBUTE_COL = "numCols";
private static final String ATTRIBUTE_ORIENTATION = "orientation";
private static final String ATTRIBUTE_REVERSE_LAYOUT = "reverse";


public static final LayoutManagerBuilder<ProteusGridLayoutManager> BUILDER = new LayoutManagerBuilder<ProteusGridLayoutManager>() {

@NonNull
@Override
public ProteusGridLayoutManager create(@NonNull ProteusRecyclerView view, @NonNull ObjectValue config) {

int orientation = config.getAsInteger(ATTRIBUTE_ORIENTATION, GridLayoutManager.VERTICAL);
boolean reverseLayout = config.getAsBoolean(ATTRIBUTE_REVERSE_LAYOUT, false);

int col = config.getAsInteger(ATTRIBUTE_COL, 1);



return new ProteusGridLayoutManager(view.getContext(), col, orientation, reverseLayout);
}
};


public ProteusGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
super(context, spanCount, orientation, reverseLayout);
}





Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the excess new lines be removed?

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