Current shape is now saved
This commit is contained in:
@ -1,18 +1,19 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
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;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
|
||||
/**
|
||||
* Created by Julian on 22.10.2017.
|
||||
@ -28,16 +29,26 @@ public class PlayerShapeButton implements View.OnClickListener {
|
||||
private Button button;
|
||||
private Animation rotation;
|
||||
|
||||
public PlayerShapeButton(Context context, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener) {
|
||||
public PlayerShapeButton(GameActivity gameActivity, PlayerShape playerShape, PlayerShapeButtonOnClickListener clickListener, boolean marginToRight) {
|
||||
this.clickListener = clickListener;
|
||||
this.playerShape = playerShape;
|
||||
view = LayoutInflater.from(context).inflate(R.layout.shape_button, null);
|
||||
view = LayoutInflater.from(gameActivity).inflate(R.layout.shape_button, null);
|
||||
view.setLayoutParams(createLayoutParams(marginToRight));
|
||||
textView = (TextView) view.findViewById(R.id.shape_button_textview);
|
||||
textView.setTypeface(gameActivity.getTypeface());
|
||||
textView.setText(playerShape.getNameId());
|
||||
button = (Button) view.findViewById(R.id.shape_button_button);
|
||||
button.setBackgroundDrawable(context.getResources().getDrawable(playerShape.getDrawableId()));
|
||||
button.setBackgroundDrawable(gameActivity.getResources().getDrawable(playerShape.getDrawableId()));
|
||||
button.setOnClickListener(this);
|
||||
rotation = AnimationUtils.loadAnimation(context, R.anim.shape_button_rotation);
|
||||
rotation = AnimationUtils.loadAnimation(gameActivity, R.anim.shape_button_rotation);
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams createLayoutParams(boolean marginToRight){
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
if(marginToRight)
|
||||
params.setMargins(0, 0, 60, 0);
|
||||
return params;
|
||||
}
|
||||
|
||||
public void startRotating() {
|
||||
|
Reference in New Issue
Block a user