Search in sources :

Example 1 with FlipAnimation

use of com.instructure.teacheraid.animation.FlipAnimation in project instructure-android by instructure.

the class GuessWhoStudentFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null) {
        return null;
    }
    View view = inflater.inflate(R.layout.guess_who_student_fragment, container, false);
    rootView = (RelativeLayout) view.findViewById(R.id.rootView);
    rootView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            FlipAnimation flipAnimation = new FlipAnimation(cardFront, cardBack);
            if (cardFront.getVisibility() == View.GONE) {
                flipAnimation.reverse();
                hasFlipped = false;
            } else {
                hasFlipped = true;
            }
            rootView.startAnimation(flipAnimation);
        }
    });
    cardFront = (RelativeLayout) view.findViewById(R.id.cardFront);
    cardBack = (RelativeLayout) view.findViewById(R.id.cardBack);
    User user = this.getArguments().getParcelable(Const.USER);
    name = (TextView) view.findViewById(R.id.studentName);
    name.setText(user.getShortName());
    avatar = (ImageView) view.findViewById(R.id.avatar);
    Picasso.with(getActivity()).load(user.getAvatarURL()).into(avatar);
    // show the back view
    if (savedInstanceState != null && savedInstanceState.getBoolean(Const.GUESS_WHO_CARD_FLIPPED)) {
        // we want the card to flip, but we don't want the animation. So use the same logic but set the
        // duration to 0 so it happens instantly
        FlipAnimation flipAnimation = new FlipAnimation(cardFront, cardBack);
        flipAnimation.setDuration(0);
        rootView.startAnimation(flipAnimation);
        hasFlipped = true;
    }
    return view;
}
Also used : User(com.instructure.canvasapi.model.User) FlipAnimation(com.instructure.teacheraid.animation.FlipAnimation) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 User (com.instructure.canvasapi.model.User)1 FlipAnimation (com.instructure.teacheraid.animation.FlipAnimation)1