Commit 49a4328c authored by Varun Patil's avatar Varun Patil

Complete body page implementation

parent bdb2f77f
......@@ -31,6 +31,7 @@ import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.MainActivity;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.ShareURLMaker;
import in.ac.iitb.gymkhana.iitbapp.adapter.BodyAdapter;
import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter;
import in.ac.iitb.gymkhana.iitbapp.adapter.UserAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
......@@ -218,6 +219,7 @@ public class BodyFragment extends Fragment {
eventRecyclerView.setAdapter(eventAdapter);
eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Get users from roles */
final List<Role> roles = body.getBodyRoles();
final List<User> users = new ArrayList();
for (Role role : roles) {
......@@ -228,6 +230,8 @@ public class BodyFragment extends Fragment {
}
}
}
/* Initialize People */
RecyclerView userRecyclerView = (RecyclerView) getActivity().findViewById(R.id.people_card_recycler_view);
UserAdapter userAdapter = new UserAdapter(users, new ItemClickListener() {
@Override
......@@ -246,6 +250,41 @@ public class BodyFragment extends Fragment {
});
userRecyclerView.setAdapter(userAdapter);
userRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize Parent bodies */
RecyclerView parentsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.parentorg_card_recycler_view);
BodyAdapter parentAdapter = new BodyAdapter(body.getBodyParents(), new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyParents().get(position));
}
});
parentsRecyclerView.setAdapter(parentAdapter);
parentsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize child bodies */
RecyclerView childrenRecyclerView = (RecyclerView) getActivity().findViewById(R.id.org_card_recycler_view);
BodyAdapter childrenAdapter = new BodyAdapter(body.getBodyChildren(), new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyChildren().get(position));
}
});
childrenRecyclerView.setAdapter(childrenAdapter);
childrenRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
/** Open body fragment for a body */
private void openBody(Body body) {
Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(body));
BodyFragment bodyFragment = new BodyFragment();
bodyFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
ft.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
private class updateDbBody extends AsyncTask<Body, Void, Integer> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment