Commit f805defa authored by Varun Patil's avatar Varun Patil

Hide irrelevant card list titles in Body Fragment

parent 375c4f61
...@@ -130,6 +130,14 @@ public class BodyFragment extends Fragment { ...@@ -130,6 +130,14 @@ public class BodyFragment extends Fragment {
}); });
} }
private void setVisibleIfHasElements(int[] viewIds, List list) {
if (list != null && list.size() > 0) {
for (int viewId: viewIds){
getActivity().findViewById(viewId).setVisibility(View.VISIBLE);
}
}
}
private void displayBody(final Body body) { private void displayBody(final Body body) {
TextView bodyName = (TextView) getView().findViewById(R.id.body_name); TextView bodyName = (TextView) getView().findViewById(R.id.body_name);
TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description); TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description);
...@@ -138,6 +146,12 @@ public class BodyFragment extends Fragment { ...@@ -138,6 +146,12 @@ public class BodyFragment extends Fragment {
ImageButton shareBodyButton = getActivity().findViewById(R.id.share_body_button); ImageButton shareBodyButton = getActivity().findViewById(R.id.share_body_button);
final Button followButton = getActivity().findViewById(R.id.follow_button); final Button followButton = getActivity().findViewById(R.id.follow_button);
/* Show relevant card titles */
setVisibleIfHasElements(new int[]{R.id.body_events_title, R.id.event_card_recycler_view}, body.getBodyEvents());
setVisibleIfHasElements(new int[]{R.id.body_orgs_title, R.id.org_card_recycler_view}, body.getBodyChildren());
setVisibleIfHasElements(new int[]{R.id.body_parents_title, R.id.parentorg_card_recycler_view}, body.getBodyParents());
setVisibleIfHasElements(new int[]{R.id.body_people_title, R.id.people_card_recycler_view}, body.getBodyRoles());
/* Set body information */ /* Set body information */
bodyName.setText(body.getBodyName()); bodyName.setText(body.getBodyName());
Picasso.with(getContext()).load(body.getBodyImageURL()).into(eventPicture); Picasso.with(getContext()).load(body.getBodyImageURL()).into(eventPicture);
......
...@@ -127,6 +127,8 @@ ...@@ -127,6 +127,8 @@
android:textSize="16sp" /> android:textSize="16sp" />
<TextView <TextView
android:id="@+id/body_events_title"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
...@@ -136,12 +138,15 @@ ...@@ -136,12 +138,15 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/event_card_recycler_view" android:id="@+id/event_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" /> android:nestedScrollingEnabled="false" />
<TextView <TextView
android:id="@+id/body_orgs_title"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
...@@ -151,12 +156,15 @@ ...@@ -151,12 +156,15 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/org_card_recycler_view" android:id="@+id/org_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" /> android:nestedScrollingEnabled="false" />
<TextView <TextView
android:id="@+id/body_people_title"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
...@@ -166,12 +174,15 @@ ...@@ -166,12 +174,15 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/people_card_recycler_view" android:id="@+id/people_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" /> android:nestedScrollingEnabled="false" />
<TextView <TextView
android:id="@+id/body_parents_title"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
...@@ -181,6 +192,7 @@ ...@@ -181,6 +192,7 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/parentorg_card_recycler_view" android:id="@+id/parentorg_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
......
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