Skip to content

Commit

Permalink
Fix expand icon button on weights table r6
Browse files Browse the repository at this point in the history
Expand icon only shows when needed, bigger icon & expands weight table
  • Loading branch information
ekigamba committed Sep 20, 2017
1 parent 747f182 commit 3847240
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ public void onCompletedMeasuring(int height) {
});
dialogView.findViewById(R.id.growth_chart).setVisibility(View.GONE);
//Change the icon
scrollButton.setImageResource(R.drawable.ic_icon_collapse);
scrollButton.setImageResource(R.drawable.ic_icon_expand);

} else {
isExpanded = false;
dialogView.findViewById(R.id.growth_chart).setVisibility(View.VISIBLE);
dialogView.findViewById(R.id.ll_growthDialogView_weightTableLayout).getLayoutParams().height =
getResources().getDimensionPixelSize(R.dimen.weight_table_height);
//Revert the icon
scrollButton.setImageResource(R.drawable.ic_icon_expand);
scrollButton.setImageResource(R.drawable.ic_icon_collapse);
}
}
});
Expand All @@ -241,7 +241,7 @@ public void onCompletedMeasuring(int height) {
return dialogView;
}

private void refreshPreviousWeightsTable(ViewGroup dialogView, Gender gender, Date dob) {
private void refreshPreviousWeightsTable(final ViewGroup dialogView, Gender gender, Date dob) {
TableLayout tableLayout = (TableLayout) dialogView.findViewById(R.id.weights_table);
for (Weight weight : weights) {
TableRow dividerRow = new TableRow(dialogView.getContext());
Expand Down Expand Up @@ -289,6 +289,21 @@ private void refreshPreviousWeightsTable(ViewGroup dialogView, Gender gender, Da
curRow.addView(zScoreTextView);
tableLayout.addView(curRow);
}

//Now set the expand button if items are too many
final ScrollView weightsTableScrollView = (ScrollView) dialogView.findViewById(R.id.weight_scroll_view);
getHeight(weightsTableScrollView, new ViewMeasureListener() {
@Override
public void onCompletedMeasuring(int height) {
int childHeight = weightsTableScrollView.getChildAt(0).getMeasuredHeight();
ImageButton scrollButton = (ImageButton) dialogView.findViewById(R.id.scroll_button);
if (childHeight > height) {
scrollButton.setVisibility(View.VISIBLE);
} else {
scrollButton.setVisibility(View.GONE);
}
}
});
}

private void refreshGrowthChart(ViewGroup parent, Gender gender, Date dob) {
Expand Down Expand Up @@ -574,4 +589,4 @@ public void onGlobalLayout() {
});
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@

<ImageButton
android:id="@+id/scroll_button"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:scaleType="centerInside"
android:padding="5dp"
android:visibility="gone"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:background="@null"
android:src="@drawable/ic_icon_expand" />
android:src="@drawable/ic_icon_collapse" />
</RelativeLayout>

<TableLayout
Expand Down

0 comments on commit 3847240

Please sign in to comment.