package de.frajul.endlessroll.views;

import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;

/**
 * Created by Julian on 18.03.2018.
 */

public class BombErrorMessage implements Animation.AnimationListener{

    private TextView view;
    private Animation animation;
    private boolean animationRunning = false;

    public BombErrorMessage(GameActivity gameActivity){
        LayoutInflater inflater = LayoutInflater.from(gameActivity);
        view = (TextView) inflater.inflate(R.layout.bomb_error_message, null);
        view.setTypeface(gameActivity.getTypeface());
        animation = AnimationUtils.loadAnimation(gameActivity, R.anim.fade_out_accelerating);
        animation.setAnimationListener(this);
    }

    public void show(float xPos, float yPos){
        animationRunning = true;
        view.setX(xPos - (float) view.getWidth() / 2);
        view.setY(yPos);
        view.startAnimation(animation);
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        animationRunning = false;
    }

    public TextView getView() {
        return view;
    }

    public boolean isAnimationRunning() {
        return animationRunning;
    }

    @Override
    public void onAnimationStart(Animation animation) {
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }
}
