use of com.instructure.speedgrader.util.ExpandCollapseAnimation in project instructure-android by instructure.
the class StudentListView method initListView.
private void initListView(View popupView) {
// get the listview inside our popupwindow and set our adapter to it
mListView = (ListView) popupView.findViewById(R.id.studentList);
mSubmissionsAdapter = new UserSubmissionsListAdapter(mActivity.getApplicationContext(), mSubmissionsList, mAssignment, mListView, ((App) mActivity.getApplication()).showStudentNames(), mListener);
if (isSortByName) {
mSubmissionsAdapter.sortSubmissionsByName(((App) mActivity.getApplication()).showUngradedStudentsFirst());
} else {
mSubmissionsAdapter.sortSubmissionsByGrade();
}
final ViewGroup header = (ViewGroup) LayoutInflater.from(mActivity).inflate(R.layout.student_list_headerview, mListView, false);
final RelativeLayout row = (RelativeLayout) header.findViewById(R.id.row);
final LinearLayout dropDown = (LinearLayout) header.findViewById(R.id.rowDropdown);
final RadioGroup radioGroup = (RadioGroup) header.findViewById(R.id.radioGroup);
final ImageView expandArrow = (ImageView) header.findViewById(R.id.expandArrow);
final TextView sectionTitle = (TextView) header.findViewById(R.id.sectionTitle);
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ExpandCollapseAnimation.setHeightForWrapContent(mActivity, dropDown);
ExpandCollapseAnimation expandCollapseAnimation = new ExpandCollapseAnimation(dropDown, 200);
expandCollapseAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
RotateAnimation rotationAnim;
if (dropDown.getHeight() < 50) {
// For some reason, onAnimatinoEnd is getting called slightly before the animation actually ends, causing the height to be a value something greater than 0.
// currently closed
rotationAnim = new RotateAnimation(180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
} else {
// currently open
rotationAnim = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
}
rotationAnim.setDuration(100);
rotationAnim.setFillAfter(true);
expandArrow.startAnimation(rotationAnim);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
dropDown.startAnimation(expandCollapseAnimation);
}
});
// Set our arrow to gray
final Drawable d = CanvasContextColor.getColoredDrawable(mApplicationContext, R.drawable.ic_cv_arrow_down_fill, ContextCompat.getColor(mActivity.getApplicationContext(), R.color.lightGray));
expandArrow.setImageDrawable(d);
mListView.addHeaderView(header);
mListView.setTextFilterEnabled(true);
mListView.setAdapter(mSubmissionsAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// show the submission clicked
dismiss();
int positionInList = mSubmissionsAdapter.getPositionForSubmission((Submission) mListView.getItemAtPosition(position));
mListener.onCurrentSubmission(positionInList);
}
});
initSectionsRadioGroup(radioGroup, sectionTitle, header);
}
Aggregations