First implementation of Shape shop
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
||||
import de.frajul.endlessroll.entities.shapes.PlayerShapeButtonOnClickListener;
|
||||
import de.frajul.endlessroll.main.GameLog;
|
||||
|
||||
/**
|
||||
* Created by Julian on 22.10.2017.
|
||||
*/
|
||||
|
||||
public class PlayerShapeButton implements View.OnClickListener {
|
||||
|
||||
private PlayerShape playerShape;
|
||||
private PlayerShapeButtonOnClickListener clickListener;
|
||||
|
||||
private View view;
|
||||
private TextView textView;
|
||||
private Button button;
|
||||
private Animation rotation;
|
||||
|
||||
public PlayerShapeButton(Context context, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener) {
|
||||
this.clickListener = clickListener;
|
||||
this.playerShape = playerShape;
|
||||
view = LayoutInflater.from(context).inflate(R.layout.shape_button, null);
|
||||
textView = (TextView) view.findViewById(R.id.shape_button_textview);
|
||||
textView.setText(playerShape.getNameId());
|
||||
button = (Button) view.findViewById(R.id.shape_button_button);
|
||||
button.setBackgroundDrawable(context.getResources().getDrawable(playerShape.getDrawableId()));
|
||||
button.setOnClickListener(this);
|
||||
rotation = AnimationUtils.loadAnimation(context, R.anim.shape_button_rotation);
|
||||
}
|
||||
|
||||
public void startRotating() {
|
||||
button.startAnimation(rotation);
|
||||
}
|
||||
|
||||
public void stopRotating() {
|
||||
button.clearAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clickListener.onClick(this);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public PlayerShape getPlayerShape() {
|
||||
return playerShape;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user